All checks were successful
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 4m4s
standards workspaces build + test / aac-rs (pull_request) Successful in 1m45s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 1m27s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 1m26s
standards workspaces build + test / map-rs (pull_request) Successful in 2m0s
standards workspaces build + test / mesh-rs (pull_request) Successful in 1m14s
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Successful in 3s
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
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]>
65 lines
3.1 KiB
Rust
65 lines
3.1 KiB
Rust
//! Noisy Clifford circuits from the command line.
|
|
//!
|
|
//! ```text
|
|
//! cargo run --release --example qec_frame --features quantum_frame -- gen 5 5 0.001
|
|
//! cargo run --release --example qec_frame --features quantum_frame -- dem circuit.txt
|
|
//! cargo run --release --example qec_frame --features quantum_frame -- sample circuit.txt 100000 7
|
|
//! cargo run --release --example qec_frame --features quantum_frame -- decode circuit.txt events.txt
|
|
//! cargo run --release --example qec_frame --features quantum_frame -- rate circuit.txt 100000 7
|
|
//! ```
|
|
use wai_quantum::quantum_frame::{error_model, parse, sample, surface_code_memory};
|
|
use wai_quantum::quantum_match::MatchingGraph;
|
|
|
|
fn main() {
|
|
let a: Vec<String> = std::env::args().collect();
|
|
let read = |p: &str| std::fs::read_to_string(p).expect("read circuit");
|
|
match a.get(1).map(String::as_str) {
|
|
Some("gen") => {
|
|
let d: u32 = a[2].parse().unwrap();
|
|
let r: u32 = a[3].parse().unwrap();
|
|
let p: f64 = a[4].parse().unwrap();
|
|
print!("{}", surface_code_memory(d, r, p));
|
|
}
|
|
Some("dem") => {
|
|
let c = parse(&read(&a[2])).expect("parse");
|
|
print!("{}", error_model(&c).expect("model").to_text());
|
|
}
|
|
Some("sample") => {
|
|
let c = parse(&read(&a[2])).expect("parse");
|
|
let shots: usize = a[3].parse().unwrap();
|
|
let seed: u64 = a[4].parse().unwrap();
|
|
let s = sample(&c, shots, seed);
|
|
for d in 0..s.detectors {
|
|
println!("D{d} {}", s.count(d));
|
|
}
|
|
let flips = (0..shots).filter(|&i| s.flips(i) & 1 == 1).count();
|
|
println!("L0 {flips}");
|
|
}
|
|
// One line per shot of fired detector indices; prints one predicted
|
|
// observable mask per line.
|
|
Some("decode") => {
|
|
let c = parse(&read(&a[2])).expect("parse");
|
|
let g = MatchingGraph::from_model(&error_model(&c).expect("model")).expect("graphlike");
|
|
let mut out = String::new();
|
|
for line in read(&a[3]).lines() {
|
|
let fired: Vec<u32> = line.split_whitespace().map(|t| t.parse().unwrap()).collect();
|
|
out += &format!("{}\n", g.decode(&fired).expect("decode"));
|
|
}
|
|
print!("{out}");
|
|
}
|
|
// Sample and decode: logical failures out of shots, and the time spent.
|
|
Some("rate") => {
|
|
let c = parse(&read(&a[2])).expect("parse");
|
|
let shots: usize = a[3].parse().unwrap();
|
|
let seed: u64 = a[4].parse().unwrap();
|
|
let g = MatchingGraph::from_model(&error_model(&c).expect("model")).expect("graphlike");
|
|
let t0 = std::time::Instant::now();
|
|
let s = sample(&c, shots, seed);
|
|
let t1 = t0.elapsed();
|
|
let f = g.failures(&s).expect("decode");
|
|
let t2 = t0.elapsed() - t1;
|
|
println!("{f} {shots} sample_s={:.3} decode_s={:.3}", t1.as_secs_f64(), t2.as_secs_f64());
|
|
}
|
|
_ => eprintln!("usage: qec_frame gen D ROUNDS P | dem FILE | sample FILE SHOTS SEED | decode FILE EVENTS | rate FILE SHOTS SEED"),
|
|
}
|
|
}
|