Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added gpu-enabled CI via the new gpubox runner #167

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/build-with-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ jobs:
with:
name: tket
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
installCommand: "nix profile install --accept-flake-config nixpkgs#cachix"
- name: Build pytket-cutensornet
run: nix build --accept-flake-config
#
# need GPU runners for this
#
#test:
# needs: build
# runs-on: nixos-gpu
# steps:
# - uses: actions/checkout@v4
# - uses: cachix/install-nix-action@V28
# - uses: cachix/cachix-action@v15
# with:
# name: tket
# authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# - name: Test pytket-cutensornet
# run: nix run .#tests --accept-flake-config
test:
needs: build
runs-on: cuda
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@V28
- uses: cachix/cachix-action@v15
with:
name: tket
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
installCommand: "nix profile install --accept-flake-config nixpkgs#cachix"
- name: Test pytket-cutensornet
# impure is necessary due to nixgl usage (system-dependent cuda)
run: nix run .#tests --impure --accept-flake-config
54 changes: 52 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
'';
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.tket.url = "github:CQCL/tket";
inputs.nixpkgs.follows = "tket/nixpkgs";
outputs = { self, nixpkgs, flake-utils, tket }:
inputs = {
flake-utils.url = "github:numtide/flake-utils";
tket.url = "github:CQCL/tket";
nixpkgs.follows = "tket/nixpkgs";
nixgl.url = "github:nix-community/nixGL";
};
outputs = { self, nixpkgs, flake-utils, tket, nixgl }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
Expand All @@ -20,6 +23,8 @@
cudaSupport = true;
};
overlays = [
(nixgl.overlay)

(self: super: {
inherit (tket.packages."${system}") tket pytket;
})
Expand Down
8 changes: 5 additions & 3 deletions nix-support/pytket-cutensornet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ EOF
pytest
pytest-lazy-fixture
]);
nixgl-bin = self.lib.getExe self.nixgl.auto.nixGLNvidia;
in super.writeShellScriptBin "run-pytket-cutensornet-tests" ''
HOME=$(mktemp -d);
export HOME;
echo "---------------------------";
env;
echo "---------------------------";
NIXGL_PATH="$(${nixgl-bin} printenv LD_LIBRARY_PATH)";
WSL_PATH="/usr/lib/wsl/lib";
LD_LIBRARY_PATH="$NIXGL_PATH:$WSL_PATH:$LD_LIBRARY_PATH";
export LD_LIBRARY_PATH;
${test-env}/bin/pytest -s ${../tests};
'';
}
12 changes: 6 additions & 6 deletions tests/test_structured_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def test_circ_approx_explicit_mps(circuit: Circuit) -> None:
SimulationAlgorithm.MPSxGate,
cfg,
)
assert np.isclose(mps_gate.get_fidelity(), 0.4, atol=1e-1)
assert mps_gate.get_fidelity() >= 0.3
assert mps_gate.is_valid()
assert np.isclose(mps_gate.vdot(mps_gate), 1.0, atol=cfg._atol)

Expand All @@ -555,21 +555,21 @@ def test_circ_approx_explicit_mps(circuit: Circuit) -> None:
SimulationAlgorithm.MPSxMPO,
cfg,
)
assert np.isclose(mps_mpo.get_fidelity(), 0.6, atol=1e-1)
assert mps_mpo.get_fidelity() >= 0.5
assert mps_mpo.is_valid()
assert np.isclose(mps_mpo.vdot(mps_mpo), 1.0, atol=cfg._atol)

# Fixed virtual bond dimension
# Check for MPSxGate
cfg = Config(chi=8, leaf_size=4, float_precision=np.float32)
mps_gate = simulate(libhandle, circuit, SimulationAlgorithm.MPSxGate, cfg)
assert np.isclose(mps_gate.get_fidelity(), 0.03, atol=1e-2)
assert mps_gate.get_fidelity() >= 0.02
assert mps_gate.is_valid()
assert np.isclose(mps_gate.vdot(mps_gate), 1.0, atol=cfg._atol)

# Check for MPSxMPO
mps_mpo = simulate(libhandle, circuit, SimulationAlgorithm.MPSxMPO, cfg)
assert np.isclose(mps_mpo.get_fidelity(), 0.05, atol=1e-2)
assert mps_mpo.get_fidelity() >= 0.04
assert mps_mpo.is_valid()
assert np.isclose(mps_mpo.vdot(mps_mpo), 1.0, atol=cfg._atol)

Expand All @@ -588,15 +588,15 @@ def test_circ_approx_explicit_ttn(circuit: Circuit) -> None:
# Check for TTNxGate
cfg = Config(truncation_fidelity=0.99, leaf_size=3, float_precision=np.float32)
ttn_gate = simulate(libhandle, circuit, SimulationAlgorithm.TTNxGate, cfg)
assert np.isclose(ttn_gate.get_fidelity(), 0.751, atol=1e-3)
assert ttn_gate.get_fidelity() >= 0.75
assert ttn_gate.is_valid()
assert np.isclose(ttn_gate.vdot(ttn_gate), 1.0, atol=cfg._atol)

# Fixed virtual bond dimension
# Check for TTNxGate
cfg = Config(chi=120, leaf_size=3, float_precision=np.float32)
ttn_gate = simulate(libhandle, circuit, SimulationAlgorithm.TTNxGate, cfg)
assert np.isclose(ttn_gate.get_fidelity(), 0.854, atol=1e-3)
assert ttn_gate.get_fidelity() >= 0.85
assert ttn_gate.is_valid()
assert np.isclose(ttn_gate.vdot(ttn_gate), 1.0, atol=cfg._atol)

Expand Down
Loading