Dirty-Qubit Borrowing
- Dirty-Qubit Borrowing is the temporary use of ancilla qubits with unknown states that must be returned to exactly their original state, preserving any entanglement.
- It enables quantum circuits to recycle idle qubits, notably reducing the number of clean qubits required in reversible arithmetic and Shor-era constructions.
- The technique is formalized in both circuit synthesis and programming language semantics, underpinning T-gate tradeoffs and safe uncomputation in state preparation.
Dirty-qubit borrowing is the temporary use of ancillary qubits whose initial state is unknown and may be entangled, under the requirement that the computation be independent of those initial states and that the borrowed qubits be returned exactly to their original state. In the circuit literature, dirty ancillae or borrowed qubits are extra qubits in an unknown state that must be restored before the circuit ends; in the programming-languages literature, the same idea is formalized as safe uncomputation, with the overall effect required to be the identity on the borrowed subsystem. The technique is motivated by the scarcity of fresh clean qubits and by the observation that large quantum algorithms often contain qubits that encode coherent quantum information but remain idle for parts of the computation (Low et al., 2018, Su et al., 24 Aug 2025, Gidney, 2017).
1. Definition and core criterion
A clean ancilla is an extra qubit initialized in a known state, typically . A dirty qubit, or dirty ancilla, is an extra qubit whose initial state is unknown and possibly entangled with other parts of the computation, but which can be used temporarily provided the subroutine returns it exactly to its original state. A standard formal pattern is
for all unknown states on the borrowed qubits; this is the operational meaning of dirty-qubit borrowing in circuit synthesis and state preparation (Low et al., 2018).
The programming-languages formulation makes the same requirement semantic. For a program and a qubit , safe uncomputation means that for all ,
for some quantum operation on the remaining qubits. In this form, dirty-qubit borrowing is not merely a resource heuristic but a program property: every possible execution must act as the identity on the borrowed qubit. The same paper proves equivalent state-restoration and entanglement-preservation statements, including preservation of any external entanglement involving the borrowed qubit (Su et al., 24 Aug 2025).
This definition separates dirty-qubit borrowing from ordinary ancilla allocation. A clean ancilla may be overwritten and later reset to ; a dirty ancilla must be restored to whatever state it had originally, including any correlations that existed before the borrowing scope began. That stronger condition is what allows idle qubits to be reused safely.
2. Reversible arithmetic and Shor-era constructions
A major circuit-level development was the use of dirty ancillae in reversible arithmetic for factoring. āFactoring with clean qubits and 0 dirty qubitsā gives reversible classical circuits for arithmetic operations aided by dirty ancillae and improves the number of clean qubits needed to factor an 1-bit number with Shorās algorithm from 2 to 3, assisted by 4 dirty qubits, without increasing the asymptotic size or depth of the circuit (Gidney, 2017).
In that construction, dirty bits are any temporarily unused wires. The central constraint is that they may start in an arbitrary, unknown state and must be restored exactly. The arithmetic toolkit includes addition, offset, comparison, increment, pivot-flips, modular addition, modular negation, modular doubling, modular scaled-addition, and modular bimultiplication. The period-finding construction uses 5 total qubits: a single repeatedly reused phase-estimation qubit, an 6-qubit work register, and an 7-qubit ancilla register whose most significant bit is clean and fixed to 8, while the remaining 9 qubits are dirty (Gidney, 2017).
A characteristic primitive is modular bimultiplication. Instead of treating an ancilla register as disposable workspace, the circuit updates two registers symmetrically, multiplying one by 0 and the other by 1 modulo 2. The ancilla register may therefore be dirty at the start, and a final clean-up multiplication restores it to its original value. This construction is the main mechanism by which dirty ancillae reduce the clean-qubit requirement in period finding (Gidney, 2017).
The broader significance is methodological. Dirty-qubit borrowing in these reversible circuits is not an isolated trick but a design discipline: use reversible subroutines, ensure local uncomputation, and arrange the global algorithm so that any net action on the borrowed workspace can be canceled exactly. The resulting asymptotic costs remain 3 gates and 4 depth for the factoring construction, while the clean-qubit requirement is reduced to 5 (Gidney, 2017).
3. SpaceāT tradeoffs in state preparation and synthesis
Dirty-qubit borrowing also became a systematic resource tradeoff in fault-tolerant synthesis. āTrading T gates for dirty qubits in state preparation and unitary synthesisā studies arbitrary state preparation and unitary synthesis in Clifford+T, with the explicit goal of borrowing idle qubits as dirty ancillas to reduce T-count (Low et al., 2018).
The central mechanism is a T-efficient data-lookup oracle implemented by the SelectSwap network. For a 6-bit oracle output and tunable parameter 7, the SelectSwap construction has
8
In the modified version, only
9
qubits must be clean; the remaining 0 qubits can be dirty. The borrowed registers are entangled with the data during the computation and then disentangled and returned to their original state, which is exactly the operational meaning of dirty-qubit borrowing (Low et al., 2018).
For state preparation of an arbitrary 1-dimensional pure state specified by classical data, the paper uses 2 clean qubits and
3
dirty qubits, with T-count
4
For unitary synthesis of 5 specified columns, the corresponding bound is
6
The paper proves lower bounds showing that these spaceāT tradeoffs are optimal up to logarithmic factors, and in the best case yield a quadratic improvement in T-count over prior ancillary-free approaches (Low et al., 2018).
In this line of work, dirty-qubit borrowing is not tied to a particular arithmetic family. It becomes a generic compiler-level principle: almost all ancillas used for data lookup and amplitude-loading machinery can be dirty, while only 7 qubits must be clean (Low et al., 2018).
4. Language semantics and formal verification
A later development was to lift dirty-qubit borrowing from circuit folklore to language semantics. āBorrowing Dirty Qubits in Quantum Programsā introduces a \textsf{QBorrow} language with an explicit borrowing construct 0 and defines its denotation by ranging over all qubits in 8, the set of qubits syntactically unused by 9. Formally,
0
Borrowing is therefore nondeterministic at the semantic level: any idle physical qubit may instantiate the placeholder 1 (Su et al., 24 Aug 2025).
The same paper defines safe uncomputation exactly as identity action on the borrowed subsystem and proves two particularly important equivalents. First, for every global state and every one-qubit pure state 2, if the reduced state of 3 is 4 initially, then it remains 5 after every execution. Second, the borrowed qubitās entanglement with any external auxiliary system is preserved exactly. These equivalences make the operational meaning of safe borrowing precise: the borrowed qubit is invisible to the rest of the program except as temporary workspace whose full state is restored (Su et al., 24 Aug 2025).
For classical circuits composed only of 6 and multi-controlled NOT gates, the paper gives an efficient verification reduction. A dirty qubit 7 is safely uncomputed if restoration holds for 8 and 9, and the check reduces to the unsatisfiability of two Boolean formulas, one testing preservation of 0 and the other testing whether any other output depends on the initial value of 1. The implementation uses CVC5 and Bitwuzla and verifies adder circuits up to 200 qubits and MCX circuits up to 3499 qubits (Su et al., 24 Aug 2025).
This formalization resolves a long-standing ambiguity in the phrase āborrow a dirty qubit.ā In circuit design, the phrase often meant that a construction was believed to restore its borrowed workspace. In the semantics of \textsf{QBorrow}, that belief becomes a theorem or a failed proof obligation.
5. Recycling, reset, and experimental ancilla reuse
Dirty-qubit borrowing is closely related to, but not identical with, broader qubit-reuse mechanisms. āRecycling qubits in near-term quantum computersā proposes a rewinding protocol that unitarily resets qubits when a circuit has a common convolutional form. The protocol generates fresh qubits from used ones by partially applying the time-reversed quantum circuit over qubits that are no longer in use, and in the absence of noise the state of a subset of these qubits becomes 2, up to an error exponentially small in the number of gates applied. The paper also provides numerical evidence that the protocol works in the presence of noise and formulates a condition under which the noise-resilience follows rigorously (Anikeeva et al., 2020).
This protocol is not dirty-qubit borrowing in the strict sense because the original unknown state of the qubit is not preserved; instead, the used qubit is approximately reset to a fresh ancilla state. Even so, it belongs to the same resource family: qubits are reused rather than allocated anew, and the reuse is certified by structural properties of the circuit (Anikeeva et al., 2020).
A platform-level realization of repeated ancilla reuse appears in neutral atoms. āRepeated ancilla reuse for logical computation on a neutral atom quantum computerā demonstrates the ability to measure and re-initialize, and if necessary replace, a subset of atoms while maintaining coherence in other atoms. The system performs logical circuits that include single- and two-qubit gates as well as repeated midcircuit measurement, highlights the capability by performing up to 41 rounds of syndrome extraction in a repetition code, and combines midcircuit measurement and atom replacement with real-time conditional branching to demonstrate heralded state preparation of a logically encoded Bell state. The measured impact on register qubits per MCM cycle is an atom loss of 3 and a Ramsey contrast loss among surviving atoms of 4 (Muniz et al., 11 Jun 2025).
This suggests a broader operational family of qubit reuse mechanisms. Strict dirty-qubit borrowing restores an unknown initial state; recycling and midcircuit reset restore a known fresh state. Both reduce pressure on scarce clean ancillas, but they solve different resource problems and make different semantic promises.
6. Related uses of ādirtyā qubits and scope of the term
The phrase ādirty qubitā is not uniform across quantum information. In āThe battle of clean and dirty qubits in the era of partial error correction,ā a clean-and-dirty setup partitions an 5-qubit device into 6 clean qubits and 7 dirty qubits, where clean qubits evolve unitarily and dirty qubits are followed by a noise channel. In that setting, dirty qubits are uncorrected noisy qubits, not borrowed ancillas that must be restored. The paper shows the appearance of Noise-Induced Barren Plateaus in an Ising-model Hamiltonian variational ansatz, observes this even if only a single qubit is noisy and given a deep enough circuit, and finds that for every noiseless qubit in the circuit there is an exponential suppression in concentration of gradient observables, with the exponent related to the ratio of dirty-to-total qubits (Bultrini et al., 2022).
A second neighboring usage appears in noisy-storage cryptography. āCryptography from Noisy Storageā models qubits stored by an adversary as noisy resources and proves that a protocol for oblivious transfer is secure for any amount of quantum-storage noise, as long as honest players can perform perfect quantum operations. There, ādirtyā refers to decohered storage rather than to a borrowable ancilla whose state must be restored (0711.2895).
A third neighboring usage concerns physical carriers. āQubit carriers with internal degrees of freedom in a non-factorable stateā studies particles that carry logical qubits while hidden internal degrees of freedom are non-factorable. The key parameter is
8
and the transferred state becomes
9
Here the relevant issue is distinguishability and dephasing of the carrier, not safe borrowing of an idle computational qubit (Mikova et al., 2012).
These distinctions matter because they mark different notions of ādirtiness.ā In the borrowing literature, dirtiness means unknown initial state plus exact restoration. In partial error correction, it means exposure to noise. In noisy storage, it means decoherence as a cryptographic assumption. In carrier models, it means inaccessible internal degrees of freedom. Conflating these notions obscures the central invariant of dirty-qubit borrowing: the borrowed subsystem must be returned exactly, including any entanglement it carried at the moment of borrowing.