The problem error correction solves
Every operation on today's qubits fails with some probability. A useful algorithm may need millions or billions of operations, so even a per-operation failure probability of one in a thousand makes it essentially certain that something goes wrong long before the end. Better hardware lowers that probability, but no physical device is perfect, and for long computations the required improvement is many orders of magnitude. Quantum error correction is the strategy of building reliable logical qubits out of unreliable physical ones, so that the logical failure probability can be made smaller than the physical one, and smaller still by spending more qubits.
This lesson explains why that is possible at all. At first sight quantum mechanics seems to forbid it: you cannot copy an unknown state, errors form a continuum rather than a finite list, and looking at a qubit disturbs it. Each obstacle turns out to have a precise answer, and together the answers form the basis of every code in this course. We start with the classical idea the quantum codes generalise.
The classical repetition code
Suppose a channel flips each transmitted bit independently with probability . To protect one bit, send it times ( odd) and decode by majority vote. The vote fails exactly when more than half of the copies were flipped. The number of flips is binomially distributed, so the logical failure probability is
For the vote fails when two or three copies flip:
Worked example. With , . With five copies, . At the three-copy code gives , about 34 times better than an unprotected bit.
Three features of this formula carry over to every code we study.
- Polynomial suppression. For small the leading term is with : a code that corrects errors turns a rate into a rate of order .
- A break-even point. Encoding helps only when . For the repetition code this holds for every ; at the output is random whatever is. The value of below which a larger code beats a smaller one is the classical ancestor of a threshold.
- The decoder is part of the code. Majority vote is the minimum-weight decision: it assumes the smallest number of flips consistent with what it sees, which is the most likely explanation when .
Three apparent obstacles
Try to repeat this construction for a qubit .
No-cloning. There is no unitary that maps to for every (see the foundations course). So we cannot make three copies to vote on.
Errors are continuous. A classical bit is either flipped or not. A qubit can be rotated by any small angle about any axis, or partly decohere. If every one of infinitely many errors needed its own correction, no finite procedure could cope.
Measurement disturbs the state. Majority vote reads every copy. Reading a qubit in the computational basis collapses to or , destroying exactly the information we want to protect.
These were taken seriously as arguments against quantum computing until Shor constructed a nine-qubit code that corrects an arbitrary error on any one qubit (Shor 1995), and Steane independently found a seven-qubit code (Steane 1996). The rest of this lesson shows how each obstacle is avoided, using the simplest example.
Redundancy without copies
Instead of copying the state, entangle it. The encoding circuit below maps on qubit , with starting in , to
This is not three copies of : the product state contains terms such as , while contains only and . The circuit is linear, so it does not violate no-cloning. What is redundant is the basis information: in each branch the three qubits agree. The two-dimensional subspace spanned by the logical basis states and is the code space.
Measuring parities, not qubits
A bit flip on one qubit takes out of the code space, for example . To find the flipped qubit we do not read the qubits. We measure two parity checks, the observables and , each with eigenvalues . Their outcomes form the syndrome:
| Error | Syndrome | Correction | ||
|---|---|---|---|---|
| none | none | |||
Here records eigenvalue . The key point is that both basis states of each branch give the same syndrome: and both have and . The syndrome therefore says which error happened while revealing nothing about and , and the measurement leaves the superposition intact. This answers the third obstacle: we measure only operators that are constant on the code space and its displaced copies, never the encoded information itself.
In a circuit, each check is copied onto an ancilla qubit by two CNOTs and the ancilla is measured:
Ancilla ends in for every basis state , so its outcome is the parity, and because the parity is the same in both branches of the superposition the ancilla does not become entangled with the encoded amplitudes. The next lesson treats this code, and its phase-flip partner, in full.
Errors become discrete
Now the second obstacle. Any single-qubit operator can be written in the Pauli basis,
because is an orthogonal basis of matrices under the trace inner product. Take a coherent over-rotation of qubit 0, . Applied to the encoded state it gives
The two terms lie in orthogonal syndrome subspaces: the first has syndrome , the second . Measuring the syndrome therefore projects onto one term. With probability we see and the state is already ; with probability we see , the state is up to a global phase, and applying restores it. Either way the final state is exactly .
Worked example. For rad the syndrome is with probability and with probability , and the corrected fidelity is 1 in both cases. The continuum of angles has collapsed onto two discrete events, "no error" and "".
The argument is linear, so it extends to any error, including decoherence described by Kraus operators : expand each in Paulis, and if the code corrects each Pauli term it corrects every linear combination of them. Correcting a finite set of Pauli errors is enough to correct every error in their linear span. This is the discretisation of errors, and it is why codes are designed and analysed against Pauli errors.
The bit-flip code is not a complete quantum code. A phase error commutes with both checks, so the syndrome stays , yet is a different logical state. Shor's code handles both types by nesting a phase-flip code around three bit-flip codes (Shor 1995).
You can check all of this numerically in a few lines:
import numpy as np
X = np.array([[0, 1], [1, 0]], dtype=complex)
Z = np.diag([1.0, -1.0]).astype(complex)
I = np.eye(2, dtype=complex)
def kron(*ops):
out = np.array([[1.0 + 0j]])
for op in ops:
out = np.kron(out, op)
return out
alpha, beta, theta = 0.6, 0.8j, 0.3
psi = np.zeros(8, dtype=complex)
psi[0], psi[7] = alpha, beta # alpha|000> + beta|111>
rx = np.cos(theta / 2) * I - 1j * np.sin(theta / 2) * X
damaged = kron(rx, I, I) @ psi # over-rotation of qubit 0
P = (np.eye(8) - kron(Z, Z, I)) / 2 @ (np.eye(8) + kron(I, Z, Z)) / 2 # syndrome (1, 0)
branch = P @ damaged
prob = np.vdot(branch, branch).real
corrected = kron(X, I, I) @ branch / np.sqrt(prob)
print(round(prob, 4), round(abs(np.vdot(psi, corrected)) ** 2, 12)) # 0.0223 1.0
The Knill-Laflamme conditions
When can a code correct a given set of errors? Let be an orthonormal basis of the code space and a set of error operators. Knill and Laflamme proved (Knill and Laflamme 1997) the following.
Theorem (Knill-Laflamme conditions). There is a recovery operation that corrects every error in , and therefore every linear combination of them, if and only if
where the numbers do not depend on and .
The conditions say two things. For : an error must never map one logical state onto something overlapping a different logical state, or the errors would confuse logical information. For : the overlap must be the same for every logical state, so no measurement that distinguishes errors can also learn anything about the encoded state. This is the precise form of "measure the error, not the data".
Example 1. For the bit-flip code with : for , is a product of one or two 's, which maps and to states of Hamming weight 1 or 2, orthogonal to both code words, so every entry is 0. For , gives . The conditions hold.
Example 2. With : but , so would have to equal both. The conditions fail, matching the earlier observation that the bit-flip code cannot see phase errors.
Example 3. With : maps to , so . A single flip on qubit 0 and a double flip on qubits 1 and 2 have the same syndrome but differ by the logical operator , so no decoder can handle both. This is why a code that corrects all single errors still fails on some double errors.
The threshold idea
So far a code reduces to roughly , assuming perfect encoding, syndrome measurement and correction. Real syndrome circuits are built from the same noisy gates, and they can introduce errors faster than they remove them. Two results make the situation hopeful.
First, error correction can be made fault-tolerant: circuits can be designed so that a single fault causes at most a correctable pattern of errors. Second, codes can be scaled. In the concatenation argument, each level of encoding maps an error rate to about , so after levels the rate is about , which falls doubly exponentially in when .
Theorem (threshold theorem, informal). For noise that is sufficiently weak and sufficiently local (independent or weakly correlated faults), there is a constant such that any quantum circuit can be simulated to any desired accuracy with only polylogarithmic overhead, provided every physical operation fails with probability below . Precise versions with explicit noise models were proved by Aharonov and Ben-Or (1999) and, with a rigorous lower bound of for adversarial independent stochastic noise and concatenated distance-3 codes, by Aliferis, Gottesman and Preskill (2006).
A threshold is a property of a noise model, a code family and a decoder together, not of a device or of a code alone. Rigorous proofs give conservative lower bounds; numerical studies of specific codes under specific noise models give much higher estimates, which we will compute ourselves for the surface code later in the course. A device is "below threshold" for a code only in the operational sense that its logical error rate decreases as the code grows, which has to be measured.
Common mistakes
- "Encoding copies the state." is an entangled state, not . The redundancy is in the correlations, not in copies.
- Measuring the data to find the error. Measuring individual qubits collapses the encoded state. Only operators that act identically on all logical states, such as , may be measured.
- Thinking small rotations need small corrections. The syndrome measurement discretises the error; the correction is always a full Pauli (or nothing), applied with the probability the measurement dictates.
- Treating the bit-flip code as a full quantum code. It detects no phase errors at all, and its distance against arbitrary Pauli errors is 1.
- Quoting a threshold without its assumptions. A threshold value means nothing without the noise model, the code family, the decoder and the unit of the error rate.
Summary
- The classical repetition code turns a flip rate into , which is for three copies.
- Quantum codes replace copies by entanglement, majority vote by measurement of parity checks, and continuous errors by their Pauli components.
- Syndrome measurement reveals the error without revealing the logical state, and it projects any error onto a discrete Pauli error.
- The Knill-Laflamme conditions decide exactly which error sets a code can correct.
- The threshold theorem says that below a model-dependent error rate, arbitrarily reliable computation is possible with modest overhead.
The exercise asks you to verify these statements numerically: the exact repetition formula against Monte Carlo, the projection of coherent rotations onto discrete errors, and the Knill-Laflamme conditions for correctable and uncorrectable error sets. Next, the repetition code works through bit-flip and phase-flip codes, their syndromes and logical error rates, and their use as a memory over many rounds. For a textbook treatment of this material see Nielsen and Chuang, chapter 10.