wai-quantum 0.6.6: Clifford circuits measured in a product basis, exactly, by cut-rank #340

Merged
dcharlot merged 5 commits from wai/quantum-cutrank-0.6.6 into main 2026-10-19 20:26:27 -04:00
Owner

wai-quantum 0.6.6. Exact amplitudes, probabilities and samples of a Clifford circuit followed by one layer of single-qubit gates at any angles. The cost is set by the state's cut-rank along an order of its qubits, not by the number of qubits.

What it does

  • Tableau::graph_form writes a stabilizer state as local Cliffords (H^h S^s Z^z per qubit) on a graph state.
  • quantum_cutrank (a new feature, in full) sums ⟨x| ⊗ V_q |ψ⟩ = 2^{-n/2} Σ_z ∏_q W_q[x_q][z_q] (−1)^{Σ_{a~b} z_a z_b} one qubit at a time along an order, in a table of 2^{cut-rank} entries.
    • Each qubit is an in-place pass: a merge where the boundary space loses a dimension, the qubit's signed terms, and a doubling or an XOR-shifted sum for its edges ahead.
    • The passes depend only on the graph and the order, so they are planned once per state.
    • By Parseval, the table's norm is a prefix's probability, so the same passes sample exactly.
    • Precision::Single stores the table in f32 with f64 arithmetic.
    • anneal_order searches orders for less work (Σ 2^cut) and never returns a worse one.
    • Every reduction is summed in fixed chunks, so a result is the same bits at any thread count.
  • Examples:
    • cutrank_qasm: cut-ranks, annealed orders, amplitudes and exact samples from an OpenQASM 2 Clifford bulk with a closing single-qubit layer.
    • patch_xeb: patched cross-entropy from measured shots, each patch on the dense state vector.
    • tn_cost: one amplitude's contraction cost as find_path finds it.
  • The README gets a feature row and a section, the changelog an entry, and every lockfile that pins wai-quantum moves to 0.6.6.

Evidence

  • Tests:
    • the graph form rebuilds the state (40 random circuits);
    • amplitudes equal the state vector's in probability and relative phase (30 circuits, up to 12 qubits);
    • forward, reverse and shuffled orders agree (24 to 54 qubits);
    • single-precision tables agree with double;
    • samples follow the exact law and are seeded;
    • annealing lowers the work and keeps the amplitudes;
    • cut-ranks match the entanglement of GHZ and product states.
  • Mutants caught: the merge's signs, the sampling choice, the doubling's sign, the fold's coefficient, the graph form without its S.
  • A 70-qubit graph-state sampling circuit (nearest-neighbour Clifford bulk, then a non-Clifford basis on every qubit), on the build host:
    • an annealed order keeps every cut at 29 bits or fewer (32 in the natural order);
    • one amplitude in 0.53 s, one exact sample in 1.1 to 1.5 s, largest table 4 GiB in f32;
    • amplitudes agree between orders and precisions to about 1e-7 relative.
  • Checked on the build host:
    • scripts/check-lockfiles.sh;
    • cargo check --no-default-features --features quantum_cutrank --examples;
    • cargo test --release --features full --lib quantum_cutrank (7 passed) and -- quantum_tableau (10 passed);
    • clippy with -D warnings reports nothing in the files this PR touches. The rest of the library's test code has lints of its own, which CI does not check.
  • Public-text checks clean: names, vanity metrics, comparative prose, tests in CI, orphan sources.

🤖 Generated with Claude Code

**wai-quantum 0.6.6.** Exact amplitudes, probabilities and samples of a Clifford circuit followed by one layer of single-qubit gates at any angles. The cost is set by the state's cut-rank along an order of its qubits, not by the number of qubits. ### What it does - **`Tableau::graph_form`** writes a stabilizer state as local Cliffords (`H^h S^s Z^z` per qubit) on a graph state. - **`quantum_cutrank`** (a new feature, in `full`) sums `⟨x| ⊗ V_q |ψ⟩ = 2^{-n/2} Σ_z ∏_q W_q[x_q][z_q] (−1)^{Σ_{a~b} z_a z_b}` one qubit at a time along an order, in a table of `2^{cut-rank}` entries. - Each qubit is an in-place pass: a merge where the boundary space loses a dimension, the qubit's signed terms, and a doubling or an XOR-shifted sum for its edges ahead. - The passes depend only on the graph and the order, so they are planned once per state. - By Parseval, the table's norm is a prefix's probability, so the same passes sample exactly. - `Precision::Single` stores the table in `f32` with `f64` arithmetic. - `anneal_order` searches orders for less work (Σ 2^cut) and never returns a worse one. - Every reduction is summed in fixed chunks, so a result is the same bits at any thread count. - **Examples:** - `cutrank_qasm`: cut-ranks, annealed orders, amplitudes and exact samples from an OpenQASM 2 Clifford bulk with a closing single-qubit layer. - `patch_xeb`: patched cross-entropy from measured shots, each patch on the dense state vector. - `tn_cost`: one amplitude's contraction cost as `find_path` finds it. - The README gets a feature row and a section, the changelog an entry, and every lockfile that pins wai-quantum moves to 0.6.6. ### Evidence - **Tests:** - the graph form rebuilds the state (40 random circuits); - amplitudes equal the state vector's in probability and relative phase (30 circuits, up to 12 qubits); - forward, reverse and shuffled orders agree (24 to 54 qubits); - single-precision tables agree with double; - samples follow the exact law and are seeded; - annealing lowers the work and keeps the amplitudes; - cut-ranks match the entanglement of GHZ and product states. - **Mutants caught:** the merge's signs, the sampling choice, the doubling's sign, the fold's coefficient, the graph form without its S. - **A 70-qubit graph-state sampling circuit** (nearest-neighbour Clifford bulk, then a non-Clifford basis on every qubit), on the build host: - an annealed order keeps every cut at 29 bits or fewer (32 in the natural order); - one amplitude in 0.53 s, one exact sample in 1.1 to 1.5 s, largest table 4 GiB in `f32`; - amplitudes agree between orders and precisions to about 1e-7 relative. - **Checked on the build host:** - `scripts/check-lockfiles.sh`; - `cargo check --no-default-features --features quantum_cutrank --examples`; - `cargo test --release --features full --lib quantum_cutrank` (7 passed) and `-- quantum_tableau` (10 passed); - clippy with `-D warnings` reports nothing in the files this PR touches. The rest of the library's test code has lints of its own, which CI does not check. - **Public-text checks clean:** names, vanity metrics, comparative prose, tests in CI, orphan sources. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Tableau::graph_form writes the state as local Cliffords on a graph state.
quantum_cutrank (feature quantum_cutrank, in full) then sums
⟨x|⊗V_q|ψ⟩ = 2^{-n/2} Σ_z ∏ W_q[x_q][z_q] (−1)^{Σ_{a~b} z_a z_b} one qubit at a
time along an order, in a table of 2^{cut-rank} entries: each qubit is an
in-place pass (a merge where the boundary space loses a dimension, the
qubit's signed terms, a doubling or an XOR-shifted sum for its edges
ahead). By Parseval the table's norm is the prefix probability, so the same
passes sample exactly. Reductions are summed in fixed chunks.

Tests: the graph form rebuilds the state (40 random circuits); amplitudes
equal the state vector's in probability and relative phase (30 circuits up
to 12 qubits); forward, reverse and shuffled orders agree (24–54 qubits, at
least 30 comparisons); samples follow the exact law (60k shots) and are
seeded; cut-ranks of GHZ and product states. Mutants caught: merge signs,
the sampling choice, the graph form without its S, the doubling's sign.

examples/cutrank_qasm reads an OpenQASM 2 Clifford bulk with a closing
single-qubit layer. On the tracker's 70-qubit random graph-state instance
(max cut 32 bits, matching an independent tableau): an exact amplitude in
about 7.6 s and an exact sample in about 14 s on the build host, 69 GB peak
in f64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The table operations (coordinate swaps, kernel merges, doublings, XOR
  sums, the sign masks) depend on the graph and the order alone, so they
  are planned once per state; an amplitude or a sample only runs passes.
- Precision::Single stores the table in f32 (arithmetic stays f64): half
  the memory and traffic, amplitudes within 1e-5 of the double ones (test).
- A merge followed by a doubling is one pass; a doubling no longer
  zero-fills. Every pass is cut into fixed chunks, so reductions do not
  depend on the threads.
- work() = Σ 2^cut, passes() tallies the passes by kind, and
  anneal_order(moves, seed) searches orders by simulated annealing, never
  returning a worse one (test: lower work, same amplitudes).

On the tracker's 70-qubit random graph-state instance (build host):
natural order, max cut 32: amplitude 6.2 s (f64) / 4.7 s (f32), sample
7.5 s (f32). Annealed order (seed 3, 20 000 moves): max cut 29, work 6.5×
less, largest table 4 GiB in f32: amplitude 0.53 s, exact sample 1.49 s,
amplitudes agreeing with the natural order's double ones to 1e-7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patch_xeb simulates each patch of a patched circuit exactly on the dense
state vector and scores the measured shots (normalised linear XEB per
patch, the product, its error). On a published 61-qubit experiment's
release it reproduces the released per-circuit fidelities to 5e-7 (their
JSON's rounding). tn_cost prints log10 of one amplitude's contraction cost
as find_path sees it, with the largest intermediate and the slices.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A feature row and a section for quantum_cutrank; the changelog entry; the
version in every lockfile that pins it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wai-quantum cutrank: clippy's is_multiple_of and an enumerated loop
All checks were successful
wai-quantum portable tensor program / tensor program · CPU, mutants, GPU builds (pull_request) Successful in 32s
wai-quantum CPU vector units / member · vector unit, rvv 1024-bit (riscv64, emulated) (pull_request) Successful in 17s
wai-quantum CPU vector units / member · vector unit, sve 128-bit (aarch64, emulated) (pull_request) Successful in 26s
wai-quantum CPU vector units / member · vector unit, rvv 128-bit (riscv64, emulated) (pull_request) Successful in 12s
wai-quantum CPU vector units / member · vector unit, sve 2048-bit (aarch64, emulated) (pull_request) Successful in 10s
wai-quantum signal processor / processor and member · signal processor, emulated (pull_request) Successful in 13m59s
wai-quantum CPU vector units / member · vector unit, avx2 (x86_64 silicon) (pull_request) Successful in 13s
wai-quantum CPU vector units / member · vector unit, sve 512-bit (aarch64, emulated) (pull_request) Successful in 13s
wai-quantum WebGPU member / member · software Vulkan (linux) (pull_request) Successful in 2m8s
wai-quantum WebGPU member / shader checks · browser build · wasip2 inertness · MSRV (pull_request) Successful in 3m8s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 3m15s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 12m23s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 18s
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Successful in 5m16s
WAI conformance / codec wrappers · fuzz smoke, text decode limits, C entry points, provenance, the semantic path (pull_request) Successful in 42s
wai-web reach builds / wai-web reach builds · the package of record, every output as recorded (pull_request) Successful in 2m44s
wai-pack / wai-pack · macos (pull_request) Successful in 1m1s
wai-quantum dataflow member / member · dataflow device absent (macos) (pull_request) Successful in 13s
wai-quantum FPGA member / member · FPGA datapath, simulated (macos) (pull_request) Successful in 1m5s
wai-quantum Metal member / member · Metal (macos) (pull_request) Successful in 28s
wai-web reach builds / wai-web reach builds · this tree's wai-web, every rung on its engine line (pull_request) Successful in 4m4s
wai-quantum neural-processor member / member · neural processor (macos) (pull_request) Successful in 5m32s
wai-quantum OpenCL member / member · OpenCL GPU (macos) (pull_request) Successful in 20s
wai-quantum service / service · macos (pull_request) Successful in 29s
wai-quantum matrix-extension member / member · matrix extension absent (macos) (pull_request) Successful in 10s
wai-quantum portable tensor program / tensor program · Metal and the arm64 CPU (macos) (pull_request) Successful in 14s
wai-quantum CPU vector units / member · vector unit absent (macos) (pull_request) Successful in 13s
wai-quantum WebGPU member / member · Metal (macos) (pull_request) Successful in 2m18s
wai-quantum WebGPU member / member · browser WebGPU (macos) (pull_request) Successful in 1m33s
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (pull_request) Successful in 3m51s
c1c325002f
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!340
No description provided.