Linear-Time Maximum Likelihood Decoding of Surface Codes over the Quantum Erasure Channel

Surface codes are among the best candidates to ensure the fault-tolerance of a quantum computer. In order to avoid the accumulation of errors during a computation, it is crucial to have at our disposal a fast decoding algorithm to quickly identify and correct errors as soon as they occur. We propose a linear-time maximum likelihood decoder for surface codes over the quantum erasure channel. This decoding algorithm for dealing with qubit loss is optimal both in terms of performance and speed.

Surface codes are among the best candidates to ensure the fault-tolerance of a quantum computer. In order to avoid the accumulation of errors during a computation, it is crucial to have at our disposal a fast decoding algorithm to quickly identify and correct errors as soon as they occur. We propose a linear-time maximum likelihood decoder for surface codes over the quantum erasure channel. This decoding algorithm for dealing with qubit loss is optimal both in terms of performance and speed.

PACS numbers:
Introduction-Surface codes [1,2] are one of the leading candidates to ensure the fault-tolerance of a quantum computer. Error correction is based on the measurement of local operators on a lattice of qubits. The measurement outcome, called the syndrome, is then processed by the decoding algorithm which uses this information to infer the error which occurred. In order to avoid the accumulation of errors during computation, it is essential for the decoder to be fast. Any speed-up of the decoder leads indirectly to a reduction of the noise strength, since a shorter time between two rounds of correction induces the appearance of fewer errors.
The quantum erasure channel [3,4] is the noise model that represents photon loss or leakage outside the computational space in multi-level systems. The loss of a qubit is equivalent to applying a random Pauli error to this qubit, while giving, as additional data, the position of the error. For stabilizer codes, this extra information reduces the decoding problem to solving a linear system, which can be done with cubic complexity. In the particular case of surface codes, the syndrome of an error is a set of vertices of a lattice and decoding amounts to finding a set of paths connecting these vertices by pairs. One could pick two vertices and connect them by a path and repeat until all the syndrome vertices are matched. This would lead to a quadratic complexity. This strategy was adopted by Dennis et al. to decode Pauli errors [2] or by Barrett and Stace in the case of a combination of Pauli errors and erasures [5].
In the present work, we propose a linear-time maximum likelihood decoder for erasures over surface codes. This is optimal both in terms of performance and in terms of complexity. Our algorithm can be used with any surface code, with arbitrary genus, and any type of boundary [6][7][8], including hyperbolic codes [9][10][11]. In comparison, in the case of Pauli errors the efficient algorithm for maximum likelihood decoding over surface codes obtained by Bravyi, Suchara and Vargo [12], only applies to a restricted set of surfaces.
In the rest of the paper, we describe our decoding algorithm and we prove that it is a maximum likelihood decoder. To illustrate the decoding strategy, we first consider Kitaev's surface codes, then we generalize the approach to surfaces with boundaries, which are more relevant for practical purposes [6][7][8].
Kitaev's surface codes -Kitaev's surface codes [1] are obtained by imposing local constraints on qubits placed on a closed surface. Since only the combinatorial structure of the surface matters, we denote by (V, E, F ) such a surface with vertex set V , edge set E and face set F . These three sets are assumed to be finite. An edge e ∈ E is a pair of distinct vertices e = {u, v}. A face is a region of the surface homeomorphic to a disc and delimited by a set of edges. We represent a face by the set of edges lying on its boundary. We assume that the graph (V, E) has neither loops nor multiple edges. We also suppose that its dual is well defined and satisfies the same properties.
Consider the Hilbert space H = (C 2 ) E . Each qubit is indexed by an egde e and the Pauli operator acting on this qubit as the matrix X, Y or Z and acting trivially elsewhere is denoted respectively by X e , Y e or Z e . Kitaev's surface code is defined to be the ground space of the Hamiltonian The operators X v and Z f generate a group S, the stabilizer group, which fixes the code space. Elements of S are called stabilizers. The Z-stabilizers, that are products of face operators Z f , are the operators of {I, Z} ⊗E whose support is a trivial cycle of G. By cycle, we mean here a subset of edges of G which meets every vertex an even number of times. A cycle is said to be trivial if it lies on the boundary of a set of faces. In the same way, X-stabilizers correspond to trivial cycles of the dual graph. The correction of Pauli errors is based on the measurement of the generators X v and Z f which tells us whether or not the error commutes with these operators. The outcome of this measurement is called the syndrome of the error. Errors with a trivial syndrome, meaning that commute with all the stabilizers, can be seen as operators acting on the code space and are called logical operators. For instance, stabilizers are trivial logical operators. Non-trivial logical operators correspond to non-trivial cycles in the graph G or its dual.
Maximum likelihood decoding for qubit loss -The quantum erasure channel is one of the most simple noise models. Each qubit is lost, or erased, independently with probability p. Such a loss can be detected and the missing qubit is then replaced by a totally mixed state I/2.
, we see that this new qubit can be interpreted as the original state which suffers from a Pauli error I, X, Y or Z chosen uniformly at random. The set of lost qubits is denoted by E. The encoded state is subjected to a random uniform Pauli error P whose support is included in E. Denote this condition by P ⊂ E.
Just like when dealing with Pauli noise, one can then measure the stabilizer generators X v and Z f and try to recover the error P from its syndrome. The main difference with Pauli channels is the additional knowledge of the erasure pattern E. Since operators of S act trivially on the code space, the goal of the decoder is to identify the coset P · S of the error, knowing the set E and the syndrome σ of P . The optimal strategy, called maximum likelihood decoding, is to maximize the conditional probability P(P · S|E, σ).
To illustrate how the knowledge of the erasure E simplifies the decoding problem, assume that we found an errorP ⊂ E whose syndrome matches σ. Both errors P andP have the same syndrome, henceP and P differ in a logical operator L ⊂ E, trivial or not. Due to the fact that errors Q ⊂ E are uniformly distributed, P(Q·S|E, σ) is proportional to the number |Q · S ∩ E| of Pauli errors of that coset that are included in E. This number depends only on the number |S ∩ E| of stabilizers having support inside E, which shows that all the cosets are equiprobable. Therefore, maximum likelihood decoding consists simply of returning an error cosetP · S such that P ⊂ E and the syndrome of P is equal to a given σ. This proves that Lemma 1. Given an erasure E ⊂ E for a surface code and a measured syndrome σ, any cosetP · S of a Pauli errorP ⊂ E of syndrome σ is a most likely coset.
The same argument can be applied to any stabilizer code.
A linear-time maximum likelihood decoder -We now propose a fast algorithm that returns such a most likely coset for Kitaev's surface codes. We detail the construction of the Z-part of the error. The same algorithm will be applied to the dual graph to recover the X-part of the error.
Only measurements of operators X v can detect a Zerror. The syndrome of a Z-error P is thus the subset σ(P ) ⊂ V of vertices v such that X v anti-commutes with this error. Equivalently, it is the set of vertices surrounded by an odd number of qubits supporting an error Z. In order to translate our decoding problem into a graphical language, denote by ∂(A) the set of vertices that a subset A ⊂ E encounters an odd number of times and call it the boundary of A. The syndrome of the Zerror pattern supported on A is exactly ∂(A). Given E ⊂ E and σ ⊂ V , we are looking for a subset of edges Figure 1: (a) A square lattice of the torus. Opposite sides are identified. Red thick edges mark the set E of erased qubits which support some Z-error. Its syndrome is indicated by large red nodes. (b) A spanning forest F E (thick red lines in (b)) is constructed. Then, starting from the leaves, an error included in the F E is constructed using the syndrome.
Here, this provides a correct estimation of the error up to a stabilizer.
We now describe Algorithm 1 which is illustrated on Fig. 1.
Paradoxically, an obstacle to a linear-time complexity is the presence of cycles in E. Although cycles increase the number of paths from a vertex to another and potentially make it easier to find one, they also make it easier to make suboptimal choices. Our basic idea is not to try to sequentially find paths that pair the syndrome vertices together but instead to shrink recursively the set of edges on which we have yet to make a decision. To this end we select a spanning forest F E inside E, that is a maximal subset of edges of E that contains no cycle and spans all the vertices of E. If E is a connected graph, then F E is also connected and is called a spanning tree. Such a forest can be found in linear time.
Equipped with the forest F E that contains all the syndrome vertices, we can now find the required subset A very efficiently. Starting with the empty set, we construct A, by applying recursively the following rules.
(R1) Pick a leaf, that is an edge e = {u, v} connected to the forest through only one of its 2 endpoints, say v. The vertex u is called a pendant vertex. Assume first that u ∈ σ, then we add the edge e to the set A and we flip the vertex v. By flipping, we mean that v is added to the set σ if v / ∈ σ and it is removed from σ in the case v ∈ σ. Then, e is removed from the forest F E .
(R2) In the case when u / ∈ σ, this edge is simply removed from F E and A is kept unchanged.
Through these 2 steps, we peel the forest F E until only an empty set remains. The construction of the set A is then complete. This procedure relies on the following obvious remark, stated as a lemma to emphasize the role of the two rules applied in Algorithm 1.
Lemma 2 (leaf alternative). Let A be a subset of edges of a tree T . If e = {u, v} is a leaf with pendant vertex u, then (R1) either u ∈ ∂(A) and e ∈ A, (R2) or u / ∈ ∂(A) and e / ∈ A.
This strategy is guaranteed to end after a finite number of steps. It remains to show that it returns the expected set A. We must verify that such a set A exists and that the peeling process does not depend on the order in which leaves of the forest are removed. This is done in the proof of Theorem 1.

Algorithm 1 Maximum Likelihood decoding
Require: A surface G = (V, E, F ), an erasure E ⊂ E and the syndrome σ ⊂ V of a Z-error. Ensure: A Z-error P such that P ⊂ E and σ(P ) = σ.
1: Construct a spanning forest F E of E. (R1) If u ∈ σ, add e to A, remove u from σ and flip v in σ.

5:
(R2) If u / ∈ σ do nothing. 6: Return P = e∈A Ze. Theorem 1. For surface codes with bounded degree and faces of bounded size, applying Algorithm 1 to the graph and to its dual produces a linear-time maximum likelihood decoder.
During step 3 of the algorithm, a naive approach would be to look for a leaf by running over the forest at each round but this strategy would lead to a super-linear complexity. However, we can ensure linear complexity by running over the whole forest and precomputing a list of leaves. For a bounded degree graph, this list can then be updated in constant time at each round when an edge is removed from the forest.
Proof. Finding a spanning forest has a linear cost, then our algorithm runs over each edge of the forest only once, leading to a linear-time complexity overall. We have to prove that the set A, constructed by this algorithm, satisfies the claimed properties. The fact that A ⊂ E is immediate. Only the condition ∂(A) = σ deserves some attention. First, we will show that, for any choice of F E , there exists a set A ⊂ F E such that ∂(A) = σ and that this set is unique. Then we will see that applying (R1) and (R2), starting from the leaves, indeed constructs this set A.
There exists a subset B such that B ⊂ E and ∂(B) = σ since σ is the syndrome of an error. We will reroute the paths contained in B to squeeze this subset inside F E without changing its boundary. Let x 1 , . . . , x m be the edges of B\F E . By maximality of the forest F E , adding any extra edge x i to F E creates a cycle γ i ⊂ F E ∪ {x i }. In order to remove x 1 from the set B, replace B by B 1 = B∆γ 1 where ∆ denotes the symmetric difference of these two sets of edges. Then, x 1 / ∈ B 1 , only edges of F E are added to B and x 2 , . . . , x m are untouched. By repeating this transformation, one creates a sequence This set A is unique. Indeed if there exists two such subsets A and A , their symmetric difference A∆A is a subset of the forest which has a trivial boundary ∂(A∆A ) = ∅ meaning that A∆A is a cycle. Since this cycle is in a forest, it can only be the empty set, proving that A = A . Now that existence and unicity of A are established, we see that the alternative offered by Lemma 2 can only end with the set A. The result of our algorithm is independent of the order in which we pick the leaves in step 3 by unicity of A. The existence of A garanties that our algorithm finds this set after peeling the whole forest.
Surfaces with boundaries -Kitaev's construction of surface codes can be generalized to surfaces with boundaries, that is closed surfaces punctured with holes. Introducing boundaries leads to a key simplification for the experimental realization of topological codes. One can obtain non-trivial surface codes based on planar lattices. This motivates the generalization of our decoding algorithm to such surface codes. Two kinds of codes based on surfaces with boundaries have been suggested. First, Freedman and Meyer noticed that one can consider a surface with boundaries [6]. Algorithm 1 can be immediately adapted to these codes. Secondly, Bravyi and Kitaev introduced two different types of stabilizers supported on two types of boundaries [7]. Adapting our decoding algorithm to these codes presents two difficulties. First, the syndrome depends on the type of boundary and second, the spanning forest has to be grown in a way that depends on the boundary type.
We use the formalism of [8] that encompasses both generalizations of Kitaev's codes. We consider a surface G = (V, E, F ) with boundary, which means that some edges belong to a unique face. On the boundary, some edges and their endpoints are declared to be open. We  (R1) If u ∈ σ, add e to A, remove u from σ and flip v in σ.
Consider an erasure E ⊂E which comes with a Pauli error affecting erased qubits. Again, it suffices to focus on the correction of the Z-part of the error. Open vertices do not support any measurement X v . Hence, the syndrome of a Z-error of support A ⊂E is given by the restriction of ∂(A) to non-open vertices. Denote bẙ ∂(A) ⊂V this restricted boundary. The missing information on open vertices makes it impossible to reconstruct the error starting from those vertices. We must find a way to peel the whole forest using only non-open vertices. In order to be sure that the peeling algorithm is not stuck before removing all the edges of the forest, we will grow the forest starting from open vertices and peel it the other way round as depicted in Figure 2.
Let us explain Algorithm 2. An example is depicted in Fig. 2. We must adapt the way the spanning forest is obtained. First, let us explain a simple strategy to find a spanning tree of a connected graph H = (V, E). For a general graph, applying this method to all the connected components produces a spanning forest. Our starting point is a tree T that contains only a single arbitrary vertex v of H and no edge. We grow T by adding edges incident to the tree that connect T with a vertex of H that does not already belong to T . After adding |V | − 1 edges, one gets our spanning tree.
In algorithm 2, we will grow a spanning forest of a graph H = (V, E) equipped with a marked subset of vertices O ⊂ V that we call the seed. The spanning tree of a connected component containing a vertex v O ∈ O is constructed starting with this vertex v O . Then, just as before we add edges that reach new vertices but we also require that these newly reached vertices do not belong to O. If the connected component does not contain any seed vertex, the previous method applies.
Theorem 2. For generalized surface codes with bounded degree and faces of bounded size, applying Algorithm 2 to the graph and to its dual produces a linear-time maximum likelihood decoder. Proof. Existence and uniqueness of the set A follow from the same argument as in the proof of Theorem 1 after replacing cycles by relative cycles. Recall that a relative cycle is a subset of edges that meets each non-open vertex an even number of time. The space of relative cycles of graph is studied for instance in Section 4.1 of [8]. Then, Lemma 2, which provides the recursive construction of the error, is used in an identical way. We only need to make sure that the pendant vertices u picked in step 3 are not open. Our algorithm picks these vertices by reversing the construction of the forest with open vertices as a seed. This guarantees that one can peel the whole forest and we end up with the correct set A which provides the support of this error.
Concluding remarks -In this work, we considered the decoding problem of surface codes over the quantum era-sure channel. Despite the presence of inconvenient short cycles, we managed to design an optimal decoding algorithm that runs in linear time. Our basic idea is to remove these short cycles by decoding within a spanning forest. In the case of classical error correction, studying linear-time decoding from erasures paved the way for better and better linear (or quasi-linear) decoders in the case of more complicated channels. We may hope that in the quantum setting, solving the decoding problem for the erasure channel may similarly lead towards improved decoders for more complicated noise models and other families of codes. In particular, a serious obstacle to decoding quantum LDPC codes is also the presence of short cycles in their Tanner graph. How to deal with them in general remains widely open [13][14][15][16]. It is crucial to consider such generalizations that may allow for fault-tolerant universal quantum computation with a considerably reduced overhead [17]. One could also consider the correction of losses assuming imperfect gates and measurements [18,19] or in the context of linear optical quantum computing where photon losses are a major obstacle [20][21][22][23].