Skip to content

Commit a6a2e44

Browse files
committed
Upgrading PyQrack dependency and workflows. (#504)
Apparently, in the latest version they have added a flag to disable OpenCL, which I think will make supporting pyqrack a lot easier. I want to try this out and see if it works! EDIT: doesn't work, however, I can specify a fine-grained platform which should fix the issues with which pyqrack to install.
1 parent 5e750f1 commit a6a2e44

File tree

8 files changed

+1887
-1297
lines changed

8 files changed

+1887
-1297
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424
uses: astral-sh/setup-uv@v6
2525
with:
2626
# Install a specific version of uv.
27-
version: "0.5.1"
27+
version: "0.8.4"
2828
enable-cache: true
2929
cache-dependency-glob: "uv.lock"
3030
- name: Set up Python ${{ matrix.python-version }}
3131
run: uv python install ${{ matrix.python-version }}
3232
- name: Install the project
33-
run: uv sync --upgrade --dev --group dev-linux
33+
run: uv sync --dev --all-extras --no-extra pyqrack-cuda
3434
- name: Run tests
3535
# For example, using `pytest`
3636
run: uv run just coverage

pyproject.toml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ dependencies = [
1717
"rich>=13.9.4",
1818
"pydantic>=1.3.0,<2.11.0",
1919
"pandas>=2.2.3",
20-
"pyqrack>=1.38.2,<1.41; sys_platform == 'darwin'",
21-
"pyqrack-cpu>=1.38.2,<1.41 ; sys_platform != 'darwin'",
20+
"pyqrack>=1.69.0; sys_platform == 'darwin-arm64'",
21+
"pyqrack-cpu>=1.69.0; sys_platform != 'darwin-arm64'",
2222
]
2323

2424
[project.optional-dependencies]
@@ -41,10 +41,10 @@ cirq = [
4141
"qpsolvers[clarabel]>=4.7.0",
4242
]
4343
pyqrack-opencl = [
44-
"pyqrack>=1.38.2 ; sys_platform != 'darwin'",
44+
"pyqrack>=1.69.0; sys_platform == 'darwin-arm64'",
4545
]
4646
pyqrack-cuda = [
47-
"pyqrack-cuda>=1.38.2",
47+
"pyqrack-cuda>=1.69.0",
4848
]
4949
stim = [
5050
"stim>=1.15.0",
@@ -75,34 +75,6 @@ dev = [
7575
"rust-just>=1.36.0",
7676
"tomlkit>=0.13.2",
7777
]
78-
dev-linux = [
79-
"cirq-core[contrib]>=1.4.1",
80-
"lark>=1.2.2",
81-
"pyqrack-cpu>=1.38.2",
82-
"qbraid>=0.9.5",
83-
"ffmpeg>=1.4",
84-
"matplotlib>=3.9.2",
85-
"pyqt5>=5.15.11",
86-
"tqdm>=4.67.1",
87-
"stim>=1.15.0",
88-
"cirq-core>=1.4.1",
89-
"cirq-core[contrib]>=1.4.1",
90-
"qpsolvers[clarabel]>=4.7.0",
91-
]
92-
dev-mac-arm = [
93-
"cirq-core[contrib]>=1.4.1",
94-
"ffmpeg>=1.4",
95-
"lark>=1.2.2",
96-
"matplotlib>=3.9.2",
97-
"pyqrack>=1.38.2",
98-
"pyqt5>=5.15.11",
99-
"qbraid>=0.9.5",
100-
"tqdm>=4.67.1",
101-
"stim>=1.15.0",
102-
"cirq-core>=1.4.1",
103-
"cirq-core[contrib]>=1.4.1",
104-
"qpsolvers[clarabel]>=4.7.0",
105-
]
10678

10779
[tool.isort]
10880
profile = "black"

test/cirq_utils/noise/test_noise_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def test_simple_model(model: cirq.NoiseModel, qubits):
6464

6565
kernel = squin.cirq.load_circuit(noisy_circuit)
6666
RewriteNoiseStmts(kernel.dialects)(kernel)
67-
pyqrack_sim = StackMemorySimulator(min_qubits=2)
67+
pyqrack_sim = StackMemorySimulator(
68+
min_qubits=2, rng_state=np.random.default_rng(1234)
69+
)
6870

6971
pops_bloqade = [0.0] * 4
7072

test/cirq_utils/noise/test_noisy_ghz.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def fidelity(rho: np.ndarray, sigma: np.ndarray) -> float:
8686
# do the same in squin
8787
kernel = squin.cirq.load_circuit(noisy_circuit)
8888
RewriteNoiseStmts(kernel.dialects)(kernel)
89-
sim = StackMemorySimulator(min_qubits=n)
89+
sim = StackMemorySimulator(
90+
min_qubits=n, rng_state=np.random.default_rng(1234)
91+
)
9092
rho_squin = np.zeros((2**n, 2**n), dtype=np.complex128)
9193
nshots = 300
9294
for _ in range(nshots):

test/cirq_utils/noise/test_one_zone_correlated_noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_model_with_defaults():
5151

5252
RewriteNoiseStmts(kernel.dialects)(kernel)
5353

54-
sim = StackMemorySimulator(min_qubits=2)
54+
sim = StackMemorySimulator(min_qubits=2, rng_state=np.random.default_rng(1234))
5555
pops = [0.0] * 4
5656
nshots = 300
5757
for _ in range(nshots):

test/pyqrack/squin/test_kernel.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22

3+
import numpy as np
34
import pytest
45
from kirin.dialects import ilist
56

@@ -22,7 +23,15 @@ def new():
2223
assert isinstance(qubit := result[0], PyQrackQubit)
2324

2425
out = qubit.sim_reg.out_ket()
25-
assert out == [1.0] + [0.0] * (2**3 - 1)
26+
out = np.asarray(out)
27+
28+
i = np.abs(out).argmax()
29+
out /= out[i] / np.abs(out[i])
30+
31+
expected = np.zeros_like(out)
32+
expected[0] = 1.0
33+
34+
assert np.allclose(out, expected, atol=2.2e-7)
2635

2736
@squin.kernel
2837
def m():

test/pyqrack/test_target.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import math
22
import textwrap
33

4+
import numpy as np
45
import pytest
56
from kirin import ir
67
from kirin.dialects import ilist
@@ -115,11 +116,14 @@ def multiple_registers():
115116

116117
out = qubit.sim_reg.out_ket()
117118

118-
assert out[0] == 1
119-
for i in range(1, len(out)):
120-
assert out[i] == 0
119+
out = np.asarray(out)
120+
i = np.abs(out).argmax()
121+
out /= out[i] / np.abs(out[i])
121122

122-
assert True
123+
expected = np.zeros_like(out)
124+
expected[0] = 1.0
125+
126+
assert np.allclose(out, expected, atol=2.2e-7)
123127

124128

125129
def test_measurement():

uv.lock

Lines changed: 1856 additions & 1255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)