|q⟩ Bad Qubits

advanced · Programming · Implementing the Surface Code

Stabilizer Measurement Cycles

A surface-code computation is a sequence of identical measurement cycles. In each cycle every ancilla is entangled with its data neighbours and then measured, producing one classical bit per check. We never measure the data qubits directly — that would destroy the logical state — so the ancilla acts as a probe that reports a parity while leaving the data's superposition intact.

Extracting a Z-type check with an ancilla

To measure the plaquette operator Z0Z1Z_0 Z_1 without learning the individual values of qubits 00 and 11, we use a fresh ancilla aa prepared in 0|0\rangle and apply a CNOT from each data qubit into the ancilla:

CNOT0aCNOT1a  q0q10a=q0q1q0q1a.\text{CNOT}_{0\to a}\,\text{CNOT}_{1\to a}\;|q_0 q_1\rangle|0\rangle_a = |q_0 q_1\rangle\,|q_0 \oplus q_1\rangle_a.

The ancilla ends up holding the parity q0q1q_0 \oplus q_1. Measuring it returns

Crucially the data register is left in q0q1|q_0 q_1\rangle untouched, and for a superposition the ancilla measurement projects only onto a definite parity sector, never onto a single data basis state. That is exactly what lets the same check repeat round after round.

A quiet round

Consider the cleanest possible cycle: both data qubits in 0|0\rangle, no error present. The parity is even, so the ancilla measures 00 with certainty. The whole register stays in

00010a,|0\rangle_0 |0\rangle_1 |0\rangle_a,

and the syndrome bit reads 00 — "this check sees nothing wrong." Establishing this error-free baseline is the first thing any decoder needs; the next lesson injects an error and watches the bit flip.

Try it

Build one quiet round of the Z0Z1Z_0 Z_1 check. Use qubits 00 and 11 as data (both 0|0\rangle) and qubit 22 as the ancilla. Apply c.cx(0, 2) and c.cx(1, 2), then measure the ancilla. The grader checks that the only outcome with non-zero probability is 000|000\rangle — syndrome 00.

Run your code to see the quantum state.

After running, the Probabilities tab should show a single bar at 000000 with probability 11.

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