wai-quantum 0.3.25: error correction at circuit level, sampled, modelled and decoded exactly #143

Merged
dcharlot merged 1 commit from wai-quantum-qec into main 2026-10-04 20:39:11 -04:00
Owner

What

wai-quantum 0.3.25 handles error correction at the circuit level. An experiment is what it physically is: a noisy Clifford circuit with detectors and observables. The crate can now sample it, derive its detector error model, decode it exactly, and measure the code model that resource estimates otherwise take on trust.

quantum_frame

  • parse reads the ecosystem's circuit text:

    • resets and measurements in Z and X;
    • H, S, √X, Paulis, CX, CZ and SWAP;
    • flip and depolarizing noise;
    • detectors, observables and REPEAT.

    Anything else is an error, not a skipped line.

  • sample is bit-packed Pauli-frame simulation, 64 shots per word, with geometric skipping between noise hits. It is reproducible from (circuit, shots, seed).

  • error_model uses backward sensitivity propagation.

    • It converts depolarizing channels to equivalent independent mechanisms exactly and XOR-merges identical mechanisms.
    • It refuses non-deterministic detectors.
    • A graphlike mechanism stays one matching edge. Otherwise it splits into X and Z halves, then into per-qubit parts.
  • surface_code_memory generates the rotated surface-code memory experiment.

quantum_match

  • Exact minimum-weight perfect matching: Dijkstra on integer weights, then Edmonds' blossom.
    • Boundary paths are computed once per graph.
    • Pairs dominated by their boundary paths are cut, which provably cannot change the optimum.
  • memory_experiment and fit_code_model measure P(d) = a·(p/p*)^((d+1)/2). Under uniform circuit noise the result is a ≈ 0.023, p* ≈ 0.0100.
  • CodeFit::surface_code turns that fit into a resource-estimate model.

CLI

  • wai-quantum qec [-d --rounds --p --shots --seed --json] | --file | --circuit | --dem | --fit
  • wai-quantum estimate … --prefactor A --threshold P estimates on a measured code.

Evidence

Against an independent implementation:

  • Generated circuits are identical byte for byte in all 135 configurations (d 2–15, 1–8 rounds, three noise strengths).
  • Error models are identical mechanism for mechanism in all 41 circuits: rotated and unrotated surface codes in both bases, plus repetition codes, up to a d = 9, 9-round model with 12,705 mechanisms. Worst relative probability difference: 8.3e-13.
  • Logical error rates over the d ∈ {3,5,7} × p ∈ {0.2,…,0.5}% grid agree point by point; the largest difference is |z| = 1.38. Decoding the same sampled shots, per-shot predictions agree 98.8–100%, with equal failure counts within noise.

tests/frame_reference.rs keeps one circuit and one model from that implementation as in-repo fixtures. The X-basis fixture covers parser paths that our generator never emits.

Inside the crate:

  • Blossom equals brute force on 3,000 random graphs, including graphs with no perfect matching.
  • A distance-5 repetition code corrects every error of weight ≤ 2.
  • Sampled detector rates match the model's marginals (5σ, 200k shots).
  • A mirrored random Clifford circuit over every gate type ties the sampler's forward rules to the model's backward rules.

Mutations. Each of these fails a named test:

  • the depolarizing conversion;
  • the CX, S, √X or CZ rule on either side;
  • the reset determinism check;
  • the decomposition policy.

Determinism.

  • bit_identity pins sampling, decoding and the fit; all 10 pins pass natively and under wasm32-wasip2.
  • repro gains an in-crate exp, within an ulp of the platform on 400k inputs.
  • qec output is byte-identical natively and as a WASI component, including an ingested circuit.

Suite. cargo test --locked --features full --lib --tests: 354 + 10 + 2 + 3 passed. Every feature builds alone with zero warnings, and clippy is clean on the new code.

Honest boundary

The decoder is exact first and fast second. At d = 9 a fired detector's boundary cap still spans much of the lattice, so a shot costs about half a millisecond. A region-growing matcher is the next step. Sampling is not the bottleneck: over a million d = 9 shots per second.

🤖 Generated with Claude Code

## What `wai-quantum` 0.3.25 handles error correction at the circuit level. An experiment is what it physically is: a noisy Clifford circuit with detectors and observables. The crate can now sample it, derive its detector error model, decode it exactly, and measure the code model that resource estimates otherwise take on trust. **`quantum_frame`** - `parse` reads the ecosystem's circuit text: - resets and measurements in Z and X; - H, S, √X, Paulis, CX, CZ and SWAP; - flip and depolarizing noise; - detectors, observables and `REPEAT`. Anything else is an error, not a skipped line. - `sample` is bit-packed Pauli-frame simulation, 64 shots per word, with geometric skipping between noise hits. It is reproducible from `(circuit, shots, seed)`. - `error_model` uses backward sensitivity propagation. - It converts depolarizing channels to equivalent independent mechanisms exactly and XOR-merges identical mechanisms. - It refuses non-deterministic detectors. - A graphlike mechanism stays one matching edge. Otherwise it splits into X and Z halves, then into per-qubit parts. - `surface_code_memory` generates the rotated surface-code memory experiment. **`quantum_match`** - Exact minimum-weight perfect matching: Dijkstra on integer weights, then Edmonds' blossom. - Boundary paths are computed once per graph. - Pairs dominated by their boundary paths are cut, which provably cannot change the optimum. - `memory_experiment` and `fit_code_model` measure `P(d) = a·(p/p*)^((d+1)/2)`. Under uniform circuit noise the result is a ≈ 0.023, p* ≈ 0.0100. - `CodeFit::surface_code` turns that fit into a resource-estimate model. **CLI** - `wai-quantum qec [-d --rounds --p --shots --seed --json] | --file | --circuit | --dem | --fit` - `wai-quantum estimate … --prefactor A --threshold P` estimates on a measured code. ## Evidence **Against an independent implementation:** - Generated circuits are identical byte for byte in all 135 configurations (d 2–15, 1–8 rounds, three noise strengths). - Error models are identical mechanism for mechanism in all 41 circuits: rotated and unrotated surface codes in both bases, plus repetition codes, up to a d = 9, 9-round model with 12,705 mechanisms. Worst relative probability difference: 8.3e-13. - Logical error rates over the d ∈ {3,5,7} × p ∈ {0.2,…,0.5}% grid agree point by point; the largest difference is |z| = 1.38. Decoding the same sampled shots, per-shot predictions agree 98.8–100%, with equal failure counts within noise. `tests/frame_reference.rs` keeps one circuit and one model from that implementation as in-repo fixtures. The X-basis fixture covers parser paths that our generator never emits. **Inside the crate:** - Blossom equals brute force on 3,000 random graphs, including graphs with no perfect matching. - A distance-5 repetition code corrects every error of weight ≤ 2. - Sampled detector rates match the model's marginals (5σ, 200k shots). - A mirrored random Clifford circuit over every gate type ties the sampler's forward rules to the model's backward rules. **Mutations.** Each of these fails a named test: - the depolarizing conversion; - the CX, S, √X or CZ rule on either side; - the reset determinism check; - the decomposition policy. **Determinism.** - `bit_identity` pins sampling, decoding and the fit; all 10 pins pass natively and under `wasm32-wasip2`. - `repro` gains an in-crate `exp`, within an ulp of the platform on 400k inputs. - `qec` output is byte-identical natively and as a WASI component, including an ingested circuit. **Suite.** `cargo test --locked --features full --lib --tests`: 354 + 10 + 2 + 3 passed. Every feature builds alone with zero warnings, and clippy is clean on the new code. ## Honest boundary The decoder is exact first and fast second. At d = 9 a fired detector's boundary cap still spans much of the lattice, so a shot costs about half a millisecond. A region-growing matcher is the next step. Sampling is not the bottleneck: over a million d = 9 shots per second. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wai-quantum 0.3.25: error correction at circuit level, sampled, modelled and decoded exactly
All checks were successful
no-vanity-metrics / WAI public text names no comparison (pull_request) Successful in 3s
no-vanity-metrics / WAI public text names no company or product (pull_request) Successful in 3s
standards workspaces build + test / eoc-rs (pull_request) Successful in 1m54s
standards workspaces build + test / jcp-rs (pull_request) Successful in 1m26s
standards workspaces build + test / openpay (pull_request) Successful in 4m53s
standards workspaces build + test / proof-rs (pull_request) Successful in 1m12s
standards workspaces build + test / sandbox-rs (pull_request) Successful in 2m11s
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 3m38s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 7m57s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 54s
WAI conformance / cargo-class corpora · linux (pull_request) Successful in 3m59s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 12s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 2m15s
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Successful in 2m10s
WAI conformance / cross-arch byte-equality · linux (pull_request) Successful in 26s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 48s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 1m13s
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Successful in 1m2s
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Successful in 1m3s
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Successful in 3m55s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 1m44s
standards workspaces build + test / arl-rs (pull_request) Successful in 22m23s
standards workspaces build + test / joule-ui-rs (pull_request) Successful in 20m55s
standards workspaces build + test / jouledesk-rs (pull_request) Successful in 19m6s
standards workspaces build + test / joulehook-rs (pull_request) Successful in 10m16s
standards workspaces build + test / sense-rs (pull_request) Successful in 7m52s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 9m59s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 6m11s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 31s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 2m21s
ed592d76f9
quantum_frame takes an error-correction experiment as what it is: a noisy
Clifford circuit with detectors and observables.

- parse reads the ecosystem's circuit text (resets and measurements in Z and
  X, H/S/sqrt(X)/Paulis/CX/CZ/SWAP, flip and depolarizing noise, detectors,
  observables, REPEAT), and refuses anything else rather than skipping it.
- sample is bit-packed Pauli-frame simulation, 64 shots per word, with
  geometric skipping between noise hits; reproducible from
  (circuit, shots, seed).
- error_model derives the detector error model by backward sensitivity
  propagation. It converts depolarizing channels to equivalent independent
  mechanisms exactly, XOR-merges identical ones, and refuses non-deterministic
  detectors. A graphlike mechanism stays one matching edge; otherwise it splits
  into X and Z halves, then into per-qubit parts.
- surface_code_memory generates the rotated surface-code memory experiment.

quantum_match decodes by exact minimum-weight perfect matching: Dijkstra on
integer weights, with boundary paths computed once and dominated pairs cut,
then Edmonds' blossom. memory_experiment and fit_code_model measure
P(d) = a(p/p*)^((d+1)/2): a = 0.023, p* = 0.0100 under uniform circuit
noise, and CodeFit::surface_code feeds that into a resource estimate.

Checked against an independent implementation:
- generated circuits identical byte for byte (135 configurations, d 2-15,
  1-8 rounds);
- error models identical mechanism for mechanism, to 1e-12 in probability
  (41 circuits: rotated and unrotated surface codes in both bases,
  repetition codes);
- decoded logical error rates within 1.4 standard errors on all 12 grid
  points.

tests/frame_reference.rs keeps a circuit and a model from that implementation
as fixtures. Blossom equals brute force on 3000 random graphs. A mirrored
random Clifford circuit over every gate type ties the sampler's forward rules
to the model's backward ones. Mutating the depolarizing conversion, any gate
rule on either side, the determinism check or the decomposition fails a named
test. bit_identity pins sampling, decoding and the fit natively and under
wasm32-wasip2; repro gains an in-crate exp, within an ulp.

CLI: wai-quantum qec [-d --rounds --p --shots --seed --json] | --file |
--circuit | --dem | --fit, and estimate --prefactor/--threshold for a
measured code. Byte-identical natively and under wasm32-wasip2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!143
No description provided.