This issue is part of unitaryHACK26. You have to be registered to complete this issue.
Learn more about the PR submission process here and about unitaryHACK rules here!
A note about AI Slop: while we are open to collaboration with LLMs for unitaryHACK, fully AI-generated PRs are not acceptable. It is at the maintainers' discretion whether or not LLM-generated PRs are the right fit for the issues, and those that appear fully AI-generated may be immediately rejected. Read unitaryHACK's full AI Policy here.
Note from the maintainer: If you have not contributed before to open source projects, no AI agent use is permitted for this issue.
QuantumClifford already has a strong error-correction layer: code definitions,
parity checks, syndrome circuits, and the faults_matrix helper that maps
physical Pauli faults to logical faults. Stim uses detector error model (.dem)
files as a compact interchange format for syndrome-detector graphs and logical
observable flips. Exporting .dem files from QuantumClifford codes would make it
much easier to compare QuantumClifford simulations with Stim-based workflows and
external decoders.
Relevant links:
Desired user-facing behavior
A user should be able to create a detector error model from one of the ECC code
types and write it to a .dem file that Stim can parse:
using QuantumClifford
using QuantumClifford.ECC
dem = detector_error_model(Steane7(); px=1e-3, py=0.0, pz=1e-3)
write_detector_error_model("steane7.dem", dem)
The exact API can be adjusted, but it should support both returning an in-memory
model and writing directly to an IO or filename:
detector_error_model(code; px, py, pz)
write_detector_error_model(io, dem)
write_detector_error_model(path::AbstractString, dem)
Suggested implementation
Start with a code-capacity detector error model generated from the code's parity
checks:
- Use
parity_checks(code) as the detector definitions.
- For each physical qubit and each enabled Pauli fault (
X, Y, Z), compute
the stabilizer checks flipped by that fault.
- Use
faults_matrix(code) to compute which logical observables are flipped by
the same fault.
- Emit one
error(p) D... L... line per nonzero physical fault probability.
- Emit deterministic detector and logical-observable declarations so output is
stable across runs and easy to test.
For example, a single-qubit Pauli error that flips checks 1 and 4 and logical
observable 0 should produce a line equivalent to:
The exact detector numbering can follow QuantumClifford's internal stabilizer
row order. Please document the convention.
In scope
- A small internal representation for detector error models, or a direct writer
if that is simpler.
- Support for independent
X, Y, and Z physical fault probabilities.
- Export for at least the built-in ECC codes where
parity_checks and
faults_matrix are available.
- Deterministic
.dem text output.
- Unit tests for a few small codes.
- A smoke test that verifies the emitted
.dem file can be parsed by Stim when
Stim is available in the test environment. This can be optional or guarded so
the Julia test suite does not require Python by default.
- Documentation with a short example.
Out of scope
- Full circuit-to-DEM extraction for noisy syndrome extraction circuits.
- Modeling correlated gate faults from a full hardware schedule.
- Coordinates, repeated rounds, or
repeat blocks, unless they fall out
naturally from the implementation.
- Building or integrating a decoder.
Acceptance criteria
detector_error_model(Steane7(); px=..., py=..., pz=...) or an equivalent API
exists and is exported or documented.
- The generated
.dem files follow Stim's detector error model syntax.
- Tests check that detector targets match the stabilizers flipped by the
corresponding Pauli error.
- Tests check that logical targets match
faults_matrix(code).
- The output ordering is deterministic.
- Docs show how to generate a
.dem file and parse it with Stim.
This issue is part of unitaryHACK26. You have to be registered to complete this issue.
Learn more about the PR submission process here and about unitaryHACK rules here!
A note about AI Slop: while we are open to collaboration with LLMs for unitaryHACK, fully AI-generated PRs are not acceptable. It is at the maintainers' discretion whether or not LLM-generated PRs are the right fit for the issues, and those that appear fully AI-generated may be immediately rejected. Read unitaryHACK's full AI Policy here.
Note from the maintainer: If you have not contributed before to open source projects, no AI agent use is permitted for this issue.
QuantumClifford already has a strong error-correction layer: code definitions,
parity checks, syndrome circuits, and the
faults_matrixhelper that mapsphysical Pauli faults to logical faults. Stim uses detector error model (
.dem)files as a compact interchange format for syndrome-detector graphs and logical
observable flips. Exporting
.demfiles from QuantumClifford codes would make itmuch easier to compare QuantumClifford simulations with Stim-based workflows and
external decoders.
Relevant links:
Desired user-facing behavior
A user should be able to create a detector error model from one of the ECC code
types and write it to a
.demfile that Stim can parse:The exact API can be adjusted, but it should support both returning an in-memory
model and writing directly to an
IOor filename:Suggested implementation
Start with a code-capacity detector error model generated from the code's parity
checks:
parity_checks(code)as the detector definitions.X,Y,Z), computethe stabilizer checks flipped by that fault.
faults_matrix(code)to compute which logical observables are flipped bythe same fault.
error(p) D... L...line per nonzero physical fault probability.stable across runs and easy to test.
For example, a single-qubit Pauli error that flips checks 1 and 4 and logical
observable 0 should produce a line equivalent to:
The exact detector numbering can follow QuantumClifford's internal stabilizer
row order. Please document the convention.
In scope
if that is simpler.
X,Y, andZphysical fault probabilities.parity_checksandfaults_matrixare available..demtext output..demfile can be parsed by Stim whenStim is available in the test environment. This can be optional or guarded so
the Julia test suite does not require Python by default.
Out of scope
repeatblocks, unless they fall outnaturally from the implementation.
Acceptance criteria
detector_error_model(Steane7(); px=..., py=..., pz=...)or an equivalent APIexists and is exported or documented.
.demfiles follow Stim's detector error model syntax.corresponding Pauli error.
faults_matrix(code)..demfile and parse it with Stim.