wai-quantum 0.3.21

A deterministic quantum stack in pure Rust: byte-exact circuit simulation (statevector / stabilizer / tensor-network MPS / sparse-Pauli backends), 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
//! The smallest complete thing: build a circuit, simulate it exactly, and get a
//! hash that is the same on every machine.
//!
//!     cargo run --example bell

use wai_quantum::quantum::Circuit;
use wai_quantum::quantum_toolchain as qt;

fn main() {
    let mut c = Circuit::new(2);
    c.h(0).cx(0, 1); // a Bell pair

    let sv = c.simulate().expect("simulate");

    println!("circuit    {} qubits, {} gates", c.n_qubits, c.ops.len());
    let (backend, why) = qt::recommend_backend(&c);
    println!("backend    {backend:?} — {why}");

    println!("outcomes");
    for (state, p) in qt::top_outcomes(&sv, 4) {
        if p > 0.0 {
            println!("  |{state:02b}>  {p:.6}");
        }
    }

    // Not "a hash of this run" — the reconstruction is byte-exact, so this is the
    // same value natively, in a browser, and in a WASI component at the edge.
    let h = sv.statevector_hash();
    print!("state-hash ");
    for b in h {
        print!("{b:02x}");
    }
    println!();
}