Quantum computing · Theory and numerics (AI-assisted)

Reducing RSA-2048 Factoring Resources Below One Billion Toffolis via LLM-Driven Verifiable Quantum Compilation

Xiaodi Li, Yuqing Wang, Xue Chen, Yang-Yang Tang, Linghui Chen, Tao Zhang

arXiv:2611.31158v1 ↗PDF ↗Submitted 23 November 2026

Question
Shor's algorithm for a 2048-bit RSA modulus is dominated by modular exponentiation. The 2019 design of Gidney and Ekerå uses about 6,200 logical qubits and \(2.7\times10^9\) Toffoli gates. Gidney's 2025 design works modulo thousands of small primes (a residue number system), which cuts the logical qubits to about 1,400 and the physical qubits below a million, but it needs 4.5 to 11 billion Toffolis. Can the residue approach be made cheap in gates without giving back the qubit savings?
Result
A deterministic compiler, whose main algorithmic improvements were found by large-language-model-driven search, produces a frontier of RSA-2048 circuits between 1,306 and 2,919 logical qubits. At 2,433 logical qubits the expected factoring cost is \(0.978\times10^9\) Toffolis under Gidney's adder accounting, a qubit–Toffoli product of \(2.38\times10^{12}\), 70.1% below Gidney's best of \(7.96\times10^{12}\). At 2,485 qubits it is \(0.961\times10^9\) Toffolis, or \(0.984\times10^9\) under strict bit-level counting. Six representative circuits were checked at the gate level across all of their roughly 20,000 primes.

The paper in detail

Shor's algorithm computes \(g^x\bmod N\) in superposition. In the residue number system approach, the large modular product is never formed. The exponent is processed in windows; for each of about 20,000 primes \(p\) near \(2^{20}\), the circuit computes the residue of \(g^x\) modulo \(p\) from a table of discrete logarithms, then folds it into an approximate value of \(g^x/N\) on a small accumulator through the Chinese remainder theorem. This needs only about \(n/2\) logical qubits for an \(n\)-bit modulus, but each prime repeats its own lookups and conversions, which is where the gates go.

The paper reorganizes the four stages together rather than one at a time. The biggest saving comes from sharing each table lookup across a batch of up to 24 primes, which divides the lookup cost per prime by the batch size. Sharing needs room for 24 lanes of partial sums, so the lanes are compressed to 26 or 27 bits, the following division modulo \(p-1\) is made to work in place on those lanes, and the measurement-based cleanup of lookups is done window by window instead of at the end.

Compression introduces rare overflows, at probabilities near \(10^{-10}\) that no simulation can sample. The authors bound them analytically, with Hoeffding bounds for 27-bit lanes and moment-generating-function bounds computed exactly from the tables for 26-bit lanes, and convert them into a bound on the trace distance of the whole channel. The compiled circuits are emitted as explicit gate streams, and every mid-circuit measurement outcome is tracked symbolically, so phase cleanup can be verified for all \(2^M\) measurement histories.

The resulting frontier dominates Gidney's serial designs across his whole qubit range and passes below a billion expected Toffolis at 2,433 qubits. A concurrent preprint by Sharma and Lau also shares lookups across up to eight primes; against its circuits the authors report 25% to 43% fewer Toffolis at equal or fewer qubits. Mapping the circuits onto surface-code hardware is left open, and the authors expect intermediate operating points to balance qubits, gates and classical post-processing.

Transferable methods

  1. Offset unsigned lanes and non-restoring division modulo p − 1

    Each batched lane holds a sum of discrete logarithms that must next be reduced modulo \(p-1\). Storing the sum centred on its mean saves bits, but a signed register cannot be reduced in place. Shifting by a classically known offset keeps the register unsigned, and a non-restoring division that exploits the trailing zeros of \(p-1\) needs only one adder per step.

    Let \(\mu\) be the rounded mean of the sum \(S\) and \(\ell=20\). With half-width \(H=2^{D-\ell-1}(p-1)\) and offset \(B=\mu-H\), store \[U=(S-B)\bmod 2^D.\] Every sum within \(H\) of the mean satisfies \(0\le U<2H<2^D\), and \(2H\) is a multiple of \(p-1\), so reducing \(U\) modulo \(p-1\) gives \(S-B\) modulo \(p-1\). The constant \(B\) is folded into the next stage's classical lookup table, so it costs one constant addition per prime.

    Write \(p-1=2^tm\) with \(m\) odd. Each division step works on a slice of \(w=\ell+1-t\) bits and adds or subtracts \(m\) depending on the previous quotient bit \(q\). Editorial derivation: subtraction is obtained from one uncontrolled adder by conjugating with bitwise complements: since \(\bar X=-X-1\) modulo \(2^w\), \[\overline{\,\bar X+m\,}=-(-X-1+m)-1=X-m\pmod{2^w}.\] So \(X\mapsto\bigl((X\oplus q^{\otimes w})+m\bigr)\oplus q^{\otimes w}\) adds \(m\) when \(q=0\) and subtracts it when \(q=1\), using CNOTs from \(q\) instead of a second adder. Editorial check: the identity holds exhaustively for \(w=3,4,5\) and every odd \(m\). The paper reports 238 instead of 504 Toffolis per prime for this stage.

    Batching works because the lookup at each exponent window is the same for all primes in a batch except for the table contents; with \(k\) lanes sharing one address computation, its cost per prime falls as \(1/k\), while each lane adds \(D\) qubits. The qubit–Toffoli product therefore has a minimum, reached at \(k=22\) for the primary family.

    How to reuse it

    Choosing register offsets so that each stage receives its input in the representation it can process in place, and building subtraction from addition by complement conjugation, removes conversion copies in any pipeline of reversible arithmetic.

  2. Dyadic accumulation on the circle and certified overflow tails

    The final value is needed only as a fraction modulo 1. Rounding each Chinese-remainder slice to a dyadic grid and adding modulo \(2^f\) removes the borrow qubit and comparator of the earlier design, and rare overflows that cannot be sampled are bounded analytically instead.

    Each slice contributes \(C_\alpha/N\) modulo 1. Store the nearest grid point \[v_\alpha=\Bigl\lfloor\frac{2^fC_\alpha+\lfloor N/2\rfloor}{N}\Bigr\rfloor\bmod 2^f,\] and add the \(v_\alpha\) with ordinary binary addition, whose overflow is exactly reduction modulo \(2^f\). Multiples of \(N\) vanish modulo 1, so there is no wraparound drift, and symmetric rounding keeps each slice's error within \(\pm\tfrac12 2^{-f}\), a third smaller in diameter than the floor-based scheme.

    Overflow occurs when a lane's sum leaves its window of half-width \(H\). For independent window contributions, the standard Hoeffding bound (stated here editorially) gives \[\Pr\bigl[|S-\mathbb E S|\ge H\bigr]\le2\exp\Bigl(-\frac{2H^2}{\sum_i(b_i-a_i)^2}\Bigr)\] for terms in \([a_i,b_i]\). For 26-bit lanes the paper replaces the worst-case ranges by moment-generating functions computed exactly from the table entries, since nearly uniform discrete logarithms have about a third of the worst-case variance.

    A failure probability becomes a channel distance through a dilation argument: if the ideal and actual circuits agree except on branches of total probability \(p_{\rm bad}\), and the ancillas are reset on every branch, the trace distance between the channels is at most \(2\sqrt{p_{\rm bad}}\). The paper reports \(\eta\le3.37\times10^{-5}\) per run for its primary family, which enters the probability that a run must be repeated.

    How to reuse it

    Accumulating fractions on a dyadic circle with natural overflow suits any phase-estimation or modular-sum circuit that needs a value only modulo 1. Exact tail bounds computed from known tables are a way to certify events far too rare to simulate.

Source: Sec. II.1 (offset unsigned lanes, non-restoring division, Eqs. (1)–(2); dyadic torus accumulation, Eq. (3)); Sec. II.2 (rolling lookups); Sec. II.3 (overflow tail bounds); Sec. III (frontier and verification). Based on the linked paper version. Derivations marked as editorial, and suggested uses in other problems, are editorial guidance rather than results of the paper.

Context & limitations

Why it matters. This is the first RSA-2048 design below a billion Toffolis, and it improves on Gidney and Ekerå's 2019 design in both logical qubits and gates. Compared with Gidney's 2025 design, the same logical qubit range now costs several times fewer gates. It is also an example of language-model search applied to a complete fault-tolerant algorithm, kept honest by symbolic checks of measurement phases and analytic bounds on rare overflows.

Limitations. All counts are logical. The sub-billion points use about 2,400 logical qubits, roughly 1,000 more than the 1,400 behind Gidney's sub-million physical-qubit estimate; the lowest-qubit point (1,306) still needs \(6.3\times10^9\) Toffolis. No physical qubit count or run time is given, and the authors note that wide batching raises the ratio of two-qubit Clifford gates to Toffolis from about 13 to about 90, which affects surface-code layout. Gate-level verification covers six circuits and uses the single-base proxy \(3^x\bmod N\). Compressed registers fail with probability bounded analytically (for example \(\eta\le3.37\times10^{-5}\) per run) rather than ruled out. The comparison relies partly on the authors' re-simulation of Gidney's circuits. The authors state that the main algorithmic and compilation improvements were generated with GPT-6 Astra and that they checked all proofs, circuits and claims.

Description based on the full arXiv HTML of v1, read 2026-11-25: Secs. I–IV, Tables 1–2 and the AI usage disclosure. The appendices (circuit topology, proofs of Propositions 1–5, verification workflow) were not read. Editorial checks: 2,433 × 0.9783 × 10^9 = 2.380 × 10^12, which is 70.1% below 7.957 × 10^12; 0.9608 and 0.9317 against Gidney's minimum of 4.4869 × 10^9 give the stated 78.6% and 79.2%. The non-restoring division identity of Eq. (2) was checked exhaustively for widths 3 to 5 and all odd constants.