|q⟩ Bad Qubits

advanced · Programming · Implementing Error-Correcting Codes

Syndrome Extraction Circuits

Syndrome extraction is the heart of the QEC cycle. It answers the question "did an error occur, and where?" without revealing the encoded data — no individual data qubit is ever measured. The tool is the stabilizer: a multi-qubit Pauli operator whose eigenvalue we read out through an ancilla.

Stabilizers of the bit-flip code

The codewords 000|000\rangle and 111|111\rangle are both +1+1 eigenstates of the two operators

S1=Z0Z1,S2=Z1Z2.S_1 = Z_0 Z_1, \qquad S_2 = Z_1 Z_2.

These are the stabilizer generators. Any superposition of the codewords is also stabilized: S1ψL=S2ψL=+ψLS_1|\psi_L\rangle = S_2|\psi_L\rangle = +|\psi_L\rangle. A ZiZjZ_i Z_j operator measures the parity of qubits ii and jj — it returns +1+1 when they agree and 1-1 when they differ — while saying nothing about whether they are both 00 or both 11. That is exactly the data-blind information we need.

What an error does to the syndrome

An XX error on a single data qubit flips that qubit, changing one or two parities:

| Error | Z0Z1Z_0Z_1 | Z1Z2Z_1Z_2 | Syndrome (s1,s2)(s_1,s_2) | |-------|----------|----------|----------------------| | none | +1+1 | +1+1 | (0,0)(0,0) | | X0X_0 | 1-1 | +1+1 | (1,0)(1,0) | | X1X_1 | 1-1 | 1-1 | (1,1)(1,1) | | X2X_2 | +1+1 | 1-1 | (0,1)(0,1) |

Here we write a 1-1 eigenvalue as the bit 11. Each single-qubit error has its own unique two-bit syndrome — the property that makes the code correctable.

Measuring a parity with an ancilla

We cannot apply Z0Z1Z_0 Z_1 and "look at" its eigenvalue directly. Instead we copy the parity onto a fresh ancilla. Starting the ancilla in 0|0\rangle, two CNOTs do the job:

cx(0,3); cx(1,3).\texttt{cx(0,3)};\ \texttt{cx(1,3)}.

The first writes qubit 0 into the ancilla; the second XORs qubit 1 on top. The ancilla ends in q0q1|q_0 \oplus q_1\rangle — precisely the Z0Z1Z_0 Z_1 parity bit. A second ancilla collects q1q2q_1 \oplus q_2 the same way.

Try it

A bit-flip error has been injected on data qubit 0. Wire up the two parity measurements onto the ancillas and measure the register. The grader checks the measurement distribution: the syndrome must come out as (s1,s2)=(1,0)(s_1, s_2) = (1, 0) with certainty.

Run your code to see the quantum state.

Open the Probabilities tab after running: a single outcome should carry all the weight — the bitstring 10010, whose last two bits 10 are the syndrome pointing at qubit 0.

Sign in on the full site to ask questions and join the discussion.