Quantum Algorithms Database

Quantum Error-Correcting Codes (Shor Code, Surface Code)

Algorithms and encoding schemes for protecting quantum information from errors by spreading it across multiple physical qubits.

Last reviewed September 30, 2026. Check the linked sources for anything that may have changed since.

Year

1995 (Shor code; Steane code 1996); 1997 (surface and toric codes); 2024 (qLDPC demonstrations)

Inventor(s)

Peter Shor; Andrew Steane; Alexei Kitaev; Sergey Bravyi and Kitaev; Austin Fowler and others

Speedup Type

No Speedup Claimed

Difficulty

★★★★★

Overview

Quantum error correction, or QEC, protects fragile quantum information from noise by spreading it across many physical qubits. Together those qubits form a logical qubit whose error rate can be made far lower than that of any individual physical qubit, as long as the physical error rate is below a threshold. QEC is the technology that turns noisy hardware into a computer capable of long, reliable calculations.

The idea seems impossible at first. Quantum states cannot be copied, and measuring them destroys them. The breakthrough, made in 1995, was to find ways to detect errors by measuring parities that reveal what went wrong without revealing the data, so errors can be fixed without disturbing the information.

The problem

Protecting fragile quantum information from decoherence and gate errors without violating the no-cloning theorem.

History

Peter Shor published the first quantum error-correcting code in 1995, a nine-qubit code that protects one qubit against any single-qubit error. Andrew Steane's seven-qubit code followed in 1996, and Calderbank and Shor and Steane developed the CSS construction. In 1997 Daniel Gottesman introduced the stabilizer formalism, which gives a systematic way to describe codes, and Alexei Kitaev proposed the toric code, a code based on a lattice with topological protection. Bravyi and Kitaev adapted it to planar surfaces in 1998.

The threshold theorem, proven in the late 1990s by Aharonov and Ben-Or, Kitaev, and Knill, Laflamme, and Zurek, says that arbitrarily long computations are possible if the physical error rate is below a constant threshold. Fowler, Mariantoni, Martinis, and Cleland laid out a practical surface-code architecture in 2012. In 2023 Google showed a distance-5 surface code with slightly lower error than distance 3, and in December 2024 its Willow chip showed logical error rates falling as the code grew from distance 3 to 5 to 7, the first below-threshold result on a superconducting platform. IBM published high-rate qLDPC codes in 2024, and trapped-ion and neutral-atom groups have reported logical-qubit experiments.

Intuition

The simplest classical code repeats each bit three times and takes a majority vote. A quantum code cannot copy a state, but it can entangle it with extra qubits so that information is stored in correlations. The three-qubit bit-flip code maps the state a times 0 plus b times 1 to a times 000 plus b times 111. A flip on any one qubit is detected by comparing neighbors' parities without measuring the state itself.

A real quantum code must handle both bit flips and phase flips. Shor's code nests a phase-flip repetition code inside a bit-flip repetition code, using nine qubits. The surface code arranges data qubits on a grid with two types of stabilizer checks, one detecting bit flips and one detecting phase flips, measured repeatedly. Each round produces a syndrome, a pattern of check outcomes that a classical decoder uses to infer the most likely errors.

The key property is that logical errors become exponentially rare as the code distance d grows, if the physical error rate p is below the threshold p sub th. The logical error rate falls roughly like (p over p sub th) to the power (d plus 1) over 2. For the surface code the threshold is about 1% with realistic circuit noise, which hardware now meets, though with large overheads.

How it works

Encodes one logical qubit across many physical qubits in an entangled configuration, allowing errors to be detected and corrected via syndrome measurements without directly observing the protected quantum information.

  1. Encode the logical qubit into a block of physical qubits using entangling gates so that the information is spread across the block.
  2. Repeatedly measure the stabilizer checks using ancilla qubits, producing syndrome bits without measuring the logical information.
  3. Send the syndrome history to a classical decoder, which finds the most likely set of physical errors that explains it.
  4. Apply corrections, or in many designs track the errors in software instead of physically correcting them.
  5. Perform logical gates by transversal operations, lattice surgery, or code deformation, and prepare special magic states for non-Clifford gates, distilling them to high fidelity.
  6. Measure the logical qubit at the end of the computation by measuring the physical qubits and decoding the result.

Worked example

Consider the three-qubit bit-flip code. A single qubit state a times 0 plus b times 1 is encoded as a times 000 plus b times 111. Suppose the second qubit flips by mistake. Measuring the parity of qubits 1 and 2 gives 1, and the parity of qubits 2 and 3 gives 1, which together identify qubit 2 as the culprit. Applying an X gate to qubit 2 restores the original encoded state, and the data never was measured.

With a physical error rate of 1% per qubit per round, the code fails only if two or more qubits flip, which happens with probability about 3 times 0.01 squared, or 0.03%, roughly 30 times lower. For the surface code at distance 7, Google observed that logical errors per cycle were about half those at distance 5, and the logical memory outlived its best physical qubit by more than a factor of two.

Complexity and resources

ThresholdAbout 1% for the surface code with circuit-level noise; higher for some other codes under idealized noise
Qubits per logical qubit (surface code)About 2 times d squared, so hundreds to thousands depending on target error
Logical error scalingFalls exponentially with code distance when below threshold
DecodingMust keep up with microsecond-scale syndrome cycles; real-time decoders are demonstrated at small distance
Overhead for useful algorithmsEstimates range from about 1,000 physical qubits per logical qubit to far fewer with qLDPC codes

Hardware needs

Physical gate and measurement errors well below 1%, with fast, mid-circuit measurement and reset.

Real-time classical decoding hardware linked to the qubit controls.

Large qubit counts, from hundreds for experiments to millions for large algorithms.

Real-world impact

The central technology required for fault-tolerant quantum computing at scale; without it, large quantum algorithms like Shor's cannot run reliably on real hardware.

Applications

Enabling fault-tolerant algorithms such as Shor's algorithm and large chemistry simulations.

Storing quantum memories for long durations.

Protecting qubits in quantum networks and repeaters.

Defining resource estimates and roadmaps for companies such as Google, IBM, Quantinuum, and QuEra.

Limitations

  • The overhead in qubits is large: useful machines need many physical qubits per logical qubit.
  • Logical operations beyond the Clifford set need expensive magic state distillation or alternatives.
  • Correlated errors, leakage, and slow decoding can degrade performance.
  • Experiments so far demonstrate quantum memory and a few logical operations, not full fault-tolerant algorithms.

Common misconceptions

  • Error correction does not copy the state. It entangles and measures parities instead.
  • It does not remove all errors. It reduces them exponentially if the hardware is good enough.
  • More qubits do not always help. If the physical error rate is above threshold, larger codes make things worse.

How it compares

Error mitigation reduces the effect of noise on near-term devices without extra qubits but cannot scale to long circuits.

Surface codes need only local operations but have low rates, while qLDPC codes need long-range connections but promise ten times fewer qubits.

Bosonic codes such as cat and GKP codes build some protection into each oscillator, reducing the overhead of the outer code.

Why it matters

QEC is the central requirement for large quantum computers. Every credible roadmap to useful algorithms, from Google's and IBM's to Quantinuum's and QuEra's, depends on it, and progress in logical error rates is now the main measure of hardware advancement.

For learners, QEC is also the best window into why quantum computing is hard and how it can be done. The ideas of syndromes, stabilizers, thresholds, and distance appear in nearly every hardware announcement.

Why error correction was thought impossible, and how it was shown possible

Classical error correction copies information: store a bit three times and take a majority vote. Quantum states cannot be copied (the no-cloning theorem), and measuring a qubit to check it destroys its superposition. For a time this seemed to make protecting quantum information impossible. Calderbank and Shor's paper 'Good quantum error-correcting codes exist' (arXiv quant-ph/9512032, submitted September 1995) is one of the results that settled the question.

The paper defines a quantum error-correcting code as a unitary encoding of k qubits into n qubits such that the original state can be rebuilt even if any t of the qubits suffer arbitrary, possibly correlated, decoherence. Instead of copying the state, the code spreads the information across all n qubits, so that measuring up to t of them reveals nothing about the encoded state, yet the state can be recovered.

The CSS construction and the rate result

The construction builds on two classical linear codes C1 and C2, with C2 contained in C1. If both have minimum distance d, the quantum code corrects t = floor((d - 1)/2) errors and covers both bit-flip and phase-flip errors. A counting argument in the style of the classical Gilbert-Varshamov bound shows that good codes exist. The paper states an asymptotic rate of 1 - 2 H2(2t/n), where H2 is the binary entropy function, and also gives upper bounds on the rate.

In plain terms: you can protect quantum data at a non-zero rate, meaning a fixed fraction of the qubits can carry information, if the number of errors you must correct is a small enough fraction of n. The existence proof does not say how to build an efficient decoder or how many qubits a useful machine needs, which is where much later work, including surface codes and qLDPC codes, comes in.

  • Encode: k logical qubits into n physical qubits.
  • Detect: measure parity-like checks (syndromes) that reveal the error but not the data.
  • Correct: apply a fix based on the syndrome, repeated every cycle.
  • Threshold idea: below some physical error rate, adding more qubits makes things better rather than worse.

Where this meets real hardware

Practical machines need codes that tolerate realistic noise, have fast decoders and fit the chip's wiring. Company roadmaps on this site (for example IBM's qLDPC plan) are attempts to turn the existence results into hardware. This page did not open those engineering papers, so it makes no claim about the best code today.

Frequently asked questions

What is a logical qubit?

A qubit encoded across many physical qubits using an error-correcting code, with an error rate much lower than any physical qubit.

What is the threshold theorem?

It states that if the physical error rate is below a certain threshold, quantum computations of any length can be made reliable with a modest overhead.

What is the surface code?

A code that arranges qubits on a 2D grid with local parity checks. It has a high threshold of about 1% and needs only nearest-neighbor interactions, so it is the leading code for superconducting chips.

Has error correction been demonstrated?

Yes. Google's Willow chip showed logical error rates falling as the surface code grew to distance 7, and other groups have demonstrated logical qubits on ions and neutral atoms.

How many physical qubits per logical qubit are needed?

It depends on the code and the physical error rate. For the surface code estimates range from hundreds to a thousand or more, and qLDPC codes may reduce that by a factor of about ten.

Related algorithms

References and further reading

Sources opened and checked on December 1, 2026. Resource estimates and claims change, so check the originals.

  1. Good quantum error-correcting codes exist (arXiv (A. R. Calderbank, P. W. Shor)) Opened. Source for the code definition, the CSS-style construction and the rate 1 - 2H2(2t/n).

→ Read the full deep-dive in our Learning Center

← Back to Algorithms Database