Skip to content
Closed
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
8cc90c4
bring record analysis work over
johnzl-777 Nov 9, 2025
4e56293
save wip test_record_analysis
johnzl-777 Nov 10, 2025
7c1c306
Merge branch 'main' into john/repeat-support
johnzl-777 Nov 10, 2025
8115bf4
Merge branch 'main' into john/repeat-support
johnzl-777 Nov 11, 2025
eee712d
update to new kirin
johnzl-777 Nov 11, 2025
4e1da7b
almost there, still a problem with invariance checking
johnzl-777 Nov 17, 2025
09130c6
loop invariance support complete
johnzl-777 Nov 18, 2025
cf5cb1f
add a set observable just to really make sure things work properly
johnzl-777 Nov 18, 2025
43675fd
fix variable names in test
johnzl-777 Nov 20, 2025
d19f3ef
move record analysis prototype into measure id analysis
johnzl-777 Nov 21, 2025
6bbf11f
add REPEAT statement in stim
johnzl-777 Nov 21, 2025
ca354af
save work before trying to hammer down obnoxious ownership issues
johnzl-777 Nov 23, 2025
3f7ad41
corrected logic in record analysis prototype with Kai's advice, can s…
johnzl-777 Nov 24, 2025
d4113e6
get rid of a bunch of debug print statements
johnzl-777 Nov 24, 2025
4920273
remove more record analysis debug prints and move everything into mea…
johnzl-777 Nov 24, 2025
a8da761
try to merge in latest work
johnzl-777 Dec 4, 2025
79880d4
Merge branch 'main' into john/repeat-support
johnzl-777 Dec 7, 2025
a39a126
latest attempt to try to reconcile type lattices
johnzl-777 Dec 8, 2025
8c5f453
Merge branch 'main' into john/repeat-support
johnzl-777 Dec 8, 2025
b4c4559
still need to find a solution to proper IfElse handling
johnzl-777 Dec 9, 2025
5aa3bfc
Merge branch 'main' into john/repeat-support
johnzl-777 Dec 9, 2025
927fcd8
figured out way to handle scf.IfElse with new lattice
johnzl-777 Dec 9, 2025
4d62a47
get decent portion of qubit and annotate to stim tests fully working,…
johnzl-777 Dec 10, 2025
5013602
delay CSE due to getitem uniqueness issues
johnzl-777 Dec 10, 2025
4da0eed
Merge branch 'main' into john/repeat-support
johnzl-777 Dec 10, 2025
9be26cd
fix coordinate conversion with ilist as the new type for set_detector
johnzl-777 Dec 11, 2025
782ca80
caught some problems with coordinate rewrite as well as address analy…
johnzl-777 Dec 12, 2025
356dcfd
need to remove dead measures, confirm full repetition code works
johnzl-777 Dec 12, 2025
d4858d3
remove debug print statement
johnzl-777 Dec 12, 2025
1b4fbd4
fix test failures with coordinates
johnzl-777 Dec 15, 2025
32a6582
restore test functionality, missed the measurement inbetween to get t…
johnzl-777 Dec 15, 2025
0fec8ba
finish turning development examples into proper tests
johnzl-777 Dec 16, 2025
9ec62d4
finally let go of the original record analysis. Farewell old friend
johnzl-777 Dec 16, 2025
d4f2bb3
Merge branch 'main' into john/repeat-support
weinbe58 Dec 17, 2025
41c663f
make emit test cleaner
johnzl-777 Jan 8, 2026
7312190
Merge branch 'main' into john/repeat-support
johnzl-777 Jan 8, 2026
3ff722e
get Rafael's latest work to pass with current infrastructure
johnzl-777 Jan 8, 2026
54d3d15
resolve merge conflict with main
johnzl-777 Jan 20, 2026
0c57b70
work with explicit observable idx
johnzl-777 Jan 20, 2026
c0e9203
add surface code memory test
johnzl-777 Jan 22, 2026
8e61f22
add fix for unrolling things that live in REPEATable loops
johnzl-777 Jan 25, 2026
216331b
completed surface code memory test. Coordinates need some additional …
johnzl-777 Jan 25, 2026
42253ed
update pre-commit to stay in line with CI
johnzl-777 Jan 25, 2026
2d0e023
update pre-commit to stay in line with CI
johnzl-777 Jan 25, 2026
26b2477
fix incorrect coordinate format causing test to fail
johnzl-777 Jan 25, 2026
4756567
resolve merge conflict with main
johnzl-777 Jan 27, 2026
2bb15cf
get rid of unnecessary comment
johnzl-777 Jan 29, 2026
e6a2444
add missing logic for predicate handling
johnzl-777 Jan 29, 2026
9f44948
Merge branch 'main' into john/repeat-support
johnzl-777 Jan 29, 2026
4cdc9dc
get rid of unnecessary test
johnzl-777 Jan 29, 2026
92f2d4d
get another test to pass
johnzl-777 Jan 29, 2026
6e05d6f
remove another xfail test, unroll works as expected with REPEAT
johnzl-777 Jan 29, 2026
8e4f8f6
get multiple ifs on same predicated measurement to work
johnzl-777 Feb 2, 2026
dc88348
change the MeasurementIDAnalysis type lattice so there is no need for…
johnzl-777 Feb 2, 2026
85c7bba
Merge branch 'main' into john/repeat-support
johnzl-777 Feb 2, 2026
afc09ba
get rid of old comment
johnzl-777 Feb 3, 2026
f49b915
Merge branch 'main' into john/repeat-support
johnzl-777 Feb 3, 2026
41e7427
provide information on reason for xfail marker
johnzl-777 Feb 3, 2026
711e7dd
re-enable ALL CSE, remove dependence on special CSE ordering altogether
johnzl-777 Feb 3, 2026
5ee87d0
remove old redundant unit test
johnzl-777 Feb 4, 2026
d6ef809
add additional logic to restore IfElse measurement ID analysis
johnzl-777 Feb 4, 2026
ae23aa5
resolve merge conflict with new analysis from Phil
johnzl-777 Feb 5, 2026
146cc4b
rename some things I didn't agree with Claude/Cursor on
johnzl-777 Feb 5, 2026
39595a9
implement the easier revisions from Phil's feedback
johnzl-777 Feb 5, 2026
36a54d8
decouple the types from the GlobalRecordState tracking
johnzl-777 Feb 5, 2026
f10e37d
incorporate more feedback
johnzl-777 Feb 5, 2026
7f63fe3
remove assertions in ScfForToStim
johnzl-777 Feb 5, 2026
47d2bff
add coordinate propogation infrastructure to measurement ID analysis
johnzl-777 Feb 6, 2026
f44f025
get rid of index filling logic, it doesn't match the semantics proper…
johnzl-777 Feb 10, 2026
a49959e
tidy some of the helper functions up
johnzl-777 Feb 13, 2026
2df087c
get support for accumulation semantics completed
johnzl-777 Feb 16, 2026
cd62823
Merge branch 'main' into john/repeat-support
johnzl-777 Feb 16, 2026
f3312ea
add some clarifying comments
johnzl-777 Feb 17, 2026
cf95d84
allow negative indices + detectors to work in loop
johnzl-777 Feb 17, 2026
37f916e
correct the color code init test, gates definitely wrong for subkernel
johnzl-777 Feb 18, 2026
fe1487d
Merge branch 'main' into john/repeat-support
johnzl-777 Feb 18, 2026
5007f01
Merge branch 'main' into john/repeat-support
johnzl-777 Feb 19, 2026
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
1 change: 1 addition & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ mch = "mch"
IY = "IY"
ket = "ket"
typ = "typ"
anc_qs = "anc_qs" # "ancilla qubits" variable abbreivation - used to be autocorrected to AND_QS! :sigh:
OT = "OT"
64 changes: 58 additions & 6 deletions src/bloqade/analysis/measure_id/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,77 @@

from kirin import ir
from kirin.analysis import ForwardExtra
from kirin.dialects import ilist
from typing_extensions import Self
from kirin.analysis.forward import ForwardFrame

from .lattice import MeasureId, NotMeasureId
from .lattice import (
MeasureId,
NotMeasureId,
RawMeasureId,
MeasureIdTuple,
)


@dataclass
class GlobalRecordState:
type_for_scf_conds: dict[ir.Statement, MeasureId] = field(default_factory=dict)
buffer: list[RawMeasureId] = field(default_factory=list)

def add_record_idxs(self, num_new_records: int) -> MeasureIdTuple:
# adjust all previous indices
for record_idx in self.buffer:
record_idx.idx -= num_new_records

# generate new indices and add them to the buffer
new_record_idxs = [RawMeasureId(-i) for i in range(num_new_records, 0, -1)]
self.buffer += new_record_idxs
# Return for usage, idxs linked to the global state
return MeasureIdTuple(data=tuple(new_record_idxs), obj_type=ilist.IList)

def clone_measure_id_tuple(
self, measure_id_tuple: MeasureIdTuple
) -> MeasureIdTuple:
cloned_members = []
for measure_id in measure_id_tuple.data:
cloned_measure_id = self.clone_measure_ids(measure_id)
cloned_members.append(cloned_measure_id)
return MeasureIdTuple(
data=tuple(cloned_members),
obj_type=measure_id_tuple.obj_type,
predicate=measure_id_tuple.predicate,
)

def clone_raw_measure_id(self, raw_measure_id: RawMeasureId) -> RawMeasureId:
cloned_raw_measure_id = RawMeasureId(
raw_measure_id.idx, predicate=raw_measure_id.predicate
)
self.buffer.append(cloned_raw_measure_id)
return cloned_raw_measure_id

def clone_measure_ids(self, measure_id_type: MeasureId) -> MeasureId:
if isinstance(measure_id_type, RawMeasureId):
return self.clone_raw_measure_id(measure_id_type)
elif isinstance(measure_id_type, MeasureIdTuple):
return self.clone_measure_id_tuple(measure_id_type)
return None

def offset_existing_records(self, offset: int):
for record_idx in self.buffer:
record_idx.idx -= offset


@dataclass
class MeasureIDFrame(ForwardFrame[MeasureId]):
num_measures_at_stmt: dict[ir.Statement, int] = field(default_factory=dict)
global_record_state: GlobalRecordState = field(default_factory=GlobalRecordState)
type_for_scf_conds: dict[ir.Statement, MeasureId] = field(default_factory=dict)
measure_count_offset: int = 0


class MeasurementIDAnalysis(ForwardExtra[MeasureIDFrame, MeasureId]):

keys = ["measure_id"]
lattice = MeasureId
# for every kind of measurement encountered, increment this
# then use this to generate the negative values for target rec indices
measure_count = 0
detector_count = 0
observable_count = 0
Expand All @@ -34,8 +88,6 @@ def initialize_frame(
) -> MeasureIDFrame:
return MeasureIDFrame(node, has_parent_access=has_parent_access)

# Still default to bottom,
# but let constants return the softer "NoMeasureId" type from impl
def eval_fallback(
self, frame: ForwardFrame[MeasureId], node: ir.Statement
) -> tuple[MeasureId, ...]:
Expand Down
Loading
Loading