Skip to content

Commit d0c6ce7

Browse files
committed
Unmark & fix a bunch of qasm2 tests
1 parent 3d97bb2 commit d0c6ce7

File tree

12 files changed

+15
-53
lines changed

12 files changed

+15
-53
lines changed

src/bloqade/qasm2/parse/lowering.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ def visit_Instruction(self, state: lowering.State[ast.Node], node: ast.Instructi
450450
func.Invoke(
451451
callee=value,
452452
inputs=tuple(params + qargs),
453-
kwargs=tuple(),
454453
)
455454
)
456455

src/bloqade/qasm2/rewrite/uop_to_parallel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def same_id_checker(ssa1: ir.SSAValue, ssa2: ir.SSAValue):
6666
assert isinstance(hint1, lattice.Result) and isinstance(
6767
hint2, lattice.Result
6868
)
69-
return hint1.is_equal(hint2)
69+
return hint1.is_structurally_equal(hint2)
7070
else:
7171
return False
7272

src/bloqade/squin/analysis/schedule.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,17 @@ def push_current_dag(self, block: ir.Block):
185185
self.stmt_dag = StmtDag()
186186
self.use_def = {}
187187

188-
def run_method(self, method: ir.Method, args: tuple[GateSchedule, ...]):
189-
# NOTE: we do not support dynamic calls here, thus no need to propagate method object
190-
return self.run_callable(method.code, (self.lattice.bottom(),) + args)
188+
def method_self(self, method: ir.Method) -> GateSchedule:
189+
return self.lattice.bottom()
191190

192-
def eval_stmt_fallback(self, frame: ForwardFrame, stmt: ir.Statement):
193-
if stmt.has_trait(ir.IsTerminator):
191+
def eval_fallback(self, frame: ForwardFrame, node: ir.Statement):
192+
if node.has_trait(ir.IsTerminator):
194193
assert (
195-
stmt.parent_block is not None
194+
node.parent_block is not None
196195
), "Terminator statement has no parent block"
197-
self.push_current_dag(stmt.parent_block)
196+
self.push_current_dag(node.parent_block)
198197

199-
return tuple(self.lattice.top() for _ in stmt.results)
198+
return tuple(self.lattice.top() for _ in node.results)
200199

201200
def _update_dag(self, stmt: ir.Statement, addr: address.Address):
202201
if isinstance(addr, address.AddressQubit):

test/qasm2/passes/test_global_to_parallel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import List
22

3-
import pytest
43
from kirin import ir, types
54
from kirin.rewrite import Walk, Fixpoint, CommonSubexpressionElimination
65
from kirin.dialects import py, func, ilist
@@ -18,7 +17,6 @@ def as_float(value: float):
1817
return py.constant.Constant(value=value)
1918

2019

21-
@pytest.mark.xfail
2220
def test_global2para_rewrite():
2321

2422
@qasm2.extended
@@ -79,7 +77,6 @@ def main():
7977
assert_methods(expected_method, main)
8078

8179

82-
@pytest.mark.xfail
8380
def test_global2para_rewrite2():
8481

8582
@qasm2.extended

test/qasm2/passes/test_global_to_uop.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import List
22

3-
import pytest
43
from kirin import ir, types
54
from kirin.rewrite import Walk, Fixpoint, CommonSubexpressionElimination
65
from kirin.dialects import py, func
@@ -18,7 +17,6 @@ def as_float(value: float):
1817
return py.constant.Constant(value=value)
1918

2019

21-
@pytest.mark.xfail
2220
def test_global_rewrite():
2321

2422
@qasm2.extended

test/qasm2/passes/test_heuristic_noise.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
from kirin import ir, types
32
from kirin.dialects import func, ilist
43
from kirin.dialects.py import constant
@@ -256,7 +255,6 @@ def test_parallel_cz_gate_noise():
256255
assert_nodes(block, expected_block)
257256

258257

259-
@pytest.mark.xfail
260258
def test_global_noise():
261259

262260
@qasm2.extended

test/qasm2/passes/test_parallel_to_global.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import pytest
2-
31
from bloqade import qasm2
42
from bloqade.qasm2.passes.parallel import ParallelToGlobal
53

64

7-
@pytest.mark.xfail
85
def test_basic_rewrite():
96

107
@qasm2.extended
@@ -32,7 +29,6 @@ def main():
3229
)
3330

3431

35-
@pytest.mark.xfail
3632
def test_if_rewrite():
3733
@qasm2.extended
3834
def main():
@@ -67,7 +63,6 @@ def main():
6763
)
6864

6965

70-
@pytest.mark.xfail
7166
def test_should_not_be_rewritten():
7267

7368
@qasm2.extended
@@ -93,7 +88,6 @@ def main():
9388
)
9489

9590

96-
@pytest.mark.xfail
9791
def test_multiple_registers():
9892
@qasm2.extended
9993
def main():
@@ -126,7 +120,6 @@ def main():
126120
)
127121

128122

129-
@pytest.mark.xfail
130123
def test_reverse_order():
131124
@qasm2.extended
132125
def main():

test/qasm2/passes/test_parallel_to_uop.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import List
22

3-
import pytest
43
from kirin import ir, types
54
from kirin.dialects import py, func
65

@@ -17,7 +16,6 @@ def as_float(value: float):
1716
return py.constant.Constant(value=value)
1817

1918

20-
@pytest.mark.xfail
2119
def test_cz_rewrite():
2220

2321
@qasm2.extended

test/qasm2/passes/test_uop_to_parallel.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import pytest
2-
31
from bloqade import qasm2
42
from bloqade.qasm2 import glob
53
from bloqade.analysis import address
64
from bloqade.qasm2.passes import parallel
75
from bloqade.qasm2.rewrite import SimpleOptimalMergePolicy
86

97

10-
@pytest.mark.xfail
118
def test_one():
129

1310
@qasm2.gate
@@ -50,7 +47,6 @@ def test():
5047
)
5148

5249

53-
@pytest.mark.xfail
5450
def test_two():
5551

5652
@qasm2.extended
@@ -89,7 +85,6 @@ def test():
8985
_, _ = address.AddressAnalysis(test.dialects).run(test)
9086

9187

92-
@pytest.mark.xfail
9388
def test_three():
9489

9590
@qasm2.extended

test/qasm2/test_count.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pytest
21
from kirin import passes
32
from kirin.dialects import py, ilist
43

@@ -16,7 +15,6 @@
1615
fold = passes.Fold(qasm2.main.add(py.tuple).add(ilist))
1716

1817

19-
@pytest.mark.xfail
2018
def test_fixed_count():
2119
@qasm2.main
2220
def fixed_count():
@@ -36,7 +34,6 @@ def fixed_count():
3634
assert address.qubit_count == 7
3735

3836

39-
@pytest.mark.xfail
4037
def test_multiple_return_only_reg():
4138

4239
@qasm2.main.add(py.tuple)
@@ -54,7 +51,6 @@ def tuple_count():
5451
assert isinstance(ret.data[1], AddressReg) and ret.data[1].data == range(3, 7)
5552

5653

57-
@pytest.mark.xfail
5854
def test_dynamic_address():
5955
@qasm2.main
6056
def dynamic_address():
@@ -64,14 +60,16 @@ def dynamic_address():
6460
qasm2.measure(ra[0], ca[0])
6561
qasm2.measure(rb[1], ca[1])
6662
if ca[0] == ca[1]:
67-
return ra
63+
ret = ra
6864
else:
69-
return rb
65+
ret = rb
66+
67+
return ret
7068

7169
# dynamic_address.code.print()
7270
dynamic_address.print()
7371
fold(dynamic_address)
74-
frame, result = address.run_analysis(dynamic_address)
72+
frame, result = address.run(dynamic_address)
7573
dynamic_address.print(analysis=frame.entries)
7674
assert isinstance(result, Unknown)
7775

@@ -92,7 +90,6 @@ def dynamic_address():
9290
# assert isinstance(result, ConstResult)
9391

9492

95-
@pytest.mark.xfail
9693
def test_multi_return():
9794
@qasm2.main.add(py.tuple)
9895
def multi_return_cnt():
@@ -110,7 +107,6 @@ def multi_return_cnt():
110107
assert isinstance(result.data[2], AddressReg)
111108

112109

113-
@pytest.mark.xfail
114110
def test_list():
115111
@qasm2.main.add(ilist)
116112
def list_count_analy():
@@ -120,12 +116,11 @@ def list_count_analy():
120116
return f
121117

122118
list_count_analy.code.print()
123-
_, ret = address.run_analysis(list_count_analy)
119+
_, ret = address.run(list_count_analy)
124120

125121
assert ret == AddressReg(data=(0, 1, 3))
126122

127123

128-
@pytest.mark.xfail
129124
def test_tuple_qubits():
130125
@qasm2.main.add(py.tuple)
131126
def list_count_analy2():
@@ -136,7 +131,7 @@ def list_count_analy2():
136131
return f
137132

138133
list_count_analy2.code.print()
139-
_, ret = address.run_analysis(list_count_analy2)
134+
_, ret = address.run(list_count_analy2)
140135
assert isinstance(ret, PartialTuple)
141136
assert isinstance(ret.data[0], AddressQubit) and ret.data[0].data == 0
142137
assert isinstance(ret.data[1], AddressQubit) and ret.data[1].data == 1
@@ -166,7 +161,6 @@ def list_count_analy2():
166161
# assert isinstance(result.data[5], AddressQubit) and result.data[5].data == 6
167162

168163

169-
@pytest.mark.xfail
170164
def test_alias():
171165

172166
@qasm2.main

0 commit comments

Comments
 (0)