An introduction to the Steane code
The Steane code is a simple quantum error correction code, that nevertheless has a number of interesting properties.
- The Steane code encodes the state of one logical qubit into the state of 7 physical qubits, in a way that any one qubit error can be corrected.
- By concatenating the code with itself, more errors can be corrected.
- Most gates and operations that we would like to do can be done in fault-tolerant fashion.
- It is a stabilizer code, as well as a CSS code. This is useful because such codes have a well-developed mathematical machinery.
While, it will likely never be used for actual quantum computation, it is a good test bed for both learning about quantum error correction, and possibly to run experiments on NISQ devices. The
Hamming Code
The Steane code is related to the classical error-correcting code, the Hamming code [1]. In the Hamming code, a message of 4 bits is encoded into a block of 7 bits, where the generator matrix There are possible messages, and associated codewords. The codewords have the property that they obey the relation , where the parity check matrix The fact that for all valid codewords can be used to detect and correct errors. Suppose some error occurs and flips some bits of . This operation can be represented as , where is another 7 bit vector. Applying to the corrupted codeword , we obtain the syndrome , which is a length 3 vector. Each entry is a linear combination of the entries of the corrupted codeword, and acts as a check. In particular, there are 8 possible errors that this code can correct - no error, or a single bit-flip on one of the bits. If there is no error, then . Otherwise, as each column of is unique, an with exactly one 1 will be equal to exactly one of these columns. Hence, we can match with the columns of to determine which bit has flipped. Finally we can correct by adding to it.
One important fact to note about the above is that the operation reveals no information about , but only about . While not so important for classical error correction, this feature is required for every quantum error correcting code.
Stabilizer codes
A quantum error correcting code has to protect against not just flip errors, but also phase errors, i.e. the state can be transformed to or , or both. Stabilizer codes do so by encoding the quantum state into a state stabilized by an appropriate Abelian subgroup of the Pauli group . This means for every , the encoded state is a eigenvalue state. We can write this as
Any group can be specified by a set of generators, and such a description is efficient. If a group is Abelian, as is , then generators are sufficient to describe the group. Moreover, we note that for a stabilizer group , if its generators stabilize then so do all members. And if any does not stabilize a state, then at least one generator will not as well. Hence, we can almost entirely work with generators when talking about stabilizer groups and codes.
A given group/code can correct against a specific set of of errors , and their linear combinations. The action of any non-trivial error in is that is no longer stabilized by at least one generator. Hence, to detect errors, we have to check via appropriate measurements which, if any, of the stabilizers don't stabilize a state.
To compute which errors lead to which generator not being stabilized, the rule is that if and only and don't commute will the corrupted state not be stabilized by . To make computation easy, here is a simple rule. Let any operator in be associated with a binary vector of length . This vector has form where is the "$X$ part" and and is the "$Z$ part". Let , where . Then, For example if , then is associated with the vector .
Then and anti-commute iff , and commute iff .
CSS codes
CSS codes are those stabilizer codes, where each generator of either consists of a product of operators, or a product of operators. A very simple CSS code is the repetition code, in which a one qubit state is encoded into a three qubit state, and that can corrects a single bit-flip error on any of the three qubits. The code has the corresponding stabilizer group . You can see that every generator is only a product of operators, so this is a CSS code. We will note the design principle of quantum error correction: a -type generator fails to stabilize a state that has encounted some error. Here if error occurs, then the first stabilizer will fail to stabilize the corrupted state, etc.
Similarly, another design principle is that -type generators will fail to stabilize a state that has encounted a error. This is why the repetition code that corrects a single phase-flip error is associated with the group .
Steane Code
Keeping the above in mind let us now present the Steane code. We are going to encode the state of one qubit into the state of seven qubits. Let's try to design it, using the fact that it is associated with the Hamming code.
First, we need to correct a phase-flip error on any of the seven qubits. There are eight total possibilities here: no phase-flip error, or a phase-flip error on a single qubit. To distinguish between these eight possibilities, we need 3 bits of information. A measurement of a generator can yield one bit of information (either it stabilizes the corrupted state or not). So, we need three -type generators to determine this. For our case, we are going to use the Hamming code to do this. Each row of the parity check matrix, of the Hamming code (which were the checks in the classical case), will define one generator for our code. Each row defines the -part of the length vector associated with each generator (and the -part is zero). Reading off, the generators are Why does this work? Or to ask differently, can we say without doing any calculations involving quantum states or operators, that for each of the 8 possible errors at least one of the generators will trigger? Moreover, will for each of the 8 possible errors a unique set of generators will trigger? The answer to this question is that we already know that in the classical case, each of the 8 errors result in a different syndrome, and the same thing will happen in the quantum case. Why is this? Because if and the error , where has exactly one non-zero entry (corresponding to the single-qubit phase-error), then the commutation relations, can just be written as . This is exactly like the classical syndrome calculation, which we already know yields exactly enough information to determine the error.
Great! Now, what about the bit-flip errors. Well, we will need type errors, and we will construct them from in exactly the same way. We will have, Measuring these on the corrupted codewords will yield information about any bit-flip errors.
Usually, all the generators are written as one matrix, with one row for each generator. For the Steane code, the matrix is
Encoded zero state
To be able to see the code in action, we should construct the encoded basis states Like all encoded states, these states are stabilized by all elements of the stabilizer group, i.e. and similarly for .
We use this property to construct the zero state. More correctly, we will construct one state that is in the code, and designate it as the zero state. To do so, consider the action of, say on . We see that This tell us that is not stabilized by . But, note that So converts between these two states. This tell us that the state is stabilized by (we are going to ignore normalization). Further note that If you think about it a moment, you will realize that acting on any state, constructs a state stabilized by .
With this in mind, we see that is stabilized by both and . Taking the same argument forward, we determine that
Now, we could blindly compute the action of on this state for the -type generators, but instead we think about it for a second. First realize that the rows of the parity-check matrix must be linearly independent (so they generate independent checks), and this means that every pair coincides at exactly an even number of location. This means that in for , there will be an even number of operators coinciding with the s in each component state. For instance, note that because of this even coincidence. Hence, the state is already stabilized by . Consequently, we can arbitrarily start calling the zero state.
In order to construct the state, the easiest way is by using the encoded gate operations.
Encoded Pauli gate operations
The logical single-qubit operations, are quite simple to construct. They are
One can check that these anti-commute . They also commute with every element in Steane code's stabilizer group, but are not in the group itself. Which means that they preserve the codespace but do rotate it.
Clifford gates
The Clifford gates are generated by , and these gates, along with the Pauli gates, are all we need for correcting errors on the physical qubits. The logical and gates are obtained in a transversal fashion, We can check this is correct by verifying their conjugation relations with the Pauli gates.
For the logical gate, we need two logical qubits. Suppose, the first logical qubit is encoded in physical qubits 0-6, and the second logical qubit in physical qubits 7-13. Then, the logical with the first logical qubit as control is as follows.
# https://github.com/abdullahkhalids/stac
import stac
cx_circuit = []
for i in range(7):
cx_circuit.append(['cx', i, 7+i])
stac.draw_circuit(cx_circuit, output='latex', scale=0.7)
Transversality and Fault-Tolerance
One important aspect of the gates discussed above are that they are transversal. To understand this, we will call the qubits that make up one logical qubits, or a set of ancilla brought about to do a single measurement, a code block. Then a transversal operation is one which (1) applies one qubit gates to the qubits in a code block, and (2) only interacts each qubit in a given block with at most one unique qubit in a different code block. You can see that the Clifford gates for the Steane code are all transversal.
This is important for fault tolerance. What is that? A fault-tolerant quantum circuit is one in which, if an error occurs on a single qubit, it doesn't produce more errors in the same block. This ensures our model of errors where we say that all errors occur independently. If an error in a block led to more errors in the same block, those would be correlated errors. Such errors would make it much more difficult to do error-free logical computation.
Encoded one state
The encoded one state is simply
Tomorrow we will start constructing and simulating various circuits related to the Steane code.
[1] J. Preskill, Fault-Tolerant Quantum Computation, (1997).