Add experimental Stim MPP rewriter#246
Open
masa10-f wants to merge 1 commit into
Open
Conversation
Add graphqomb.stim_mpp_rewriter.rewrite_to_mpp, which rewrites noiseless gate-level syndrome-extraction circuits into abstract MPP measurements. Each measurement Pauli is conjugated backwards through its segment's Clifford body via stim.PauliString.before, stabilizers of freshly initialized measured-out ancillas are substituted by +1, and the inferred data product replaces the measurement at the same record position so DETECTOR and OBSERVABLE_INCLUDE annotations copy verbatim. MR splits into MPP plus a reset, and a CheckMapping sidecar links every record to its inferred product. By default every rewritten segment is verified against its source by cross-checking stabilizer-flow generators with measured-out ancillas reset in both copies, so residual data-qubit unitaries raise MppRewriteVerificationError. Noise, classical feedback, and reuse of unreset measurement post-states raise UnsupportedSyndromeCircuitError. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #246 +/- ##
==========================================
+ Coverage 86.55% 86.57% +0.02%
==========================================
Files 31 32 +1
Lines 5264 5573 +309
Branches 937 997 +60
==========================================
+ Hits 4556 4825 +269
- Misses 499 524 +25
- Partials 209 224 +15 🚀 New features to boost your workflow:
|
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.
Summary
Adds an experimental module
graphqomb.stim_mpp_rewriterthat rewrites noiseless gate-level syndrome-extraction circuits into abstractMPPmeasurements:How it works
stim.PauliString.before, i.e.U† P U) and substitutes+1for stabilizers of freshly initialized, measured-out ancillas. Stripping is restricted to qubits measured out within the same segment, so round-1 data resets are kept in the inferred products.DETECTOR/OBSERVABLE_INCLUDEare copied verbatim,MRsplits intoMPP+ reset, and trivial data measurements pass through unchanged.CheckMappingsidecar linking every record to its inferred signed Pauli product, segment index, and source ancilla, for downstream MBQC lowering.Verification
By default every rewritten segment is verified against its source segment by cross-checking
flow_generators()in both directions (with measured-out ancillas reset in both copies to discard the intentionally different post-measurement states). This catches residual data-qubit unitaries hidden in the extraction body, which per-producthas_flowchecks alone would miss. Passverify=Falseto skip.Scope
UnsupportedSyndromeCircuitError.REPEATblocks are flattened (bakesSHIFT_COORDSinto detector coordinates); preserving them is future work, as is a GF(2) record-transform stage for flag/cat-state circuits.Validation
surface_code:rotated_memory_z/xandrepetition_code:memory(stim-generated, noiseless) round-trip with identical measurement counts, detector counts, andreference_detector_and_observable_signs(); middle rounds infer exactly the code stabilizers.qec.stim_mpp.stabilizer_code_from_stim_textimporter.Test plan
tests/test_stim_mpp_rewriter.py(gadgets in all bases, MR splitting, detector/observable preservation, generated-circuit round trips, tag preservation, and rejection/verification-failure paths)🤖 Generated with Claude Code