Exact Fault-Tolerant Quantum Circuit Compilation, Optimization, and Verification in Lumbda
Chemistry, Quantitative Finance, Combinatorial Search, and Full-Scale Post-Quantum Cryptography
Companion Technical Paper #2 · Lumbda Project
Source: git.unturf.com/engineering/unturf/lumbda · License: AGPL-3.0-only
December 2026
Abstract
Fault-tolerant quantum algorithms live or die by exact logical resource counts—logical qubit width (Q), non-Clifford Toffoli count (T), critical-path Toffoli depth (T-Depth), and logical spacetime volume (Q × T)—yet most published resource estimates stop at analytic formulas or unverified gate scripts that overlook relative-phase kickback and ancilla-garbage entanglement. This paper presents an end-to-end constructive compilation, optimization, and exact verification pipeline built in Lumbda (a multi-tier Lisp/Scheme runtime in C, Rust, and Python) paired with the standalone C11 circuit optimizers qecc_opt v4 and qecc_sat_opt v4. Parameterized Scheme metaprograms emit deterministic, streaming binary circuits in the canonical QECCOPS1 intermediate representation using a 1-qubit LIFO ancilla wire pool that enforces zero width fragmentation (Q_hi == Q_act), zero dirty resets (R = 0), and zero-Toffoli measurement-based uncomputation (HMR plus classically controlled Clifford phase fixes).
We evaluate the full toolchain across 276 verified circuit configurations spanning four constructive, non-cryptanalytic application domains—Quantum Chemistry & Materials (57 configs), Quantitative Finance, QAE & Scientific PDEs (84 configs), Combinatorial Optimization & SAT (64 configs), Symmetric & Post-Quantum Cryptography (31 core + 19 full-scale configs), plus 21 baseline reference kernels. Every single circuit is verified on 64 bit-sliced randomized basis-state shots with randomized HMR measurement outcomes both before and after optimization, recording 0 classical output errors, 0 relative-phase errors, and 0 ancilla-garbage errors across all 276/276 configurations. Headline full-scale milestones include:
Full 10-Round NIST FIPS 197 AES-128 & Grover Key-Search Oracle (273 Q): Complete reversible on-the-fly 128-bit quantum key expansion with zero extra key registers compiles full 10-round encryption in 273 logical qubits and 11,520 Toffolis, and the complete reversible Grover key-search phase oracle (forward encryption, 14-ancilla C^128 Z target-ciphertext phase flip adding 0 extra qubits, and full 10-round uncomputation) in 273 Q and 23,304 T, verified bit-for-bit on official NIST FIPS 197 Appendix B plus 63 randomized and 1-bit-sensitivity shots.
Full 256-Coefficient, 7-Layer NIST FIPS 203 ML-KEM In-Place NTT/INTT (3,096–3,110 Q): Exact NIST FIPS 203 Algorithm 9/10 over Z_3329[X]/(X^256 + 1) executes all 896 butterflies over 3,072 ABI qubits while sharing only 19–38 serial scratch qubits, reaching a minimum spacetime volume of 1.202 × 10^9 at 3,110 Q and 386,464 T (verified across 16,384 exact 12-bit modular coefficient checks per circuit).
Bit-Exact Cross-Tier Compiler Parity: Independent Lumbda runtimes—C with x86_64 JIT (1.36 s), C bytecode VM (2.53 s), zero-dependency Rust bytecode VM (10.86 s), and Python—emit bit-for-bit identical QECCOPS1 binary streams on the 332,161-op (18,601,032-byte) AES-128 Grover oracle (SHA-256 = 02059756efe5717336833f8a2987d5d618064e6fd789a4dfefa7e112258c8b5a).
1. Introduction and Contributions
Translating high-level fault-tolerant quantum algorithms into concrete, surface-code-ready gate sequences requires simultaneously solving four engineering problems: (1) expressive parameterized circuit generation without hand-unrolling millions of gates, (2) strict ancilla lifecycle discipline so temporary wires never fragment logical width, (3) phase-clean circuit optimization capable of eliminating redundant Toffoli, Clifford, and routing gates at multi-million-op scale, and (4) fast, exact verification that checks not only classical outputs but also relative phase kickback and ancilla restoration to |0>.
Existing quantum software frameworks typically address only a subset of these requirements. High-level circuit DSLs often materialize full in-memory ASTs that stall past a few hundred thousand gates, rely on naive register-level allocators that inflate peak qubit width, or verify only classical truth tables while overlooking measurement-induced Pauli-Z phase defects. Conversely, hand-tuned paper constructions frequently report asymptotic or per-subroutine estimates without assembling, optimizing, and verifying the complete reversible circuit end-to-end.
This paper demonstrates that Lumbda—a compact, multi-tier Scheme runtime designed for deterministic metaprogramming—paired with the standalone C11 post-construction optimizers qecc_opt v4 and qecc_sat_opt v4 bridges this gap cleanly on commodity CPU hardware.
1.1 Summary of Contributions
Streaming QECCOPS1 Compilation & Zero-Fragmentation Wire Allocation (§2): A portable Scheme circuit library (qbench_lib.lsp) and native circuit-stream-* primitives emit canonical 56-byte gate records directly to disk or compressed QECCOPSZ frames while enforcing Q_hi == Q_act, R = 0 dirty resets, and bit-exact parity across C, Rust, and Python tiers.
Stacked Algebraic + SAT-Proved Fault-Tolerant Optimization (§3): A two-stage CPU-only optimization stack combining qecc_opt v4 (exact truth-table/affine/quadratic rewriting, measurement absorption, parity-span phase-fix folding, Pauli-frame & linear-block compression, live-interval compaction) with qecc_sat_opt v4 (bidirectional pure-CX Gaussian synthesis, affine CCX -> HMR uncomputation, and condition-aware backward-cone DPLL/SAT rewriting backed by formal UNSAT certificates).
Dual-Gate Streaming Exact Verification (§4): A 64-shot bit-sliced streaming simulator (< 30 MB RAM on 7.4M-op circuits) that verifies computational outputs, exact relative phases under randomized HMR outcomes, and clean |0> ancilla restoration both pre- and post-optimization.
276-Circuit Constructive Benchmark Suite Across Four Domains (§5): Complete, Pareto-swept, 100%-verified fault-tolerant implementations spanning chemistry, quantitative finance/PDEs, combinatorial search/SAT, and full-scale NIST FIPS 197 AES-128, FIPS 202 Keccak-f[1600], and FIPS 203 ML-KEM-256 NTT/INTT.
One-Command CPU-Only Reproducibility (§6): Every number in this paper is reproduced deterministically on CPU-only hardware with automatic temporary-file cleanup.
Suite |
Scope & Implemented Kernels |
Runner |
Configs |
Verified |
|---|---|---|---|---|
Baseline Showcase |
4 foundational kernels (01–04) |
verify_and |
21 |
21 / 21 |
Domain 1: Chemistry & Materials |
Alias QROM, 2D Hubbard, DF/THC Givens |
bench_d1 |
57 |
57 / 57 |
Domain 2: QAE, LinAlg & PDEs |
Option QAE MAC, 1D PDE Stencil, Newton 1/x |
bench_d2 |
84 |
84 / 84 |
Domain 3: Combinatorial & SAT |
NAF Max-Cut, Dual Knapsack, 3-SAT, 3-Coloring |
bench_d3 |
64 |
64 / 64 |
Domain 4: Core PQC & Symmetric |
FIPS 197 AES-128 Rd, Keccak-f[W], ML-KEM Bfly |
bench_d4 |
31 |
31 / 31 |
Domain 4: Full-Scale (4D & 4E) |
10-Rd AES-128 Grover (8) + ML-KEM 256 NTT (11) |
bench_d4f |
19 |
19 / 19 |
Total Verified Suite |
14 deep-dive kernels + 4 baseline kernels |
All CPU |
276 |
276 / 276 |
Figure 1. Constructive fault-tolerant quantum benchmark landscape across all 276 verified configurations. Panel A plots the verified minimum logical qubit ladder from 30 Q (dual-constraint 0/1 Knapsack) up to 3,110 Q (full 256-coefficient NIST FIPS 203 ML-KEM NTT). Panel B summarizes verified post-optimization Toffoli (or width) and spacetime volume (Q × T) reductions relative to the unoptimized baseline reference kernels.
2. Compiler and Streaming IR Architecture
2.1 Pure-Scheme Parameterized Circuit Synthesis
Every benchmark kernel in the suite is authored as pure functional Scheme running atop Lumbda. Parameterized higher-order builders—such as unary-iteration tree traversals, carry-chunked adders, GF(2) linear basis trackers, and bit-heap compressors—accept explicit architecture knobs (--qrom-split, --uncompute-split, --chunk-cap, --window, --lanes, --batch) that trace smooth (Q, T, T-Depth) Pareto frontiers without duplicating circuit logic.
To support multi-million-gate circuits without exhausting host memory, the emitter batches gate records into fixed-size chunks (8,192 ops/batch in qbench_lib.lsp) or streams directly through Lumbda's native circuit-stream-* primitives (circuit-stream-open!, circuit-stream-alloc!, circuit-stream-free!, circuit-stream-emit!, circuit-stream-close!).
2.2 The QECCOPS1 / QECCOPS2 / QECCOPSZ Binary Container Family
All compilers, optimizers, and verifiers communicate through a single deterministic binary circuit stream format with three wire-compatible encodings auto-detected by an 8-byte file magic:
Format |
Header (16 Bytes) |
Record Layout |
Intended Role |
|---|---|---|---|
QECCOPS1 |
"QECCOPS1" + u64 LE n_ops |
56 B/op: u32 kind, pad, 6 × u64 LE operand slots |
Canonical uncompressed interchange (Scheme emitters & streaming sim) |
QECCOPS2 |
"QECCOPS2" + u64 LE n_ops |
24 B/op: u8 kind, flags, u16 pad, 5 × u32 LE |
Compact 32-bit-indexed binary layout (2.33× smaller in-memory/disk) |
QECCOPSZ |
"QECCOPSZ" + u64 LE n_ops |
Streaming zstd frame of 56 B/op QECCOPS1 records |
Archival & fast IPC (19–23× ratio, 128 MiB window cap, exact length) |
Each canonical 56-byte QECCOPS1 record encodes (kind, q_control2, q_control1, q_target, c_target, c_condition, r_target) with 0xFFFFFFFFFFFFFFFF (NO_SLOT) denoting unused operand slots. The 18-operation instruction set covers all fault-tolerant Clifford+Toffoli primitives plus classical measurement feedback and register ABI metadata:
Op IDs |
Mnemonics |
Category |
Semantics & Fault-Tolerant Cost |
|---|---|---|---|
13, 14 |
CCX, CCZ |
Non-Clifford Toffoli |
1 Toffoli (4 T gates via Gidney temporary-AND) |
8–10 |
CX, CZ, SWAP |
2-Qubit Clifford |
0 Toffolis; SWAP elided virtually during optimization |
12 |
HMR |
X-Basis Measure & Reset |
0 Toffolis; measures q in X-basis into c, resets q to |0>, records phase kickback |
11 |
R |
Computational Reset |
Forbidden in constructive suite (R = 0 across all 276 configs) |
6, 7, 0 |
X, Z, NEG |
Pauli / Global Phase |
0 Toffolis; classically conditionable via c_condition |
3–5 |
BIT_INVERT, BIT_STORE0/1 |
Classical Bit Ops |
Classical measurement-bit algebra for phase-fix uncomputation |
15, 16 |
PUSH_COND, POP_COND |
Structured Condition Stack |
Lexical classical-control scope; folded into inline c_condition by qecc_opt v4 |
1, 2, 17 |
REGISTER, APPEND_REG, DEBUG_PRINT |
ABI & Diagnostics |
Declares external ABI input/output qubits (Reg 0) so optimizers preserve exact interface |
2.3 LIFO Wire-Pool Allocation and Zero-Dirty-Reset Discipline
Conventional register-based quantum allocators suffer from width fragmentation when temporary arrays of differing sizes are allocated and freed out of order. Our shared runtime (qbench_lib.lsp) eliminates width fragmentation completely by managing all non-ABI ancillas through a 1-qubit LIFO wire pool:
alloc-abi! registers all external input/output qubits consecutively inside Register 0 so every downstream pass and verifier agrees on the exact ABI boundary.
alloc-wire! pops a recycled clean |0> wire from the LIFO free list or bumps the physical high-water counter q-next only when no clean wire is free.
free-wire! pushes an uncomputed wire back onto the free list (and free-reg! returns vectors in reverse order to maximize wire-ID locality).
This guarantees two structural invariants across all 276 emitted circuits:
Zero Width Fragmentation (Q_hi == Q_act): The highest allocated qubit index equals the exact peak concurrent live qubit count.
Zero Ancilla Leaks & Zero Dirty Resets (Q_live_end == Q_abi, R = 0): Every scratch qubit is explicitly uncomputed back to |0> before being returned to the pool—never discarded via computational-basis reset R.
Uncomputation uses Gidney's measurement-based temporary-AND discipline (and-uncompute!): computing t = a & b into a clean wire costs 1 Toffoli (CCX), while uncomputing t applies HMR(t -> m) followed by classically controlled CZ_if(m, a, b) at 0 Toffoli cost. For polarized conjunctions (a ^ pa) & (b ^ pb), the phase fix decomposes into CZ_if, Z_if, and NEG_if—and for multi-term quadratic products (such as Radix-4 Booth partial products and Berry ANF QROM banks), a single HMR cancels all degree-2 cross-terms with zero backward Toffolis.
2.4 Bit-Exact Cross-Tier Compiler Parity
Because Lumbda implements identical R5RS/Scheme semantics across independent C, Rust, and Python runtimes, the exact same unmodified .lsp circuit generator runs across tiers and produces byte-identical binary output. The table below records cross-tier compilation parity on the full 10-round FIPS 197 AES-128 Grover key-search oracle (Use Case 4D: 273 Q, 332,161 ops, 18,601,032 bytes):
Lumbda Runtime Tier |
Idle Wall Time |
Output Bytes |
QECCOPS1 SHA-256 Digest |
|---|---|---|---|
C + x86_64 JIT (c/lumbda --jit) |
1.36 s |
18,601,032 |
02059756efe57173...789a4dfefa7e112258c8b5a |
C Bytecode VM (c/lumbda --fast) |
2.53 s |
18,601,032 |
02059756efe57173...789a4dfefa7e112258c8b5a |
Rust Bytecode VM (zero-dep) |
10.86 s |
18,601,032 |
02059756efe57173...789a4dfefa7e112258c8b5a |
Python Bytecode VM (reference) |
Reference |
18,601,032 |
02059756efe57173...789a4dfefa7e112258c8b5a |
The full 64-character SHA-256 digest matches identically across every tier: 02059756efe5717336833f8a2987d5d618064e6fd789a4dfefa7e112258c8b5a. This provides strong cross-implementation assurance against runtime compilation defects: any divergence in integer arithmetic, bit operations, or control flow immediately breaks the stream digest.
3. Exact Optimization Pipeline: qecc_opt v4 and qecc_sat_opt v4
Raw emitted circuits frequently contain cross-boundary redundancies—constant controls exposed when a subcircuit is specialized to a classical parameter, commuting Clifford cancellations across module boundaries, duplicate intermediate products across neighboring arithmetic blocks, and reversible uncomputation Toffolis that can be lowered to 0-Toffoli HMR + CZ_if phase fixes. Our pipeline stacks two standalone, 100% CPU-only C11 optimizers designed to preserve exact unitary and phase semantics.
3.1 Stage 1: qecc_opt v4 Peephole, Algebraic, and Compaction Passes
Invoked as qecc_opt in.ops.bin -o mid.ops.bin --compact-qubits --rounds 2, Stage 1 runs eight phase-clean passes to a fixed point:
Pass Flag |
Core Mechanism |
Verified Transformations |
|---|---|---|
cond |
Classical Condition Folding |
Folds PUSH_COND; op; POP_COND into inline c_condition; propagates BIT_STORE0/1 & BIT_INVERT; removes dead ops. |
zero |
Basis-Constant Propagation |
Tracks freshly allocated |0>/|1> ancillas (never assuming ABI inputs are constant); downgrades CCX->CX->X; forces const HMR. |
truth |
Exact Boolean / Affine / Quadratic Witness Tracker |
6-atom exact truth table + 32-atom XOR-affine + 32-monomial quadratic tracker with O(1) live-holder table; linearizes affine AND gates. |
mabsorb |
K3a Measurement Absorption & Uncompute CCX → HMR |
Absorbs adjacent gates into HMR boundaries and lowers clean uncomputation CCX gates into 0-T HMR + CZ_if phase fixes. |
pscan |
GF(2) Parity-Span Phase Fix |
Compresses multi-gate classically conditioned parity phase-fix chains emitted by Berry QROM and nested temporary-AND uncomputation. |
fold |
gate_fold_nct, o1_cancel, pauli_frame, lin64, swap_elide |
Self-inverse O(1) commuting cancellation, sandwich folding, virtual SWAP permutation elision (ABI-safe inside rounds, full post-compact), Pauli-frame propagation, & 64-bit linear synthesis. |
hold |
HP3 Flat-Product Holds & Duplicate Loans |
Retains live 1/2/3-wire XOR witnesses and flat-product duplicates across short intervals to eliminate recomputed Toffolis. |
compact |
Live-Range Interval Packing (--compact-qubits) |
Colors non-overlapping qubit and classical-bit lifetimes to recover minimum physical width Q after algebraic simplifications. |
3.2 Stage 2: qecc_sat_opt v4 Formally Sound SAT/DPLL Post-Optimizer
Piped directly after qecc_opt v4 (for all circuits up to ~1M ops), qecc_sat_opt v4 applies four global structural and SAT-backed passes with built-in 64-shot exact self-verification (--verify):
Pass 1A–1C (Routing & Commuting Cleanup): Recognizes 3-CX swap idioms into explicit OP_SWAP, elides virtual SWAP permutations globally, collapses CX triangles and X-CX-X conjugations, and performs O(1) commuting self-inverse cancellation.
Pass 2 (Bidirectional Pure-CX Gaussian Synthesis): Extracts maximal contiguous pure-CX linear blocks, synthesizes minimum-gate bidirectional Gaussian eliminations over GF(2), and self-verifies the matrix identity before committing any replacement.
Pass 3 (Exact Affine CCX -> HMR Uncomputation): Identifies ancilla wires whose target state is an exact affine function of earlier controls prior to erasure, replacing backward CCX uncomputations with 0-Toffoli HMR + CZ_if/Z_if sequences.
Pass 4A–4D (Unified Condition-Aware Backward-Cone SAT/DPLL Prover): Builds the exact Tseitin CNF over each candidate CCX gate's backward light-cone (respecting classical condition guards) and requires a formal UNSAT certificate before committing any rewrite:
4A (Implication & Global Witness): Proves a & b == 0 (delete), a & b == 1 (rewrite to X), or a & b == w (rewrite to CX).
4B (Multi-CX Affine Span Witness): Proves a & b equals an XOR parity of k <= 6 live qubits, lowering 1 Toffoli to k Cliffords.
4C (bind81 Classical-Bit Lifting): Detects when a control qubit is provably equal to a classical bit cb, rewriting CCX(q_cl, b, t) into classically conditioned CX_if(cb, b, t) (0 Toffolis).
4D (g1_equiv Pre-HMR Product Coalescing): Detects when a later CCX(a, b, t) computes the exact same product held earlier by a wire w before w was erased via HMR; inserts CX(w, t) prior to w's erasure and deletes the later Toffoli.
3.3 Measured Optimization Impact Across Domains
Even on heavily hand-engineered circuits emitted by specialized Scheme generators, the stacked qecc_opt v4 + qecc_sat_opt v4 pipeline delivers substantial, provably exact reductions across every domain:
Verified Circuit |
Raw T → Opt T |
T Delta |
Ops Raw → Opt |
Dominant Passes |
|---|---|---|---|---|
2C. Newton 1/sqrt(x) (w=8, booth) |
318 → 199 |
-37.4% |
— |
truth, SAT 4A–4D |
4C. ML-KEM Butterfly (w=1, cap=3) |
2,624 → 1,849 |
-29.5% |
17.6k → 14.4k |
truth, SAT 4D |
4C. ML-KEM Butterfly (w=1, cap=4) |
2,150 → 1,558 |
-27.5% |
14.8k → 12.2k |
truth, hold |
1A. Alias QROM (L=64, dirty sub-50Q) |
348 → 288 |
-17.2% |
3,239 → 2,828 |
pscan, mabsorb |
3C. 3-SAT (N=20, M=84, B=20, grp=1) |
316 → 272 |
-13.9% |
— |
SAT 4D (g1_equiv) |
4E. ML-KEM Full 256 NTT (w=1, cap=12) |
919.0k → 850.3k |
-7.5% |
7.42M → 6.77M |
truth, fold |
4D. 10-Rd AES-128 Grover (L=1, 273 Q) |
23,478 → 23,304 |
-0.7% |
332.2k → 265.0k |
fold, lin64 (-20.2% ops) |
Notice that on structured symmetric circuits such as 10-round AES-128 (4D), where S-box Toffoli counts are already near the multiplicative complexity floor (32 T per Boyar–Peralta S-box), the optimizer still cuts total gate operations by -20.2% (332,161 → 264,957 ops) and removes 174 redundant Toffolis across the C^128 Z and uncomputation boundaries while lowering critical-path T-depth from 22,593 to 21,915.
4. Verification Methodology and Threat Model
4.1 Why Classical-Basis-Only Verification Is Insufficient
In fault-tolerant quantum circuits composed of Clifford+Toffoli gates plus measurement-based uncomputation (HMR), verifying only the classical map |x, 0> → |f(x), 0> misses three fatal defect classes:
Relative-Phase Corruption: Under HMR uncomputation, measuring a wire t in the X basis projects |t> onto |+> or |-> and injects a random phase (-1)^(t · m) that must be cancelled identically by downstream CZ_if/Z_if/NEG_if gates. A single missing or mis-polarized phase-fix gate leaves classical outputs 100% intact while scrambling relative phases across superposition branches—completely destroying interference in Grover search, QAE, and QSP.
Ancilla Entanglement Leakage (Dirty Scratch): If any non-ABI ancilla wire finishes in |1> instead of |0> on even one computational basis input, it remains entangled with the data register. Reusing that wire later corrupts subsequent subcircuits, and tracing it out decoheres the algorithm.
Optimizer Unsoundness Under Classical Feedback: Peephole or SAT rewrites that treat HMR measurements as deterministic, commute gates illegally past conditioned phase flips, or assume ABI inputs start in |0> can silently introduce phase or output defects on rare inputs.
4.2 Streaming 64-Shot Exact Simulator and Dual-Gate Audit
Our verification harnesses (verify_and_bench.py, bench_domain{1..4}.py, and bench_domain4_full.py) execute an exact, bit-sliced 64-shot streaming simulator directly over the QECCOPS1 binary stream (reading 65,536-op / 3.67 MB chunks so even 7.4M-op ML-KEM-256 circuits verify in < 30 MB host RAM). Each qubit and classical bit is represented as a 64-bit integer packing 64 independent basis-state shots executed in parallel via bitwise operations:
For each HMR(qt → ct) under active condition mask cond, the simulator draws 64 independent uniform random measurement outcomes r, updates bits[ct] = (bits[ct] & ~cond) ^ (r & cond), accumulates the exact X-basis measurement kickback phase ^= (qubits[qt] & r & cond), and resets qubits[qt] &= ~cond.
Every Z, CZ, CCZ, and NEG gate XORs its exact phase contribution into the 64-bit phase mask.
Every single one of the 276 configurations must pass a strict dual-gate audit—once on the raw emitted QECCOPS1 circuit before optimization, and again on the final optimized circuit after qecc_opt v4 (+ qecc_sat_opt v4)—checking three invariants simultaneously across all 64 shots:
Exact Classical Output Parity (0 errors): Output registers match an independent Python mathematical ground-truth oracle bit-for-bit (including official NIST FIPS 197 Appendix B test vectors, 1-bit flipped sensitivity cases, FIPS 203 Algorithms 9 & 10 cross-checked against schoolbook negacyclic polynomial convolution, exact Jordan–Wigner fermionic signs, planted 3-SAT/3-Coloring satisfying assignments and near-miss perturbations, and certified ULP error bounds for truncated arithmetic).
Exact Relative-Phase Parity (0 errors): The 64-bit phase vector equals the exact expected oracle phase mask (0 for compute-only circuits; exact target bitmask for Grover/Hubbard/Knapsack/SAT phase oracles) under independent randomized HMR outcomes.
Zero Ancilla Garbage (0 errors): Every single non-ABI qubit q not in Register 0 terminates identically at 0 across all 64 shots.
4.3 Explicit Resource Metric Convention
To prevent apples-to-oranges comparisons across the FTQC literature, every table in this paper reports exact, directly counted metrics from the final verified QECCOPS1 stream:
Q: Exact total logical qubits (Q_hi == Q_act).
T: Exact Toffoli count (CCX + CCZ). Under Gidney's temporary-AND decomposition, each Toffoli compiles to 4 non-Clifford T-gates, while HMR + classically controlled CZ_if/Z_if/NEG_if uncomputation costs 0 T-gates.
T-Depth: Exact critical-path Toffoli depth computed along the circuit DAG, tracking both qubit dependencies and classical measurement-bit feedback dependencies across HMR and PUSH/POP_COND.
Q × T: Exact logical spacetime volume (product of total logical qubits and Toffoli count).
Ops: Total QECCOPS1 operations (non-Clifford + Clifford + Pauli + classical feedback + metadata).
5. Domain-by-Domain Empirical Results
All post-optimization metrics reported below are 100% verified (0 classical, 0 phase, 0 ancilla errors pre- and post-opt). Stars (*) denote non-dominated Pareto-frontier configurations within each benchmark target.
5.2 Domain 2: Quantitative Finance, QAE, and Scientific PDEs (84 / 84 Verified)
Reversible fixed-point multiply-accumulate (MAC), sparse finite-difference stencils, and nonlinear reciprocals underpin Quantum Amplitude Estimation (QAE) for derivative pricing and fault-tolerant PDE solvers. Our Domain 2 library (domain2_lib.lsp) introduces five arithmetic optimizations:
Direct Gidney Controlled-Narrow Adder: Eliminates both the w-qubit partial-product buffer and w-Toffoli carry uncomputation, cutting equal-width controlled addition from 3w Toffolis / 2w + 1 ancillas to 2w - 1 Toffolis / w - 1 ancillas.
Radix-4 Booth MAC with Degree-2 0-T HMR Phase Fix: Recodes the multiplier two bits at a time, halving carry-propagation sweeps and uncomputing degree-2 partial products M[i] = (is1 & a_i) ^ (is2 & a_{i-1}) with 0 backward Toffolis via HMR + two CZ_if. Cuts 100% bit-exact (0 ULP) w=16 option-oracle Toffolis from 906 T to 502 T (-44.6% T).
Zero-Extra-Register 1-Level Split-Word MAC: Uses exact in-place linear conjugation (1 - 2^h) on the accumulator plus 2 carry qubits to evaluate a 3-subproduct split multiplication with zero extra w-bit product registers (106 Q, 727 T at w=16, -19.8% T vs baseline).
Truncated Fixed-Point MAC & Fused ReLU Payoff Comparator: Drops t = w - g low-order fractional bits with proven worst-case error ≤ ceil(t / 2^g) ULP (halved under signed Booth cancellation) and fuses European Call ReLU (P > strike) & ((P - strike) >> shift >= thr) into P >= strike + thr * 2^shift, cutting payoff comparator Toffolis by -83.5% (91 T → 15 T at w=16).
Zero-Squaring In-Place QROM Seed Swap for Newton–Raphson (1/x, 1/sqrt(x)): Precomputes both y_0 and y_0^2 in a 16-entry unary-iteration QROM (14 T) and transforms reg_y: y_0^2 → y_0 in-place via XOR, eliminating the squaring multiplier entirely.
Use Case & Target |
Configuration |
Raw Q/T |
Opt Q |
Opt T |
Opt Q×T |
Err / Note |
|---|---|---|---|---|---|---|
2A. QAE Option w=12 |
Baseline 02_qae (exact) |
74/543 |
74 |
512 |
37,888 |
0 ULP ref |
2A. QAE Option w=12 |
Exact booth, cap=6, call |
66/561 |
66 |
541 |
35,706 |
0 ULP min-Q |
2A. QAE Option w=12 |
Exact booth, cap=0, call |
86/292 |
86 |
292 |
25,112 |
0 ULP -43% T |
2A. QAE Option w=12 |
Trunc schoolbook, t=10, c=4 |
50/531 |
50 |
507 |
25,350 |
≤1 ULP |
2A. QAE Option w=12 |
Trunc booth, t=10, cap=0 |
67/207 |
67 |
207 |
13,869 |
≤1 ULP -60% |
2A. QAE Option w=16 |
Baseline 02_qae (exact) |
98/949 |
98 |
906 |
88,788 |
0 ULP ref |
2A. QAE Option w=16 |
Exact schoolbook, cap=4 |
80/2232 |
80 |
2,192 |
175,360 |
0 ULP min-Q |
2A. QAE Option w=16 |
Exact booth, cap=0, call |
114/502 |
114 |
502 |
57,228 |
0 ULP -45% T |
2A. QAE Option w=16 |
Trunc schoolbook, t=14, c=4 |
63/1105 |
63 |
1,068 |
67,284 |
≤2 ULP |
2A. QAE Option w=16 |
Trunc booth, t=14, cap=0 |
87/341 |
87 |
341 |
29,667 |
≤1 ULP -62% |
2B. 1D PDE w=8 |
update, norm, c=1/4, cap=0 |
43/46 |
43 |
46 |
1,978 |
<60 Q |
2B. 1D PDE w=12 |
mark, norm, c=1/4, cap=4 |
46/157 |
46 |
146 |
6,716 |
<60 Q |
2B. 1D PDE w=12 |
mark, norm, c=1/4, cap=0 |
51/49 |
51 |
48 |
2,448 |
<60 Q |
2B. 1D PDE w=16 |
mark, norm, c=1/4, cap=4 |
59/271 |
59 |
253 |
14,927 |
<60 Q 16-bit |
2B. 1D PDE w=16 |
mark, norm, c=1/4, cap=0 |
67/65 |
67 |
64 |
4,288 |
0-T shifts |
2C. Newton 1/x w=8 |
schoolbook / booth |
41/267 |
41 |
214 / 201 |
8,774 |
0.8–1.0% rel |
2C. Newton 1/x w=10 |
schoolbook / booth |
49/327 |
49 |
274 / 258 |
13,426 |
0.12% rel |
2C. Newton 1/x w=12 |
schoolbook / booth |
58/450 |
58 / 70 |
388 / 322 |
22,504 |
0.12% rel |
2C. 1/sqrt(x) w=8 |
schoolbook / booth |
44/350 |
44 |
251 / 199 |
10,348 |
-37.4% opt |
2C. 1/sqrt(x) w=12 |
schoolbook / booth |
60/546 |
60 / 72 |
448 / 345 |
24,840 |
0.16% rel |
Remarkably, a full 3-point Dirichlet heat-diffusion PDE stencil oracle with norm thresholding fits strictly under 60 logical qubits up to full 16-bit precision (59 Q, 253 T via 0-Toffoli dyadic shifts), while reversible 12-bit Newton–Raphson 1/x and 1/sqrt(x) achieve 0.12%–0.16% relative accuracy in 70–72 Q and 322–345 T.
5.3 Domain 3: Combinatorial Optimization and SAT (64 / 64 Verified)
Grover-style quantum search for QUBO, Max-Cut, Knapsack, 3-SAT, and Graph 3-Coloring relies on low-width, zero-garbage phase oracles. Domain 3 (d3_csa_lib.lsp) contributes:
Strict Non-Adjacent Form (NAF) Weight Recoding: Recodes signed edge/item weights (e.g., 7 = 8 - 1, 15 = 16 - 1) whenever NAF strictly reduces non-zero bits, folding constant offsets into the classical threshold (-16.4% T at W=4 and -20.6% T + -40 Q at W=8).
Zero-Scratch In-Place Edge-Parity Materialization: Pairs edges with conflict-free orientations to compute x_u ^ x_v directly on the input register with 0 scratch qubits and 50% fewer CX gates.
Universal Wallace/Dadda 3:2 & 2:2 Bit-Heap with 0-T HMR Undo: Compresses weighted bit columns across global, batch, and col modes with zero backward Toffolis.
Dual-Constraint 0/1 Knapsack Shared-CSA Phase Oracle: Enforces W(x) ≤ W_max and V(x) ≥ V_min simultaneously with zero oracle target qubits (Q_abi = N), offering seq (N + 14..21 Q), dual, and shared (joint 3:2 CSA triples shared across weight and value columns) modes.
2-Level O(sqrt(M)) Clause Batching, 2-Tier SAT Grouping, & 1-T Graph 3-Coloring: Distributive literal-pair factoring, Boolean resolution, and cross-polarity sharing cut 3-SAT Toffolis by -25.7% (2.02 T/clause) while holding hard N=48, M=192 3-SAT and V=32 Graph 3-Coloring strictly under 100 logical qubits.
Use Case & Scale |
Configuration |
Raw Q/T |
Opt Q |
Opt T |
Opt Q×T |
Frontier |
|---|---|---|---|---|---|---|
3A. Max-Cut N=24, W=4 |
Baseline 03_comb (best) |
47/553 |
47 / 65 |
530 / 416 |
24,910 |
ref |
3A. Max-Cut N=24, W=4 |
col k=3, naf=1, ph=1 |
41/342 |
41 |
340 |
13,940 |
* min-Q |
3A. Max-Cut N=24, W=4 |
col k=15, naf=1, kl=0 |
49/222 |
49 |
215 |
10,535 |
* (-57.7% QT) |
3A. Max-Cut N=24, W=4 |
global, naf=1, ph=1 |
127/102 |
127 |
102 |
12,954 |
* (-75.5% T) |
3A. Max-Cut N=64, W=4 |
Baseline tw=8, csa=1 |
143/1146 |
141 |
1,019 |
143,679 |
ref |
3A. Max-Cut N=64, W=4 |
col k=3, naf=1, kl=0 |
86/1038 |
86 |
1,036 |
89,096 |
* min-Q |
3A. Max-Cut N=64, W=4 |
col k=15, naf=1, kl=0 |
94/564 |
94 |
556 |
52,264 |
* (-63.6% QT) |
3A. Max-Cut N=64, W=4 |
global, naf=1 |
315/249 |
315 |
249 |
78,435 |
* (-75.6% T) |
3B. Knapsack N=16 |
seq k=3 / shared sh=1 |
30/223 |
30 / 83 |
222 / 53 |
4,389 |
* (N+14 Q) |
3B. Knapsack N=32 |
seq k=3 / dual k=15 |
49/501 |
49 / 65 |
495 / 255 |
16,575 |
* (N+17 Q) |
3B. Knapsack N=32 |
shared sh=1, naf=1 |
170/105 |
170 |
104 |
17,680 |
* min-T |
3B. Knapsack N=64 |
seq k=7 / dual k=15 |
85/917 |
85 / 100 |
907 / 531 |
53,100 |
* (N+21 Q) |
3B. Knapsack N=64 |
shared sh=1, naf=1 |
350/214 |
350 |
214 |
74,900 |
* min-T |
3C. 3-SAT N=20, M=84 |
B=6, grp=1 / 1-lvl |
48/348 |
48 / 203 |
326 / 170 |
15,648 |
* (<50 Q) |
3C. 3-SAT N=32, M=128 |
B=8, grp=1 / 1-lvl |
67/599 |
67 / 345 |
577 / 310 |
38,659 |
* (<70 Q) |
3C. 3-SAT N=48, M=192 |
B=12, grp=1 |
98/916 |
98 |
876 |
85,848 |
* (<100 Q) |
3C. 3-Color V=16 (32Q) |
B=6 / 1-lvl |
50/171 |
50 / 127 |
170 / 95 |
8,500 |
* |
3C. 3-Color V=32 (64Q) |
B=8 / 1-lvl |
90/355 |
90 / 255 |
354 / 191 |
31,860 |
* (<100 Q) |
5.4 Domain 4: Symmetric and Post-Quantum Cryptography (50 / 50 Verified)
Quantitative fault-tolerant resource bounds for NIST-standardized symmetric and post-quantum primitives are essential for defensive security sizing (such as NIST Security Categories 1–5). Domain 4 evaluates three core cryptographic building blocks (4A–4C, 31 configs) and two full-scale, end-to-end NIST cryptographic circuits (4D–4E, 19 configs).
Core Primitives (4A–4C, 31 / 31 Verified)
4A — 9-Ancilla Boyar–Peralta AES-128 Round & 145 Q 10-Round Classical-Key Cipher: By materializing all 23 top-linear wires in-place on the 8 input wires via an invertible GF(2) basis tracker (make-lin-basis) and all 15 Stage-3 linear wires in-place on the 9-wire nonlinear core, S-box ancillas compress 5.33× (48 → 9 ancillas/lane) and HMR count drops 4× (36 → 9). Out-of-place routing implements ShiftRows in 0 gates, while exact Markowitz PLU implements MixColumns in 0 Toffolis, 0 ancillas. In pipeline mode, full rounds run at 512 T/round from 265 Q (serial, Td=480) to 400 Q (16× parallel, Td=30, -60.4% Q & Q×T vs S-box-only baseline). In true in-place mode, all 10 FIPS 197 rounds with classical keys fit in 145 Q and 10,240 T.
4B — Full FIPS 202 Keccak-f[W] Round in Exact Q = W + 3: Exploiting odd column height (5 rows), theta executes completely in-place via banded z-major PLU (0 ancillas, 0 T), rho o pi is 0-gate virtual routing, and a new 6-Toffoli, 3-ancilla in-place chi_5 uses the exact identity u_i = (~b_i) & (b_{i+1} ^ u_{i+2}) to cut Toffolis by -14.3% and T-depth by -42.8% (1,603 Q, 1,920 T, Td = 1,281 for full SHA-3 / Keccak-f[1600]).
4C — FIPS 203 ML-KEM In-Place Z_3329 NTT Butterfly: Factors (a, t) → (a + t, a - t) mod 3329 over 24 ABI qubits using 2t mod 3329 (22 T) and zero-extra-adder reverse subtraction, exploiting 2 × 3329 - 4096 = 2562 < 3329 so overflow ov and B ≥ 3329 are mutually exclusive (wrap = ov ^ (B ≥ 3329), 0 OR-gates). Sweeping QROM window w in {1..4} and carry chunk cap in {3..12} traces a verified 43 Q (1,558 T) to 62 Q (416 T, Q×T = 25,792) Pareto frontier for both Cooley–Tukey (CT) and Gentleman–Sande (GS) butterflies.
Use Case |
Configuration |
Raw Q/T |
Opt Q |
Opt T |
Td |
Opt Q × T |
|---|---|---|---|---|---|---|
4A. AES-128 Round |
pipeline, L=1 (serial) |
265/512 |
265 |
512 |
480 |
135,680 |
4A. AES-128 Round |
pipeline, L=4 (4× par) |
292/512 |
292 |
512 |
120 |
149,504 |
4A. AES-128 Round |
pipeline, L=16 (16× par) |
400/512 |
400 |
512 |
30 |
204,800 |
4A. AES-128 In-Place |
R=10 FULL FIPS 197 |
145/10240 |
145 |
10,240 |
9,760 |
1,484,800 |
4B. Keccak-f[200] |
R=1, L=1, chi=6t (NEW) |
203/240 |
203 |
240 |
161 |
48,720 |
4B. Keccak-f[400] |
R=1, L=1, chi=6t (NEW) |
403/480 |
403 |
480 |
321 |
193,440 |
4B. Keccak-f[1600] |
R=1, L=1, chi=6t (SHA-3) |
1603/1920 |
1,603 |
1,920 |
1,281 |
3,077,760 |
4C. ML-KEM Butterfly |
CT z=17, w=1, cap=4 (minQ) |
43/2150 |
43 |
1,558 |
1,555 |
66,994 |
4C. ML-KEM Butterfly |
CT z=17, w=4, cap=8 (<60Q) |
59/668 |
59 |
576 |
572 |
33,984 |
4C. ML-KEM Butterfly |
CT z=17, w=3, cap=12 (minT) |
62/470 |
62 |
416 |
416 |
25,792 |
4C. ML-KEM Butterfly |
GS z=1729, w=4, cap=12 inv |
62/432 |
62 |
423 |
423 |
26,226 |
Full-Scale Showcase 4D: Complete 10-Round FIPS 197 AES-128 & Grover Oracle (8 / 8 Verified)
A true Grover key-search oracle for AES-128 holds both the 128-bit plaintext/state and the 128-bit secret key in quantum superposition (256 ABI qubits). Naive key-schedule circuits allocate 10 × 128 = 1,280 extra qubits to store round keys. Our aes128_full_oracle.lsp executes the entire FIPS 197 key schedule reversibly on the fly with 0 extra key registers:
Forward Round Key Step (RK[r-1] → RK[r]): RotWord(w3) is 0-gate virtual indexing; w0 ^= SubWord(RotWord(w3)) executes 4 out-of-place 9-ancilla Boyar–Peralta S-boxes (4 × 32 = 128 T/round), reusing the exact same LIFO scratch pool; k[0] ^= Rcon[r] uses pure Pauli-X gates; and the in-place CX cascade w1 ^= w0; w2 ^= w1; w3 ^= w2 updates the remaining 96 key bits in 0 T.
Exact Inverse Key Step (RK[r] → RK[r-1]): Reverses the CX cascade to recover old_w3 before XOR-cancelling Rcon[r] and SubWord(RotWord(old_w3)) from w0 (128 T/round, 0 extra key registers).
Zero-Extra-Qubit C^128 Z Target-Ciphertext Phase Flip: After Round 10 encryption, a 2-level 4-nibble × 8-group C^128 Z tree flips the phase iff the 128-bit ciphertext matches the classical target. Its peak ancilla footprint is 14 qubits, which fits strictly inside AES's already-allocated 17-qubit scratch pool (8 tmp + 9 S-box), adding 0 extra qubits before full 10-round inverse uncomputation (using exact emit-plu-inv! for InvMixColumns, 0-gate InvShiftRows, InvSubBytes, and inverse key expansion).
Configuration |
Raw Q |
Raw T |
Raw Td |
Opt Q |
Opt T |
Opt Td |
Opt Q×T (Ops) |
|---|---|---|---|---|---|---|---|
encrypt, R=1, L=1 (1-rd qkey) |
273 |
1,152 |
1,116 |
273 |
1,152 |
1,096 |
314,496 (13.7k) |
encrypt, R=10, L=1 (min-Q) |
273 |
11,520 |
11,160 |
273 |
11,520 |
10,960 |
3.145M (131.7k) |
encrypt, R=10, L=2 (<300 Q) |
290 |
11,520 |
5,580 |
290 |
11,520 |
5,480 |
3.341M (136.1k) |
encrypt, R=10, L=4 (4× par) |
324 |
11,520 |
2,790 |
324 |
11,520 |
2,740 |
3.732M (136.3k) |
roundtrip, R=10, L=1 (fwd+inv) |
273 |
23,040 |
22,311 |
273 |
23,032 |
21,733 |
6.288M (262.6k) |
grover, R=10, L=1 (min-Q) |
273 |
23,478 |
22,593 |
273 |
23,304 |
21,915 |
6.362M (265.0k) |
grover, R=10, L=2 (<300 Q) |
290 |
23,478 |
11,450 |
290 |
23,264 |
11,020 |
6.747M (274.5k) |
grover, R=10, L=4 (4× par) |
324 |
23,478 |
5,870 |
324 |
23,237 |
5,568 |
7.529M (275.0k) |
Every 4D circuit is verified pre- and post-optimization on official NIST FIPS 197 Appendix B (Key = 2b7e1516..., PT = 3243f6a8... → CT = 3925841d...), 1-bit flipped Key and Plaintext true-negative cases, and 60 randomized (Key, PT) shots: exact -1 phase kickback iff AES128(Key, PT) == target_CT, with 0 classical, 0 phase, and 0 ancilla errors.
Full-Scale Showcase 4E: Full 256-Coefficient, 7-Layer FIPS 203 ML-KEM NTT/INTT (11 / 11 Verified)
The Number-Theoretic Transform over Z_3329[X]/(X^256 + 1) is the computational heart of NIST FIPS 203 (ML-KEM / Kyber). Our mlkem_ntt_full.lsp compiles exact FIPS 203 Algorithm 9 (NTT) and Algorithm 10 (NTT^-1) using the exact BitRev7 twiddle table zeta_k = 17^(BitRev_7(k)) mod 3329. At full ML-KEM scale (N = 256), all 7 layers × 128 butterflies = 896 in-place butterflies execute over 256 × 12 = 3,072 ABI qubits while sharing a single serial LIFO scratch pool of only 19–38 qubits (reaching an emitter floor of 3,091 Q at w=1, cap=4):
Configuration |
Raw Q |
Raw T |
Raw Td |
Opt Q |
Opt T |
Opt Td |
Opt Q×T (Ops) |
|---|---|---|---|---|---|---|---|
N=8, NTT, w=1, cap=4, L=1 |
115 |
17,080 |
16,776 |
115 |
14,364 |
14,326 |
1.652M (105.3k) |
N=8, NTT, w=4, cap=12, L=1 |
134 |
3,456 |
3,420 |
134 |
3,415 |
3,415 |
457.6k (30.6k) |
N=8, INTT, w=4, cap=12, L=1 |
134 |
6,080 |
6,020 |
134 |
5,909 |
5,905 |
791.8k (51.9k) |
N=8, roundtrip, w=4, cap=12 |
134 |
9,536 |
9,440 |
134 |
9,326 |
9,322 |
1.250M (82.3k) |
N=16, NTT, w=4, cap=12, L=1 |
230 |
10,368 |
10,266 |
230 |
10,254 |
10,248 |
2.358M (92.3k) |
N=32, NTT, w=4, cap=12, L=1 |
422 |
27,648 |
27,390 |
422 |
27,370 |
27,356 |
11.55M (246.9k) |
N=64, NTT, w=4, cap=12, L=1 |
806 |
69,120 |
68,468 |
806 |
68,478 |
68,432 |
55.19M (618.3k) |
N=256, NTT, w=1, cap=12 (<3100) |
3,096 |
918,956 |
918,956 |
3,096 |
850,275 |
846,390 |
2.632B (6.77M) |
N=256, NTT, w=4, cap=4, L=1 |
3,105 |
697,984 |
682,618 |
3,105 |
647,757 |
644,071 |
2.011B (5.62M) |
N=256, NTT, w=4, cap=12 (minQT) |
3,110 |
387,072 |
383,498 |
3,110 |
386,464 |
386,208 |
1.202B (3.59M) |
N=256, NTT, w=4, cap=12, L=4 |
3,146 |
387,072 |
348,612 |
3,146 |
385,191 |
381,172 |
1.212B (3.59M) |
Every N = 256 configuration is verified both pre- and post-optimization across 64 shots × 256 coefficients = 16,384 exact 12-bit modular coefficient checks with zero classical, phase, or ancilla errors.
Figure 2. Verified Pareto frontiers for the full-scale cryptographic benchmarks (Domain 4D & 4E). Panel A shows the Qubit vs. Critical-Path T-Depth tradeoff for full 10-round FIPS 197 AES-128 quantum-key encryption and the complete Grover key-search phase oracle, with the compact < 300 Q regime shaded in green. Panel B shows the pre- and post-optimization Toffoli frontier for the full 256-coefficient, 7-layer FIPS 203 ML-KEM NTT plotted against shared scratch qubits above the 3,072-qubit ABI.
5.5 Architectural Perspective: Early-FTQC Physical Footprint
Under a standard rotated surface code at physical gate error p = 10^-3 (2 d^2 physical qubits per logical qubit, ~25% lattice-surgery routing overhead, plus 1–2 magic-state distillation factories):
Early-FTQC Scientific & Optimization Band (30–98 Q, d = 15..21): Dual-constraint Knapsack (30 Q), DF/THC chemistry Givens cores (37–69 Q), 16-bit PDE stencils (59 Q), QAE option pricing (50–87 Q), and N=48 3-SAT / V=32 3-Coloring (90–98 Q) translate to ~20K–130K physical qubits—well inside early fault-tolerant hardware roadmaps.
Full Symmetric & PQC Primitives (273–3,110 Q, d = 21..29): Even with aggressive 0-extra-key-register compression (273 Q for AES-128 Grover) and minimal 19–38-qubit scratch sharing (3,110 Q for a single ML-KEM NTT), full cryptographic oracles still require hundreds to thousands of logical qubits before multiplying by exponential Grover query depth (~2^64–2^80 iterations for symmetric key search), quantitatively reinforcing the practical robustness of NIST symmetric and lattice PQC standards.
6. Reproducibility Guide
All 276 verified benchmark circuits, optimizers, and streaming verifiers run 100% CPU-only on standard Linux hardware and automatically delete all temporary .ops.bin files upon completion.
6.1 Unified Master Suite (257 Configs) and Full-Scale Domain 4 (19 Configs)
# 1. Fast end-to-end smoke check across all 5 suites / 4 domains (18 circuits, ~8 s): python3 examples/quantum-benchmarks/run_all_domains.py --quick # 2. Full 257 / 257 verification across Baseline + Domains 1–4 (~4 min CPU-only): python3 examples/quantum-benchmarks/run_all_domains.py --full # 3. Full-scale Domain 4D (10-round AES-128 Grover) & 4E (256-coeff ML-KEM NTT) (19/19): python3 examples/quantum-benchmarks/domain4_pqc_symmetric/bench_domain4_full.py # Filtered runs (e.g., 4D AES-128 only or N=256 ML-KEM NTT only): python3 examples/quantum-benchmarks/domain4_pqc_symmetric/bench_domain4_full.py --filter "4d." python3 examples/quantum-benchmarks/domain4_pqc_symmetric/bench_domain4_full.py --filter "N=256"
6.2 Direct Single-Circuit Compilation & Cross-Tier SHA-256 Parity Check
# Direct Lumbda circuit emission examples:
./c/lumbda -f examples/quantum-benchmarks/domain1_chemistry/01b_fermi_hubbard_select.lsp \
--lx 8 --ly 8 --spin-swap 1 --bc open
./c/lumbda -f examples/quantum-benchmarks/domain4_pqc_symmetric/aes128_full_oracle.lsp \
--mode grover --rounds 10 --lanes 1
./c/lumbda -f examples/quantum-benchmarks/domain4_pqc_symmetric/mlkem_ntt_full.lsp \
--n-coeffs 256 --mode ntt --window 4 --chunk-cap 12 --lanes 1
# Verify bit-exact cross-tier parity (C --jit, C --fast, Rust) on 10-Rd AES-128 Grover:
tmp=$(mktemp -d) && trap 'rm -rf "$tmp"' EXIT
./c/lumbda --jit -f examples/quantum-benchmarks/domain4_pqc_symmetric/aes128_full_oracle.lsp \
--mode grover --rounds 10 --lanes 1 --out "$tmp/jit.ops.bin"
./c/lumbda --fast -f examples/quantum-benchmarks/domain4_pqc_symmetric/aes128_full_oracle.lsp \
--mode grover --rounds 10 --lanes 1 --out "$tmp/fast.ops.bin"
./rust/target/release/lumbda -f examples/quantum-benchmarks/domain4_pqc_symmetric/aes128_full_oracle.lsp \
--mode grover --rounds 10 --lanes 1 --out "$tmp/rust.ops.bin"
sha256sum "$tmp"/*.ops.bin
# Expected: 02059756efe5717336833f8a2987d5d618064e6fd789a4dfefa7e112258c8b5a (18,601,032 B)
7. Conclusion and Future Directions
We have presented a complete, self-contained fault-tolerant quantum compilation, optimization, and exact verification stack built on Lumbda, qecc_opt v4, and qecc_sat_opt v4, validated across 276 verified circuit configurations spanning chemistry, quantitative finance/PDEs, combinatorial search/SAT, and full-scale NIST symmetric and post-quantum cryptography. By combining deterministic Scheme metaprogramming, 1-qubit LIFO ancilla pooling (Q_hi == Q_act, R = 0), 0-Toffoli measurement-based uncomputation, formally sound SAT-backed peephole rewriting, and dual-gate 64-shot exact verification, the pipeline achieves bit-exact cross-tier compiler parity and pushes full 10-round FIPS 197 AES-128 Grover oracles down to 273 logical qubits and full 256-coefficient FIPS 203 ML-KEM NTTs down to 3,096–3,110 logical qubits with zero classical, phase, or ancilla defects.
Promising next steps include extending qecc_sat_opt v4 with streaming partitioned cones for >10M-op circuits, compiling full 24-round Keccak-f[1600] sponge oracles and end-to-end ML-KEM key-encapsulation circuits, and coupling QECCOPSZ output directly to lattice-surgery surface-code schedulers for hardware-calibrated spacetime layouts.
References
Gidney, "Halving the cost of quantum addition," Quantum 2, 74 (2018).
Berry, C. Gidney, M. Motta, J. R. McClean, and R. Babbush, "Qubitization of Arbitrary Basis Quantum Chemistry Leveraging Sparsity and Low Rank Factorization," Quantum 3, 208 (2019).
Babbush, C. Gidney, D. W. Berry, N. Wiebe, J. McClean, A. Paler, A. Fowler, and H. Neven, "Encoding Electronic Spectra in Quantum Circuits with Linear T Complexity," Phys. Rev. X 8, 041015 (2018).
Low, V. Kliuchnikov, and L. Schaeffer, "Trading T-gates for dirty qubits in state preparation and unitary synthesis," Quantum 8, 1375 (2024).
Cuccaro, T. G. Draper, S. A. Kutin, and D. P. Moulton, "A new quantum ripple-carry addition circuit," arXiv:quant-ph/0410184 (2004).
Boyar and R. Peralta, "A new combinational logic minimization technique with applications to cryptology," SEA 2010, LNCS 6049, pp. 178–189 (2010).
NIST, Advanced Encryption Standard (AES), Federal Information Processing Standards Publication FIPS 197 (2001; updated 2023).
NIST, SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions, Federal Information Processing Standards Publication FIPS 202 (2015).
NIST, Module-Lattice-Based Key-Encapsulation Mechanism Standard (ML-KEM), Federal Information Processing Standards Publication FIPS 203 (2024).