From the Steane syndrome extraction of quantum error correcting code, we use ancilla qubit prepared in logical X/Z basis to detect logical Z/X errors in the logical data state (The CNOT is transversal).

Every material tell me that it works because X errors will propogate to the left part of ancilla and Z errors will propogate to the right part. However, I'm confused how the measurement works. For example in the left part, even there is no error (Or applying a stabilizer), measuring logical + at Z basis will cause uncertain results, and X error just make thing more complex. Can somebody explain how the measure work and why it can get the syndrome?

enter image description here

  • $\begingroup$ Where did you get this circuit from? $\endgroup$
    – DaftWullie
    Commented Apr 27, 2020 at 7:41
  • $\begingroup$ arxiv.org/abs/1605.05647v4, there is a lot of other similar cricuit if you search steane syndrome extraction $\endgroup$
    – Lucas
    Commented Apr 27, 2020 at 10:49

3 Answers 3


There is much more information provided here which may help.

Let me start by clarifying that the aim is not to detect and correct logical errors, but to detect and correct physical errors, i.e. those that occur on single physical qubits rather than the encoded qubit.

At the macro level, the answer is that if you have an $X$ error (say), you use a controlled-not to propagate it to another qubit where it appears as an $X$ error. Measuring in the $X$ basis cannot see that error. For example, if a single qubit state was in $|+\rangle$, an $X$ error would not change it, and you would be unable to detect the error. On the other hand, if the qubit was initially in $|0\rangle$ then the possibility of a flip would put it in either $|0\rangle$ or $|1\rangle$, which can be detected with a $Z$ measurement. (Put another way, $X$ errors commute with $X$ measurements, so they do not affect each other.)

More specifically, let's start by thinking about what happens if there is no error. In that case, $|+\rangle$ is the eigenstate of controlled-not, so it never changes. This is what initially threw me trying to think about a $Z$ measurement on this. But of course, it's not logical $Z$ measurement, but physical. So, basically, you'll get a single answer corresponding to one of the basis states used in either to 0 or 1 logical state, with no control over which. Let's call that answer $x$. What we do know is that $H\cdot x=0$, where $H$ is the parity-check matrix of the code (I'm being a bit loose about which of the two it is).

Now, what happens if there was a single physical $X$ error somewhere on the logical qubit. Controlled-nots (and we should think about the individual physical ones here, not the logical ones) propagate $X$ rotations from control to target. So, instead of getting an answer $x$, we'd get an answer $x\oplus e$ where $e$ is a vector representing the single qubit that had the error. So, now, if you apply the parity-check matrix, you get $$ H\cdot(x\oplus e)=(H\cdot x)\oplus(H\cdot e)=H\cdot e. $$ The whole point of the parity-check matrices is that they can let you identify any single-qubit $e$. Hence, you know what correction to provide.


I'd like to add some details to DaftWullie's answer. The key point is that while the logical $X$ operator, which I'll write as $X_L$, must, by definition, satisfy

$$ X_L \left|+\right>_L = \left.|+\right>_L, \quad X_L \left|-\right>_L = -\left|-\right>_L $$

the analogous equation does not hold when $X_L$ is replaced with an $X$ operator acting on a single qubit. The $\oplus$ on the bottom wire in the diagram, connected to its control on the top wire, indicates a controlled $X$ operator on each qubit. (CNOT pairing up wires, not a logical $X_L$.) In general this combination of CNOTs does not leave $\left|+\right>$ invariant.

Preliminaries on CSS codes. For simplicity, we suppose that the input codeword, on the top 'wire' (inverted commas since this indicates multiple wires) in the diagram in the question is zero logical, $\left|0\right>_L$. For Steane extraction we are working in a CSS code with $k$ logical qubits: let $P$ and $Q$ be the relevant matrices so

$$\left|0\right>_L = \sum_{u \in \langle P \rangle} \left|u\right>$$

where $\langle P \rangle$ is the row-space of $P$, and, by a MacWilliams' type calculation,

$$\left|+\right>_L = \frac{1}{2^{m/2}} \sum_{v \in \langle Q^\perp \rangle} \left|v\right>$$

where $m$ is the dimension of $\langle Q^\perp \rangle$.

Example. In the Steane $[[7,1,3]]$ code, using the parity check matrix from the Wikipedia article we have $$ P = Q = \left( \begin{matrix} 1 & 0 & 0 & 1 & 0 & 1 & 1 \\ 0 & 1 &0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 1 & 0 & 1 & 1 & 1 \end{matrix} \right) $$ and $\langle Q^\perp \rangle = \langle P \rangle \oplus \langle 1111111 \rangle$, where $\oplus$ is the direct sum of vector spaces, so $\left|0\right>_L = \sum_{u \in \langle P \rangle} \left|u\right>$ and $$\left|+\right>_L = \frac{1}{\sqrt{2}} \sum_{u \in \langle P \rangle} \left|u\right> + \frac{1}{\sqrt{2}} \sum_{u \in \langle P \rangle} \left| u + 1111111\right> = \frac{1}{\sqrt{2}} \left|0\right>_L + \frac{1}{\sqrt{2}} \left|1\right>_L.$$ In general for an $[[n,k,d]]$ quantum code, $\left|+\right>_L$ is a sum of $2^k$ basis states in the $Z$-logical basis.

Diagrams. The diagram below shows the action of the CNOT pairing up each wire when the input qubit is a basis state in the $Z$-basis

|u> -------*---- |u>
|w> -------+---- |u+w>

Observe that flipping a bit in $u$ means that we get a corresponding bit flip in $u+w$. Thus we can deduce the second diagram below shows how a single qubit $X$ error, gets `copied down' onto the ancilla.

 ---X---*------            ------*---X---
        |           =            |
 -------+------            ------+---X---

Calculation. We can now calculate the effect of a single qubit error, say in position $1$. On the input wires we have $X^1 \left|0\right>_L$ and $\left|+\right>_L$. On the output wires, by the second diagram, we have $X^1 \left|0\right>_L$ and

$$\frac{1}{2^{k/2}} \sum_{v \in \langle Q^\perp \rangle} X^1 \left|v\right>.$$

This expresses the output on the bottom 'wire' in the $Z$-basis. When we measure we get a random state $X^1 \left| v \right>$ where $v \in \langle Q^\perp \rangle$. This tells us $\overline{v_1} v_2 \ldots v_n$ where $v_1 v_2 \ldots v_n$ is a codeword in the code with generator matrix $Q^\perp$ and parity check matrix $Q$. We can now take the syndrome of this word and discover (provided this code is $1$-error correcting) that there was an error in the first position.

Example concluded. For the Steane [[7,4,1]]-code, we measure $\overline{v_1}v_2 \ldots v_n$ where $v_1v_2\ldots v_n$ is a codeword in the Hamming $[7,4,3]$-code with parity check matrix $P$. For instance, one codeword is $1110001$, so we might measure $0110001$. We now calculate the syndrome by left-multiplying the column vector by $P$, to get

$$ \left( \begin{matrix} 1 & 0 & 0 & 1 & 0 & 1 & 1 \\ 0 & 1 &0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 1 & 0 & 1 & 1 & 1 \end{matrix} \right) \left( \begin{matrix} 0 \\ 1 \\ 1 \\ 0 \\ 0 \\ 0 \\ 1 \end{matrix} \right) = \left( \begin{matrix} 1 \\ 0 \\ 0 \end{matrix} \right). $$

Since this is the first column of $P$, we conclude that there was an $X$ error in the first position.



TLDR: we start with $\ket{+}_L$ because $\ket{+}$ is stabilized by $X$-gate. Start with $\ket{+}_L$ does not interfere the code space. Indeed all of the measurement results are random, but the product of selected indices gives the eigenvalue of a stabilizer, which is the syndrome (eg. if one stabilizer is $IIIZZZZ$, its eigenvalue is the product of the result of the 4th-7th measurement, which must be 1, in our case).

In this discussion, we only consider the first half of the syndrome extraction, since the second half is a mere dual of the first.

We discuss why we use $\ket{+}_L$ first. The key part here is transversal CNOT implements logical transversal CNOT in CSS code (you can verify this with stabilizer formalism where the stabilizers are invariant after CNOT and the logical operators are "as if" there is a transversal logical CNOT). Thus, if we agree that transversal CNOT($\ket{\psi},\ket{+}$)=$\ket{\psi},\ket{+}$ (you can verify this yourself), then transversal CNOT_L($\ket{\psi}_L,\ket{+}_L$)=$\ket{\psi}_L,\ket{+}_L$, which preserves the code space as we don't want the syndrome extraction to disturb the code space. Another reason is, if $\ket{+}_L$ is encoded in the same code as the data qubit, it also introduces the same stabilizers as the data qubit, which is very convenient for our following discussion.

Let's consider the simplest example. Suppose the data qubit is $\ket{\psi}=\ket{0}$ and we place an ancilla that starts with $\ket{0}$ to perform CNOT($\ket{\psi},\ket{0}$) and measure on $Z$-basis the second qubit. If there is no error, the measurement will give 1 (the +1 eigenvalue of $Z$). If there is an $X$ error, the measurement will give -1 (the -1 eigenvalue of $Z$). Observe that we have indirectly measured the eigenvalue of the first qubit.

Now let's use stabilizer formalism to repeat the example above. Initially, the stabilizer generators are $[ZI,IZ]$. If there is no error, they become $[ZI,ZZ]$ after CNOT, which is equal to $[ZI,IZ]$ (up to multiplication by the first stabilizer). Now we measure $IZ$. According to Nielsen and Chuang, we should get +1, because $IZ \in <ZI,IZ>$. If there is $X$ error, the initial stabilizer generators become $[-ZI,IZ]$ since $XZX=-Z$. After CNOT, they become $[-ZI,ZZ]$, which is equal to $[-ZI,-IZ]$ (up to multiplication by the first stabilizer). Now we measure $IZ$, and we get -1 for the same reason. Observe that the stabilizers in the ancilla are the same before and after the CNOT, up to the phase of the first stabilizer.

Recall that using $\ket{+}_L$ introduces the stabilizers the same as those used in the data. From the discussion above, we roughly have the model above applied to every pair of qubits. To see this, consider the transversal CNOT gates that connect $(1,n+1),(2,n+2), \dots$ qubits, and the two qubit model we discussed above applies to every $(1,n+1),(2,n+2), \dots$ qubit pairs. Thus, intuitively, we very roughly understand how the syndromes in the data are measured in the ancilla. But why are the products of certain measurement results the syndrome?

We now make a rigorous example with stabilizer formalism with Steane 7 qubit code. We focus on the ancilla only. Suppose the first qubit has an $X$ error, then its stabilizer generators are: $$XXXXXXX \\ IIIXXXX \\ IXXIIXX \\ XIXIXIX\\ IIIZZZZ \\ IZZIIZZ \\ -ZIZIZIZ.$$ Notice that we have an additional stabilizer $XXXXXXX$ since it stabilizes $\ket{+}_L$. After individual and separate qubit-wise measurements of $Z_1,Z_2,Z_3,Z_4$, the stabilizer generators are: $$s_1IIIZIII (1)\\ s_2IIZIIII (2)\\ s_3IZIIIII (3)\\ s_4 ZIIIIII (4)\\s_5IIIZZZZ (5) \\ s_6IZZIIZZ (6) \\ s_7ZIZIZIZ (7),$$ where each of $s_1,s_2,s_3,s_4=-1$ or 1 with probability 1/2 and $s_5=s_6=1$ and $s_7=-1$. We obtain these stabilizer generators because the measurement operators anticommute with the first four stabilizers, so the stabilizers are destroyed and the measurement operators remain and the outcome is -1 or 1 with probability 1/2, according to Nielsen and Chuang.

Consider the measurement outcomes of measuring $Z_5,Z_6,Z_7$. Notice that $Z_5$=$(5)\cdot(6) \cdot (2) \cdot (3) \cdot (4)$, then $s_5 \cdot s_6 \cdot s_2 \cdot s_3 \cdot s_4 \cdot Z_5 \in <stabs>$, which means the fifth measurement outcome is $s_2 \cdot s_3 \cdot s_4$ since $s_5=s_6=1$. Similarly the sixth measurement outcome is $s_7 \cdot s_5 \cdot s_1 \cdot s_3 \cdot s_4=-s_1 \cdot s_3 \cdot s_4$, and the seventh measurement outcome is $s_5 \cdot s_6 \cdot s_7 \cdot s_1 \cdot s_2 \cdot s_4=-s_1 \cdot s_2 \cdot s_4$.

The measurement of the stabilizer $IIIZZZZ$ is the product of the 4th to 7th measurement result, which is $$ s_4 \cdot s_2 \cdot s_3 \cdot s_4 \cdot -s_1 \cdot s_3 \cdot s_4 \cdot -s_1 \cdot s_2 \cdot s_4=1,$$ because $s_i^2=1$. Similarly, we can check that the measurement of the stabilizer $IZZIIZZ$ is 1 and that of $ZIZIZIZ$ is -1. Therefore, the syndrome observed is [1,1,-1], or in binary, [0,0,1], which is exactly the syndrome of the error on the first qubit according to the parity-check matrix of the Hamming[7,4] code, on which the Steane 7 qubit code bases.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.