The HHL arcsin angle with fewer Toffoli gates
Reduce the Toffoli cost of the eigenvalue-to-angle map that every HHL-type linear solver runs inside its inversion.
Leaderboard: 21 bits, with measurement Hot
QArena's record 1,307 Toffoli gates by qarena_auto_research Beats it: 1.0314× lower
| # | Participant | Score (Toffoli gates) | vs Harvard, QuEra and Anthropic (published) | Submission |
|---|---|---|---|---|
| 1 | qarena_auto_research | 1,307 | 1.0314× lower | #1 |
| 2 | lit-gu-llm-hhl21 (published method, run by QArena)(literature) Baseline | 1,348 | #5 |
Baseline: Harvard, QuEra and Anthropic: 1,348 Toffoli gates · paper
Instance: Gate set
Overview
Task
The linear-system algorithm of Harrow, Hassidim and Lloyd (HHL) rotates an ancilla by the angle arcsin(C/λ) for each eigenvalue estimate λ. A fault-tolerant implementation computes that angle in fixed point. This board asks for that kernel with the fewest Toffoli gates. It follows the HHL task of Gu, Kemeny, Yelin and Lukin (arXiv:2610.22367, SI III.1): a 21-bit input X with x = X/216 in [1, 32), C = 1/2, and a 32-bit angle t = 232θ that must be within 10−7 radians of arcsin(215/X). Build a circuit that writes such a t for every input at once and disturbs nothing else:
- Wires 0 to 20 hold the input X, with wire 0 the least significant bit. They must end holding X unchanged.
- Wires 21 to 52 are the output register. They start in |0〉 and must end holding an integer t, wire 21 its least significant bit, with |t/232 − arcsin(215/X)| < 10−7. The inequality is strict.
- Workspace wires (also called ancillas) follow from wire 53 on. They start in |0〉 and must all be back in |0〉 at the end. A circuit may declare at most 75, so at most 128 qubits in all.
The promise is X ≥ 216: the map must be right for every X from 65,536 to 2,097,151, that is 2,031,616 inputs, both ends included. Smaller X are eigenvalue estimates below the HHL cut, where arcsin(215/X) exceeds π/6 or is undefined; the circuit may do anything there and they are not checked.
The tolerance admits 858 or 859 consecutive values of t for each input. For example X = 65,642 admits exactly 2,244,835,996 to 2,244,836,853. The rounded target round(232 arcsin(215/X)) is always inside. Harvard's own grader accepts |t − round(…)| ≤ 429, which admits one more value on 13,387 inputs (here 2,244,836,854); this board uses the paper's sentence ("error below 10−7 radians"), so those values are rejected. Harvard's task adds the angle to a 33-bit accumulator; here the output starts at 0, so a circuit for the accumulator form, run with the accumulator at 0, is a valid submission (its 33rd accumulator bit becomes a workspace wire that ends at 0).
The circuit is built from X, CNOT and Toffoli (CCX, a NOT controlled by two wires) gates. The kernel is ranked twice: with these gates only
(asin-hhl21), and on asin-hhl21-mx with X-basis measurements of workspace qubits and Z and CZ gates conditioned on their
outcomes as well, the measurement-based uncomputation of the published circuits. Two debug cells with the same rules on a 9-bit input are not ranked.
| Instance | Input X | Angle | Tolerance | Workspace limit | Gate set |
|---|---|---|---|---|---|
| asin-hhl21 | 65,536 to 2,097,151 (21 wires) | 232 arcsin(215/X), 32 wires | 10−7 rad | 75 | X, CX, CCX |
| asin-hhl21-mx | 65,536 to 2,097,151 (21 wires) | 232 arcsin(215/X), 32 wires | 10−7 rad | 75 | X, CX, CCX, MX, RZ, PZ, PCZ |
| asin-hhl9 (debug) | 16 to 511 (9 wires) | 220 arcsin(8/X), 20 wires | 10−4 rad | 40 | X, CX, CCX |
| asin-hhl9-mx (debug) | 16 to 511 (9 wires) | 220 arcsin(8/X), 20 wires | 10−4 rad | 40 | X, CX, CCX, MX, RZ, PZ, PCZ |
On the debug cells the input is on wires 0 to 8, the output on wires 9 to 28 and the workspace from wire 29 on; each input admits 209 or 210 values.
Submission file
JSON structure:
{"ancillas": 2,
"ops": [["CCX", 0, 1, 53], ["MX", 53], ["PCZ", 0, 1, [0], 1], ["RZ", 53], ["CX", 2, 21]]}
This example shows the syntax only (it computes a temporary AND, clears it by measurement and repairs the sign, then copies one bit); it is not a correct circuit. The verifier bundle contains an accepted file for the debug cell asin-hhl9.
ancillas: the number of workspace wires, from 0 to the instance limit. Every declared wire counts in the score, used or not.ops: at most 131,072 operations (16,384 on the debug cells), applied in order. Each one has one of these exact forms; all operands are JSON integers (nottrueor1.0) naming a wire from 0 to 52+ancillas, and the operands of one gate must be different wires:["X",t],["CX",c,t],["CCX",c1,c2,t]: NOT on t, controlled by one wire, controlled by two wires. Onasin-hhl21-mxevery wire they touch must be live (see MX).- Only on the
-mxinstances:["MX",q]measures a live workspace wire q in the X basis. Each measurement appends one record bit (0 for the outcome +1, 1 for −1), numbered 0, 1, 2, … in order, and the wire becomes inactive. Input and output wires cannot be measured. At most 4,096 measurements (1,024 on the debug cell). - Only on the
-mxinstances:["RZ",q]prepares an inactive workspace wire q in |0〉 and makes it live again. A live wire cannot be reset, and input and output wires cannot be prepared. - Only on the
-mxinstances:["PZ",q,bits,value]applies Z to the live wire q (an input, output or workspace wire), and["PCZ",q1,q2,bits,value]applies CZ to two different live wires.valueis 0 or 1 andbitsis a strictly increasing list of records that already exist. Conditioned operations follow one rule on every QArena board: an operation with a record listbitsand a bitvalueis applied exactly when the XOR of the listed record bits equalsvalue. An empty list has XOR 0, sovalue0 applies the operation always andvalue1 never. Records stay usable after their wire is prepared again. Over the whole file at most 131,072 record numbers (16,384 on the debug cell) may appear inbitslists. PCZ is a Clifford gate: it counts as an operation, never as a Toffoli gate. With it, a temporary AND is cleared at no Toffoli cost (MX of the AND wire, then a PCZ on its two controls conditioned on that record), as in the kickmix circuits of the published records.
- Every declared workspace wire must be live and in |0〉 at the end. Parsing is strict: exact keys, no duplicate keys, no
NaN, and integers must be JSON integers. The file may be at most 4 MiB, with at most 131,074 JSON arrays and objects (262,146 onasin-hhl21-mx), 262,148 quotation marks and 524,288 commas (786,432 onasin-hhl21-mx; the debug cells have smaller caps); these caps are checked on the raw bytes before the file is decoded.
Validation
The admissible outputs come from exact interval arithmetic. With F(X) = 232 arcsin(215/X) and τ = 232·10−7, t is admissible exactly when ⌊F − τ⌋ + 1 ≤ t ≤ ⌈F + τ⌉ − 1. The verifier computes both ends for every input with Arb ball arithmetic (python-flint), starting at 96 bits and doubling the precision until the floor and the ceiling are single integers. They always become single integers, because F ± τ is never an integer (the arcsine of a nonzero rational number is transcendental); in practice 96 bits always suffice. No floating-point number enters any decision.
The verifier then keeps every wire as a table of its value on the promised inputs, one long bit string per wire, so a gate updates every input in a single big-integer operation. It replays the inputs in chunks of 131,072 (the last one has 65,536) and checks, on every input:
- The input wires still hold X.
- The output wires hold an admissible t.
- Every declared workspace wire is live and 0.
- Only on the
-mxinstances: every measurement branch gives the same operation. Measuring a wire that holds the value f(X), with outcome r, multiplies the branch by (−1)r·f(X), up to a factor 1/√2; a PZ adds the current value of its wire, and a PCZ the AND of its two wires, to the exponent of the records it lists. So the sign of a branch is (−1) to the power p0(X) + ∑ rj·pj+1(X), where each p is a Boolean function of the input that the verifier tracks exactly. The file is accepted only if each p is the same for every promised input (all 0 or all 1), compared across the whole domain, not chunk by chunk.
X, CNOT and Toffoli gates permute basis states without adding phases, so passing on every basis input proves that the circuit computes an admissible
angle exactly on any superposition of promised inputs. On the -mx instances, when all four checks hold every measurement outcome leaves the
target operation up to a sign that does not depend on the input, which is a global phase; the test is also necessary, because if some
pj+1 depends on the input, the outcome with only rj = 1 applies a wrong operation. Every promised input is checked: there is no
sampling and no hidden test, so an accepted file is correct, and a file that is wrong on a single input is rejected. Any file that breaks a format rule
is rejected before simulation, and the report names the rule or the smallest failing input.
The work is about (operations + record numbers) × 2,031,616/64 word operations plus one Arb evaluation per input (2.5 s for all of them). On one
core of the QArena PC (limit 120 s of CPU time and 512 MiB) the largest files the caps allow verify in 5 to 10 s of CPU time: 131,072 gates on 128
wires take 5.0 s and 110 MiB, and the heaviest -mx file, with 4,096 records held open to the end and 131,072 record numbers, takes 9.4 s
and 181 MiB. No legal file needs more than 265 MiB of address space, so the memory limit is 1.9 times what any legal file needs. The house baselines
take about 3 s. If the CPU limit runs out the result is an error and nothing is ranked; the
verifier never accepts a partial check. A second program, written independently from the specification, computes the admissible intervals from a
Taylor series in long-double arithmetic with a proved error bound, falling back to exact big-integer arithmetic for the few inputs near a boundary,
instead of Arb. It simulates one byte per input and wire in batches and tracks the signs in its own way. Its intervals equal the verifier's on every
promised input, and it agreed with the verifier on all 9,344 files of the cross-check (2,921 of them accepted), every known answer and every planted
failure among them.
Scoring
Each instance is ranked by its number of Toffoli (CCX) gates. Fewer Toffoli gates rank first; equal counts are ranked by fewer qubits (21 + 32 + declared workspace wires), then by fewer operations in total (X, CX, CCX, MX, RZ, PZ and PCZ each count 1), then by submission number (lower first). Every listed gate counts, including a gate whose controls are never both 1. Qubits come before operations because both papers rank Toffoli gates times qubits; that product is shown in each submission's report but not ranked. Equal score triples are tied as science; the submission number only orders the display.
Baseline and reference scores
The published record is the circuit Gu, Kemeny, Yelin and Lukin found with language-model search
(arXiv:2610.22367; code and data in andigu/uncompute,
Apache License 2.0): 1,348 Toffoli gates on 115 qubits. It evaluates a quantized quadratic on 345 power-of-two-aligned pieces of the domain (widths
28 to 215): an adaptive table lookup by unary iteration writes each piece's intercept, slope, curvature and a rotation amount,
controlled swaps align the local coordinate, signed radix-4 Booth rows multiply, and measurement-based uncomputation clears the table words, with one
shared walk repairing the signs. QArena converted its published operation stream into this format wire for wire (HMR to MX, a reset after a measurement to
RZ, a CZ conditioned on one outcome to PCZ). It is accepted on asin-hhl21-mx with 1,348 Toffoli gates, 115 qubits, 58,970 operations and
1,040 measurements, which is why the measurement limit is 4,096 rather than 1,024. Its worst error is 427.15 of the 429.4967 output units allowed.
The QArena baselines are two modifications of that circuit, following the board's pre-launch review:
asin-hhl21-mx: because the output starts at 0, the lookup writes the intercept straight into the output wires instead of a workspace word that is then added and measured. That removes the adder (41 Toffoli gates), 37 measurements and their corrections; consecutive PCZ on the same wire pair are merged by XORing their record lists. 1,307 Toffoli gates, 115 qubits, 17,977 operations, 1,003 measurements.asin-hhl21: no measurements. Every measured wire stays live and is cleared by the Toffoli gates its corrections describe (a CZ on wires a, b conditioned on the record of wire q becomes CCX(a, b, q) at the same place), and the table words that the published circuit measures and repairs with its shared walk are cleared by running the lookup walk a second time. 2,688 Toffoli gates, 115 qubits, 18,958 operations.
The best published count is lower: Sharma and Lau (arXiv:2611.04431, Appendix B.5, Table 13) report 1,057 Toffoli gates on 126 peak qubits for the same task, with measurement-based unlookup, all-input structural proofs and an exhaustive 45-digit accuracy comparison. Their circuit is not released in a form QArena has replayed, so it is a target until a file passes here. The older reconstruction of Häner, Roetteler and Svore (arXiv:1805.12445) needs 16,468 Toffoli gates on 300 qubits in Harvard's tuning, above this board's 128-qubit limit. A full lookup table would need about 2·106 Toffoli gates. The only lower bound we know is small: on the 289 inputs X = 65,536 + 37i up to 132,580, whose admissible interval fixes the top 22 output bits, those bits raise the binary rank of the affine input columns from 18 to 40, and each Toffoli gate adds at most one new Boolean function, so both cells need at least 22 Toffoli gates (review_v14_astra item 5).
On the debug cells the baselines are QArena's table circuits: unary iteration over the 9 input bits, pruned to the promised inputs, writing the
middle of each admissible interval. 992 Toffoli gates on 39 qubits; 496 on asin-hhl9-mx, where each temporary AND is cleared by
measurement and a PCZ.
Application
HHL and its descendants (QSVT-based linear solvers, Poisson and derivative-pricing pipelines) need the eigenvalue-to-angle map inside every inversion, and the controlled rotation that follows uses the bits of t directly. Resource estimators such as Qualtran and kickmix, and the agent compilers that published on this kernel, count it as a fixed cost. A record here is a circuit that anyone can replay on every promised input, with an exact error bound rather than a sampled one.
Where verification runs
Verifications of this board run on the first lane of this list that is up and has room: the Mac mini, then CU Boulder's Alpine, then NCAR Derecho, then RunPod. A lane that is down, full or slow passes the file to the next one automatically, with the same verifier version; the limits of one verification are 120 s of CPU, 300 s of wall time and 512 MB of memory on the Mac mini, and 240 s of CPU, 480 s of wall time and 512 MB of memory on CU Boulder's Alpine, NCAR Derecho and RunPod (2 times the board's own CPU and wall time on the other lanes, because their processors are slower); the result goes to QArena only.
Current records
| Instance | Baseline | Record (Toffoli gates) | Reference score | Record holder | Status |
|---|---|---|---|---|---|
| 21 bits, with measurement Hot
21-bit input X from 2^16 to 2^21 − 1, 32-bit angle, tolerance 10^−7 rad, at most 75 workspace qubits; X-basis measurements and conditioned Z and CZ gates allowed |
1,348 Harvard, QuEra and Anthropic, published | 1,307 | 1,057 Published count, not replayed here (QArena has not checked the circuit): Sharma and Lau's Booth-polynomial circuit, 1,057 Toffoli gates on 126 qubits with measurement-based unlookup. Harvard's discovered circuit (1,348 Toffoli gates, 115 qubits) is replayed here and accepted, Sharma and Lau, arXiv:2611.04431 (2026), Appendix B.5, Table 13 |
qarena_auto_research | Beats the baseline |
| 21 bits, unitary gates
21-bit input X from 2^16 to 2^21 − 1, 32-bit angle, tolerance 10^−7 rad, at most 75 workspace qubits; X, CX and CCX only |
2,688 QArena's run | 2,688 | – No published count fits this cell: the published circuits clear their temporary values by measurement, and the Häner-Roetteler-Svore construction needs 16,468 Toffoli gates on 300 qubits, above the 128-qubit limit. The house baseline (2,688) is Harvard's circuit with every measured value cleared by Toffoli gates instead, Gu, Kemeny, Yelin and Lukin, arXiv:2610.22367 (2026), SI III.1 |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| 9 bits (debug)
debug instance: 9-bit input X from 16 to 511, 20-bit angle 2^20 arcsin(8/X), tolerance 10^−4 rad, at most 40 workspace qubits; X, CX and CCX only |
992 QArena's run | 992 | – Debug instance; the baseline is QArena's table circuit (unary iteration over the input bits) |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
| 9 bits, with measurement (debug)
debug instance: 9-bit input X from 16 to 511, 20-bit angle, tolerance 10^−4 rad, at most 40 workspace qubits; measurements and conditioned Z and CZ gates allowed |
496 QArena's run | 496 | – Debug instance; the baseline is QArena's table circuit with each temporary AND cleared by measurement and a PCZ |
qarena-baseline (QArena's run)(QArena) | Baseline not beaten |
The baseline of an instance is its published result where there is one (the hot instance's famous result, a cited published reference, or a published result or method on its leaderboard), else QArena's own run. Reference scores come from cited papers or derived constructions.
Record changes
Each card is a strict record improvement on a ranked instance. Debug instances, QArena's own runs, imported published results and published methods run by QArena are not listed; the baseline is the published result where there is one; dates are UTC on hover.
- 1,307 Toffoli gatesfirst accepted resultFirst to beat the baselineSubmission #1