Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Skip Learn navigation
Encyclopedia
Topic

Uncomputation

Coherently reversing a computation to remove unwanted work-register correlations while preserving a useful result.

Also called compute-uncompute, garbage cleanup

Edition released Coverage: Overview · Technical
On this page

Definition and significance

Uncomputation clears temporary quantum workspace by reversing the operations that created it. A classical program can overwrite a temporary variable, but irreversible erasure of an entangled quantum register can destroy information needed for interference. The standard strategy retains enough inputs to reverse the calculation, uses the computed result in a reversible way, then applies the inverse subroutine.

Mechanism and mathematical treatment

Suppose U maps |x>|0> to |x>|f(x)>. A coherent input sum_x a_x|x>|0> becomes sum_x a_x|x>|f(x)>. If the second register is traced out, off-diagonal terms between x and y survive only when f(x)=f(y). That loss of coherence is not repaired by merely resetting the register afterward.

Instead, a third register can receive an XOR of the classical output label: |f(x)>|0>->|f(x)>|f(x)>. Applying U dagger to the first two registers then gives sum_x a_x|x>|0>|f(x)>. This operation copies orthogonal computational labels while retaining their correlations; it does not clone an arbitrary unknown quantum state.

Fully worked reference example

Take f(x)=x for one qubit, with input |+> and work |0>. A CNOT computes f and produces (|00>+|11>)/sqrt(2). Tracing out the work qubit yields I/2, so a later H on the input gives random outcomes. If the CNOT is instead reversed, the two-qubit state returns to |+>|0>, and H on the input yields 0 with certainty.

For phase marking, insert Z on the work register before reversing CNOT. The state becomes (|00>-|11>)/sqrt(2), then |->|0>, then |1>|0> after H on the input. The temporary register has been cleared while its useful phase effect remains.

Limitations and common misconceptions

Uncomputation has a resource cost. Reversing arithmetic can approximately double a circuit segment, and storing intermediate values can trade qubits against recomputation. Measurement-based cleanup is possible in specific constructions with tracked corrections; it must not be presented as a universal license to measure and erase any work register.

Scientific relationships

Reversing workspace calculations can produce a clean phase oracle.

Auxiliary workspace must often be restored coherently for reuse.

An adjoint specialization can reverse a suitable unitary operation.

Cleanup after a nonlinear predicate with an exact reduced state

Let x consist of two input bits, initially |++>, and let a be a clean work qubit. Compute f(x)=x0 x1 into a. The resulting state is (|00>|0>+|01>|0>+|10>|0>+|11>|1>)/2. If a is discarded, the input density matrix splits into a coherent three-dimensional unmarked block and a one-dimensional marked block. In the ordered input basis, it is one-quarter times [[1,1,1,0],[1,1,1,0],[1,1,1,0],[0,0,0,1]].

Apply H tensor H to the input after discarding a. The probability of 00 is <++|rho|++>=10/16=5/8: nine contributions come from the unmarked block and one from the marked diagonal. Each of the other three outcomes has probability 1/8. By contrast, coherently reversing the predicate computation returns |++>|0>, after which 00 is certain. This fully solved instance quantifies how much interference is lost when nonlinear garbage is erased.

Now insert a Z on a before coherent reversal. The final input is (|00>+|01>+|10>-|11>)/2. Its Hadamard transform has four amplitudes of magnitude 1/2, giving a uniform distribution. The three outcomes—certain 00, a 5/8-biased distribution, and a uniform distribution—correspond to three different programs: cleanup without marking, discard without cleanup, and marking followed by cleanup. They should never be conflated because the temporary register ends unobserved in all three descriptions.

Copying a result does not remove its correlations

Add a clean output register b and copy the computed predicate from a to b with CNOT. Reversing the predicate computation clears a but leaves sum_x |x>|0>|f(x)>/2. The data and b remain entangled. This is the desired result if b is the coherent output, but it does not restore the data to |++>. If b is discarded, the same block-dephased input state reappears. Uncomputation clears workspace while preserving information intentionally retained as output; it cannot erase the consequences of that retained information.

For the AND example, measuring b gives zero with probability 3/4 and one with probability 1/4. Conditional on zero, the data is (|00>+|01>+|10>)/sqrt(3). Conditional on one, it is |11>. These conditional states expose exactly which coherence survives. Their weighted mixture reproduces the reduced matrix above. A measurement record can be useful, but conditioning on it changes the task and must be included in any stated success probability.

This reasoning generalizes to a function f with many output labels. Tracing out an output register removes the matrix element |x><y| whenever f(x) and f(y) are orthogonal labels with different values. The surviving blocks are the fibers of f. If f is constant, no coherence is lost; if f is injective, every off-diagonal element between different inputs disappears. These two boundary cases give immediate consistency checks for a proposed cleanup procedure.

A reversible recomputation schedule

Consider a classical chain u=f(x), v=g(u), w=h(v), embedded reversibly with separate registers. A straightforward coherent implementation stores u,v,w and then reverses g and f after copying or otherwise using w appropriately. However, reversing g requires u, and reversing f requires x. Overwriting u prematurely breaks the inverse schedule. The dependencies form a reversible pebbling problem: retaining more intermediates uses more workspace, while recomputing them uses more gates.

A concrete two-stage schedule for a clean final output is: compute u from x; compute v from u; copy the computational label v into output z; uncompute v using u; uncompute u using x. The final state has x and z, with both temporary registers restored. The compute and uncompute portions each contain one call to f and one to g, plus the output-copy operation. If f or g uses internal work, its own cleanup contract must be satisfied before the outer schedule is correct.

When the output is a phase rather than a retained bit string, the copy step can be replaced by a diagonal phase operation on v. The inverse then clears both temporary registers while leaving a phase on x. This is often the appropriate interface for an oracle used repeatedly inside amplitude amplification. The cost of the inverse is real: one logical oracle call can contain a forward arithmetic calculation and its full reversal.

For a small reversible network, classical truth tables verify register restoration on basis inputs, while phase-sensitive matrix checks verify the marked construction. The two checks have different scopes. A measured-reset shortcut may happen to restore the expected computational value on every basis test yet fail on superpositions because it has leaked which-input information.

Sources

  • A. Barenco et al. · · Research paper · Publication status unspecified · arXiv · DOI 10.1103/PhysRevA.52.3457
    Verification scope

    Selected source text checked ·

    Source anchors gate-decomposition conventions. New worked instances are independent mathematical constructions, not reported experiments.