Skip to content

Decoding

A quantum error-correcting code produces syndromes. It does not say what to do about them. Something has to look at the pattern of fired checks and decide on a correction, and that something is an ordinary classical program called a decoder. This last lesson is about the decoder’s problem, and it starts by handing the problem to you.

A syndrome does not identify an error. Many different errors fire the same checks: on the surface code, a single flip and a chain of four flips that ends in the same place look identical. The decoder sees only the syndrome and must commit to one correction.

It helps that the decoder does not need to find the true error. Call the true error EE and the decoder’s correction CC. After the correction, what remains on the data is the product CECE. Since CC was chosen to silence every check, CECE fires nothing, and by the stabilizer lesson there are only two possibilities:

  • CECE is a product of generators. It does nothing to the encoded state. Success, even if CC and EE look quite different.
  • CECE is a logical operator. The encoded qubit has been changed and no check will ever notice. Failure.

So the errors that share a syndrome fall into a few classes, and the decoder’s real task is to guess the right class.

Check

A decoder’s correction differs from the true error by a product of two checks. Did it succeed?

For a small code the decoder can be a table. The five-qubit code has four generators and so 16 syndromes, and each was matched to its error in the stabilizer lesson. The Steane code has 64.

The approach dies quickly. A surface code of distance dd has d2−1d^2 - 1 checks and therefore 2d2−12^{d^2-1} possible syndromes. At d=5d = 5 that is about seventeen million. At d=11d = 11 it is more than 103610^{36}. No table will do. The decoder must compute its answer from the structure of the code.

If errors strike qubits independently, each with a small probability pp, then a particular pattern of ww errors has probability proportional to (p/(1−p))w(p/(1-p))^w. Fewer errors are likelier. A natural rule, then:

Among all errors that would produce this syndrome, choose one with the fewest flips.

This is minimum-weight decoding. For the surface code it has a pleasing geometric form. Recall that the checks see only the endpoints of chains of errors, and that a chain may also end invisibly on an edge of the patch. So a syndrome is a scatter of points, and explaining it means joining the points up: each fired check is connected by a chain either to another fired check or to an edge. The smallest explanation is the way of pairing them that uses the least total chain.

Pairing up points at the least total cost is a classic problem called minimum-weight perfect matching, and an efficient algorithm for it has been known since the 1960s. That is the workhorse decoder for the surface code.

Below, XX errors have struck a surface code patch at random. You cannot see them. You can see which Z checks are firing. Click data qubits to flip them, and make every check go quiet. Then find out whether you chose the right class. Your record is kept next to that of a matching decoder working from the same syndromes.

GameYou are the decoder

This simulator needs JavaScript.

Things to try:

  1. Play several rounds at d=3d = 3. A single firing check, with no partner, usually means one flip on a qubit next to it in the top or bottom row.
  2. Switch to d=5d = 5. Now pairs of firing checks appear, and you must decide whether two belong to one chain or to two separate chains that each run off an edge.
  3. When you win, press the button to see the matching decoder’s flips. They are often different from yours, and from the real errors, and equally good.
  4. Raise the error rate to 15% or more. Notice how often the syndrome has two reasonable explanations, and how often both you and the matching decoder lose.

Only XX errors and Z checks appear in this game. A real decoder plays the mirror-image game for ZZ errors and X checks at the same time.

Sometimes the true error is not the likeliest one. If errors cover more than half of a path across the patch, the shortest explanation of the syndrome is the other part of the path, and the minimum-weight correction completes a logical operator. No decoder can avoid this. The syndrome simply does not contain the information.

What a bigger code buys is that such unlucky patterns need more errors: at least (d+1)/2(d+1)/2 of them in a line. Below threshold, each extra error is a further factor of improbability, and that is the exponential suppression of the last lesson.

The game above is the easy version. Real decoding differs in three ways.

The syndrome lies. Measuring a check is a physical operation and can give the wrong answer. A single reading cannot be trusted, so the checks are measured round after round and the decoder looks for changes between rounds. A data error makes a check change and stay changed. A faulty measurement makes it change and then change back. The points to be paired up now live in three dimensions, two of space and one of time, and a measurement error appears as a pair of points separated in time. The matching idea carries over unchanged. The graph just gets bigger.

Check

One check reports 1 in round 5 and 0 in every other round. All other checks report 0 throughout. What is the likeliest explanation?

It must be fast. On superconducting hardware a new round of syndromes arrives about every microsecond. A decoder that falls behind never catches up: the backlog grows, and any logical gate that depends on the decoder’s answer has to wait. So decoders are judged on speed as much as accuracy, and are often built into dedicated hardware. Decoding a running surface code in real time has been demonstrated at small distances. Doing it at the scale of a useful computer is still an open engineering problem.

Matching is not optimal. It handles XX and ZZ errors separately, so it misses the fact that a YY error produces both kinds of syndrome at once. And it looks for the single likeliest error, when what matters is the likeliest class: a class containing many moderately likely errors can outweigh one containing a single likely error. Other decoders make different trades:

  • Union-find decoders grow clusters around fired checks until they merge. They are faster than matching and slightly less accurate.
  • Maximum-likelihood decoders add up whole classes of errors. They are the most accurate and far too slow for large codes.
  • Belief-propagation decoders, borrowed from classical coding theory, suit the quantum LDPC codes mentioned in the surface code lesson.
  • Neural-network decoders are trained on syndrome data, including data from real devices, and have matched or beaten matching for accuracy in published tests. Their speed at scale is the open question.

You started with three qubits and a majority vote that seemed impossible to carry out. Since then:

  • the repetition code showed how to find an error without looking at the data,
  • the Shor code showed that correcting bit flips and phase flips is enough to correct everything,
  • stabilizers reduced a code to a list of commuting checks,
  • CSS codes built those checks from classical codes,
  • the surface code made them local and scalable,
  • fault tolerance showed that faulty parts can still add up to a reliable whole, below a threshold,
  • and decoding closed the loop from syndrome back to correction.

This is the machinery behind every proposal for a large quantum computer. Much of it is still being improved: codes that need fewer qubits, cheaper ways to perform the hard gates, and decoders that are faster and more accurate. The other tracks say what such a machine would be used for. Quantum Algorithms is the natural next step.

RecallAnswer from memory, then check
LessonFinish this lesson