# Announcing AncillaQ: Quantum circuits, redesigned from the math up

**Author:** Siddharth Lalwani (Almond Quantum)  
**Published:** 2026-11-26  
**Canonical URL:** https://almond.org/writing/announcing-ancillaq  
**Repository (Apache-2.0):** https://github.com/almond-lab/AncillaQ (v1.0.0; formerly Strata)

> **Release note:** Originally previewed on X as *Strata 0.7* (https://x.com/almondquantum/status/2124563061696806989), the project has been renamed to **AncillaQ** and released as **v1.0.0** after 14 additional optimization sprints across fusion plasma modeling, FeMoCo quantum chemistry, and Decoded Quantum Interferometry.

## Summary

Most gates in a quantum circuit aren't doing quantum mechanics — they're doing bookkeeping. Paying for fault-tolerant qubits to unpack raw lookup tables and run temporary scratchpad math backward is like renting a particle accelerator to unzip a spreadsheet.

Competing on Google Quantum AI's Verifiable Quantum Circuit Compilation (VQCC) benchmark while building AncillaQ, we cut verified fault-tolerant cost by **13.5x, 34.3x, and 80.1x** across three flagship workloads (**33.32x** geometric-mean speedup), while reducing batched 256-lane causal-cone verification to **23 microseconds (0.023 ms)** per rewrite on million-gate circuits.

| Workload | Domain | Reference Cost | Optimized Cost (v0.7 -> Latest) | Qubits | Speedup |
| --- | --- | --- | --- | --- | --- |
| Algebraic Decoder (DQI) | Combinatorial optimization | 24.44 trillion | 305.0B -> 305.0B | 901 -> 900 | 80.1x |
| Fusion Plasma (1/sqrt(x)) | Nuclear fusion modeling | 2,076,774 | 60,874 -> 60,581 | 62 -> 37 | 34.3x |
| FeMoCo Catalyst (DF-THC) | Nitrogen-fixation chemistry | 3.356 billion | 251.1M -> 249.1M | 427 -> 405 | 13.5x |
| **Composite Portfolio** | **Geometric mean** | **1.00x** | **33.18x -> 33.32x** | — | **33.32x** |

## 1. Why Quantum Programs Are Expensive to Run

Two rules govern fault-tolerant quantum circuit costs:

1. **Not all operations cost the same.** Simple bit flips and XORs (`CX`) are cheap in error-corrected hardware. Nonlinear logic gates like Toffoli (`CCX` / `CCZ`) and arbitrary rotations require expensive magic-state factories.
2. **You cannot just hit Delete on temporary memory.** Discarding an entangled scratch qubit destroys quantum interference. By default, scratch arithmetic must be uncomputed in reverse, doubling the bill.

## 2. Lesson 1: Compress the Representation Before You Compile a Single Gate

In the FeMoCo nitrogen-fixation chemistry circuit (1,219 molecular terms, 75 rotation angles per address), starter 10-bit lookup tables cost **11,400 Toffolis per loader pass** on 427 qubits. Treating the classical chemistry factorization and quantum QROM loader as a single joint optimization problem drops loader cost to **3,357 Toffolis** on 405 qubits:

- **Error-Boundary Co-Fitting:** Slide continuous classical weights along the exact error-constraint nullspace (`BoundarySlider`, `GramTensorWeightSolver`) so 7-bit words still meet chemical accuracy (20 milli-Hartree).
- **Encoding Transitions & Dead-Slot Planting:** Encode bitwise XOR transitions between consecutive batches and turn unused dead slots in the Givens rotation tree into free algebraic variables (`DeadSlotPlanter`).
- **Linear Matroid Parity:** Extract free affine `CX` parity relations and pair quadratic terms over finite fields (`lovasz_matroid_parity_rank`, `LinearMatroidParityPlanner`).

## 3. Lesson 2: Borrow Idle Wires and Measure Instead of Recomputing

Squeezing the nuclear fusion `1/sqrt(x)` pipeline from **62 qubits down to 37 qubits** drops verified cost **34.3x** (2,076,774 -> 60,581) using two core mechanisms:

- **Measurement-Based Uncomputation (MBU):** Measure scratch qubits in the X basis (`HMR`) to reset them to `|0>` for zero Toffolis, repaying branch-dependent sign kickbacks cheaply with classically controlled `CZ_IF` gates (`demolish_and_piggyback`, `fit_multi_cut_phase`).
- **Affine Wire Loans:** When idle wires in a tight window satisfy an affine `GF(2)` parity relation, XOR neighbors to zero an idle wire, borrow it as clean scratch space, and restore it at the end for zero extra qubits and zero extra Toffolis (`find_affine_wire_loans`, `ancillaq wire-loans`).

## 4. Lesson 3: 23-Microsecond Discovery Speed

Traditional text-based circuit verification takes ~4.2 seconds per candidate on 1M-gate circuits (5.5 hours for 5,000 hypotheses). AncillaQ's compiled C++20 / OpenMP engine eliminates that wall:

| Operation (1M gates, 64 qubits) | Text Pipeline | AncillaQ C++20 Native | Speedup |
| --- | --- | --- | --- |
| Open and index binary `.kmb` circuit | 3,400 ms | 44.9 ms | 76x |
| Full live-wire & freedom profile | 4,800 ms | 18.9 ms | 254x |
| Verify one local candidate rewrite | 4,200 ms | 0.431 ms | 9,745x |
| Verify a batch of rewrites (per candidate) | 4,200 ms | 0.0233 ms (23 us) | 180,258x |
| Exhaustive 3.13M-input phase-margin check | 1,950 ms | 15.9 ms | 123x |

## 5. What's New in AncillaQ v1.0.0

- **Fast `<10s` Mathematical Kill-Switches (`ancillaq.gates`):** `RotationPruningGate` (HiGHS minimax LP), `ArithmeticTaperGate` (mandatory `ndiff > 0` no-op guard), `ConditionBitTracer` (zero-copy `OR` vs `XOR` vs `HMR` bit provenance + `CX_IF`/`SWAP_IF` flags), `BijectiveTransformGatekeeper`, and `BatchSizeOptimizer`.
- **500x Faster Tensor Co-Design (`ancillaq.gram`):** `GramTensorWeightSolver` (`O(R^3)` exact Gram `opt_W`), `LowRankResidualTracker` (zero-`D`-update CD), `AnchoredSuperKickILS`, `L1PreservingColumnPruner`, `ErrorDiffusionTreeEncoder`, and `ActiveSetBoundarySnap`.
- **Finite-Field, Symplectic & Pebble Algebra (`ancillaq.algebra` + C++20):** `CurveRankBound`, `CentroidDissector`, OpenMP `flip_graph_gf2_fast` with plus-escapes, `DicksonCCZReducer` (with mandatory `check_span_safety()`), `SharedOperandLeftoverBound`, and `SpookyPebbleUndoAdder`.
- **QROM Forensics & Governance (`ancillaq.qrom`, `ancillaq.sprint`):** `inspect_table`, `B23PlaneAnnealer`, `SelectiveChainUnlocker`, `AutoSplitDispatcher`, `LinearMatroidParityPlanner`, `CostLedger`, `ExpensiveHMRProfiler`, `SprintRunner`, and `fork_pool`.

## 6. Co-Design Playbooks

1. **v1.0 Kill-Switches & Co-Design Playbook:** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-V1-CO-DESIGN.md
2. **Numerical Co-Fitting Playbook (`cofit` & `gram`):** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-COFIT.md
3. **Minimax Truncation & Rotation Refitting LP Playbook:** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-TRUNCATION-LP.md
4. **Peak-Qubit Shapes, MBU Pebbling & Affine Wire Loans Playbook:** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-SHAPES-PEBBLING.md
5. **Measurement-Based Uncomputation & Multi-Cut Phase Playbook:** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-MBU-PHASE.md
6. **Boundary `BIT_*`, Projective `GF(2^k)` & Bilinear Tensors Playbook:** https://github.com/almond-lab/AncillaQ/blob/main/docs/PLAYBOOK-BOUNDARY-TENSORS.md
7. **Zero-Copy C++20 Latency Architecture Guide:** https://github.com/almond-lab/AncillaQ/blob/main/docs/LATENCY-ARCHITECTURE.md
8. **5-Minute Quickstart:** https://github.com/almond-lab/AncillaQ/blob/main/docs/QUICKSTART-5MIN.md
9. **Autonomous Agent Research Skill (`SKILL.md`):** https://github.com/almond-lab/AncillaQ/blob/main/skills/ancillaq-research/SKILL.md

## Companion Almond Quantum Writing

- Design Patterns for Optimizing Quantum Circuits, Dispatch 1: https://almond.org/writing/quantum-circuit-design-patterns-1
- Design Patterns for Optimizing Quantum Circuits, Dispatch 2: https://almond.org/writing/quantum-circuit-design-patterns-2
- The 50 best-funded quantum computing companies of 2026: https://almond.org/writing/quantum-50
