Skip to main content

Plain-Language Intuition

Mode: Simple / School
Correcting errors is expensive. Detecting them is much cheaper, and often good enough: if an error is detected, throw the run away and try again. The smallest useful detection code uses four qubits. All valid code states share one property: the four qubits always contain an even number of 1s. A fifth qubit acts as a flag. It checks the parity of the four data qubits using four CNOTs: - even number of 1s: the flag stays 0. All good. - odd number of 1s: the flag reads 1. A bit-flip has happened somewhere. The flag cannot say which qubit flipped, so the error cannot be repaired, but the bad run is caught. A matching check with X-type gates catches phase flips in the same way. This little code has been run on real hardware many times to show that encoded qubits can outperform bare ones.

Fault Tolerance

The [[4,2,2]] Error-Detecting Code: quick reference

Encodes two logical qubits in four physical ones and flags a bit-flip anywhere with a single parity check.

Topic
Fault Tolerance
Level
Advanced
Circuit size
5 Qubits
Key result
The smallest code that detects any single-qubit error

Concepts covered: Error Detection, Stabilizer Codes, Code Parameters [[n,k,d]], Post-Selection

How the [[4,2,2]] Error-Detecting Code works, step by step

  1. Encode a Logical State. A Hadamard and three CNOTs entangle the four data qubits. Every part of the state has an even number of 1s.
  2. A Bit-Flip Error Occurs. Noise flips Q2. Now every part of the state has an odd number of 1s.
  3. Measure the Parity Check. Four CNOTs add up the parity of the data qubits on the flag qubit (Q4).
  4. Read the Flag. The flag reads 1. An error occurred, so this run is discarded.

Frequently asked questions

What is the [[4,2,2]] Error-Detecting Code?

Encodes two logical qubits in four physical ones and flags a bit-flip anywhere with a single parity check. It is a advanced-level topic in fault tolerance.

How many qubits does the [[4,2,2]] Detection Code circuit use?

The QuanBit tutorial uses a 5 qubits circuit. Key result: The smallest code that detects any single-qubit error.

Can I simulate [[4,2,2]] Detection Code online for free?

Yes. The interactive [[4,2,2]] Detection Code tutorial at https://www.quanbit.tech/learn/error-detection-422 runs free in the browser with nothing to install. You can step through the circuit gate by gate, watch the probabilities, statevector and Bloch spheres update, build the circuit yourself and take a short quiz.