The surface code is a topological quantum error correcting code, and an example of a stabilizer code, defined on a two-dimensional spin lattice.A. Y. Kitaev, Proceedings of the 3rd International Conference of Quantum Communication and Measurement, Ed. O. Hirota, A. S. Holevo, and C. M. Caves (New York, Plenum, 1997) The first type of surface code introduced by Alexei Kitaev in 1997 was the toric code, which gets its name from its periodic boundary conditions, giving it the shape of a torus. These conditions give the model translational invariance, which is useful for analytic study. The toric code is the simplest and most well studied of the quantum double models. It is also the simplest example of topological order—Z2 topological order (first studied in the context of Z2 spin liquid in 1991). The toric code can also be considered to be a Z2 lattice gauge theory in a particular limit.
However, on many quantum computation platforms, experimental realization of a surface code is much easier if the code can be embedded on a 2D plane. This motivated the design of another type of surface code with open boundary conditions, the planar code. As of 2025, Google Quantum AI has implemented a distance-7 planar code on their newest generation of superconducting quantum processors, Willow processor, demonstrating a below-threshold physical error rate.
Definition
The surface code is defined on a two-dimensional lattice, usually chosen to be the square lattice. Below, we will first illustrate the basic concept with the toric code, where the lattice has periodic boundary conditions, i.e., the top boundary is connected to the bottom and the left boundary to the right. Topologically, this is equivalent to defining the lattice on a torus.
A qubit is located on each edge of the lattice. For a lattice, there are horizontal edges and vertical edges, thus qubits in total. Stabilizer operators are defined on the qubits around each vertex and plaquette (face) of the lattice as follows:
Here denotes the edges touching the vertex , and denotes the edges surrounding the plaquette . The code space of the toric code is the subspace for which all stabilizers act trivially, hence for any state in this space it holds that
For the toric code, this space is four-dimensional, and so can be used to store two qubits of quantum information. This can be proven by considering the number of independent stabilizer operators: For a lattice, there are vertex stabilizers and plaquette stabilizers, but the product of all vertex stabilizers is and so is the product of all plaquette stabilizers. Therefore there are independent stabilizers, leaving 2 qubits worth of degrees of freedom.
The occurrence of errors will usually move the state out of the code space, resulting in vertices and plaquettes for which the above condition does not hold. Specifically, a Pauli error on qubit flips the two vertex stabilizers such that (the endpoints of the edge ), and a Pauli error on qubit flips the two plaquette stabilizers such that (the plaquettes on either side of the edge ). The positions of these violations is the syndrome of the code, which can be used for error correction.
The unique nature of topological codes such as the surface code is that stabilizer violations can be interpreted as quasiparticles. Specifically, if the code is in a state such that , a quasiparticle known as an anyon can be said to exist on the vertex . Similarly a violation of some is associated with an anyon on the plaquette . The code space, with no stabilizer violation, corresponds to the anyonic vacuum. The above-mentioned fact that the product of all vertex (resp. plaquette) stabilizers is means that the number of (resp. ) anyons on a toric code is always even.
A single-qubit error can be associated with an edge, and creates a pair of anyons at both endpoints of that edge. However, two anyons at the same location will annihilate each other, so a error can also effectively move an anyon along an edge, allowing anyons to be transported on the lattice. If the initial pair of anyons end up meeting each other and annihilating, then their paths form a loop. If the loop is topologically trivial, then it can be written as a combination of plaquettes ( stabilizer generators) on the lattice. Therefore the loop represents a stabilizer of the code, and has no effect on the stored information. The annihilation of the anyons, in this case, corrects all of the errors involved in their creation and transport. However, if the loop is topologically non-trivial, then it represents a non-trivial logical operator. Although re-annihilation of the anyons returns the state to the code space, it also implements a logical operation on the stored information. The errors, in this case, are therefore not corrected but consolidated. On a torus, there are two independent topologically non-trivial loops: One looping horizontally on the toric code lattice, one looping vertically. These can be identified with the operators of the two logical qubits encoded in the toric code.
By considering the dual graph of the lattice, it can be seen that the above paragraph also applies to errors and anyons. Note that the horizontal operator and the vertical operator belong to the same qubit, and vice versa. This ensures the correct commutation relations between logical operators.
Error correction
Consider the noise model for which bit and phase errors occur independently on each qubit, both with probability . When is low, this will create sparsely distributed pairs of anyons which have not moved far from their point of creation. Correction can be achieved by identifying the pairs that the anyons were created in (up to an equivalence class), and then re-annihilating them to remove the errors. As increases, however, it becomes more ambiguous as to how the anyons may be paired without risking the formation of topologically non-trivial loops. This gives a threshold probability, under which the error correction will almost certainly succeed. Through a mapping to the random-bond Ising model, this critical probability has been found to be around 11%.
Other error models may also be considered, and thresholds found. In all cases studied so far, the code has been found to saturate the Hashing bound. For some error models, such as biased errors where bit errors occur more often than phase errors or vice versa, lattices other than the square lattice must be used to achieve the optimal thresholds.
Erasure errors have also been studied using statistical-physics mappings; Masayuki Ohzeki estimated error thresholds for surface codes with lost qubits by analyzing related spin-glass models.
These thresholds are upper limits and are useless unless efficient algorithms are found to achieve them. The most well-used algorithm is minimum weight perfect matching. When applied to the noise model with independent bit and flip errors, a threshold of around 10.5% is achieved. This falls only a little short of the 11% maximum. However, matching does not work so well when there are correlations between the bit and phase errors, such as with depolarizing noise.
Open boundary conditions When adapting the surface code to open boundary conditions, special boundary behaviors arise. As a motivating example, consider defining a surface code in the same way as above, but on an square grid graph. Some vertices on the boundary will have degree 3 instead of 4 (and the corner vertices will have degree 2), so there will be some weight-3 (and weight-2) stabilizers.
The most important characteristic of such an open boundary is that a Pauli error no longer necessarily flips two plaquette stabilizers. An edge on the boundary only has one adjacent plaquette, and thus an error on the corresponding qubit will only flip a single , or in the language of anyons, only create or annihilate a single anyon. One could say that this type of code boundary (known as a smooth boundary) is a source and sink for anyons.
In a surface code with open boundaries, in addition to true loops, one needs to consider paths that start and end at a boundary, which are usually specific to anyon types. In our grid graph example, an anyon can be created at any location on the boundary, move across the grid, and be annihilated at any other location on the boundary. However, since there is only one type of boundary, all these paths are topologically trivial. For example, if an anyon is created somewhere in the middle of the top boundary, moves one step horizontally, then is annihilated again by the top boundary, then its path corresponds to one of the weight-3 stabilizers mentioned above. Meanwhile, anyons can only move within the boundary, so all anyon loops are topologically trivial too. This indicates that this code does not encode any logical qubit, which can be verified by counting qubits and stabilizers: There are qubits (lattice edges), independent vertex stabilizers, and independent plaquette stabilizers (due to the boundary, the product of all plaquette stabilizers is no longer and all of them are independent), and .
To design an open-boundary surface code with a non-trivial codespace, it is necessary to use another type of boundary, the rough boundary which acts as the dual of the smooth boundary. To create a rough boundary, we start from the smooth boundary and remove the edges (qubits) on the boundary that only neighbor one plaquette, but keep those plaquettes as weight-3 stabilizers. The vertex stabilizers on the original boundary are now weight-1 and no longer properly commute with the modified plaquette stabilizers, so those vertex stabilizers are removed too, leaving some "dangling" edges on the lattice (thus the name "rough"). The result is a boundary that acts as a source and sink for anyons.
Now consider a lattice with smooth top and bottom boundaries, and rough left and right boundaries. Such a lattice defines an (unrotated) planar code. An anyon moving from the top boundary to the top boundary is still a topologically trivial path, but one moving from the top boundary to the bottom boundary is no longer topologically trivial, because the anyon could not have exited at the left or right boundary anymore. Similarly, the topologically non-trivial path for anyons is one moving from the left boundary to the right boundary. If the original grid has rows and columns of vertices (before removing the vertex stabilizers on the left and right boundaries), then both types of topologically non-trivial paths have minimum length , indicating that the code encodes a single logical qubit with code distance . The number of logical qubits can again be checked by counting stabilizers: (now the vertex stabilizers are all independent too, due to the "dangling edges" that are only part of one vertex stabilizer).
Rotated planar code The rotated planar code is a variant of the planar code that removes almost half of the physical qubits without affecting the code distance. A distance- rotated planar code has physical qubits, compared to for the unrotated code. The four corners of the unrotated planar code lattice are cut off along diagonal lines, creating new boundaries. The resulting lattice is still in the shape of a square, but rotated by 45°, thus the name.
Conceptually, a surface code can encode a logical qubit with code distance as long as it has four boundaries with alternating types (smooth or rough), and the distance between opposing boundaries (i.e., boundaries of the same type) along lattice edges (Manhattan distance for the square lattice) is at least . This condition holds for the rotated square lattice when these four boundaries coincide with the four sides of the rotated square. For example, the northeast and southwest boundaries may be smooth boundaries while the northwest and southeast boundaries are rough boundaries. Diagonal smooth and rough boundaries have weight-2 and stabilizers respectively.