Pricing…Open Lab
· ~7 min read · edited by Pattanaik Ramswarup

The Surface Code Explained Simply, Without the Math

The surface code is a way to protect one reliable qubit by spreading it over a flat grid of physical qubits. Between them sit helper qubits that keep checking whether small groups of neighbors still agree, laid out like the squares of a checkerboard. When an error happens, a few checks change, and a normal computer uses that pattern to work out what went wrong and undo it.

Why does everyone talk about the surface code?

Qubits make mistakes. To run long, useful programs, a quantum computer must catch and fix those mistakes while the program runs. That is called quantum error correction.

There are many ways to do it. The surface code is the one most talked about, and the one many large chip roadmaps are built around. Google used it for its best-known error-correction result on the Willow chip.

This page explains the idea with no math. If you are new to why one reliable qubit needs many real ones, read logical vs physical qubits first.

What problem does the surface code have to solve?

Fixing errors in normal computers is easy. You keep copies and compare them. Quantum computers cannot do that, for two reasons.

  1. You cannot copy an unknown qubit. A rule of quantum physics forbids it.
  2. You cannot look at a qubit's value without changing it. Reading a qubit forces it to a plain 0 or 1, and the delicate state is gone. See measurement.

So the question is strange. How do you find an error in something you are not allowed to look at?

The answer: you never ask a qubit what its value is. You only ask whether a small group of qubits agree with each other. That is a question you can answer without learning the values themselves.

What is a parity check?

A parity check asks one yes-or-no question: is the number of 1s in this group even or odd?

Here is an everyday version. Two friends each flip a coin and hide it. You ask them, "Do your coins match?" They say yes. Now you know they match, but you still do not know if both are heads or both are tails. You learned about the relationship, not the coins.

In a quantum computer, a spare qubit does the asking. It is called a measure qubit (some people say helper or ancilla qubit). It links to a few data qubits with gates. Then the measure qubit alone is read. Its answer says even or odd. The data qubits are never read, so their delicate state survives.

Unlike the coin example, there are two kinds of error to watch for. A bit flip swaps 0 and 1. A phase flip changes the sign of an amplitude, which you cannot see by reading 0s and 1s at all. So the code needs two kinds of check.

What does a check look like when an error hits?

Three data qubits (0, 1, 2) and two measure qubits. Qubit 3 checks whether qubits 0 and 1 agree. Qubit 4 checks whether qubits 1 and 2 agree. An X on qubit 1 plays the error. Every one of the 1,024 shots reads 11010: both checks light up, which points at qubit 1.standby
12345q0|0⟩q1|0⟩q2|0⟩q3|0⟩q4|0⟩X
press run to acquire
counts: sampledamplitudes: statevector, exactengine: in-browser
Open in the Lab →

How did two checks find the broken qubit?

Read the result 11010 from right to left, because the rightmost digit is qubit 0:

  • Qubit 0 = 0, qubit 1 = 1, qubit 2 = 0. The middle data qubit was flipped.
  • Qubit 3 = 1. Check "do 0 and 1 agree?" says no.
  • Qubit 4 = 1. Check "do 1 and 2 agree?" says no.

Now play detective. Which single flip would upset both checks? Only a flip on qubit 1, because it is the one qubit both checks share. A flip on qubit 0 would upset only the first check. A flip on qubit 2 would upset only the second.

This pattern of lit-up checks is called the syndrome, like the set of symptoms a doctor uses to name an illness. In a real machine, you would never read the data qubits. The syndrome alone is enough to know which one to fix. We read them here only so you can see the error for yourself.

This is a one-line version. The surface code does the same thing on a flat grid, for both kinds of error. The chapter on stabilizers and syndromes builds it up step by step.

Why is the surface code shaped like a checkerboard?

Picture a checkerboard. Put a data qubit at every corner where squares meet. Now put one measure qubit in the middle of every square.

Each measure qubit checks the four data qubits at the corners of its square. Along the outer edge, a few extra half-squares check just two.

Now color the squares like a real checkerboard:

  • The dark squares run one kind of check. They catch bit flips.
  • The light squares run the other kind. They catch phase flips.

Every data qubit touches both colors. So any single error of either kind lights up the squares next to it. A normal computer, called the decoder, looks at which squares lit up. It works out the most likely set of errors that would cause that pattern, and undoes it.

The board as a whole holds one logical qubit. Its information is not stored in any one place. It lives in the pattern of the whole grid. That is why no single error can destroy it.

Why do chip makers like this layout?

Look at who talks to whom. Each measure qubit only talks to the data qubits right next to it. No qubit ever needs to reach across the chip.

That fits a flat chip well. Many superconducting chips, like Willow, have qubits in a square grid, each linked only to near neighbors. The surface code asks for nothing more. See connectivity costs for why far links are expensive.

The surface code is also forgiving. It works as long as the physical error rate stays under a limit called the threshold. For the surface code, that limit is on the order of 1%. Below the threshold, a bigger board means fewer logical errors. Above it, a bigger board makes things worse, because you add more places for errors than you add protection.

What does code distance mean?

The size of the board is called its distance, written d. Distance is the smallest number of errors that could slip past the checks and flip the logical qubit without being caught. A board of distance d can fix up to (d − 1) ÷ 2 errors at once.

Work the numbers:

  • Distance 3: fixes 1 error. The board has 3 × 3 = 9 data qubits and 8 measure qubits, 17 in all.
  • Distance 5: fixes 2 errors. 25 data and 24 measure qubits, 49 in all.
  • Distance 7: fixes 3 errors. 49 data and 48 measure qubits, 97 in all.

The pattern is d × d data qubits, plus one fewer measure qubits. This is arithmetic about the code, not a vendor figure. Notice how fast it grows. Going from distance 3 to distance 7 takes almost six times as many qubits to fix three times as many errors.

Has the surface code worked on real hardware?

Yes, at small sizes. Our record for Google Willow lists these vendor-reported results:

  • Surface codes at distance 3, 5 and 7. Each step up in distance cut the logical error rate by a factor of 2.14. This is called Λ (lambda).
  • A full round of checks every 1.1 microseconds. That is about 909,000 rounds per second.

Why does Λ matter? A value above 1 means the bigger board really does protect better. That is proof the chip is below the threshold. Do the arithmetic: if each step divides the error by 2.14, two steps divide it by 2.14 × 2.14, which is about 4.6.

The speed matters too. The decoder has to read every round and keep up. If it falls behind, errors pile up faster than it can fix them.

There is a long way to go. Willow has 105 physical qubits. A distance-7 board uses 97 of them for one logical qubit. Useful programs need many logical qubits at larger distances. Our page on fault tolerance tracks what has been shown and what is still a plan.

Is the surface code the only option?

No. It is the best-known code, not the only one. Other codes use fewer physical qubits per logical qubit, but often need links between far-apart qubits. That can suit machines where any qubit can reach any other, such as trapped ions or moving neutral atoms. Some designs, like the cat qubits in Alice & Bob Boson 4, try to block one kind of error in the hardware itself.

Which approach wins is an open question. When you read a claim, ask which code was used, at what distance, and whether errors were corrected or only detected.

To build and break codes yourself, take the Errors, Noise and Quantum Error Correction course. Its chapter on the surface code goes one level deeper than this page.

Primary sources & further reading
More from the blog