Add Stim detector error model export for ECC codes#748
Closed
Oishi1029 wants to merge 2 commits into
Closed
Conversation
Add to the ECC module a code-capacity detector error model builder `detector_error_model(code; px, py, pz)` and a deterministic Stim `.dem` text writer `write_detector_error_model(io_or_path, dem)`, following the conventions of `parity_checks` (detector row order) and `faults_matrix` (logical observable row order). Closes QuantumSavory#726
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #748 +/- ##
==========================================
+ Coverage 74.01% 74.05% +0.04%
==========================================
Files 111 112 +1
Lines 7778 7825 +47
==========================================
+ Hits 5757 5795 +38
- Misses 2021 2030 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
We do not accept LLM-generated PRs by unknown developers for our bounties. |
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.
Closes #726.
Adds a code-capacity detector error model builder and a deterministic Stim
.demwriter toQuantumClifford.ECC, per the issue's suggested API:What it does
detector_error_model(code_or_stabilizer; px, py, pz)builds a smallDetectorErrorModelstruct: one independent error mechanism per qubit per enabled Pauli fault (error(p)Bernoulli semantics, matching Stim).Dᵢis 1-based rowi+1ofparity_checks(code)(QuantumClifford's stabilizer row order, as the issue suggests; documented in the docstrings). A fault flipsDᵢiff it anticommutes with that row, viacomm— so non-CSS codes work by construction.Lⱼis rowj+1offaults_matrix(code)(L0…L(k−1)logical-X,Lk…L(2k−1)logical-Z); flips arefaults_matrix(code) * stab_to_gf2(fault), read off the faults-matrix columns.write_detector_error_model(io_or_path, dem)emits explicitdetector D…/logical_observable L…declarations followed by theerror(p) D… L…lines. Output is deterministic (fixed iteration order, sorted targets,\nnewlines, Julia's platform-stable shortest float printing).error(p) L…lines; faults flipping nothing are omitted (zero decoding information; the.demgrammar wants ≥1 target).Tests
commagainst every parity-check row, and logical targets against the literalO * stab_to_gf2(fault), forSteane7, Shor9, Perfect5, Cleve8, Bitflip3, Gottesman(3)(CSS and non-CSS, k=1 and k=3) — the two acceptance criteria in their own words..demtext) for Steane7 (the issue's example call) and the non-CSS Perfect5, pinning the deterministic ordering and the documented conventions.Bitflip3), and probability validation.QC_TEST_STIM=true+ python3 withstim) that parses the exported file with the real Stim parser and checks detector/observable/error counts — off by default so the suite needs no Python, as the issue requests.Docs: docstrings (autodocs) with a
jldoctest, plus an "Exporting a Stim detector error model" section with a Stim-parsing example on the Pauli-frame ECC example page. CHANGELOG entry + dev version bump included.Out of scope, per the issue: circuit-level extraction, correlated faults, coordinates/
repeatblocks, decoders. The emitted dialect is the minimal subset of the.demgrammar, so it round-trips with any conforming DEM importer (e.g. a future #728 import path) — no dependency on one.Test evidence
Disclosure: I used Claude (Anthropic) to help draft the implementation and tests, which I then reviewed, manually verified, and tested locally. Returning unitaryHACK contributor (harmoniqs/Legato.jl#27, harmoniqs/Piccolo.jl#238). unitaryHACK 2026 submission.