wai-quantum 0.6.7: tensor networks that split controlled gates and fix projections #343

Merged
dcharlot merged 3 commits from wai/quantum-tn-split-0.6.7 into main 2026-10-19 22:37:45 -04:00
Owner

wai-quantum 0.6.7. Two exact network reductions that cut the cost of controlled-Z and controlled-X circuits by orders of magnitude.

What changes

  • Network::amplitude_split splits each gate on two or more qubits at every qubit it is block-diagonal on: a control, or a qubit it is diagonal on.
    • There G = Σ_a |a⟩⟨a| ⊗ G_a, so that qubit's part is the delta δ(out, in, k) on its wire, and the blocks G_k keep the rest, joined by a bond of dimension 2.
    • Only zeros of the matrix are read, with no arithmetic.
    • A cut through a CZ or CX costs 2 instead of the 4 of its two wires, and a cut crossed by m such gates costs 2^m less.
  • Network::reduce fixes every index that some tensor allows only one value of.
    • Every tensor holding that index keeps its entries at that value and drops the index; this repeats until nothing changes, then it simplifies.
    • Input and output projections run through diagonal gates and split deltas, so a CZ beside a projected output becomes scalars.
    • Open indices are never fixed.
  • Network::amplitude and Network::simplify are unchanged, so every pinned digest is too (tests/bit_identity: 23 passed).
  • Callers moved to split, reduced networks:
    • examples/tn_cost (TN_DENSE=1 for the old pipeline);
    • the CLI's wai-quantum tn (--whole-gates);
    • the service's tensor_network method.

Measured

On a published release's 61-qubit CZ circuits: log₁₀ multiply-adds for one amplitude, 64 trials.

depth whole gates, simplified split split, reduced
8 8.03 6.58 5.35
12 12.46 9.23 8.25
16 16.09 12.09 11.22
20 19.64 15.16 14.26

1,024 trials do not lower the split costs further.

Tests

  • Split networks, reduced or not, and reduced whole-gate networks give the state vector's amplitudes. The circuits mix CZ, CX both ways, a controlled random unitary, random diagonal gates, Toffoli, CCZ and random two-qubit unitaries, and the outputs are both projected and open.
  • CZ and CX split, a random unitary does not, and CX splits at its control.
  • On a 4 × 5 CZ grid of 12 layers, the split tree costs under an eighth of the whole-gate one.
  • Mutants caught: the delta's entry, the block-diagonal test, and the value reduce keeps.
  • Checked on the build host:
    • check-lockfiles;
    • cargo test --release --features full --lib quantum_tn (13 passed), --test tn_vs_sv, --test bit_identity;
    • the service's tests (60 passed);
    • cargo check of the CLI binary;
    • clippy reports nothing in the touched files.
  • The public-text checks are clean.

🤖 Generated with Claude Code

**wai-quantum 0.6.7.** Two exact network reductions that cut the cost of controlled-Z and controlled-X circuits by orders of magnitude. ### What changes - **`Network::amplitude_split`** splits each gate on two or more qubits at every qubit it is block-diagonal on: a control, or a qubit it is diagonal on. - There `G = Σ_a |a⟩⟨a| ⊗ G_a`, so that qubit's part is the delta `δ(out, in, k)` on its wire, and the blocks `G_k` keep the rest, joined by a bond of dimension 2. - Only zeros of the matrix are read, with no arithmetic. - A cut through a CZ or CX costs 2 instead of the 4 of its two wires, and a cut crossed by m such gates costs 2^m less. - **`Network::reduce`** fixes every index that some tensor allows only one value of. - Every tensor holding that index keeps its entries at that value and drops the index; this repeats until nothing changes, then it simplifies. - Input and output projections run through diagonal gates and split deltas, so a CZ beside a projected output becomes scalars. - Open indices are never fixed. - **`Network::amplitude` and `Network::simplify` are unchanged**, so every pinned digest is too (`tests/bit_identity`: 23 passed). - **Callers moved to split, reduced networks:** - `examples/tn_cost` (`TN_DENSE=1` for the old pipeline); - the CLI's `wai-quantum tn` (`--whole-gates`); - the service's `tensor_network` method. ### Measured On a published release's 61-qubit CZ circuits: log₁₀ multiply-adds for one amplitude, 64 trials. | depth | whole gates, simplified | split | split, reduced | |---|---|---|---| | 8 | 8.03 | 6.58 | 5.35 | | 12 | 12.46 | 9.23 | 8.25 | | 16 | 16.09 | 12.09 | 11.22 | | 20 | 19.64 | 15.16 | 14.26 | 1,024 trials do not lower the split costs further. ### Tests - Split networks, reduced or not, and reduced whole-gate networks give the state vector's amplitudes. The circuits mix CZ, CX both ways, a controlled random unitary, random diagonal gates, Toffoli, CCZ and random two-qubit unitaries, and the outputs are both projected and open. - CZ and CX split, a random unitary does not, and CX splits at its control. - On a 4 × 5 CZ grid of 12 layers, the split tree costs under an eighth of the whole-gate one. - **Mutants caught:** the delta's entry, the block-diagonal test, and the value `reduce` keeps. - **Checked on the build host:** - `check-lockfiles`; - `cargo test --release --features full --lib quantum_tn` (13 passed), `--test tn_vs_sv`, `--test bit_identity`; - the service's tests (60 passed); - `cargo check` of the CLI binary; - clippy reports nothing in the touched files. - The public-text checks are clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Network::amplitude_split builds the same network as Network::amplitude but
splits each gate on two or more qubits at every qubit it is block-diagonal on
(a control, or a qubit it is diagonal on): G = Σ_a |a⟩⟨a| ⊗ G_a becomes the
delta δ(out, in, k) on that qubit's wire and the blocks G_k, joined by a bond
of dimension 2. Only zeros of the matrix are read, so the amplitudes are the
same entries' sums. A cut through a CZ or CX then costs 2, not 4.

On the 61-qubit CZ circuits of a published release, depth 8/12/16/20, the
search (64 trials) finds log10 multiply-adds 6.58/9.23/12.09/15.16 on split
networks against 8.03/12.46/16.09/19.64 on whole-gate ones. 1024 trials do not
lower them further.

tn_cost, the wai-quantum CLI's tn subcommand (--whole-gates for the old
networks) and the service's tensor_network method build split networks.

Tests: split networks give the state vector's amplitudes on circuits of CZ,
CX both ways, a controlled random unitary, random diagonal gates, Toffoli,
CCZ and random two-qubit unitaries, with outputs projected and open; CZ and
CX split and a random unitary does not, CX at its control; on a 4 × 5 CZ grid
of 12 layers the split network's tree costs less than an eighth of the
whole-gate one's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Where a tensor is zero unless index i takes v, every tensor holding i keeps
its entries at v and drops i, repeated until nothing changes; then simplify.
Only zeros are read and entries selected. Projections run through diagonal
gates and the deltas of split ones, so a CZ beside a projected output becomes
scalars. Open indices are never fixed. simplify itself is unchanged, so
networks that do not call reduce keep their bits.

On the same 61-qubit CZ circuits (depth 8/12/16/20, 64 trials): log10
multiply-adds 5.35/8.25/11.22/14.26 split and reduced, against 6.58/9.23/
12.09/15.16 split alone and 8.03/12.46/16.09/19.64 whole and simplified.

tn_cost, the CLI's tn subcommand and the service's tensor_network method
reduce their split networks. Tests: split networks reduced, and whole-gate
networks reduced, give the state vector's amplitudes; open outputs too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wai-quantum 0.6.7: the changelog entry, and the version in every lockfile that pins it
All checks were successful
wai-quantum tensor-engine member / member · tensor engine, the kernel toolchain's simulator (linux) (pull_request) Successful in 8m4s
wai-quantum CPU vector units / member · vector unit, rvv 1024-bit (riscv64, emulated) (pull_request) Successful in 18s
wai-quantum CPU vector units / member · vector unit, sve 128-bit (aarch64, emulated) (pull_request) Successful in 36s
wai-quantum CPU vector units / member · vector unit, rvv 128-bit (riscv64, emulated) (pull_request) Successful in 13s
wai-quantum CPU vector units / member · vector unit, sve 2048-bit (aarch64, emulated) (pull_request) Successful in 10s
wai-quantum CPU vector units / member · vector unit, avx2 (x86_64 silicon) (pull_request) Successful in 13s
wai-quantum signal processor / processor and member · signal processor, emulated (pull_request) Successful in 13m54s
wai-quantum CPU vector units / member · vector unit, sve 512-bit (aarch64, emulated) (pull_request) Successful in 12s
wai-quantum WebGPU member / member · software Vulkan (linux) (pull_request) Successful in 2m12s
wai-quantum WebGPU member / shader checks · browser build · wasip2 inertness · MSRV (pull_request) Successful in 3m20s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 3m23s
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Successful in 5m23s
wai-web reach builds / wai-web reach builds · the package of record, every output as recorded (pull_request) Successful in 2m45s
wai-web reach builds / wai-web reach builds · this tree's wai-web, every rung on its engine line (pull_request) Successful in 4m18s
WAI conformance / cargo-class corpora · macos (pull_request) Successful in 23m22s
WAI conformance / cross-arch byte-equality · macos (pull_request) Successful in 28s
WAI conformance / codec wrappers · fuzz smoke, text decode limits, C entry points, provenance, the semantic path (pull_request) Successful in 1m31s
WAI energy receipts / energy receipts · macos (pull_request) Successful in 10m57s
wai-pack / wai-pack · macos (pull_request) Successful in 1m57s
wai-quantum dataflow member / member · dataflow device absent (macos) (pull_request) Successful in 19s
wai-quantum FPGA member / member · FPGA datapath, simulated (macos) (pull_request) Successful in 1m34s
wai-quantum Metal member / member · Metal (macos) (pull_request) Successful in 36s
wai-quantum neural-processor member / member · neural processor (macos) (pull_request) Successful in 7m46s
wai-quantum OpenCL member / member · OpenCL GPU (macos) (pull_request) Successful in 1m4s
wai-quantum service / service · macos (pull_request) Successful in 53s
wai-quantum matrix-extension member / member · matrix extension absent (macos) (pull_request) Successful in 12s
wai-quantum portable tensor program / tensor program · Metal and the arm64 CPU (macos) (pull_request) Successful in 34s
wai-quantum CPU vector units / member · vector unit absent (macos) (pull_request) Successful in 24s
wai-quantum WebGPU member / member · Metal (macos) (pull_request) Successful in 6m29s
wai-quantum WebGPU member / member · browser WebGPU (macos) (pull_request) Successful in 3m25s
50c6f8ec95
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!343
No description provided.