Skip to article frontmatterSkip to article content
Tutorial

Quantum Repetition Codes

Abstract

The bit-flip and phase-flip quantum repetition codes.

Keywords:qubitsRepetition Codebit-flipsphase errors.

The Quantum Repetition Code comes in two flavours, one protects against bit-flip errors and the other protects against phase-flip errors. As with the classical repetition code, the code works increasing the size of the Hilbert space, allowing logical qubits to be encoded in multiple physical qubits.

The 2-Qubit Bit-flip Repetition Code

This code encodes one logical qubit in two physical qubits and is able to detect a single bit-flip (X)\big(X \big) error.

The code-words of the code are

0L00,   1L11,\ket{0}_{L} \rightarrow \ket{00}, ~~~ \ket{1}_L \rightarrow \ket{11},

such that an arbitrary qubit can be encoded as

ψ=α0+β1encoderψL=α00+β11\begin{align*} \ket{\psi} = \alpha \ket{0} + \beta \ket{1} \xrightarrow{\rm encoder} \ket{\psi}_L = \alpha \ket{00} + \beta \ket{11} \end{align*}

The part of the expanded Hilbert space in which the logical information is encoded is called the code space, given here by

C2=Span{00,11}.\mathfrak{C}_2 = {\rm Span} \{ \ket{00}, \ket{11} \}.

The aim of the code is to detect if an error on the physical qubits have caused the state to leave the code space without disturbing the encoded information.

Consider measuring the following operator on the state,

Z1Z2=(0011)(0011),=000001011010+1111,=Φ00+Φ00++Φ01+Φ01+Φ10+Φ10+Φ11+Φ11+,\begin{align*} Z_1 \otimes Z_2 &= \big( \ket{0}\bra{0} - \ket{1}\bra{1} \big) \otimes \big( \ket{0}\bra{0} - \ket{1}\bra{1} \big), \\ &= \ket{00}\bra{00} - \ket{01}\bra{01} - \ket{10}\bra{10} + \ket{11}\bra{11}, \\ &= \ket{\Phi_{00}^{+}}\bra{\Phi_{00}^{+}} + \ket{\Phi_{01}^{+}}\bra{\Phi_{01}^{+}} - \ket{\Phi_{10}^{+}}\bra{\Phi_{10}^{+}} - \ket{\Phi_{11}^{+}}\bra{\Phi_{11}^{+}}, \end{align*}

where in the final line Z1Z2Z_1 \otimes Z_2 has been written in its eigenbasis, namely the Bell basis 💭.

Firstly, it can be seen that measuring Z1Z2Z_1 \otimes Z_2 on any state supported only within C2\mathfrak{C}_2 always gives a measurement outcome of (+1)(+1) and returns the state unchanged,

(Z1Z2)(α00+β11)=α00+β11.\big(Z_1 \otimes Z_2 \big)\big( \alpha \ket{00} + \beta \ket{11} \big) = \alpha \ket{00} + \beta \ket{11}.

Consider now that an XX-error occurs on the first qubit,

X1ψL=α10+β01,X_1 \ket{\psi}_L = \alpha \ket{10} + \beta \ket{01},

where the notation X1=X1I2X_1 = X_1 \otimes \mathbb{I}_2 has been used. A measurement of Z1Z2Z_1 \otimes Z_2 on this state would give an outcome of (1)(-1). Likewise, if an XX-error occurs on the second qubit,

X2ψL=α01+β10,X_2 \ket{\psi}_L = \alpha \ket{01} + \beta \ket{10},

a measurement of Z1Z2Z_1 \otimes Z_2 would also give an outcome of (1)(-1). If, instead, an XX-error occurs on both qubits,

X1X2ψL=α11+β00,X_1X_2 \ket{\psi}_L = \alpha \ket{11} + \beta \ket{00},

then a measurement of Z1Z2Z_1 \otimes Z_2 would give an outcome of (+1)(+1).

The outcome of measuring Z1Z2Z_1 \otimes Z_2 can therefore be used as a syndrome. If a single XX error occurs, then a measurement of Z1Z2Z_1 \otimes Z_2 is enough to detect that an error has occurred. Although, it is not enough to know if that error occurred on the first or the second qubit as both of these errors lead to the same measurement outcome. Therefore, the error cannot be corrected, only detected, as its location is not known. If, on the other hand, an XX-error has occurred on both qubits, a measurement of Z1Z2Z_1 \otimes Z_2 is not enough to determine if an error has occurred. This is a result of the qubit remaining in C2\mathfrak{C}_2 under an X1X2X_1X_2 error and therefore leading to a measurement result of (+1)(+1). This situation is therefore indistinguishable from no error having occurred.

In addition to not being able to detect a X1X2X_1X_2 error, the 2-qubit bit-flip repetition code is also unable to protect against phase errors (Z\big(Z-errors)\big). For example, consider the error

Z1ψL=α00β11.Z_1 \ket{\psi}_L = \alpha \ket{00} - \beta \ket{11}.

A measurement of Z1Z2Z_1 \otimes Z_2 would give an outcome of (+1)(+1) as this state remains in C2\mathfrak{C}_2. Hence, a Z1Z_1 error is also indistinguishable from no error having occurred and hence cannot be detected using Z1Z2Z_1 \otimes Z_2. The same if true of a Z2Z_2 error.

The 2-qubit bit-flip repetition code is therefore only useful for detecting errors in the set {I,X1,X2}\{\mathbb{I}, X_1, X_2 \}. In summary, and using the notation errorsyndrome{\rm error} \rightarrow {\rm syndrome} (with the eigenvalue +1 mapped to 0 and the eigenvalue -1 mapped to 1), the errors and corresponding syndromes of the code are

I0,X11,X21.\begin{align*} \mathbb{I} &\rightarrow 0, \\ X_1 &\rightarrow 1, \\ X_2 &\rightarrow 1. \end{align*}

Code Distance

To find the code distance of the 2-qubit bit-flip repetition code, one must find the minimum number of physical qubits upon which an error must act in order to change one logical code word to another. When considering XX-errors above, this looks to be 2 as

X1X200=11,   X1X211=00.X_1X_2 \ket{00} = \ket{11}, ~ ~ ~ X_1X_2 \ket{11} = \ket{00}.

However, quantum systems are also susceptible to ZZ-errors. To see the effect of these, consider now the logical basis of the XX operator,

+L=12(00+11),   L=12(0011),\ket{+}_L = \frac{1}{\sqrt{2}} \big( \ket{00} + \ket{11} \big), ~ ~ ~ \ket{-}_L = \frac{1}{\sqrt{2}} \big( \ket{00} - \ket{11} \big),

Any logical qubit can be written in this basis, with +L\ket{+}_L and L\ket{-}_L now being the code words. However, a single ZZ-error can move one between these code words

Zi+L=L,   ZiL=+L     i  {1,2}.Z_i \ket{+}_L = \ket{-}_L, ~ ~ ~ Z_i \ket{-}_L = \ket{+}_L ~ ~ ~ \forall ~ ~ i ~ \in ~ \{1,2\}.

Hence, the code distance is 1, not 2.

Alternatively, the distance of a code is the minimum number of errors that will go undetected. Therefore, from above, one can see that the code distance is 1 as a single ZZ error went undetected due to it not mapping the state outside of C2\mathfrak{C}_2.

The 3-Qubit Bit-flip Repetition Code

The 3-qubit bit-flip repetition code functions very similarly to the 2-qubit version, however, with one logical qubit instead encoded into three physical qubits. As a result, the 3-qubit bit-flip repetition code is able to correct one bit-flip error and detect up to two bit-flip errors.

The code-words of the code are

0L000,   1L111,\ket{0}_{L} \rightarrow \ket{000}, ~~~ \ket{1}_L \rightarrow \ket{111},

such that an arbitrary qubit can be encoded as

ψ=α0+β1encoderψL=α000+β111,\begin{align*} \ket{\psi} = \alpha \ket{0} + \beta \ket{1} \xrightarrow{\rm encoder} \ket{\psi}_L = \alpha \ket{000} + \beta \ket{111}, \end{align*}

with code space then

C3=Span{000,111}.\mathfrak{C}_3 = {\rm Span} \{ \ket{000}, \ket{111} \}.

The following operators are then measured,

Z1Z2I3,I1Z2Z3,\begin{align*} Z_1 \otimes Z_2 \otimes \mathbb{I}_3, \\ \mathbb{I}_1 \otimes Z_2 \otimes Z_3, \end{align*}

where the operators on the 1,21,2 and 2,32,3 qubits respectively are as above in the 2-qubit bit-flip repetition code.

Once again, a measurement of either Z1Z2I3Z_1 \otimes Z_2 \otimes \mathbb{I}_3 or I1Z2Z3\mathbb{I}_1 \otimes Z_2 \otimes Z_3 on any state supported only within C3\mathfrak{C}_3 always gives a measurement outcome of (+1)(+1) and returns the state unchanged,

Z1Z2I(α000+β111)=(α000+β111).\begin{align*} Z_1 \otimes Z_2 \otimes \mathbb{I} \big( \alpha \ket{000} + \beta \ket{111} \big) = \big( \alpha \ket{000} + \beta \ket{111} \big). \end{align*}

Label the measurement outcome of Z1Z2I3Z_1 \otimes Z_2 \otimes \mathbb{I}_3 as λ1\lambda_1 and I1Z2Z3\mathbb{I}_1 \otimes Z_2 \otimes Z_3 as λ1\lambda_1, such that the syndrome is (λ1,λ2)(\lambda_1, \lambda_2). The following error/syndrome relationship can then be shown

I(0,0),X3(0,1),X2(1,1),X1(1,0).\begin{align*} \mathbb{I} &\rightarrow (0,0), \\ X_3 &\rightarrow (0,1), \\ X_2 &\rightarrow (1,1), \\ X_1 &\rightarrow (1,0). \end{align*}

Therefore, if only a single qubit bit-flip occurs, a measurement of these operators is enough to not only detected that an error has occurred, but also uniquely identify where it occurred such that it can be corrected. To correct the error, one just applies XX on the qubit in which they identified the error occurred.

If one also considers the possibility of 2 qubit XX-errors also occurring then the syndromes become non-unique,

X2X3(1,0),X1X3(1,1),X1X2(0,1).\begin{align*} X_2X_3 &\rightarrow (1,0), \\ X_1X_3 &\rightarrow (1,1), \\ X_1X_2 &\rightarrow (0,1). \end{align*}

If a three qubit XX-error occurs, the state remains in C\mathfrak{C}, giving

X1X2X3(0,0),\begin{align*} X_1X_2X_3 &\rightarrow (0,0), \end{align*}

which is indistinguishable from no error having occurred.

The 3-qubit bit-flip repetition code is therefore able to correct errors in the set {I,X1,X2,X3}\{\mathbb{I}, X_1, X_2, X_3\}, it is able to detect errors in the set

{I,X1,X2,X3,X1X2,X1X3,X2X3}.\{\mathbb{I}, X_1, X_2, X_3, X_1X_2, X_1X_3, X_2X_3 \}.