Skip to content

Add code-agnostic detector discovery for Clifford tick circuits - #1363

Open
ciaranra wants to merge 2 commits into
mx-restores-x-eigenstatefrom
detector-discovery
Open

ciaranra wants to merge 2 commits into
mx-restores-x-eigenstatefrom
detector-discovery

Conversation

@ciaranra

@ciaranra ciaranra commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Stacked on #1362 (the MX fix), because the replay must execute MX as H, MZ, H. This PR retargets to dev when that one merges.

Adds code-agnostic detector discovery for Clifford TickCircuits: pecos.qec.discover_detectors(tc, observables=()), backed by pecos_qec::fault_tolerance::detector_discovery::discover_detectors.

Rule

  • Which measurements are deterministic: decided by the full symbolic history, starting from the real |0^n> state.
  • Finding the detector for a deterministic measurement j:
    • Find the latest tick boundary T such that j is still deterministic when ticks [T, tick(j)] are replayed from an unknown input. Each qubit is Bell-purified with a reference qubit to make the input unknown.
    • The search runs backwards from j, exponentially and then by bisection.
    • j's detector is its relation within that suffix, expressed over the suffix's own records by newest-first elimination.
    • Its reference is the XOR of the constants of every deterministic member.
  • Observables are inputs.
    • Each declared observable, given as its terminal records, is completed with random-source records.
    • It is rejected with an error naming it if it is not deterministic.
    • The pivot relation of each declared observable is left out of the detector set.
    • A deterministic logical parity that is not declared becomes a detector; this is documented.
  • The tick replay used by symbolic_measurement_history is factored so that the full history and the suffix probes share one gate table. symbolic_measurement_history keeps its exact behaviour and errors.

A simpler choice, picking each detector by shrinking the set of faults that flip it, was tried first and rejected. On surface final readouts it fell into local minima. Choosing by when determinism is established reproduces the hand-built detectors exactly.

Verification

  • Hand-built surface detectors: for d ∈ {3, 5}, X and Z bases, 3 and 6 rounds, the discovered record sets equal the circuit's own hand-built detectors exactly.
  • Ranks and references: rank(detectors + observables) equals the rank of the deterministic parity space from 2048-shot samples, and no observable lies in the span of the detectors.
  • Rust unit tests:
    • repeated checks, including the final-readout detector;
    • C4 swap-out syndrome rounds with unapplied feed-forward, which give single-measurement detectors;
    • a nonzero reference through a substituted deterministic member, checked against a noiseless replay;
    • implicit initialization;
    • observable completion and exclusion;
    • errors.
  • Independent review:
    • 1200+ random circuits were compared exactly against an independent Stim oracle (latest T found by linear scan), with 0 mismatches;
    • 13 of 14 mutants were killed; the survivor, a linear instead of exponential back-off, behaves identically.
  • Speed: surface d=7 takes 1.3 s at 20 rounds (1033 records) and 6.5 s at 100 rounds (4873 records), in a debug build.
  • Results:
    • cargo test -p pecos-qec: 1355 passed;
    • the qec-guppy shard, python-ci-lint and pre-commit pass.

Known limitation, pre-existing

#1360: SymbolicSparseStab::pz postselects instead of resetting when the qubit is entangled and unmeasured. Discovery inherits that, so circuits that reset an entangled qubit without measuring it can get a wrong detector. Surface memory and gadget circuits only reset after measuring and are unaffected. The fix is tracked in #1360.

A MeasureLeaked dependency inside a backward probe raises the shared replay error, even when the full history is representable. This is documented on the function.

…st deterministic suffix, newest-first relations, declared observables).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant