Skip to content

Commit

Permalink
Github Actions other-project build test
Browse files Browse the repository at this point in the history
  • Loading branch information
KowerKoint committed Nov 15, 2024
1 parent d53e3dc commit deb9c49
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 18 deletions.
160 changes: 160 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Install to System

on:
push:
paths-ignore:
- ".devcontainer/**"
- ".vscode/**"
- "doc/**"
- "*.md"
pull_request:
paths-ignore:
- ".devcontainer/**"
- ".vscode/**"
- "doc/**"
- "*.md"

jobs:
library:
name: Install Library
strategy:
matrix:
os: ["linux", "macos"]
architecture: ["x86_64", "arm64"]
device: ["cpu", "cuda"]
python-version: ["3.10"]
exclude:
- os: "macos"
device: "cuda"
# currently ARM runner is not supported
- os: "linux"
architecture: "arm64"
include:
- os: "linux"
architecture: "x86_64"
runs-on: "ubuntu-22.04"
- os: "macos"
architecture: "x86_64"
runs-on: "macos-13"
- os: "macos"
architecture: "arm64"
runs-on: "macos-14"
runs-on: ${{ matrix.runs-on }}
env:
CMAKE_C_COMPILER: ${{ matrix.runs-on == 'macos-13' && '/usr/local/opt/ccache/libexec/gcc-14'|| matrix.runs-on == 'macos-14' && '/opt/homebrew/opt/ccache/libexec/gcc-14' || '/usr/lib/ccache/gcc' }}
CMAKE_CXX_COMPILER: ${{ matrix.runs-on == 'macos-13' && '/usr/local/opt/ccache/libexec/g++-14'|| matrix.runs-on == 'macos-14' && '/opt/homebrew/opt/ccache/libexec/g++-14' || '/usr/lib/ccache/g++' }}
SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'ON' || 'OFF' }}
SCALUQ_CUDA_ARCH: "PASCAL61"
steps:
- uses: actions/checkout@v4

- name: Install Ninja
if: ${{ matrix.os == 'linux' }}
run: sudo apt update && sudo apt install ninja-build

- name: Install Ninja
if: ${{ matrix.os == 'macos' }}
run: brew install ninja

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{ github.job }}-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.device }}"
verbose: 2

- name: Install CUDA toolkit
if: ${{ matrix.device == 'cuda' }}
uses: Jimver/[email protected]
with:
cuda: "12.2.0"
method: "network"

- name: Show installed Compiler version
run: |
[ $SCALUQ_USE_CUDA = 'ON' ] && nvcc --version
ccache --version
$CMAKE_C_COMPILER --version
$CMAKE_CXX_COMPILER --version
cmake --version
ninja --version
- name: Configure
run: ./script/configure

- name: Install to system
run: sudo ninja -C build install

- name: Build and Run other project
run: |
cd example_project/
cmake -B build/
make -C build
if [ "$SCALUQ_USE_CUDA" != 'ON']; then
build/main
fi
python:
name: Install Python package
strategy:
matrix:
os: ["linux", "macos"]
architecture: ["x86_64", "arm64"]
device: ["cpu", "cuda"]
python-version: ["3.10"]
exclude:
- os: "macos"
device: "cuda"
# currently ARM runner is not supported
- os: "linux"
architecture: "arm64"
include:
- os: "linux"
architecture: "x86_64"
runs-on: "ubuntu-22.04"
- os: "macos"
architecture: "x86_64"
runs-on: "macos-13"
- os: "macos"
architecture: "arm64"
runs-on: "macos-14"
runs-on: ${{ matrix.runs-on }}
env:
CMAKE_C_COMPILER: ${{ matrix.runs-on == 'macos-13' && '/usr/local/opt/ccache/libexec/gcc-14'|| matrix.runs-on == 'macos-14' && '/opt/homebrew/opt/ccache/libexec/gcc-14' || '/usr/lib/ccache/gcc' }}
CMAKE_CXX_COMPILER: ${{ matrix.runs-on == 'macos-13' && '/usr/local/opt/ccache/libexec/g++-14'|| matrix.runs-on == 'macos-14' && '/opt/homebrew/opt/ccache/libexec/g++-14' || '/usr/lib/ccache/g++' }}
SCALUQ_USE_CUDA: ${{ matrix.device == 'cuda' && 'ON' || 'OFF' }}
SCALUQ_CUDA_ARCH: "PASCAL61"
steps:
- uses: actions/checkout@v4

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
key: "${{ github.job }}-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.device }}"
verbose: 2

- name: Install CUDA toolkit
if: ${{ matrix.device == 'cuda' }}
uses: Jimver/[email protected]
with:
cuda: "12.2.0"
method: "network"

- name: Show installed Compiler version
run: |
[ $SCALUQ_USE_CUDA = 'ON' ] && nvcc --version
ccache --version
$CMAKE_C_COMPILER --version
$CMAKE_CXX_COMPILER --version
- name: Install mypy
run: pip install mypy

- name: Install to system
run: pip install .

- name: Run / Test stub
if: ${{ matrix.device == 'cpu' }} # currently GPU runner is not supported
run: |
echo -e "from scaluq import StateVector, gate\nstate = StateVector(2)\nx = gate.X(0)\nx.update_quantum_state(state)\nprint(state.get_amplitudes())" > /tmp/sample.py
python3 /tmp/sample.py
mypy /tmp/sample.py
2 changes: 1 addition & 1 deletion include/scaluq/state/state_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void bind_state_state_vector_hpp(nb::module_& m) {
.def("set_computational_basis",
&StateVector<double>::set_computational_basis,
"Initialize with computational basis \\ket{\\mathrm{basis}}.")
.def("amplitudes",
.def("get_amplitudes",
&StateVector<double>::get_amplitudes,
"Get all amplitudes with as `list[complex]`.")
.def("n_qubits", &StateVector<double>::n_qubits, "Get num of qubits.")
Expand Down
2 changes: 1 addition & 1 deletion include/scaluq/state/state_vector_batched.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void bind_state_state_vector_batched_hpp(nb::module_& m) {
"seed"_a = std::nullopt,
"Construct batched state vectors with Haar random states. If seed is not "
"specified, the value from random device is used.")
.def("amplitudes",
.def("get_amplitudes",
&StateVectorBatched<double>::get_amplitudes,
"Get all amplitudes with as `list[list[complex]]`.")
.def("get_squared_norm",
Expand Down
16 changes: 0 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ write_to = "python/scaluq/_version.py"
homepage = "http://www.scaluq.org"

[project.optional-dependencies]
dev = [
"mypy == 1.11.2",
"scikit-build == 0.17.6",
"typing_extensions == 4.12.0",
"numpy == 1.26.0",
"nanobind == 2.0.0"
]

ci = [
"mypy == 1.11.2",
"scikit-build == 0.17.6",
"typing_extensions == 4.12.0",
"numpy == 1.26.0",
"nanobind == 2.0.0"
]

doc = [
"black == 24.4.2",
"isort == 5.13.2",
Expand Down

0 comments on commit deb9c49

Please sign in to comment.