Skip to content
Tushar Pandey

Step 5 of 8

Lesson 2: Logical CNOT between two patches

Quantum Error Correction in Practice, part 2: Computing with logical qubits

Read

Both patches use the encoder from lesson 1: A becomes |+⟩⁠L, B becomes |0⟩⁠L. Nine physical CNOTs, one between each pair of matching qubits, then act as one logical CNOT and leave a logical Bell pair.

Patches and gate layers

X check Z check fired undetermined gate XL, ZL = +1

What this lesson shows

Patch A is encoded as |+⟩⁠L and patch B as |0⟩⁠L, both with the encoder from lesson 1. Nine CNOTs, one from each qubit of A to the matching qubit of B, then act as one logical CNOT. Each copies X forward and Z backward, so X⁠L of A becomes X⁠L of A times X⁠L of B, and Z⁠L of B becomes Z⁠L of A times Z⁠L of B. Checks map to checks, so all sixteen still hold, and one faulty CNOT hits each patch at most once. The result is a logical Bell pair: read in Z, the two logical bits come out random but always equal.

Things to try

  • Press Play and follow the state panel under the figure: A becomes |+⟩⁠L, B becomes |0⟩⁠L, and after the CNOT layer both are listed as a Bell pair.
  • In Run it live, set the shots, the readout basis and the noise per gate, then press Run. A stabilizer simulator runs the circuit in your browser and reports how often the two logical bits agree and how many shots the checks discard.
  • Tick Inject one error, choose a Pauli, a qubit and the layer it follows, and run again. The heatmap shows how often each of the sixteen checks fired in each layer.

The ideal logical circuit

Step by step

  1. prepare A. H puts q0 of A in |+⟩. A CNOT acting on |0⟩⁠L would do nothing; with A in |+⟩⁠L it makes a Bell pair.
  2. encode A. Encode A with the encoder from lesson 1. It turns q0 = |0⟩ into |0⟩⁠L and q0 = |1⟩ into X⁠L|0⟩⁠L = |1⟩⁠L, so q0 = |+⟩ becomes |+⟩⁠L: X⁠L holds, Z⁠L does not.
  3. encode B. Encode B the same way from q0 = |0⟩: |0⟩⁠L, so Z⁠L holds.
  4. transversal CNOT A→B. Nine CNOTs, qi of A → qi of B. Each copies X forward and Z backward: X⁠L of A becomes X⁠L of A · X⁠L of B, Z⁠L of B becomes Z⁠L of A · Z⁠L of B. That is a logical CNOT. Checks map to checks, so all sixteen hold, and one faulty CNOT hits each patch at most once.
  5. measure. Every qubit is measured in Z. Only the checks that are Z parities can still be read. The two logical bits come out random, but always equal.

Results

How to read this table

Every shot ends with all data qubits measured, and the checks are worked out from those bits. Clean shots only gives the rate over the shots in which no check fired. Corrected by the code is the share of shots in which checks fired and a table of single errors named a qubit to flip back; After correction is the rate over all kept shots once that flip is made. Discarded by the checks is the share of shots whose fired checks are not in the table at all: those shots are dropped. No correction reads the raw bits of every shot. Bare qubits runs the same logical circuit with one unprotected qubit in place of each patch: no encoder and no checks. Each rate comes with one binomial standard error.

The first row reads a single patch prepared as |+⟩⁠L in X, with no CNOT: the starting state of patch A, kept as a reference for the two-patch rows.

Why the code loses here: the noise in this simulation acts only on gates, as the line under the table says. Both patches come from the lesson 1 encoder, and the two-patch rows add the nine transversal CNOTs on top. The bare rows use one qubit per patch and none of those CNOTs, so far less noise reaches them. The encoder is not fault tolerant: in the course's own stabilizer simulator, 44 of the 180 ways a single CNOT of the lesson 1 encoder can fail (each of its 12 CNOTs followed by one of the 15 two-qubit Pauli errors) end in a wrong logical readout after the table's correction.

Cite this lesson T. Pandey, "Lesson 2: Logical CNOT between two patches", Quantum Error Correction in Practice (2026), https://pandey-tushar.com/qec-in-practice/lesson-2.html