Haar's Half Measure

What I talk about when I talk about physics.

22 Jul 2023

Kindergarten quantum error correcting codes (P1)

You can think of the notes here are dumbed-down version of Dan Browne’s notes on topological codes and computation

The closest thing to magic we have is perhaps quantum error correction: the idea of knowing enough about a quantum state to be able to know whether a certain event had happened without knowing more so as not to collapse the state – I mean, who wouldn’t be amazed?

A toy example: Classical three-bit repetition code

We will start classically, then we generalize and make it quantum. Let us consider the notorious classical three-bit repetition code. The idea is simple, we encode bits by repeating them, i.e. we’re spreading the information

“the bit is 0”

into three different bits. This is essentially encoding. The logical $0$ is chosen such that three bits sharing the same value $0$, and similarly the logical bit $1$.

\[ \begin{align} 0_L = 000, \quad 1_L = 111 \end{align} \]

Now, what could possibly happen to our logical bit? There can be bit flips. They turn $0$ to $1$ and $1$ to $0$. In general,

\[ \begin{align} 0_L \to 001 / 010 / 100 \newline 1_L \to 011 / 101 / 110 \end{align} \]

Error detection & correction

Alice, who’s a lovely three-year-old error correcting researcher, might ask: so how do we detect these errors. One way is to check individual bits to see if they are identical. If they’re not, then an error happened. Gotcha.

Error detection (3-bit repetition code/classical): Check identicality.

Note that this detection method is only possible if we choose to encode the logical $0$ as $000$; otherwise, this detection method is not possible. See, you can choose whatever encoding scheme to your desire, but in some cases it would not be a good encoding scheme, in the sense that you would not have a straightforward measure of detecting error (or presumably correcting error, as we shall see).

Now, suppose one bit flip error had happened, and we were able to detect it. How do we correct this error? Simple enough: reset all values of the encoded bitstring to the majority value. For example, a bitstring $001$ indicates that a bit-flip error occured, and to correct it we simply reset all bits in the string to the majority value, $0$. So $001 \to 000$, and we have successfully restored the logical $0$.

Error correction (3-bit repetition code/classical): Reset to the majority bit-value.

At this point you should realize there are certain cases where we wouldn’t be able to detect nor correct an error. One such case being have more than one flipping event. For instance, $111 \to 100$. If Alice looks into the identicality of the bitstring, Alice knows an error had happened (detection: checked). But can they correct the error, without knowing that initially it was the logical $1_L$? No, Alice would mistakenly deduces a single bit flip event had happened on the first bit, and eventually erasure the information that

“the bit is 1”

This properties poses a fundamental limit on the effectiveness of a code (or a class of codes), and is characterized by something called code distance. By definition, code distance is

the smallest number of bit flips required to transform any two valid codewords into one another, denoted by $d$.

In our three-bit repetition code, there has to be three single non-repeated bit flip events to transform $000$ to $111$ and vice versa. Hence, three-bit repetition code has distance $d=3$. In general, it means that if Alice looks into the identicality, Alice knows “there’s errors” up to d-1 flipping events, and Alice could possibly succesfully correct $(d-1)/2$ errors at most.

Encoded logical operators

Now that we have some classical information, we would like to do computation with them. Say, apply a logical NOT gate. Simple enough,

\[ \operatorname{NOT} 0_L = 1_L \leftrightarrow \operatorname{NOT}(000) = 111, \]

meaning that we’re applying $\operatorname{NOT}$ on individual bits. Note that a set of encoded logical operators is non-trivially dependent on the choice of encoding scheme. This notion should become even more important as we move into the quantum realm, which we will do now.

Quantum three-bit repetition code

Now we enter the quantum realm, and we bring something along. The idea of three-bit repetition code is nice, so why not quantum three-qubit repetition code!

We define a logical qubit with the computational subspace spanned by

\[ \begin{align} |0\rangle_L = |000\rangle; |1\rangle_L = |111\rangle \end{align} \]

such that the state of the qubit is

\[ \begin{align} |\psi\rangle = \alpha |0\rangle_L + \beta|1\rangle_L \end{align} \]

meaning that we’ve spreaded the information

“the (logical) qubit is in state $|0\rangle$”

into three physical qubits.

The computational subspace $\{|000\rangle,|111\rangle\}$ is also called the codespace, reside in which are the error-free encoding of the quantum state $|\psi\rangle$.

Now, what could possiblly happen to our physical qubit? There can sure be bit flips, but there are also phase flips. The errors are

\[ \begin{align} X|0\rangle = |1\rangle\quad & X|1\rangle = |0\rangle\newline Z|0\rangle = |0\rangle \quad & Z|1\rangle=-|1\rangle \end{align} \]

Here’s a remark

If both $X$ and $Z$ errors can be corrected, then any arbitrary error can be corrected, since together $X$ and $Z$ allows universal control over the Hilbert space of any physical qubit. So, the problem boils down to detecting these two errors, and correcting them.

Before we get into the cleverness of QEC, let us look at the encoded state in the event of a single bit flip error for completeness. For example, the error is $I\otimes X\otimes I$, then the state reads

\[ \begin{align} (I\otimes X\otimes I) |\psi\rangle_L = \alpha |010\rangle + \beta|101\rangle \end{align} \]

The state is now not in the codespace, which means there’s an error. But here’s where it gets tricky (and exciting and the same time). Alice thought to herself, “so to detect an error we, again, look at the identicality of the three physical qubits.” Not so easy, because in doing so, we’d eventually collapse the state into one of its basis states. We lose the information. Alice might also consider to copy the state $|\psi\rangle_L$ into multiple copies, but in doing so she would violate the no-clone theorem, so that’s also a no.

The tricky part is to learn enough about the state of the physical qubits, so that we know whether errors had occured, what errors, and the way to correct them; but not learning more than enough

Error detection & correction

As discussed, we cannot measure individual qubits in the computational basis. Instead, we measure a certain symmetry properties of the state.

For example, one characteristic properties of the state of a logical qubit $|\psi\rangle_L$ encoded on two physical qubits is the parity of the physical pair. Alice cannot ask the question whether the two qubits are both in state $|0\rangle$. I mean she can ask the question inside her head, but then the act of measurement $\langle Z_1\rangle$ and $\langle Z_2 \rangle$ would destroy the state.

However, she can interrogate

Is your parity odd or even?

Meaning that she’d have to measure $ZZ$.

Turns out quantum mechanics allow this question to be made without projecting the state of the two qubits into their respective computational subspaces. And also state-of-the-art experiments have already demonstrate the ability to measure state parity, so it’s pretty exciting.

(In another closely related topic, one might ask if they have generated a genuine superposition of three qubits in the sense that $|\psi\rangle = |000\rangle + e^{i\phi}|111\rangle$. Turns out parity check is also very useful, see Steane’s blog here.)

Now, let us explore further the idea of measuring the parity of a pair of qubits. Let us suppose exactly one erroneous flipping event might happened, i.e. the error operators are possibly $X\otimes I\otimes I, I\otimes X\otimes I, I\otimes I\otimes X$. Our job is to detect “whether this had happened” by performing a parity check. Here’s the table that list all possible measurement outcome.

Error\Observable $Z\otimes Z\otimes I$ $Z\otimes I \otimes Z$ $I\otimes Z \otimes I$
$X \otimes I\otimes I$ $-1$ $-1$ $+1$
$I \otimes X\otimes I$ $-1$ $+1$ $-1$
$I \otimes I\otimes X$ $+1$ $-1$ $-1$

That is because, for any pair of qubits the observable $ZZ$ is $+1$ if and only if the parity is even, i.e. the logical qubit is inside the codespace, and $-1$ is the parity is odd, i.e. the logical qubit is outside the codespace.

What can we deduce from the table? Here’s the take-away remark

If the error anti-commutes with the measuring operator, then the outcome is surely $-1$.

Suppose Alice has 3 qubits, $|q_1q_2q_3\rangle$ and she measures $\langle ZZI \rangle=+1$. What does it mean? No error, or something happened with the third qubit, but that’s not certain. What if she measured $\langle ZZI \rangle =-1$? Then she knows something’s off with the first two qubits. But she wouldn’t know which is the erroneous one, b.c either $X \otimes I\otimes I$ or $I \otimes X\otimes I$ might have happened.

She would have to measure another $ZZ$. In fact, any $Z_iZ_J$ other than $Z_1Z_2$. Say this time she measures the first one and the third one, i.e. $\langle Z_1Z_3\rangle=-1$, then she would be able to conclude that the error operator is $I\otimes X \otimes I$ (see the table). You see, the set of observables has to be cleverly chosen so that one can perform error check in a resource-efficient way.

Now that Alice knew what kind of error has happened, can she resets all the qubits to the majority value? No, because that will require the knowledge of “what’s the majority value”, i.e. collapsing the information. However, as opposed to classcial error correction, where we know “yes, there’s a certain error”, in the quantum case we know “what specific error has happened”. This is extra, and we can use this extra information: the bit-flip $X$ errors are Pauli errors, meaning that they can be reversed by applying the same Pauli operator. This is because

All Paulis are self-inverse.

Hence, all we need to do is applying the same error operator on the logical qubit to correct the error.

Logical operators*

Within a certain frame of encoding came with a set of logical operations on the encoded states. In our case, quantum three-qubit repetition code, we want logical $\bar{X}$ and $\bar{Z}$ such that

\[ \begin{align} \bar{X}|0\rangle_L = |1\rangle_L, \quad &\bar{X}|1\rangle_L = |0\rangle_L\newline \bar{Z}|0\rangle_L = |0\rangle_L, \quad &\bar{Z}|1\rangle_L = -|1\rangle_L \end{align} \]

One possible choice of $\bar{X}$ and $\bar{Z}$ could be

\[ \begin{align} \bar{X} = XXX,\quad \bar{Z}=ZII \end{align} \]

Notice that we can have an odd number of physical $Z$ gates, but not even.

Code distance

Now we familiarize ourselves with the notion of the distance of a quantum code. But first, the concept the weight of an operator: it’s the number of qubits that the operator acts non-trivially on. So for example, $\bar{X}=XXX$ is weighted 3, while $\bar{Z}=ZII$ is weighted 1. Then, we have the definition of the distance.

Distance of a (quantum) code: the minimal weight of any (non-identity) encoded logical operator comes with the code.

So, for three-qubit repetition code, the minimal weight is $\bar{Z}$, hence three-qubit rep. code has a distance of 1.

If you think about it, we have good reasons to define something like the distance. The concept is closely related to the Hamming distance, but I won’t get into details about it here. Just to make it more clear, if an error (an operator) has the weight less than the code’s distance, then it would take the logical qubit out of codespace and we’d be able to detect it; however, if the error’s weight is equal to the distance, then essentially what’s happened is that we’ve moved from one codeword (a valid bitstring) to another, i.e. we wouldn’t be able to detect it, even though it happened.

Here’s another remark

the quantum three-qubit repetition code can detect 2 $X$ error and no $Z$ error.

Sure. This is because any two $X$ error has weight less than the code distance (and three errors make it a valid logical operator); and $Z$ errors are undetectable within our encoding scheme.

Stabilizer formalism

There’s a thing called “stabilizer formalism” allowing one to study quantum error correcting codes in a systematic way (classification of distance, kinds of errors the code can shield, etc.). Also, it can also be used to derive encoded logical operators (which is important!).

Any code that can be defined in the stabilizer formalism is called a stabilizer code. A stabilizer code is defined by specifying two sets of operators,

  1. (Stabilizer) generators; and
  2. Encoded logical operators

First, let us talk about the stabilizer group. Let $\{|\psi_j\rangle\}_j$ the codeword basis states ($j^\otimes$-dimensional Hilbert space). Then the stabilizer group $\mathcal{S}$ is the set of Pauli operators that leave all codeword basis states $|\psi_j\rangle$ invariant.

\[ \begin{align} P_k|\psi_j\rangle = |\psi_j\rangle, \forall P_k\in \mathcal{S} \end{align} \]

One would realize that the set of stabilizer must commute, in order for them to leave the codeword basis state invariant. Here’s a quick proof by contradiction. Suppose that two stabilizer operators (they are Pauli) don’t commute, then

\[ \begin{align} S_1S_2 = -S_2S_1 \end{align} \]

which leads to

\[ \begin{align} S_1S_2|\psi_j\rangle = |\psi_j\rangle \newline S_2S_1|\psi_j\rangle = -S_1S_2|\psi_j\rangle = -|\psi_j\rangle \end{align} \]

however, since $S_2S_1\in \mathcal{S}$ group, then it must be that $S_2S_1|\psi_j\rangle = |\psi_j\rangle$, which is a contraction. Hence, any two operators within a stabilizer group $\mathcal{S}$ must commute.

In group theory, a group $G$ is defined using a set of generators $\{g_j\}^{m}_{j=1}$. The set order, denoted by $|G|$, is specified by the number $2^m$.

There’s a useful result that links the number of logical qubits $k$, physical qubits $n$, and the number of stabilizer generators needed to generate the stabilizer group, which states that

\[ \begin{align} n-m=k \end{align} \]

Below is a loudsy proof of the statement.

! I haven’t figured out yet :).

For three-qubit repetition code, $k=1, n=3$, and hence we need $3-1=2$ generators. Where can we look for them: the Pauli group. Can we choose $X$ and $Z$ as generators? No, because they don’t commute at all ($XZ=-ZX$ anyway) so they cannot stabilize our codeword states. It turns out that we can choose $I$ and $Z$, then multiply them out to $2^2=4$ (the order of the group).

\[ \begin{align} ZZI, ZIZ, IZZ, III \end{align} \]

We’ve seen a hint of using these operators to detect errors (specifically bit-flip errors) above. By measuring the group of $m$ ($m$ measurements) stabilizer operators, one can detect errors on stabilizer codes. Since $m=n-k$, the number of measurements one have to make scales linearly with the number of physical qubits used for the encoding scheme, which is moderately great.

Encoded logical operators

We’ve known that $\bar{X}=XXX$: there’s no other choice for logical $\bar{X}$ for quantum three-qubit repetition code. However, there exists two more choices of $\bar{Z}$,

\[ \begin{align} \bar{Z}= \{ZII, IZI, IIZ, ZZZ\} \end{align} \]

Using the stabilizer formalism, one can actually characterize this set of $\bar{Z}$. First let us see the reason why we have this equivalency. Let $\mathcal{S}$ be the stabilizer group, $|\psi\rangle$ be a state in the codespace, $L$ be a logical operator. Then essentially all logical operators are different up to a stabilizer,

\[ \begin{align} S_j|\psi\rangle &= |\psi\rangle,\newline LS_j|\psi\rangle &= L|\psi\rangle \end{align} \]

so essentially what you can have is $ZII S_j$ being equivalent to $ZII$, for any $S_j\in\mathcal{S}$, e.g. $(Z\otimes I\otimes I)(Z\otimes Z\otimes I)=(Z^2\otimes Z\otimes I$), and because Pauli are self-inverse, $Z^2=I$, and we obtain $I\otimes Z\otimes I$.

To conclude the subsection, here’s the takeaway message

Given a logical operator $L$, there exists a family of $|S|=2^m$ operators $\{LS_j\}_j$ that acts equivalently on the codespace.

So I promised you that you can look for the encoded logical operators in a systematic fashion. Here’s why. It turns out earlier that in order for an operator to become the encoded logical operator $L$, it has to commute with the (entire) stabilizer group $\mathcal{S}$,

\[ \begin{align} [L,S_j] = 0, \forall S_j \in \mathcal{S} \end{align} \]

Note that we’re looking at the Pauli group $G$ (for $n$-qubits). The stabilizer $\mathcal{S}$ is a subgroup of $G$. In group theory, the set of operators in $G$ that commute with every element $S_j\in\mathcal{S}$ is the centralizer $C_G(H)$ of $\mathcal{S}$.

\[ \begin{align} C_G(H) = \{C\in G\ |\ \forall S_j\in\mathcal{S}, CS_j=S_jC\} \end{align} \]

So basically what we have to do to find the encoded logical operators is to look at the centralizer of $\mathcal{S}$.

Lastly, to wrap up the entire section, we list out the stabilizer $\mathcal{S}$ and the centralizer of $C_G(\mathcal{S})$ for three-qubit repetition code.

\[ \begin{align} \mathcal{S} = \{&ZZI, ZIZ, IZZ, III\}\newline \mathcal{C}_G(\mathcal{S}) = \{&III, ZZI, ZIZ, IZZ\newline &XXX, -YYX, -YXY, -XYY\newline &YXX, XYX, XXY, -YYY\newline &ZII, IZI, IIZ, ZZZ\} \end{align} \]

So I said that there’s only one possible choice for $\bar{X}=XXX$, but I was wrong. Note that every logical operators are different up to a stabilizer $S_j$, we can construct a set of equivalent encoded logical operators for $\bar{X}$, starting from $XXX$; they are

\[ \begin{align} \bar{X} = \{XXX, -YYX, -YXY, -XYY\} \end{align} \]

in accordance to the fact that there are $2^2$ equivalent encoded logical operators.

Toric code

Discovered by Kitaev in 1997, toric codes are designed to protect a quantum circuits whose qubits are placed on a lattice, which wrapped on a, you guess, torus. Each edge of the lattice is a qubit.

Now what do you mean by a periodic boundary condition? Let us first imagine a circle, for any function $f$ defined on the circle it follows that

\[ f(\theta)=f(\theta+2\pi) \]

so the function repeats itself. Now imagine a torus (or a donut 😋), you cut it at one cross section, then you have a two-dimensional surface. This two-dimensional surface is the lattice we’re talking about. Because the lattice is wrapped on the torus, it follows that even though we’re having a $L\times L$ lattice, there’s only $2L^2$ edges since the lower (right) gray edges are being glued to the upper (left) edges. Because each edge is a qubit, the toric code has therefore $n=2L^2$ physical qubits.

As we seen above, to find the stabilizer group for a code, we need to define a set of generators. For toric code, the two generators are plaquette generator and vertex generator. Since we have two generators, it follows that the order of the group $\mathcal{S}$ is 4.

Now, as the name suggests, the plaquette generator is a tensor product of operators associate with a plaquette. Operators on what, you might ask? The qubits. Remember that one qubit represents one edge, hence the four qubits enclosing one plaquette $P$ are the ones that being applied. Let $Z_S$ be the operator applying on one qubit, the plaquette generator is

\[ \begin{align} \bigotimes_{S\in P} Z_S \end{align} \]

Similarly, the vertex generator is a tensor product of operators associate with a vertex. Operators on what, you might ask? The qubits. The four qubits joining in to make a vertex are the ones being applied. Let $X_S$ be the operator applying on one qubit, the vertex operator is

\[ \begin{align} \bigotimes_{S\in V} X_S \end{align} \]

One might try and see if the vertex operators and plaquette operators commute. They do, indeed, since they are stablizers. If the two vertex & plaquette don’t overlap on the lattice, then it’s trivial to see that the order of operation is irrelevant. If the two vertex & plaquette do overlap, say on qubits $q_i$ and $q_j$, then

\[ \begin{align} (X_i\otimes X_j)(Z_i\otimes Z_j)|q_i q_j\rangle&=(X_iZ_i)|q_i\rangle\otimes (X_jZ_j)|q_j\rangle\newline &=-Z_iX_i|q_i\rangle \otimes -Z_jX_j|q_j\rangle\newline &= (Z_i\otimes Z_j)(X_i\otimes X_j)|q_iq_j\rangle \end{align} \]

i.e. $[X_iX_j, Z_iZ_j]=0$.

Plaquette operators

Let us now consider two adjacent plaquette operators. Question: what are the qubits being applied if we multiply these adjacent operators together? It’s the qubits lying on the joint boundary of the two plaquettes. Those who lie on the shared boundary will not be affected, since $Z^=I$. The resulting operator will apply on 6 qubits.

More generally, for any two plaquettes, if we multiply them together will result in (1) the cancellation of $Z$’s at the shared boundary and (2) $Z$’s around the overall boundary. The plaquettes are not necessarily square plaquettes. You can start by a square one, then joining them repeatedly to generate a arbitrarily shaped plaquettes, and the arguments above still hold.

Lastly, consider the product of all plaquettes in the entire lattice. Because we’re wrapping the lattice around a torus, there’s no boundary at all. No qubit is being applied a $Z$. Hence, the resulting operator is a one big identity operator,

\[ \begin{align} \prod_{P}^{L^2}\bigotimes_{S\in P}Z_S = I \end{align} \]

What does it mean? It means that the set of all plaquette operators is not an independent set of operators.

Note: An independent set of operators means that any operator in the set cannot be expressed as a product of others, i.e. the only solution to $\prod g_j^{a_j}=I$ is $a_j=0, \forall j$. This concept is strongly analogous to linearly independent, where any vector cannot be a linear combination of the others if they want to form a orthogonal basis.

A stabilizer group cannot be generated from dependent generators, so this is bad. One solution is that we remove one (whatever it is) single plaquette operator from the generator set. Now, if we were to take the product of all plaquette operators on the lattice again, but leaving one single plaquette operator out of the picture, then the product cannot be identity

\[ \begin{align} \prod_{P}^{L^2-1}\bigotimes_{S\in P}Z_S \neq I \end{align} \]

In conclusion, by leaving one single plaquette operator behind, we have $L^2-1$ independent plaquette operators (by definition of independent operators).

Dual lattice

Another concept we know know about is dual lattice. To create a dual lattice from our primal lattice, we shift the primal lattice by half a cell down to the right. The new dual lattice has the same size and same boundary conditions, only that the plaquette are now vertex, and vertex are now plaquette (in terms of the qubits they act on). Because of this, any set of four qubits are being acted on by simultenously a plaquette/vertex operator in one lattice and vertex/plaquette operator in the dual lattice. You can thus imagine a 90 degree rotation of any edges as the mapping function between the primal & dual lattice. The two lattices are therefore perpendicular.

A square lattice under such transformation is still square lattice, and we say it is self-dual. On the other hand, the dual lattice of a hexagonal lattice is a triangular lattice.

We have several good reasons to explore duality of lattice. For instance, multiplication of operators is best understood in the plaquette picture, since all we doing is just dismissing shared boundaries and promoting joint boundaries.

Vertex operators

Using lattice duality, the vertex operators in a primal lattice can be defined as the boundary of the corresponding plaquette in its the dual lattice. By the same arguments, we have $L^2-1$ independent elements in the set of generators.

\[ \begin{align} \prod_{V}^{L^2-1}\bigotimes_{S\in V} X_V \neq I \end{align} \]

Logical qubits

We have $n=2L^2$ physical qubits on the torus, $L^2-1$ independent plaquette operators and $L^2-1$ independent vertex operators, meaning a total of $k=2(L^2-1)$ generators. It then follows that toric code will have $n-k=2L^2-2L^2+2=2$ encoded logical qubits. Since we have two logical qubits, to complete the code description we find their corresponding encoded logical operators $\mathcal{L}=\{\bar{Z}_1,\bar{Z}_2, \bar{X}_1, \bar{X}_2\}$.

First let us remind ourselves with some of the criteria that any $L\in\mathcal{L}$ must satisfy

  1. They must commute with all elements of the stablizer group $\mathcal{S}$;
  2. They must not be an element of $\mathcal{S}$ themselves;
  3. They must satisfy the commutation and anti-commutation properties of $X$ and $Z$.

Let us choose a seemingly arbitrary operator, a $Z$ operator acting on a single qubit (edge). This $Z$ commute with all plaquette operators, sure, $Z^2=1$. But then what about vertex operators? All vertex operators except those immediately neighboring the edge must commute with the $Z$ because they act on different qubits, but those two vertex immediately adjacenting the qubit don’t commute with the single $ZS.

How about going one for more? Let us consider a pair of adjacent $Z$’s. Then the two $Z$’s commute with the one in between them (because of the two minus signs). Say that’s the right vertex operator, but then what about the left? They don’t. So that’s still not enough. More generally, if we form a string of $Z$ operators, regardless of its shape, there will be one vertex operator at the ends (either left or right) that the string of $Z$ don’t commute with that one.

A clever way to get over this problem is that you take the right vertex and glue to the left vertex, to form a closed loop of $Z$’s! Indeed, then we can define an encoded logical $\bar{Z}$ operator that acts on a sequence of edges on the lattice! Let us call this one the $\bar{Z}_1$ operator for the first qubit.

A side note: Such a loop for $\bar{Z}_1$ cannot be created by a product of plaquette operators. Think about it, you have one loop of plaquettes, then the product of them yield two loops of $Z$’s. That’s not one loop of $\bar{Z}$. You may extend the loop of plaquettes, but eventually they will meet because of the periodic boundary, which make them an identity.

We now proceed to define $\bar{X}_1$, who must satisfy

  1. $[\bar{X}_1, \bar{Z}_1]\neq 0$;
  2. $[\bar{X}_1, S]=0,\forall S\in\mathcal{S}$.

To find such operator, consider a loop of $X$ operators on the dual lattice, perpendicular to the loop defining $Z_1$. This operator must commute with all stabilizer elements, by the same argument one can have with the logical $Z$ operator: Any four qubits associated with a plaquette that overlap with the $X$ line will have exactly two qubits who will yield two minus signs, making them commuting; and vertex operators commute with the loop of $X$’s by definition. Although we are having these arguments on the dual lattice, we can always transform back to the primal lattice, making the vertices plaquettes, and vice versa.

It’s also easy to see that $\bar{X}_1$ does not commute with $\bar{Z}_1$, since they overlap on exactly one qubit, resulting in only one minus sign.

We now turn to the second encoded qubit. Again, we seek a pair of $\bar{X}_2$ and $\bar{Z}_2$ which commute with the stablizers and anticommute with each other. It’s quite easy to guess: if we rotate the loops corresponding to $\bar{Z}_1$ and $\bar{X}_1$ 90 degrees, we obtain two new operators which

  1. commute with $\bar{Z}_1$ and $\bar{X}_1$ (because the four operators don’t overlap on any physical qubits);
  2. commute with the plaquettes and vertices (because of the same arguments made above–$Z$’s commute with themselves and there are two minus signs for $XZ$);
  3. anticommute with each other (because they share only one physical qubit, and $XZ=-ZX$).

The set of $\mathcal{L}$ described above is not unique, as explored in the three-qubit repetition code case. One can always multiply a $L\in\mathcal{L}$ with a stabilizer $S\in\mathcal{S}$ to get a new, equivalent encoded logical operator.

Notice that the logical operators and stabilizer generators all consist solely of $Z$’s and $X$’s. This means in analyzing the equivalency we’re can make use of the fact that Pauli are self-inverse extensively.

For example, the logical $\bar{Z}$ can be multiply with a (collection) plaquette to form a new logical operator, which can be thought of as an act of deforming the loop wrapped around the torus. Although the loop is diverted from its original path, the overall properties holds.

Similarly, the logical $\bar{X}$ are defined on the dual lattice. What’s a vertex operator in the primal lattice, due to duality, is a plaquette operator in the dual lattice. The loop for $X$’s is then also diverted from the original path, but the overall properties holds.

Code distace

The code distance equals to the minimum weight of a encoded logical operator in the code. It’s easy to see that the four loops we defined above acting on $L$ physical qubits, hence the code distance $d=L$. In summary, the toric code is denoted as $[[2L^2, 2, L]]$.

In retrospect, one would like to increase the size of the lattice as much as possible, since the larger the code distance, the more likely an error being detected. But there’s a limit which we can stop without adding too much redundancy, as we will see later. This limit is called the error correction threshold.

Errors on the toric code

Error detection

An error operator $E$ is a $n$-qubit Pauli operators, so $E=\{X^\otimes, Y^\otimes, Z^\otimes\}$. We’ve also established the fact that to detect whether an error has happened, we measure the stablizers. If we get $+1$, then no error has occurred, otherwise we get $-1$, meaning that an error has occurred. The output of the stablizer measurements, which is a bitstring, is the error syndrome.

Notice that the quantum three-repetition code cannot detect the $Z$ error. Toric code can, which is really nice.

Let us first consider a $E_Z=Z$ error on a single qubit. To detect such error, we must find a stablizer that anticommute with $E_Z$. Remember that we have two kinds of stabilizer operator, the vertices and plaquettes. Plaquettes are $Z$’s, and hence they commute with $E_Z$, hence they cannot detect $E_Z$. Vertex operators on the other hand who adjoin the edge on both sides anticommute with the error. Hence, to detect a single phase flip event on toric code, we measure the output values of two adjacent vertex stabilizers.

This idea can be extended to multiple $Z$ errors. First let us consider two $Z$ errors on adjacent qubits. The vertex operator between the two qubits is now commuting with the error $E_Z\otimes E_Z$. We must therefore move to measuring the vertices that adjoin the two ends of the overall edge.

In general, given any string of $Z$ errors on the primal lattice, the only stablizer generators that will detect the errors are the vertices at the two ends of the string. Notice that if the errors occured on $L$ qubits, then the two vertex operators basically will be identified as one, therefore the errors and the vertex commute, making the errors undetectable. This is in agreement with the fact that toric code’s distance is $L$.

Detection of $X$ errors are carried in the same manner. Strings of $X$ errors on the dual lattice results in $-1$ outcomes on the plaquette operators adjoin the string on two ends in the dual lattice. Converting this back to the primal lattice, we’re measuring the plaquettes.

Since $X$ and $Z$ are the generators of Pauli group, and since two classes of errors independently affect different types of stabilizer measurements, we can consider them as two seperate error correting processes. Any insights that we have on one type of error will hold true in the dual lattice of the other error. So, we can focus on one kind of error correction and later we convert it to the dual lattice to complete the description of error correction on toric code.

Error correction

To correct Pauli errors, we reapply Pauli operators. This is straightfoward. The problem lies in where to apply the Paulis, given a certain syndrome.

There’s a concept of degeneracy in error syndrome. It means that for a given syndrome, there is a certain degree of degeneracy associated with that syndrome, such that the syndrome would indicate faulty conclusion regarding the exact error processes that occurred. In other words, multiple error processes can exhibit the same syndrome. This follows from the fact that two errors $E$ and $E’$ might be different up to any operator $L$, i.e. $E=E’L$, where $L$ is any operator that commute with the stabilizer.

This might sound a bit formal. Let us consider two strings of error that ending at the same vertex operators $V_1$, $V_2$. These two error strings result in the same syndrome $-1,-1$. Suppose Alice concludes $E’$ happened, even though $E$ happened, and applies $E’$, the resulting operator on the physical qubits is

\[ \begin{align} E’E = E’E’L = L \end{align} \]

which, if $L$ is in the stabilizer (stabilizers commute with themselves) would leave the code words invariant. Hence, in this case ($L\in\mathcal{S}$), applying $E’$ would correct $E$.

However, $L$ can be a encoded logical operator, which also commute with $\mathcal{S}$. In this case, the errors can be $E\bar{Z}_1, E\bar{Z}_2, E\bar{Z}_1\bar{Z}_2$, which all lead to the same error syndromes.

Next time, we'll talk about "10 ways how quantum computing will solve climate change."