Skip to content

Commit 63bfdff

Browse files
committed
Merge branch 'main' into david/571-kirin-upgrade-branch
2 parents 2fb5402 + 34e9679 commit 63bfdff

File tree

15 files changed

+262
-345
lines changed

15 files changed

+262
-345
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
token: ${{ secrets.CODECOV_TOKEN }} # required
4444
- name: Archive code coverage results
4545
if: matrix.python-version == '3.12'
46-
uses: actions/upload-artifact@v4
46+
uses: actions/upload-artifact@v5
4747
with:
4848
name: code-coverage-report
4949
path: coverage.xml
@@ -55,7 +55,7 @@ jobs:
5555
steps:
5656
- uses: actions/checkout@v5
5757
- name: download covearge
58-
uses: actions/download-artifact@v5
58+
uses: actions/download-artifact@v6
5959
with:
6060
name: code-coverage-report
6161
- name: check coverage

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Build distribution 📦
2020
run: uv build
2121
- name: Store the distribution packages
22-
uses: actions/upload-artifact@v4
22+
uses: actions/upload-artifact@v5
2323
with:
2424
name: python-package-distributions
2525
path: dist/
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Download all the dists
42-
uses: actions/download-artifact@v5
42+
uses: actions/download-artifact@v6
4343
with:
4444
name: python-package-distributions
4545
path: dist/
@@ -60,12 +60,12 @@ jobs:
6060

6161
steps:
6262
- name: Download all the dists
63-
uses: actions/download-artifact@v5
63+
uses: actions/download-artifact@v6
6464
with:
6565
name: python-package-distributions
6666
path: dist/
6767
- name: Sign the dists with Sigstore
68-
uses: sigstore/gh-action-sigstore-python@v3.0.1
68+
uses: sigstore/gh-action-sigstore-python@v3.1.0
6969
with:
7070
inputs: >-
7171
./dist/*.tar.gz

src/bloqade/cirq_utils/emit/base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ class EmitCirq(EmitABC[EmitCirqFrame, cirq.Circuit]):
170170
dialects: ir.DialectGroup = field(default_factory=_default_kernel)
171171
void = cirq.Circuit()
172172
qubits: Sequence[cirq.Qid] | None = None
173-
_cached_invokes: dict[int, cirq.FrozenCircuit] = field(
174-
init=False, default_factory=dict
175-
)
176173

177174
def initialize(self) -> Self:
178175
return super().initialize()

src/bloqade/squin/rewrite/U3_to_clifford.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ class Sdag(ir.Statement):
1515
pass
1616

1717

18+
class SqrtXdag(ir.Statement):
19+
pass
20+
21+
22+
class SqrtYdag(ir.Statement):
23+
pass
24+
25+
1826
# (theta, phi, lam)
1927
U3_HALF_PI_ANGLE_TO_GATES: dict[
2028
tuple[int, int, int], list[type[ir.Statement]] | list[None]
@@ -27,21 +35,21 @@ class Sdag(ir.Statement):
2735
(1, 0, 1): [gate.stmts.S, gate.stmts.SqrtY],
2836
(1, 0, 2): [gate.stmts.H],
2937
(1, 0, 3): [Sdag, gate.stmts.SqrtY],
30-
(1, 1, 0): [gate.stmts.SqrtY, gate.stmts.S],
31-
(1, 1, 1): [gate.stmts.S, gate.stmts.SqrtY, gate.stmts.S],
32-
(1, 1, 2): [gate.stmts.Z, gate.stmts.SqrtY, gate.stmts.S],
33-
(1, 1, 3): [Sdag, gate.stmts.SqrtY, gate.stmts.S],
34-
(1, 2, 0): [gate.stmts.SqrtY, gate.stmts.Z],
35-
(1, 2, 1): [gate.stmts.S, gate.stmts.SqrtY, gate.stmts.Z],
36-
(1, 2, 2): [gate.stmts.Z, gate.stmts.SqrtY, gate.stmts.Z],
37-
(1, 2, 3): [Sdag, gate.stmts.SqrtY, gate.stmts.Z],
38-
(1, 3, 0): [gate.stmts.SqrtY, Sdag],
39-
(1, 3, 1): [gate.stmts.S, gate.stmts.SqrtY, Sdag],
40-
(1, 3, 2): [gate.stmts.Z, gate.stmts.SqrtY, Sdag],
41-
(1, 3, 3): [Sdag, gate.stmts.SqrtY, Sdag],
38+
(1, 1, 0): [gate.stmts.S, SqrtXdag],
39+
(1, 1, 1): [gate.stmts.Z, SqrtXdag],
40+
(1, 1, 2): [Sdag, SqrtXdag],
41+
(1, 1, 3): [SqrtXdag],
42+
(1, 2, 0): [gate.stmts.Z, SqrtYdag],
43+
(1, 2, 1): [Sdag, SqrtYdag],
44+
(1, 2, 2): [SqrtYdag],
45+
(1, 2, 3): [gate.stmts.S, SqrtYdag],
46+
(1, 3, 0): [Sdag, gate.stmts.SqrtX],
47+
(1, 3, 1): [gate.stmts.SqrtX],
48+
(1, 3, 2): [gate.stmts.S, gate.stmts.SqrtX],
49+
(1, 3, 3): [gate.stmts.Z, gate.stmts.SqrtX],
4250
(2, 0, 0): [gate.stmts.Y],
4351
(2, 0, 1): [gate.stmts.S, gate.stmts.Y],
44-
(2, 0, 2): [gate.stmts.Z, gate.stmts.Y],
52+
(2, 0, 2): [gate.stmts.X],
4553
(2, 0, 3): [Sdag, gate.stmts.Y],
4654
}
4755

@@ -106,6 +114,10 @@ def rewrite_U3(self, node: gate.stmts.U3) -> RewriteResult:
106114
for gate_stmt in gates:
107115
if gate_stmt is Sdag:
108116
new_stmt = gate.stmts.S(adjoint=True, qubits=node.qubits)
117+
elif gate_stmt is SqrtXdag:
118+
new_stmt = gate.stmts.SqrtX(adjoint=True, qubits=node.qubits)
119+
elif gate_stmt is SqrtYdag:
120+
new_stmt = gate.stmts.SqrtY(adjoint=True, qubits=node.qubits)
109121
else:
110122
new_stmt = gate_stmt(qubits=node.qubits)
111123
new_stmt.insert_before(node)

src/bloqade/stim/emit/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
from . import impls as impls
12
from .stim_str import FuncEmit as FuncEmit, EmitStimMain as EmitStimMain

src/bloqade/stim/emit/impls.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from kirin.emit import EmitStrFrame
2+
from kirin.interp import MethodTable, impl
3+
from kirin.dialects.debug import Info, dialect
4+
5+
from bloqade.stim.emit.stim_str import EmitStimMain
6+
7+
8+
@dialect.register(key="emit.stim")
9+
class EmitStimDebugMethods(MethodTable):
10+
11+
@impl(Info)
12+
def info(self, emit: EmitStimMain, frame: EmitStrFrame, stmt: Info):
13+
14+
msg: str = frame.get(stmt.msg)
15+
emit.writeln(frame, f"# {msg}")
16+
17+
return ()

test/cirq_utils/test_cirq_to_squin.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,6 @@ def multi_arg(n: int, p: float):
402402
print(circuit)
403403

404404

405-
if __name__ == "__main__":
406-
test_kernel_with_args()
407-
408-
409-
@pytest.mark.xfail
410-
def test_amplitude_damping():
411-
test_circuit(amplitude_damping)
412-
413-
414405
def test_trotter():
415406

416407
# NOTE: stolen from jonathan's tutorial

test/cirq_utils/test_clifford_to_cirq.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from bloqade import squin
1111
from bloqade.pyqrack import Measurement, StackMemorySimulator
12-
from bloqade.cirq_utils import emit, emit_circuit
12+
from bloqade.cirq_utils import emit_circuit
1313

1414

1515
def test_pauli():
@@ -211,30 +211,6 @@ def main():
211211
print(circuit)
212212

213213

214-
@pytest.mark.xfail
215-
def test_invoke_cache():
216-
@squin.kernel
217-
def sub_kernel(q_: squin.qubit.Qubit):
218-
squin.h(q_)
219-
220-
@squin.kernel
221-
def main():
222-
q = squin.qalloc(2)
223-
q0 = q[0]
224-
sub_kernel(q0)
225-
sub_kernel(q[1])
226-
sub_kernel(q0)
227-
228-
target = emit.base.EmitCirq(main.dialects)
229-
230-
circuit = target.run(main, ())
231-
232-
print(circuit)
233-
234-
# caches as well as squin.h and squin.broadcast.h with the different qubits
235-
assert len(target._cached_invokes) == 6
236-
237-
238214
def test_rot():
239215
@squin.kernel
240216
def main():

test/pyqrack/squin/test_kernel.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def broadcast_adjoint():
186186
assert result == ilist.IList([0, 0, 0])
187187

188188

189-
@pytest.mark.xfail
190189
def test_reset():
191190
@squin.kernel
192191
def main():

0 commit comments

Comments
 (0)