Skip to content

Support custom (interleaved) syndrome-extraction schedules in detector annotation#69

Open
Pritesh402 wants to merge 1 commit into
tqec:mainfrom
Pritesh402:fix/custom-cnot-detectors
Open

Support custom (interleaved) syndrome-extraction schedules in detector annotation#69
Pritesh402 wants to merge 1 commit into
tqec:mainfrom
Pritesh402:fix/custom-cnot-detectors

Conversation

@Pritesh402

Copy link
Copy Markdown

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.

Issue creation is restricted, so opening as a PR.

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.
@nelimee nelimee added the enhancement New feature or request label Jul 3, 2026
@HaoTy HaoTy requested a review from Copilot July 6, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.schedule to (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_automatically to route affected circuits through the normalization + transplant path.
  • Add a regression test and a new interleaved schedule .stim fixture 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 thread src/tqecd/schedule.py
Comment on lines +172 to +176
elif (
inst.name in _PRESERVED_ANNOTATIONS
or inst.name in _REGENERATED_ANNOTATIONS
):
continue
Comment thread src/tqecd/schedule.py
Comment on lines +250 to +254
if (
not isinstance(inst, stim.CircuitRepeatBlock)
and inst.name in _REGENERATED_ANNOTATIONS
):
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants