wai-quantum 0.3.26: tensor-network contraction, hyper-optimised, sliced, bit-identical #144

Merged
dcharlot merged 1 commit from wai-quantum-tn into main 2026-10-04 20:40:53 -04:00

2026-10-04

Transaction Science
wai-quantum 0.3.26: tensor-network contraction, hyper-optimised, sliced, bit-identical
All checks were successful
standards workspaces build + test / proof-rs (pull_request) Successful in 1m12s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 2m14s
standards workspaces build + test / sandbox-rs (pull_request) Successful in 2m11s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 1m11s
standards workspaces build + test / map-rs (pull_request) Successful in 2m6s
standards workspaces build + test / mesh-rs (pull_request) Successful in 57s
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 3m38s
standards workspaces build + test / openpay (pull_request) Successful in 3m56s
WAI conformance / cargo-class corpora · linux (pull_request) Successful in 3m56s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 14s
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Successful in 2m9s
WAI conformance / cross-arch byte-equality · linux (pull_request) Successful in 22s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 44s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 5m7s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 1m9s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 37s
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Successful in 58s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 1m28s
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Successful in 1m0s
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 1m47s
standards workspaces build + test / arl-rs (pull_request) Successful in 3m54s
standards workspaces build + test / joule-ui-rs (pull_request) Successful in 5m38s
standards workspaces build + test / jouledesk-rs (pull_request) Successful in 4m46s
standards workspaces build + test / joulehook-rs (pull_request) Successful in 5m49s
standards workspaces build + test / sense-rs (pull_request) Successful in 5m16s
standards workspaces build + test / macOS energy backends (pull_request) Successful in 7m10s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 7m41s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 40s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 2m19s
quantum_tn turns a circuit (any unitary on any qubits, as a matrix) into the
tensor network of one amplitude or an open-output batch, and contracts it.

- Network::amplitude builds the network; simplify absorbs vectors and
  one-qubit gates into neighbours.
- find_path is a seeded hyper-optimiser over two tree families:
  - randomised greedy, scoring size(out)/c - c(size(a)+size(b)) with Gumbel
    noise;
  - recursive bipartition, multilevel (heavy-edge coarsening, several
    initial cuts, refinement at every level), with greedy leaves.
  Families alternate until one leads; later trials sample near the best
  parameters. The best few trees are reconfigured: subtrees of up to eight
  tensors are re-contracted optimally by subset dynamic programming, until
  nothing improves.
- slice fixes the index that leaves the least total work until the largest
  intermediate fits the cap, pricing each candidate incrementally. A second
  search round then finds a tree for the network with the first round's
  slices fixed (all, or the more valuable half).
- contract_plan contracts every slice in a fixed accumulation order and sums
  them in order. Threads are bounded by an 8 GiB budget; WASI runs
  sequentially. The bits are the same everywhere.

Measured on single amplitudes of random circuits on the 54-qubit
advantage-experiment grid (fSim(pi/2, pi/6), staggered couplers), 256 trials,
under ten seconds each, in log10 operations:
  m = 10: 10.48   m = 12: 13.91   m = 14: 14.63   m = 16: 17.60   m = 20: 18.77
An independently developed hyper-optimiser, given the identical networks,
lands within 0.4 of these at every depth, in either direction. The 54-qubit,
10-cycle amplitude, contracted here in 16 slices, agrees with an independent
contraction to 12 significant figures.

Tests:
- Amplitudes match a dense state vector for every tree family, with
  reconfiguration and with slicing.
- Reconfiguration reaches the exact optimum on 40 random small networks.
- Incremental slice pricing matches a full recount.
- The same seed gives the same plan.
- Mutating the permutation, the complex product, the contraction's summed
  indices, slice pricing, the slice offset or the reconfiguration DP fails a
  named test.
- bit_identity pins a plan and its sliced, threaded amplitude natively and
  under wasm32-wasip2.

CLI: wai-quantum tn --file CIRCUIT.jsonl [--bits --open --trials --seed
--cap-log2 --plan-only --json], byte-identical natively and under
wasm32-wasip2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 16:03:22 -04:00