Lattice Surgery¶
Surface Codes showed how a logical qubit can be protected. Minimum-Weight Perfect Matching showed how a decoder interprets the evidence a patch collects. Neither one answers a different question: how do two separately-protected logical qubits interact with each other?
From Protecting to Computing¶
Here are two ordinary surface-code patches, each already capable of protecting a logical qubit on its own:
Call them Logical Qubit A and Logical Qubit B. A real computation needs logical qubits to interact — to become entangled, to exchange information, to take part in two-qubit gates. But each one is protected precisely because its information is spread across many physical qubits and watched over by local checks.
How can two protected logical qubits interact without abandoning the error protection the surface code provides?
The technique real surface-code hardware uses is lattice surgery: rather than pulling logical information out of the code, or applying an ordinary two-qubit gate directly to it, lattice surgery changes which stabilizer/check measurements are being made across the boundary between two neighboring patches. You already know that a patch protects information via local checks — lattice surgery is what happens when new checks are temporarily added between two patches.
A Patch Represents a Logical Qubit¶
Before looking at the surgery itself, it's worth being precise about what's actually being operated on.
Lattice surgery operates on encoded logical qubits by modifying the relationships between their underlying physical qubits and stabilizer checks — it does not collapse either patch down into a single ordinary physical qubit. Every data qubit and check from Surface Codes is still there; surgery changes how they're connected, not what they are.
Meet the Boundaries¶
The dashed outline marks each patch's boundary — the edge facing the other patch.
A surface-code patch has edges, and different edges support different kinds of connection to a neighboring patch. At this level you don't need the formal rough/smooth vocabulary yet — just this:
The boundary is where neighboring patches can be connected through new stabilizer measurements.
Patches aren't simply placed on top of one another. The operation below changes which local checks are being measured along the shared boundary — the physical qubits themselves never move.
Main Interactive — Perform Lattice Surgery¶
Walk through the sequence yourself: Merge the boundary, Measure the new joint checks, then Split the patches back apart.
What Does the Merge Actually Do?¶
Before the merge, Patch A and Patch B each have their own independent stabilizer structure — the same kind of checks from Surface Codes, just not yet connected to anything outside their own patch.
During the merge:
- new checks are introduced across the shared boundary
- each new check involves physical qubits from both patches
- the resulting measurements provide information about a joint logical property of A and B together
Two things the merge is not:
- It does not fuse Logical A and Logical B into a single ordinary qubit — both patches, and all their physical qubits, are still there.
- It does not directly measure the individual state of Logical A or Logical B — doing that would destroy exactly the information QEC is meant to protect.
Joint Measurement¶
Instead of asking "what is the state of Logical A?" or "what is the state of Logical B?", the new boundary checks ask a different kind of question: what is a relationship between A and B?
This should feel familiar:
Earlier, a parity check told us about a relationship between physical qubits — whether two of them agreed or disagreed — without revealing either qubit's individual value. Lattice surgery extends a similar idea to encoded logical qubits.
That analogy isn't exact — logical qubits carry full quantum states, not classical bits — but the shape of the idea carries over. The core concept is:
Measure a relationship between logical qubits without individually measuring away their encoded quantum information.
Optional: how this is usually written →
More advanced treatments describe a boundary merge as measuring a joint logical operator, such as
or
depending on which kind of boundary was merged. You don't need this notation to follow the rest of this section — it's here so the vocabulary isn't a surprise if you run into it elsewhere.
Split the Patches¶
Splitting removes the temporary joint checks and restores each patch's own independent boundary. This is not simply "undo." What Logical A and Logical B carry forward depends on what the joint measurement revealed and on the protocol being performed — split does not automatically return both logical qubits to exactly the states they had before the merge.
QEC Does Not Stop During Surgery¶
It's tempting to picture lattice surgery as switching error correction off while the patches are manipulated, then switching it back on afterward. That's not what happens.
Lattice surgery is designed so logical operations can be performed while the information remains encoded and protected the entire time. The important idea at this level isn't the exact number of measurement rounds a fault-tolerant implementation needs — it's that protection never lapses.
From Surgery to Logical Operations¶
The merge → measure → split sequence is itself a building block, not the finish line.
By combining joint measurements, ancilla logical patches, and classical interpretation of the measurement outcomes, lattice surgery can implement entangling logical operations — a logical CNOT is the standard example — while keeping every qubit involved encoded and protected the entire time. We won't build the full CNOT protocol here; the result that matters is computational, not procedural: surface-code patches can compute together, not just individually survive.
Optional Exploration — Follow the Checks¶
Optional: follow the checks through the whole sequence →
The main interactive above focuses on the sequence itself. This one focuses on which checks are involved at each step, and lets you switch between three ways of looking at the same two patches.
Three abstraction levels, same underlying operation:
You don't need to track every individual check to understand lattice surgery at this level — this view exists so you can see how the logical-level story (bottom) is actually built out of physical-level detail (top) whenever you want to look.
Takeaway¶
Lattice surgery enables logical qubits encoded in surface-code patches to interact by temporarily changing stabilizer measurements along their boundaries. This allows joint logical information to be measured while the quantum information remains encoded and protected.
Zoom out across the last three sections: Surface Codes protected logical qubits, Minimum-Weight Perfect Matching decoded the errors that threaten them, and Lattice Surgery lets protected logical qubits actually compute together.
So far, this module has often treated physical qubits and errors as though they behave uniformly — every qubit equally likely to fail, every check equally reliable. Real quantum hardware does not work that way. What happens when different qubits, gates, and measurements have different error characteristics — and those characteristics change over time?