Malcolm Low | Practical AI, Computing & Quantum Research

Singapore-based practical guides, tutorials and experiments in AI, computing, modelling, simulation, optimisation and quantum computing, with research notes and hands-on workflows.

Cost of Garbage Bits in Quantum Circuits: Clean Math

Yes, uncomputed garbage bits destroy interference. Failing to clean ancilla registers creates unwanted entanglement. Check reversible uncomputation steps →

·

Written by

Part of the Quantum Computing: A Complete Learning Path series.

The Hidden Witness

Why You Must Clean Up “Junk Bits” with Uncomputation

1. The “Observer” Effect

In quantum computing, anything that “knows” what a qubit is doing acts as a Witness. Leftover data (Junk Bits) on an ancilla qubit act as witnesses, destroying the interference your algorithm needs to work.

Case A: Ideal (No Junk)

H
H
|0⟩
|0⟩

100% Interference

Case B: Broken (With Junk)

H
+
H
|0⟩
|0⟩
?
|junk⟩

Random 50/50 Noise

2. Mathematical Working

Ideal Case: (1/2) ( |0⟩ + |1⟩ + |0⟩ − |1⟩ ) = |0⟩
(Identical paths cancel perfectly.)

Junk Case: (1/2) ( |00⟩ + |10⟩ + |01⟩ − |11⟩ )
(Terms cannot cancel because the ancilla bit is different. Interference is destroyed.)

3. The Solution: Uncomputation

To restore interference, we follow the Compute-Copy-Uncompute pattern. This resets our ancilla to |0⟩ and removes the “witness.”

Input |x⟩
Ancilla |0⟩
Target |0⟩
COMPUTE
+
UNCOMPUTE
|x⟩ (Clean)
|0⟩ (Clean)
|f(x)⟩ (Result)

4. Qiskit Implementation

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator

qc = QuantumCircuit(3)
qc.h(0) 
qc.cx(0, 1) # COMPUTE: Create Junk on q1
qc.cx(1, 2) # COPY Result to q2
qc.cx(0, 1) # UNCOMPUTE: Clean Junk back to |0>
qc.h(0)     # Interference Restored!

qc.measure_all()
counts = AerSimulator().run(transpile(qc, AerSimulator())).result().get_counts()
print(f"Resulting state: {counts}")

Built with Qiskit 1.x • Quantum Series 2025

About the author

Malcolm Low is an Associate Professor at the Singapore Institute of Technology, writing on quantum computing, programming, and applied computing from Singapore.

Website: malcolmlow.com  ·  Singapore

Continue the Quantum Series

Comments

Leave a Reply