Skip to content

Commit e74f109

Browse files
committed
add AnyMeasureId specific test
1 parent e37e1ab commit e74f109

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/analysis/measure_id/test_measure_id.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from bloqade.analysis.measure_id import MeasurementIDAnalysis
66
from bloqade.stim.passes.flatten import Flatten
77
from bloqade.analysis.measure_id.lattice import (
8+
AnyMeasureId,
89
NotMeasureId,
910
MeasureIdBool,
1011
MeasureIdTuple,
@@ -160,6 +161,33 @@ def test():
160161
assert len(analysis_results) == 2
161162

162163

164+
def test_scf_cond_unknown():
165+
166+
@squin.kernel
167+
def test(cond: bool):
168+
q = squin.qalloc(5)
169+
squin.x(q[2])
170+
171+
if cond:
172+
ms = squin.broadcast.measure(q)
173+
else:
174+
ms = squin.measure(q[0])
175+
176+
return ms
177+
178+
InlinePass(test.dialects).fixpoint(test)
179+
frame, _ = MeasurementIDAnalysis(test.dialects).run_analysis(test)
180+
# the result of the analysis on this Scf.IfElse should be two AnyMeasureIds.
181+
# One AnyMeasureId is from resolving the boolean type, which does not change
182+
# during any of the branches. The other is from the fact that broadcast.measure gives
183+
# an AnyMeasureId because it cannot figure out the concrete number of measurements, which has to be
184+
# joined against the MeasureIdBool from the other branch.
185+
assert list(frame.entries.values())[-2:] == [AnyMeasureId(), AnyMeasureId()]
186+
187+
188+
test_scf_cond_unknown()
189+
190+
163191
def test_slice():
164192
@squin.kernel
165193
def test():

0 commit comments

Comments
 (0)