Stabilizer codes
The Shor code took nine-qubit state vectors to write down and a paragraph of reasoning for each kind of error. That does not scale. This lesson introduces the stabilizer formalism, introduced by Daniel Gottesman in the 1990s, in which a code is a short list of operators and a syndrome is found by counting letters. Nearly every code in use today is described this way.
Pauli strings
Section titled “Pauli strings”A Pauli string on qubits is a choice of , , or for each qubit, such as . We drop the and write . The number of letters that are not is the string’s weight.
Two facts about Pauli strings carry the whole subject.
Every Pauli string squares to the identity, so its eigenvalues are and . Measuring one gives one of those two answers.
Any two Pauli strings either commute or anticommute. For single letters you can check directly that , and the same holds for any two different letters among , , . A letter commutes with itself and with . For strings, each position where the letters are different and neither is contributes one factor of . So:
Count the positions where both strings have a non-identity letter and the letters differ. If the count is even the strings commute. If it is odd they anticommute.
For example, and clash in two positions, so they commute, even though and on their own do not. and clash in one position, so they anticommute.
Do and commute?
Position by position: and , no clash. and , clash. and , same letter. and , clash. and , no clash. Two clashes is even, so they commute. Whether two operators commute is a property of the operators and never depends on a state.
Stabilizing a state
Section titled “Stabilizing a state”An operator stabilizes a state if it leaves it alone:
In other words is an eigenstate of with eigenvalue . Some examples:
- stabilizes , and stabilizes .
- stabilizes , and stabilizes .
- and both stabilize the Bell state . The first swaps its two terms. The second gives each term a sign of or .
The Bell state is the only two-qubit state stabilized by both and . So instead of writing out its amplitudes, we can specify it by naming those two operators. That is the central idea: describe states by what leaves them unchanged.
Starting from , prepare the one state that is stabilized by both and . No target is shown: work out what the state must be.
This puzzle needs JavaScript.
Hint
stabilizes a state when gives on it, which means the two bits always differ. swaps and , so both must appear with the same amplitude.
Counting
Section titled “Counting”Each Pauli string, other than the identity, has half of all states in its eigenspace and half in its eigenspace. Requiring a state to be stabilized by one string therefore halves the available dimension. Requiring a second, independent string that commutes with the first halves it again.
On qubits the full space has dimension . With independent commuting strings, what remains has dimension : room for exactly qubits. Two strings on two qubits leave dimension , a single state, as you just found.
The strings must commute with one another, or nothing would be left at all. If and anticommute and both stabilize , then , which forces .
A code is a list of checks
Section titled “A code is a list of checks”A stabilizer code is given by a list of commuting Pauli strings, called its generators. The code space is the set of all states stabilized by every one of them.
The bit-flip code is the smallest example. Its generators are
stabilizes the basis states whose first two bits agree. stabilizes those whose last two agree. Both hold only for and , so the code space is every state . And the counting works: three qubits, two generators, one encoded qubit.
These are exactly the two parities you measured in the first lesson. The generators of a code are its syndrome measurements.
Products of generators stabilize the code space too. Here . The generators together with all their products form the stabilizer group. We only ever need to list, and measure, the generators.
Syndromes without state vectors
Section titled “Syndromes without state vectors”Here is the calculation that makes the formalism useful. Let be in the code space, let be a generator, and let an error , itself a Pauli string, strike. Now measure .
If commutes with :
The damaged state is still a eigenstate. The measurement gives and the generator sees nothing.
If anticommutes with :
The damaged state is a eigenstate. The measurement gives . We say the generator fires.
So the syndrome of an error is simply the list of generators it anticommutes with. No amplitudes are involved. For the bit-flip code and the error , a flip of the middle qubit: it clashes with once and with once, so both fire. That is the syndrome 11 from the table in the first lesson, obtained by looking at letters.
In the bit-flip code, with generators and , what is the syndrome of the error ?
clashes with in the first position, so that generator fires. It does not overlap at all. The syndrome is 10, the same as for : this code cannot tell an from a , because it ignores the that makes the difference.
Measuring any generator
Section titled “Measuring any generator”You have already built circuits that measure and . The general recipe, for any Pauli string, is the kickback circuit from the last lesson:
- put an ancilla in with an ,
- for each letter of the string, apply that letter to its qubit controlled by the ancilla: a CNOT for , a CZ for ,
- apply to the ancilla and measure it.
The ancilla reads 0 if the data is in the eigenspace and 1 if it is in the eigenspace.
Measure the Pauli string on the two data qubits, writing the result on the bottom wire. The data shown, , has and , so and the bottom wire must end in . Your circuit is also tested on five other eigenstates of , two of them entangled.
This puzzle needs JavaScript.
Hint
on the bottom wire, then a CNOT from the bottom wire to the top one, a CZ between the bottom wire and the middle one, and on the bottom wire again.
Try some codes
Section titled “Try some codes”The simulator holds three codes. Choose an error type, click qubits to apply it, and watch which generators fire. A red cell marks a position where the error clashes with a generator. Below the generators are the code’s logical operators, explained in the next section.
This simulator needs JavaScript.
Things to try:
- Bit-flip code. Put an on each qubit in turn and compare with the syndrome table from the first lesson. Then clear it and put a on any qubit. Nothing fires.
- Five-qubit code. Try all fifteen single-qubit errors, , and on each of five qubits. Every one gives a different syndrome. Four generators have possible syndromes: one for “no error” and one for each of the fifteen. Nothing is wasted.
- Two errors. In the five-qubit code, put an on qubit 0 and another on qubit 1. The syndrome looks like that of a single error elsewhere, and the decoder’s guess is wrong.
- A generator as an error. In the five-qubit code, apply , , , to qubits 0 to 3. Nothing fires, and nothing needs to.
The five-qubit code is the smallest code that corrects an arbitrary error on one qubit. No code on four or fewer qubits can do it.
Logical operators and distance
Section titled “Logical operators and distance”Experiment 1 found an error that no generator notices but which is not harmless. Experiment 4 found one that no generator notices and which is harmless. The difference is the last piece of the theory.
A Pauli string that commutes with every generator maps the code space to itself. There are two kinds:
- Products of generators. These stabilize every encoded state, so they do nothing at all.
- Everything else. These move encoded states around inside the code space. They are the logical operators: they act on the encoded qubit the way , and act on a bare one.
For the bit-flip code, swaps and , so it is a logical . And puts a minus sign on , so it is a logical . A logical operator is not unique: multiplying by a generator gives another string with the same action, so , and are logical as well.
Logical operators are exactly what we want when computing on encoded data, and exactly what we fear from noise. An error that is a logical operator cannot be detected, because it fires nothing, and it changes the data.
The distance of a code is the smallest weight of any logical operator: the smallest number of qubits that noise must hit to change the data unnoticed. A code of distance
- detects any error on up to qubits,
- corrects any error on up to qubits.
A code is summarised by three numbers, written : physical qubits, logical qubits, distance .
| Code | Generators | |
|---|---|---|
| Bit-flip code | 2 | |
| Five-qubit code | 4 | |
| Steane code (next lesson) | 6 | |
| Shor code | 8 |
The bit-flip code has distance 1 because the single-qubit string is a logical operator. As a classical code against bit flips alone it has distance 3, but as a quantum code it has a hole.
A code has distance 5. Errors on how many qubits is it guaranteed to correct?
. With three errors, the shortest explanation of the syndrome may be the other two qubits of a weight-five logical operator, and the correction would complete it.
The Shor code, again
Section titled “The Shor code, again”In this notation the nine-qubit code of the last lesson is eight strings:
Everything from that lesson can be read off. A on qubit 4 clashes with both -type strings and nothing else. on qubit 3 and on qubit 5 differ by , which is the product of the third and fourth generators, so they act identically on the code: that was the degeneracy. And nine qubits minus eight generators leaves one logical qubit.
This simulator needs JavaScript.
Things to try:
- Put a on qubit 4. Generators 7 and 8 fire, and nothing else.
- Clear it, then put a on qubit 3 and another on qubit 5. Nothing fires, and the simulator confirms that the pair is a product of generators.
- Put an on qubit 0 and a on qubit 4. The two halves of the syndrome are read separately and both errors are corrected.
One surprise is in the bottom two rows. For this code logical is made of ‘s and logical is made of ‘s. That follows from how it was built: and differ by the signs inside the blocks, so it takes phase flips to swap them.
There is a further payoff. Circuits built only from , and CNOT turn Pauli strings into Pauli strings, so a computer can follow what such a circuit does to a list of generators without ever storing amplitudes. This result, the Gottesman–Knill theorem, is why error-correcting circuits on thousands of qubits can be simulated on a laptop. It is also a reminder that these gates alone cannot give a quantum speedup. The fault tolerance lesson returns to what is missing.
Next: a systematic way of building stabilizer codes from classical ones.
Remember it
Section titled “Remember it”How do you tell whether two Pauli strings commute?
Count the positions where both have a non-identity letter and the letters differ. Even: they commute. Odd: they anticommute.
What is the code space of a stabilizer code?
The set of states left unchanged ( eigenstates) by every generator, where the generators are commuting Pauli strings.
A stabilizer code has qubits and independent generators. How many logical qubits does it hold?
. Each generator halves the dimension of the space.
In a stabilizer code, what is the syndrome of a Pauli error ?
The list of generators that anticommute with . Those are the ones whose measurement gives .
What is a logical operator of a stabilizer code?
A Pauli string that commutes with every generator but is not a product of generators. It changes the encoded state and fires no check.
What is the distance of a code, and how many errors can a distance- code correct?
The smallest weight of a logical operator. It corrects errors on up to qubits.