wai-quantum 0.4.1

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 in the default features — identical results native, in the browser, and as a WASI component at the edge; the opt-in WebGPU member reaches the platform's GPU interface.
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_hash, Circuit};
use wai_quantum::quantum_toolchain as qt;

fn main() {
    // A new circuit is in the circuit2 gateset, whose phase table is correctly
    // rounded; `Circuit::with_gateset(2, Gateset::V1)` reproduces circuit/1.
    let mut c = Circuit::new(2);
    c.h(0).cx(0, 1); // a Bell pair

    let sv = c.simulate().expect("simulate");
    // The circuit's identity covers its capability; a circuit that simulates
    // always has one.
    let id = circuit_hash(&c).expect("a valid circuit has a hash");

    println!("circuit    {} qubits, {} gates, {}", c.n_qubits, c.ops.len(), c.gateset.capability());
    print!("circuit-id ");
    for b in id {
        print!("{b:02x}");
    }
    println!();
    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!();
}