Add detector-error-model fault distance - #440
Closed
ciaranra wants to merge 1 commit into
Closed
Conversation
Member
Author
|
Folded into #415 — the commit is now on |
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.
Independent of #415 and #439; branches from
dev.Why
Code distance is not circuit distance. A distance-5 code with a syndrome-extraction circuit that spreads a single fault across multiple data qubits can have fault distance 3, so code distance alone can overstate the protection an implementation actually provides. Nothing in PECOS computed the circuit-level number:
check_undetectable_logical_errorsenumerates failing fault configurations but never reports a minimum.This adds the detector-error-model level: the minimum NUMBER OF FAULT MECHANISMS whose XOR-combined effect flips no detector but flips at least one observable. Equivalently, with
Hthe detector-by-mechanism matrix andLthe observable-by-mechanism matrix, the minimum|e|withH*e = 0andL*e != 0— structurally the same problem as stabilizer-code distance, which is why this lands beside the existing fault-tolerance checkers rather than in a separate silo.Two methods, explicitly chosen
graphlike_fault_distanceis exact when every mechanism flips at most two detectors. It searches the parity-doubled graph, treating every detector and the boundary as a BFS root, taking the minimum over roots and observables. Rooting only at the boundary is NOT exact: a DEM whose minimum cycle avoids the boundary entirely (for exampleD0 D1 L0/D1 D2/D0 D2, distance 3, no boundary edges) leaves the boundary node isolated and the search finds nothing. That case is now a regression test.exhaustive_fault_distance(max_weight)is correct for any DEM including hyperedges.max_weightis required rather than defaulted, because the cost is combinatorial in the mechanism count and the caller should own that budget.Mechanisms with hyperedges cause
graphlike_fault_distanceto fail fast with the hyperedge count rather than silently ignoring them. This is deliberate:DemMatchingGraphsilently skips hyperedges, so building on it would have returned quietly wrong distances. The implementation readsto_mechanisms()directly and reusesFaultMechanism::{xor, is_graphlike, is_hyperedge}.Both methods return the witnessing mechanism set, not just the number, mirroring
DistanceResult::min_weight_operator— knowing which faults conspire is the point of the diagnostic.Tests
Eight Rust tests plus two Python binding tests. Beyond the hand-verifiable cases (distance-1 detector-free mechanism, repetition-code triad, budget below distance, no-logical-error), three are deliberately adversarial:
The strongest guard is a seeded property test: 512 randomly generated small graphlike DEMs, asserting the two methods agree on both the distance and whether a solution exists. Fixture-based tests alone shared a blind spot with the original design (every one happened to contain a boundary edge); cross-validating an exact special case against a general reference catches that class of error rather than one instance of it.
Verified by mutation: restricting the BFS roots back to boundary-only fails both the boundary-free regression test and the property test.
Verification
cargo test -p pecos-qec: no failuresuv run --frozen pytest .../test_fault_distance.py: 2 passedjust build-debug,just lint(new files staged first so pre-commit sees them): clean