Detector error models
Extract a DEM, then sample it
Turn a noisy circuit into detector-error mechanisms for downstream decoders.
Run it
Analyze once, sample directly
Requires rstim on PATH. If you installed only rustqec with Cargo, add the Stim-style CLI below; the native package already includes it. Run in a scratch directory. The example below provides its complete input.
cargo install --locked rstim --version 0.3.0 --bin rstim --features cli,codegen-css,shot-viewer
This deterministic example resets one qubit, applies an X error with probability 1, then measures a detector and observable. Create the input in your current working directory:
cat > circuit.stim <<'STIM'
R 0
X_ERROR(1) 0
M 0
DETECTOR rec[-1]
OBSERVABLE_INCLUDE(0) rec[-1]
STIM
rstim analyze_errors --in circuit.stim --out model.dem
rstim sample_dem --in model.dem --shots 1 --out_format dets
Expected: model.dem contains error(1) D0 L0; sampling prints shot D0 L0. Next: choose a decoder.
Example results
Detection and DEM sampling
These are separate, recorded workloads. Compare implementations only within the same workload and metric; reproduction details and limits are below.
| Workload | Implementation | Metric | Result |
|---|---|---|---|
| Surface d=13, r=13 detect | rstim compiled | Elapsed time · lower is better | 34.339 ms |
| Surface d=13, r=13 detect | Stim CLI | Elapsed time · lower is better | 266.172 ms |
| Surface d=11, r=100 DEM sample | rstim | Throughput · higher is better | 329 shots/s |
| Surface d=11, r=100 DEM sample | Stim | Throughput · higher is better | 2,669 shots/s |
Benchmark evidence
Checked DEM results
Loading detector-model evidence.