Why measure only two qubits at a time
The surface code asks the hardware for one thing over and over: measure a weight-four Pauli operator such as . In a circuit model this means an ancilla, four two-qubit gates in a carefully chosen order, and a measurement. Every one of those operations can fail, and a single failure on the ancilla part-way through can spread to two data qubits (you will analyse this "hook" mechanism in detail in the next lesson). Some hardware does not even offer a convenient way to do it: in measurement-based architectures, for example those proposed with Majorana zero modes, the native operation is a direct measurement of a two-qubit Pauli product such as , with no ancilla and no entangling gate at all (Paetznick et al.).
So a natural question is whether a code can be run using only two-body Pauli measurements. Subsystem codes such as the Bacon–Shor code already measure small "gauge" operators and multiply their outcomes to learn larger stabilizers. Hastings and Haah found something stranger: a sequence of two-body measurements that, viewed as a static subsystem code, protects no logical qubit at all, yet whose time ordering continuously regenerates a toric-code-like state with two protected logical qubits on a torus (Hastings and Haah). Codes of this kind are called Floquet codes or dynamically generated codes, because the protection is a property of a periodic schedule rather than of a fixed stabilizer group.
This lesson builds the honeycomb code from its definition and verifies its key properties by exact Pauli algebra. The exercise makes you implement every step.
From subsystem codes to dynamically generated codes
Checks and the instantaneous stabilizer group
Fix qubits and a list of Pauli operators called checks. A schedule says which checks are measured in each round; checks measured in the same round must commute with each other, but checks in different rounds need not.
Suppose the system starts in some state, possibly the maximally mixed state, and we measure checks in the order the schedule prescribes. After any prefix of the schedule, the post-measurement state is a stabilizer state (or a mixture of stabilizer states with identical stabilizer group up to signs) whose stabilizer group is fixed by the measurements so far. Call it the instantaneous stabilizer group (ISG) after round . The number of logical qubits the ISG leaves free is
where the rank is the number of independent generators.
The ISG is updated by the standard stabilizer measurement rule. When a Pauli is measured:
- If anticommutes with some generators, pick one of them, ; replace every other anticommuting generator by (which now commutes with ); finally replace by . The outcome is uniformly random. The rank is unchanged.
- If commutes with every generator and is already in the group, the outcome is determined by the current signs. Nothing changes.
- If commutes with every generator and is not in the group, the outcome is random and is appended. The rank grows by one, and drops by one.
Case 3 is the dangerous one once a code is running: if commutes with the whole ISG but is not in it, then acts on the encoded information, and measuring it destroys a logical qubit. A schedule preserves its logical qubits exactly when, in the steady state, no round ever falls into case 3 for any product of the checks it measures. A practical test follows: run the schedule and watch . If it stays constant over many periods, no logical information is being measured.
All of this is linear algebra over . Write a Pauli on qubits, ignoring its phase, as a vector : sets , sets and sets both. Two Paulis commute exactly when the symplectic product is , products of Paulis are sums of vectors, and "is in the group" is a rank test after Gaussian elimination. Signs matter for the values of outcomes but never for which outcomes are random, so the whole structural analysis can drop them.
Inferring a product you never measured
Here is the mechanism that lets two-body checks build weight-six stabilizers. Take six qubits on a hexagon, numbered around it, and six edge checks on the pairs , with Pauli types X, Y, Z, X, Y, Z in turn:
Neighbouring checks share one qubit with different Pauli types, so they anticommute; checks two apart are disjoint and commute. Split them into and . Within each set everything commutes. The product of all six is, qubit by qubit (for example qubit 1 sees from and from , and ),
commutes with every : each check overlaps on two qubits, and on each of them the check's Pauli differs from 's, giving two sign flips. Now measure , then . After the round the ISG contains . Each check anticommutes with two of them, so its outcome is random, and by rule 1 the ISG after the round contains together with the products of checks that commute with all of . The product is such a product, so is now in the ISG, and its value is the product of all six outcomes. Measure again and then again, and you obtain a second value of . Without errors the two agree, so their parity is a detector, even though every single check outcome in the second and later rounds is a fair coin.
Stim checks this for us. Its detector analysis refuses any detector that is not deterministic in the noiseless circuit (Gidney, Stim).
import stim
a_round = "MPP X0*X1 Z2*Z3 Y4*Y5"
b_round = "MPP Y1*Y2 X3*X4 Z5*Z0"
circuit = stim.Circuit("\n".join([
"R 0 1 2 3 4 5",
a_round, b_round, a_round, b_round,
# W from rounds 3-4 times W from rounds 1-2: twelve measurement records
"DETECTOR " + " ".join(f"rec[-{i}]" for i in range(1, 13)),
]))
circuit.detector_error_model() # raises if the detector were random
shots = circuit.compile_sampler(seed=3).sample(4000)
print("mean of each B outcome in round 4:", shots[:, 9:12].mean(axis=0).round(2))
print("detection events:", circuit.compile_detector_sampler(seed=3).sample(4000).sum())
The detector-error-model call returns without complaint, the round-4
outcomes average close to (they are random), and there are zero detection
events. Replace Z5*Z0 by X5*X0 in the round and the call raises
ValueError: The circuit contains non-deterministic detectors, because the new
product no longer commutes with and is no longer a stabilizer.
The honeycomb code
Lattice, colours and Pauli types
Place qubits on the vertices of a honeycomb lattice wrapped on a torus. Following Kitaev's honeycomb model (Kitaev), every edge has a Pauli type, X, Y or Z, according to its direction, so that each vertex has one edge of each type; the check on an edge of type is . Hastings and Haah add a second label. The hexagonal plaquettes can be coloured with three colours, 0, 1 and 2, so that neighbouring plaquettes differ. Give each edge the colour of the two plaquettes it connects at its ends (the two plaquettes touching its endpoints that do not contain the edge; they always share a colour). Then each vertex also has one edge of each colour, the edges of one colour form a perfect matching of the qubits, and the six boundary edges of a plaquette of colour alternate between the two other colours.
The exercise builds this lattice from a triangular lattice of plaquettes: put plaquette at site with colour , and make every elementary triangle of three mutually adjacent plaquettes a qubit. For an torus with a multiple of 3 this gives qubits, edges and plaquettes. The plaquette operator is the product of its six boundary checks, a weight-six Pauli exactly like above; it commutes with every check on the lattice.
The period-3 schedule
The honeycomb code's schedule is: in round , measure every check of colour . Checks of one colour are disjoint, so each round is a single layer of commuting two-body measurements. A plaquette of colour is bounded by checks of colours and , so it is inferred whenever those two colours are measured in consecutive rounds, exactly as in the hexagon example. In the sequence every pair of distinct colours appears consecutively once per period, so every plaquette is re-inferred every three rounds and each inference can be compared with the previous one. That gives one detector per plaquette per period.
The ISG round by round: a computed example
Start from the maximally mixed state (empty ISG) on the torus, so . Running the measurement rule in symplectic form, as the exercise asks you to, gives the number of free qubits after each round:
| Round index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ... |
|---|---|---|---|---|---|---|---|---|
| Colour measured | 0 | 1 | 2 | 0 | 1 | 2 | 0 | ... |
| 36 | 24 | 13 | 2 | 2 | 2 | 2 | ... |
These are exact values computed with the reference solution of the exercise (no sampling is involved), and the same steady value appears for and . The transient makes sense: round 0 fixes the 36 colour-0 checks; round 1 replaces them by the colour-1 checks but retains the colour-2 plaquettes they imply; round 2 adds the colour-0 plaquettes, round 3 the colour-1 plaquettes. From then on the ISG is generated by all plaquettes together with the checks just measured, and stays at 2: no round ever measures logical information.
Hastings and Haah identify this steady-state ISG as a toric code on a coarser hexagonal superlattice, in which each just-measured check pairs two physical qubits into one effective qubit; on a torus the toric code encodes two logical qubits, consistent with the computed (Hastings and Haah). The exercise also computes the static picture. The group generated by all checks, viewed as a subsystem code, has a centre (products of checks commuting with every check) large enough that the number of logical qubits , with the number of gauge qubits, is zero, matching the statement in their abstract that the subsystem code has no logical qubits.
Inner and outer logical operators
Because X and Y edges together give every vertex degree two, they form disjoint cycles, and on the torus these are non-contractible zigzag loops. The product of the checks around one such loop is on every vertex of the loop (each vertex contributes ). It commutes with every check: an X or Y check on the loop overlaps it on two qubits with differing Paulis, and a Z check touching the loop agrees with it wherever they overlap. It is a product of checks, and the exercise verifies it is never in the ISG. So it is a logical operator of every ISG, and since no check ever anticommutes with it, no measurement disturbs it. Hastings and Haah call such operators inner logical operators. Being products of checks is also why the static subsystem code puts them in its centre and loses them as logical operators.
The outer logical operators are the conjugate partners. An outer operator that commutes with the ISG after round generally anticommutes with some checks of round , so it must be multiplied by checks of the current colour to become a valid representative for the next ISG. Tracking a logical observable in a Floquet memory therefore means updating it with measurement outcomes every round. Hastings and Haah describe the net effect of one period as an automorphism of the embedded toric code that exchanges its electric and magnetic logical operators, so the logical operators repeat only every six rounds (Hastings and Haah). We quote that statement; the exercise verifies the inner operators but leaves the outer ones as an extension.
Schedules that fail
The order matters. With the period-2 schedule only colour-2 plaquettes are ever inferred, and the exercise finds a steady-state of 24 on the torus instead of 2. Those extra "logical qubits" are not protected: the plaquettes that would detect errors on them are never measured. A subtler failure is the period-4 schedule : colours 0 and 2 are never measured back to back, so colour-1 plaquettes are never inferred. The rule of thumb that falls out of the algebra is that each pair of colours must appear in consecutive rounds, and you should check any proposed schedule by running the ISG update rather than by intuition.
Why weight-two measurements matter for hardware
Compare what one stabilizer measurement costs in a CNOT-based circuit. A weight-two check needs one ancilla and two CNOTs; a weight-four surface-code stabilizer needs four.
A fault on the ancilla between the two CNOTs can only reach one data qubit after it, so a two-body check has no hook errors of weight two. More importantly, some platforms can measure , or directly, with no ancilla and no two-qubit gate, in which case the whole honeycomb code is a periodic sequence of native operations. The honeycomb lattice also has degree three, which suits hardware with sparse connectivity.
What does this buy in numbers? Published simulations answer it only within stated models, and those models matter:
- Gidney, Newman, Fowler and Broughton simulated honeycomb and rotated surface code memories with a correlated minimum-weight perfect-matching decoder. In a controlled-NOT circuit model they report a threshold of 0.2–0.3% for the honeycomb code against 0.5–0.7% for the surface code; in a model with native two-body measurements, the honeycomb code's threshold lies between 1.5% and 2.0%, where is the collective error rate of the two-body measurement including correlated data depolarization (Gidney et al., 2021).
- For a planar version, Gidney, Newman and McEwen estimate the qubit count needed for a one-in-a-trillion logical error rate at a 0.1% gate-level error rate as about 7000 physical qubits, or about 900 with native two-qubit parity measurements, again within their specific noise models (Gidney, Newman and McEwen).
The honest reading is conditional: when two-body measurements are native and good, Floquet codes are strong candidates; when every check must be compiled into CNOTs, the surface code's higher circuit-level threshold usually wins. Neither result is a statement about a particular device.
Planar, CSS and other variants
The torus is convenient for analysis but not for chips. Haah and Hastings constructed boundaries for the honeycomb code, giving a planar version with one logical qubit per patch (Haah and Hastings), and Gidney, Newman and McEwen designed boundaries that need no extra connectivity (Gidney, Newman and McEwen). Paetznick and co-authors studied planar Floquet codes on Majorana-based architectures, measuring the checks directly without auxiliary qubits (Paetznick et al.).
The honeycomb code mixes X, Y and Z checks, so it is not a CSS code. Davydova, Tantivasadakarn and Balasubramanian introduced a CSS honeycomb code whose checks are each purely X-type or purely Z-type; its checks do not form a subsystem code with a useful parent, yet the schedule still embeds an instantaneous toric code and conserves logical information (Davydova et al.). Kesselring and co-authors view Floquet codes as sequences of anyon-condensation steps on the colour code and use this to construct a CSS Floquet colour code (Kesselring et al.). We mention these only qualitatively; their thresholds and overheads depend on noise models we have not reproduced here.
What this lesson verified and what it quoted
Verified by computation you can rerun (exercise and snippet): the measurement rule; the inference of weight-six plaquettes from two-body checks; round by round, including the steady state on tori with ; that the static subsystem code has ; that inner logical operators commute with every check and never enter the ISG; that schedules missing a colour pair fail; and that the Stim circuit's detectors are deterministic without noise.
Quoted from the literature, with the papers cited: the identification of the ISG with a toric code on a superlattice, the electric–magnetic exchange of outer logical operators each period, all thresholds and qubit counts, and the properties of planar and CSS variants.
Common mistakes
- Treating Floquet checks like stabilizers. Individual check outcomes after the first period are random; only products that commute with the preceding round, such as plaquettes, are detectors. Building a detector from a single check comparison across rounds gives a non-deterministic detector, which Stim reports.
- Comparing the wrong rounds. A plaquette of colour is completed by the two
rounds measuring and . Off-by-one record arithmetic is the most common
bug in Floquet circuits; let
detector_error_model()catch it. - Counting from the static code. The subsystem code generated by all checks has no logical qubits. The protection lives in the ISG of the schedule.
- Forgetting to update the logical observable. The outer logical operator must be multiplied by check outcomes as the schedule proceeds; a fixed Pauli string read out at the end is not a valid observable.
- Quoting thresholds without their model. "The honeycomb threshold is about 1.5%" is meaningful only for native two-body measurements and the decoder and error model of the cited study.
Summary
- A Floquet code is defined by a schedule of checks. Its protection lives in the instantaneous stabilizer group, which the stabilizer measurement rule updates round by round in binary symplectic form.
- Products of anticommuting two-body checks measured in consecutive rounds can be inferred as weight-six stabilizers. Comparing successive inferences gives deterministic detectors.
- The honeycomb code measures one colour of edges per round with period 3. On a torus its ISG encodes two logical qubits in the steady state, while the static subsystem code encodes none.
- Inner logical operators are products of checks and are never disturbed. Outer logical operators must be updated every round.
- Weight-two checks remove weight-two hook errors and suit native pair measurements. Published thresholds favour Floquet codes only in such models.
What next
The next lesson, Fault-tolerant quantum computing, asks how errors spread through syndrome-extraction and logic circuits, and how a universal gate set is built from fault-tolerant pieces.