open-standards/wai/wai-quantum/examples/utility.rs
Transaction Science 617075d387
Some checks failed
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Has been cancelled
no-vanity-metrics / WAI public text names no comparison (pull_request) Has been cancelled
no-vanity-metrics / WAI public text names no company or product (pull_request) Has been cancelled
standards workspaces build + test / jouleclaw-rs (pull_request) Has been cancelled
standards workspaces build + test / aac-rs (pull_request) Has been cancelled
standards workspaces build + test / arl-rs (pull_request) Has been cancelled
standards workspaces build + test / eoc-rs (pull_request) Has been cancelled
standards workspaces build + test / jcp-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-code-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-ui-rs (pull_request) Has been cancelled
standards workspaces build + test / joulecontract-rs (pull_request) Has been cancelled
standards workspaces build + test / jouledesk-rs (pull_request) Has been cancelled
standards workspaces build + test / joulehook-rs (pull_request) Has been cancelled
standards workspaces build + test / map-rs (pull_request) Has been cancelled
standards workspaces build + test / mesh-rs (pull_request) Has been cancelled
standards workspaces build + test / openpay (pull_request) Has been cancelled
standards workspaces build + test / proof-rs (pull_request) Has been cancelled
standards workspaces build + test / sandbox-rs (pull_request) Has been cancelled
standards workspaces build + test / sense-rs (pull_request) Has been cancelled
standards workspaces build + test / smart-byte-rs (pull_request) Has been cancelled
standards workspaces build + test / macOS energy backend (jcp-energy) (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · macos (pull_request) Has been cancelled
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Has been cancelled
WAI conformance / independent verifiers · claims, JWP and key discovery (Python) (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · macos (pull_request) Has been cancelled
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Has been cancelled
WAI energy receipts / energy receipts · macos (pull_request) Has been cancelled
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Has been cancelled
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Has been cancelled
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Has been cancelled
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Has been cancelled
wai-quantum 0.3.22: sparse Pauli dynamics at utility scale, and identical bits on every platform
quantum_spd computes observables of circuits up to 1024 qubits with
arbitrary rotation angles, in the Heisenberg picture. Until now every
backend took the dyadic circuit type, which allows only Clifford, T and
2π/2^k phases, and sparse-Pauli propagation stopped at 64 qubits. The
experiments that classical methods are known for reproducing were out of
reach.
- Clifford gates and quarter-turn rotations are exact.
- Continuous rotations merge in place, over an insertion-ordered term table,
  so every coefficient is added in the same order on every platform.
- Every dropped coefficient goes into a truncation bound, a rigorous limit on
  how far truncation can have moved the result.
- On the 127-qubit heavy-hex kicked-Ising circuits, it reproduces the exactly
  computed 5-step magnetization (arXiv:2308.05077 exact.csv) on all 127
  qubits: 0.995131 against 0.995131 at θ_h = π/32, exact propagation.
- 20-step ⟨Z62⟩ at 2π/32 falls inside the published converged classical
  values.

quantum_spd_receipt seals a run under a meter. The result is computed inside
the seal, floats are hashed and serialized as exact bits, and
verify_computation re-runs the job anywhere and demands the same bits. The
energy is attested, and can carry an energy-class label.

Defects fixed:
- quantum_pauli was not reproducible from run to run. It summed
  coefficients in std HashMap order, which is seeded afresh for every map, so
  six runs gave six bit patterns. It now visits terms in key order.
- Four f64 layers (vml, phasor, qfhrr, kernel) gave different bits natively
  and as a WASI component, through the platform's cos, sin, ln and atan2.
  That falsified the crate's identical-native-browser-edge claim. src/repro.rs
  computes them in-crate (fdlibm's algorithms, + − × ÷ only, within an ulp).
  The MPS backend, whose contract excludes transcendentals, used them too.
  tests/bit_identity.rs pins a digest per layer, confirmed natively and
  under wasm32-wasip2.

wai-rs:
- passthrough features quantum_spd and quantum_spd_receipt;
- `wai-quantum utility [--theta --steps --threshold -q --json --receipt]`;
- `verify` reads both receipt kinds.

The utility receipt is byte-identical natively and under wasm32-wasip2.
Dependent lockfiles were moved.

Every feature now builds on its own with no warnings. The merkle module is
compiled only for the receipt features that use it, and the QEC encoder's
row reduction only with the simulator it serves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-01 15:13:52 -04:00

31 lines
1.4 KiB
Rust

//! The 127-qubit heavy-hex kicked-Ising experiment, on a laptop.
//!
//! `cargo run --release --example utility --features quantum_spd -- [θ_h] [steps] [threshold]`
//!
//! Computes ⟨Z₆₂⟩ after `steps` Trotter steps of `RX(θ_h)` on every qubit and
//! `RZZ(−π/2)` on every edge of the heavy-hex map. Prints the value, the bound
//! on what truncation can have moved it, and the work done.
use std::time::Instant;
use wai_quantum::quantum_spd::{SpdConfig, expect_z, heavy_hex_127, kicked_ising};
fn main() {
let args: Vec<f64> = std::env::args().skip(1).map(|a| a.parse().expect("a number")).collect();
let theta_h = args.first().copied().unwrap_or(std::f64::consts::FRAC_PI_4);
let steps = args.get(1).copied().unwrap_or(20.0) as u32;
let threshold = args.get(2).copied().unwrap_or(1e-3);
let circuit = kicked_ising(127, &heavy_hex_127(), theta_h, steps);
let started = Instant::now();
let r = expect_z(&circuit, 62, &SpdConfig { threshold, max_weight: None }).expect("a valid circuit");
let secs = started.elapsed().as_secs_f64();
println!("theta_h {theta_h}");
println!("steps {steps}");
println!("threshold {threshold:e}");
println!("<Z_62> {:.6}", r.value);
println!("bound {:.3e} (|exact - value| is at most this)", r.truncation_bound);
println!("peak terms {}", r.peak_terms);
println!("updates {}", r.term_updates);
println!("seconds {secs:.2}");
}