Support custom (interleaved) syndrome-extraction schedules in detector annotation#69
Open
Pritesh402 wants to merge 1 commit into
Open
Support custom (interleaved) syndrome-extraction schedules in detector annotation#69Pritesh402 wants to merge 1 commit into
Pritesh402 wants to merge 1 commit into
Conversation
annotate_detectors_automatically silently returned an incomplete set of detectors for circuits whose schedule interleaves collapsing operations with computation (e.g. a depth-optimized rotated surface code whose X-ancilla RX shares a moment with two-qubit gates, or whose Z/X ancillas are measured in separate moments). Such circuits pass is_valid_input_circuit but Fragment only collects leading resets / trailing measurements, and matching is consecutive- only, so interleaved collapsing ops are dropped and cross-round detectors are never found. Add tqecd.schedule, which detects when a fragment would drop a collapsing op, rebuilds a logically-equivalent circuit with the canonical per-round shape, annotates it, and transplants the detectors back onto the original circuit (valid because the measurement record order is preserved). Circuits already handled correctly are left on the unchanged code path.
There was a problem hiding this comment.
Pull request overview
This PR extends detector annotation to support circuits whose syndrome-extraction schedule interleaves collapsing operations (resets/measurements) with computation, by normalizing such circuits into a canonical per-round shape for annotation and then transplanting the resulting detectors back onto the original circuit.
Changes:
- Add
tqecd.scheduleto (1) detect when fragment splitting would drop interleaved collapsing ops, (2) canonicalize the schedule, and (3) transplant detectors back onto the original circuit. - Update
annotate_detectors_automaticallyto route affected circuits through the normalization + transplant path. - Add a regression test and a new interleaved schedule
.stimfixture demonstrating previously-dropped detectors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/tqecd/test_files/valid/surface_code_rotated_memory_z_distance_3_interleaved_reset.stim |
New fixture circuit with an interleaved reset schedule and expected detector annotations. |
src/tqecd/schedule.py |
New scheduling-normalization and detector-transplant implementation. |
src/tqecd/schedule_test.py |
Tests covering schedule detection, canonicalization record-order preservation, and recovered detectors. |
src/tqecd/construction.py |
Integrates normalization path into annotate_detectors_automatically. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+172
to
+176
| elif ( | ||
| inst.name in _PRESERVED_ANNOTATIONS | ||
| or inst.name in _REGENERATED_ANNOTATIONS | ||
| ): | ||
| continue |
Comment on lines
+250
to
+254
| if ( | ||
| not isinstance(inst, stim.CircuitRepeatBlock) | ||
| and inst.name in _REGENERATED_ANNOTATIONS | ||
| ): | ||
| continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
annotate_detectors_automaticallysilently returned an incomplete set of detectors for circuits whose schedule interleaves collapsing operations with computation (e.g. a depth-optimized rotated surface code whose X-ancilla RX shares a moment with two-qubit gates, or whose Z/X ancillas are measured in separate moments). Such circuits passis_valid_input_circuitbutFragmentonly collects leading resets / trailing measurements, and matching is consecutive- only, so interleaved collapsing ops are dropped and cross-round detectors are never found.Add
tqecd.schedule, which detects when a fragment would drop a collapsing op, rebuilds a logically-equivalent circuit with the canonical per-round shape, annotates it, and transplants the detectors back onto the original circuit (valid because the measurement record order is preserved). Circuits already handled correctly are left on the unchanged code path.Issue creation is restricted, so opening as a PR.