wai-quantum 0.3.41

A deterministic quantum stack in pure Rust: byte-exact circuit simulation (statevector / stabilizer / tensor-network MPS / sparse-Pauli backends), sparse Pauli dynamics at utility scale (arbitrary angles, 1024 qubits), belief-propagation tensor networks on the hardware graph, error mitigation, qLDPC decoding, noise learning, circuit-equivalence proofs, a phasor interference-ML layer, information-theoretic limits, noisy channels and state tomography, and signed energy-accounted receipts. No QPU, no cloud, no system libraries — identical results native, in the browser, and as a WASI component at the edge.
Documentation
//! A quantum error correction threshold sweep.
//!
//! Below threshold a bigger code protects better; above it, worse. That crossing
//! is the whole reason error correction is believed to work, and it is a few
//! hundred thousand decodes away.
//!
//!     cargo run --release --example threshold --features quantum_qec

use wai_quantum::quantum_qec::{benchmark_uf, x_distance, CssCode};

fn main() {
    let trials = 4000;
    println!("rotated surface code, union-find decoder, {trials} shots per point\n");

    let codes: Vec<CssCode> = [3usize, 5, 7].iter().map(|&d| CssCode::surface(d)).collect();
    for c in &codes {
        // the distance is computed, not taken on faith from the constructor's name
        let d = x_distance(c, 6).map(|d| d.to_string()).unwrap_or_else(|| ">5".into());
        println!("  {} : n={} k={} d={}", c.id, c.n, c.k, d);
    }

    println!("\n  p        d=3        d=5        d=7");
    for p in [0.01f64, 0.02, 0.05, 0.08, 0.12, 0.16] {
        print!("  {p:<8}");
        for c in &codes {
            let (t, f) = benchmark_uf(c, p, trials, 11);
            print!(" {:>10.4}", f as f64 / t as f64);
        }
        println!();
    }
    println!("\n  Read down each column: at low p a larger code wins. Read across the\n  bottom rows: past threshold that reverses, and more qubits buy less.");
}