wai-quantum 0.3.23: belief-propagation tensor networks, a second method for the same circuits #140

Merged
dcharlot merged 1 commit from wai-quantum-bptn into main 2026-10-01 22:43:29 -04:00
Owner

wai-quantum 0.3.23 adds a second classical method for the same circuits: belief-propagation tensor networks on the hardware graph. Sparse Pauli dynamics (0.3.22) and this method approximate in unrelated ways, so where they agree, neither approximation is likely to be what they agree on.

What it does

  • State. One tensor per qubit, one bond per coupling, in Vidal gauge.
  • Gates. A two-qubit gate is a simple update: QR-reduce both sides, apply the gate, SVD, keep at most χ singular values.
  • Expectations. Each tensor's environment comes from its bond weights, or from belief propagation run to a fixed point on the norm network.
  • Gauge. regauge() brings the network into the belief-propagation gauge; run_gauged() does so after every layer.
  • Layers. edge_layers() partitions the coupling graph into layers of vertex-disjoint edges: three on heavy-hex, as the device applies them. Each layer is computed in parallel and committed in order, bit-identical to applying the gates one at a time.

Measured

Check Result
Trees, no truncation, against exact sparse Pauli dynamics exact to 3.7e-15 (and with BP environments)
127q, 5 steps, χ = 32, magnetization at θ_h = kπ/32, k = 2, 4, 6, 8 within 3.5e-7 of the exactly computed values
127q, 20 steps, ⟨Z62⟩ at θ_h = 0.2 and 0.4 0.9786 and 0.8498, the published BP-TN values (arXiv:2306.14887) at the same angles
127q, 20 steps, θ_h = 0.6 approaching the published 0.669 as χ grows: 0.696 at χ = 16, 0.676 at χ = 32
Native against wasm32-wasip2 byte-identical: pinned, and the CLI output compared

Found on the way

  • SVD orthogonality. The MPS backend's Jacobi SVD stops when |γ|² ≤ 1e-14·αβ, which leaves the singular vectors orthonormal only to about 1e-7.
    • MPS keeps U·S·V† whole, so its results are unaffected: infidelity 7.8e-16 either way.
    • Vidal-gauge expectations assume orthonormal tensors, so this backend uses an SVD run to convergence.
    • The first converged version rotated numerically null columns forever and broke V's unitarity. A probe test caught it, and now holds both properties to rounding.
  • hypot. It gave last-bit differences between native and WASI builds. |γ| is now computed from / and √ only.

wai-quantum utility --method bptn --chi N runs it from the CLI.

Verification

  • Every feature builds and tests on its own with zero warnings.
  • --features full: 323 unit, 8 bit-identity and 3 published-reference tests pass natively, and the same under wasm32-wasip2.
  • Rustdoc builds with -D warnings; the wai-rs, wai-quantum-serve and wai-web workspaces check; the comparative-prose check is clean.

A note on #137

#137 was merged before its two macOS jobs ran. They sat behind a backlog on the single macOS runner, which is the dev Mac, for over an hour. I ran both jobs' exact commands there against its head (ba653dac), in a clean worktree with its own target dir, and all passed:

  • byte-exact conformance: 73 tests;
  • the wai-rs receipt suite: 513 + 10;
  • wai-quantum --lib --tests: 310 + 7 + 2;
  • wai-quantum-serve: 2.

Its only red check, joule-code-rs on linux-arm64, was a runner failing to download the Rust toolchain, in a workspace #137 does not touch.

🤖 Generated with Claude Code

wai-quantum 0.3.23 adds a second classical method for the same circuits: belief-propagation tensor networks on the hardware graph. Sparse Pauli dynamics (0.3.22) and this method approximate in unrelated ways, so where they agree, neither approximation is likely to be what they agree on. ## What it does - **State.** One tensor per qubit, one bond per coupling, in Vidal gauge. - **Gates.** A two-qubit gate is a simple update: QR-reduce both sides, apply the gate, SVD, keep at most χ singular values. - **Expectations.** Each tensor's environment comes from its bond weights, or from belief propagation run to a fixed point on the norm network. - **Gauge.** `regauge()` brings the network into the belief-propagation gauge; `run_gauged()` does so after every layer. - **Layers.** `edge_layers()` partitions the coupling graph into layers of vertex-disjoint edges: three on heavy-hex, as the device applies them. Each layer is computed in parallel and committed in order, bit-identical to applying the gates one at a time. ## Measured | Check | Result | |---|---| | Trees, no truncation, against exact sparse Pauli dynamics | exact to 3.7e-15 (and with BP environments) | | 127q, 5 steps, χ = 32, magnetization at θ_h = kπ/32, k = 2, 4, 6, 8 | within 3.5e-7 of the exactly computed values | | 127q, 20 steps, ⟨Z62⟩ at θ_h = 0.2 and 0.4 | 0.9786 and 0.8498, the published BP-TN values (arXiv:2306.14887) at the same angles | | 127q, 20 steps, θ_h = 0.6 | approaching the published 0.669 as χ grows: 0.696 at χ = 16, 0.676 at χ = 32 | | Native against wasm32-wasip2 | byte-identical: pinned, and the CLI output compared | ## Found on the way - **SVD orthogonality.** The MPS backend's Jacobi SVD stops when |γ|² ≤ 1e-14·αβ, which leaves the singular vectors orthonormal only to about 1e-7. - MPS keeps U·S·V† whole, so its results are unaffected: infidelity 7.8e-16 either way. - Vidal-gauge expectations assume orthonormal tensors, so this backend uses an SVD run to convergence. - The first converged version rotated numerically null columns forever and broke V's unitarity. A probe test caught it, and now holds both properties to rounding. - **`hypot`.** It gave last-bit differences between native and WASI builds. |γ| is now computed from `/` and `√` only. `wai-quantum utility --method bptn --chi N` runs it from the CLI. ## Verification - Every feature builds and tests on its own with zero warnings. - `--features full`: 323 unit, 8 bit-identity and 3 published-reference tests pass natively, and the same under wasm32-wasip2. - Rustdoc builds with `-D warnings`; the wai-rs, wai-quantum-serve and wai-web workspaces check; the comparative-prose check is clean. ## A note on #137 #137 was merged before its two macOS jobs ran. They sat behind a backlog on the single macOS runner, which is the dev Mac, for over an hour. I ran both jobs' exact commands there against its head (ba653dac), in a clean worktree with its own target dir, and all passed: - byte-exact conformance: 73 tests; - the wai-rs receipt suite: 513 + 10; - wai-quantum `--lib --tests`: 310 + 7 + 2; - wai-quantum-serve: 2. Its only red check, `joule-code-rs` on linux-arm64, was a runner failing to download the Rust toolchain, in a workspace #137 does not touch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wai-quantum 0.3.23: belief-propagation tensor networks, a second method for the same circuits
All checks were successful
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 3m46s
WAI conformance / cargo-class corpora · linux (pull_request) Successful in 3m19s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 16s
WAI conformance / independent verifiers · claims, JWP and key discovery (Python) (pull_request) Successful in 2m12s
WAI conformance / cross-arch byte-equality · linux (pull_request) Successful in 23s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 44s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 1m4s
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Successful in 1m0s
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Successful in 48s
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Successful in 3m54s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 1m33s
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 4m34s
standards workspaces build + test / aac-rs (pull_request) Successful in 2m5s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 2m9s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 1m26s
standards workspaces build + test / map-rs (pull_request) Successful in 1m45s
standards workspaces build + test / mesh-rs (pull_request) Successful in 1m26s
standards workspaces build + test / openpay (pull_request) Successful in 6m16s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 4m24s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 43s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 1m39s
standards workspaces build + test / arl-rs (pull_request) Successful in 2m16s
standards workspaces build + test / joule-ui-rs (pull_request) Successful in 2m50s
standards workspaces build + test / jouledesk-rs (pull_request) Successful in 2m46s
standards workspaces build + test / joulehook-rs (pull_request) Successful in 2m42s
standards workspaces build + test / sense-rs (pull_request) Successful in 2m45s
standards workspaces build + test / macOS energy backend (jcp-energy) (pull_request) Successful in 3m18s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 4m48s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 29s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 1m38s
9bb3da572e
quantum_bptn holds a tensor-network state on the hardware's coupling graph:
one tensor per qubit, one bond per edge, in Vidal gauge.
- A two-qubit gate on an edge is a simple update: QR-reduce both sides,
  apply the gate, SVD, keep at most χ singular values.
- Expectations take each tensor's environment from its bond weights, or
  from belief propagation run to a fixed point on the norm network.
  regauge() brings the network into the belief-propagation gauge, and
  run_gauged() does so after every layer.
- Its errors are unrelated to those of sparse Pauli dynamics, so the two
  can check each other on the same circuit.

Measured:
- On trees with no truncation it is exact: 3.7e-15 against exact sparse
  Pauli dynamics, and the same with belief-propagation environments.
- 127-qubit heavy-hex, 5 steps, χ = 32: the exactly computed
  magnetization to within 3.5e-7 at θ_h = kπ/32 for k = 2, 4, 6, 8.
- 127-qubit heavy-hex, 20 steps, ⟨Z62⟩: 0.9786 at θ_h = 0.2 and 0.8498
  at θ_h = 0.4, the published belief-propagation values
  (arXiv:2306.14887) at the same angles.
- At θ_h = 0.6 it approaches the published value as χ grows (0.696 at
  χ = 16, 0.676 at χ = 32, against 0.669).

edge_layers() partitions a graph's edges into layers of vertex-disjoint
edges: Δ layers on a bipartite graph (König), three on heavy-hex.
kicked_ising() now applies its RZZ gates a layer at a time, as the device
does. For sparse Pauli dynamics this changes no bit, because the gates are
commuting exact Cliffords. A layer's gates touch disjoint tensors and bonds,
so the tensor network computes them in parallel and commits them in order,
bit-identical to applying them one at a time.

src/linalg.rs holds the complex type, the Jacobi SVD and a Householder QR,
shared with the MPS backend, whose arithmetic is unchanged. The SVD the new
backend uses runs to convergence. The original's stopping rule leaves the
singular vectors orthonormal only to about 1e-7. That is harmless where a
backend keeps U·S·V† whole, as MPS does, and is wrong to 1e-8 where
expectations assume orthonormal tensors. Its |γ| is computed from / and √:
libm's hypot made the native and WASI results differ in the last bit until
it went.

tests/bit_identity.rs pins a tensor-network run, confirmed natively and
under wasm32-wasip2. tests/utility_reference.rs holds the 5-step values by
both methods. `wai-quantum utility --method bptn --chi N` runs it from the
CLI, with output byte-identical natively and as a WASI component.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Transaction-Science/open-standards!140
No description provided.