Cellular automaton decoders for topological quantum codes with noisy measurements and beyond

We propose an error correction procedure based on a cellular automaton, the sweep rule, which is applicable to a broad range of codes beyond topological quantum codes. For simplicity, however, we focus on the three-dimensional toric code on the rhombic dodecahedral lattice with boundaries and prove that the resulting local decoder has a non-zero error threshold. We also numerically benchmark the performance of the decoder in the setting with measurement errors using various noise models. We find that this error correction procedure is remarkably robust against measurement errors and is also essentially insensitive to the details of the lattice and noise model. Our work constitutes a step towards finding simple and high-performance decoding strategies for a wide range of quantum low-density parity-check codes.


I. INTRODUCTION
Developing and optimizing decoders for quantum error-correcting codes is an essential task on the road towards building a fault-tolerant quantum computer [1][2][3].A decoder is a classical algorithm that outputs a correction operator, given an error syndrome, i.e. a list of measurement outcomes of parity-check operators.The error threshold of a decoder tells us the maximum error rate that the code (and hence an architecture based on the code) can tolerate.Moreover, decoder performance has a direct impact on the resource requirements of faulttolerant quantum computation [4].In addition, the runtime of a decoder has a large bearing on the clock speed of a quantum computer and may be the most significant bottleneck in some architectures [5,6].
Cellular-automaton (CA) decoders for topological codes [33][34][35][36][37][38][39] are particularly attractive because they are local: at each vertex of the lattice we compute a correction using a simple rule that processes syndrome information in the neighbourhood of the vertex.This is in contrast to more complicated decoders such as the minimum-  FIG. 1. Numerical error threshold estimates for the sweep decoder applied to the toric code on the rhombic dodecahedral lattice.In (a), we plot the error threshold p th (N ) as function of the number of error-correction cycles N , for an error model with equal phase-flip (p) and measurement error (q) probabilities (α = q/p = 1).The inset shows the data for N = 2 10 , where we use 10 4 Monte Carlo samples for each point.Using the ansatz in Eq. (10), we estimate the sustainable threshold to be psus ≈ 2.1%.In (b), we plot psus for error models with different values of α, where we approximate psus ≈ p th (2 10 ).
weight perfect matching algorithm [10], which requires global processing of the entire syndrome to compute a correction.Moreover, CA decoders have another advan-tage: they exhibit single-shot error correction [40,41], i.e. it is not necessary to repeat stabilizer measurements to compensate for the effect of measurement errors.
In our work we study the recently proposed sweep decoder [39], a cellular-automaton decoder based on the sweep rule.First, we adapt the sweep rule to an abstract setting of codes without geometric locality, which opens up the possibility of using the sweep decoder for generic low-density parity-check codes.Second, we show how the sweep decoder can be used to decode the 3D toric code on the rhombic dodecahedral lattice with boundaries and we prove that it has a non-zero error threshold.We remark that the original sweep decoder only works for the toric code defined on lattices without boundaries.Third, we numerically simulate the performance of the decoder in the setting with measurement errors and further optimize its performance.We use an independent and identically distributed (iid) error model with phase-flip probability p and measurement error probability q.We observe an error threshold of ∼2.1% when q = p, an error threshold of ∼2.9% when q = 0 and an error threshold of ∼8% when p → 0 + ; see Fig. 1.
We report that the sweep decoder has an impressive robustness against measurement errors and in general performs well in terms of an error-correction threshold.To compare the sweep decoder with previous work [42][43][44][45], we look at the 3D toric code on the cubic lattice, as decoding the 3D toric code on the rhombic dodecahedral lattice has not been studied before; see Table I.
The remainder of this article is structured as follows.In Section II, we start by presenting how the sweep rule can be used in an abstract setting of codes without geometric locality.Then, we outline a proof of the non-zero error threshold of the sweep decoder for the 3D toric code on the rhombic dodecahedral lattice with boundaries.We also present numerical simulations of the performance of the decoder in the setting with measurement errors for lattices with and without boundaries.Next, in Section III, we discuss the applicability of the sweep decoder and suggest directions for further research.Finally, in Section IV, we prove the properties of the sweep rule in the abstract setting, and analyze the case of lattices with boundaries.

II. RESULTS
We start this section by adapting the sweep rule [39] to the setting of causal codes, which go beyond topological quantum codes.Then, we focus on the 3D toric code on the rhombic dodecahedral lattice.We first analyze the case of the infinite lattice, followed by the case of lattices with boundaries.We finish by presenting numerical simulations of the performance of various optimized versions of the sweep decoder.

A. Sweep rule for causal codes
Recall that a stabilizer code is CSS iff its stabilizer group can be generated by operators that consist exclusively of Pauli X or Pauli Z operators.Let Q denote the set of physical qubits of the code and S be the set of all X stabilizer generators, which are measured.We refer to the stabilizers returning −1 outcome as the X-type syndrome.The X-type syndrome constitutes the classical data needed to correct Pauli Z errors.In what follows, we focus on correcting Z errors as X errors are handled analogously.
We start by introducing a partially ordered set V with a binary relation over its elements.We refer to the elements of V as locations.Given a subset of locations U ⊆ V , we say that a location w ∈ V is an upper bound of U and write U w iff u w for all u ∈ U ; a lower bound of U is defined similarly.The supremum of U , denoted by sup U , is the least upper bound of U , i.e., sup U w for each upper bound w of U .Similarly, the infimum inf U is the greatest lower bound of U .We also define the future and past of w ∈ V to be, respectively We define the causal diamond of U as the intersection of the future of inf U and the past of sup U .Lastly, for any A ⊆ 2 V , where 2 V is the power set of V , we define the restriction of A to the location v ∈ V as follows For notational convenience, we use the shorthands A = A∈A A and sup A = sup A.
Let C Q and C S be F 2 -linear vector spaces with the sets of qubits Q and X stabilizer generators S as bases, respectively.Note that there is a one-to-one correspondence between vectors in C Q and subsets of Q, thus we treat them interchangeably; similarly for vectors in C S and subsets of S. Let ∂ : C Q → C S be a linear map, called the boundary map, which for any Pauli Z error with support ⊆ Q returns its X-type syndrome σ ⊆ S, i.e., σ = ∂ .We say that a location v ∈ V is trailing for σ ∈ im ∂ iff σ| v is nonempty and belongs to the future of v, i.e., σ| v ⊂ ↑(v).Now, we proceed with defining a causal code.We say that a quadruple ((V, ), Q, S, ∂) describes a causal code iff the following conditions are satisfied.

(causal diamonds) For any finite subset of locations
U ⊆ V there exists the causal diamond ♦ (U ).
2. (locations) Every qubit Q ∈ Q and every stabilizer generator S ∈ S correspond to finite subsets of locations, i.e., Q, S ⊆ V .

(syndrome evaluation)
The syndrome ∂ of any error ⊆ Q can be evaluated locally, i.e., 5. (trailing location) For any location v ∈ V and the syndrome σ ∈ im ∂, if σ| v is nonempty and σ| v ⊂ ↑(v), then there exists a subset of qubits We can adapt the sweep rule to any causal code ((V, ), Q, S, ∂).We define the sweep rule for every location v ∈ V in the same way as in Ref. [39].
Our first result is a lemma concerning the properties of the sweep rule.But, before we state the lemma, we must make some additional definitions.Let u, v ∈ V be two locations satisfying u ≺ v.We say that a sequence of locations u ≺ w 1 ≺ . . .≺ w n ≺ v, where n = 0, 1, . .., forms a chain between u and v of length n + 1.We define N (u, v) to be the collection of all the chains between u and v.We write (N ) to denote the length of the chain N ∈ N (u, v).
Given a causal code ((V, ), Q, S, ∂), we define its corresponding syndrome graph G as follows.For each stabilizer S ∈ S, there is a node in G and we add an edge between any two nodes iff their corresponding stabilizers both have a non-zero intersection with the same qubit in Q.We define the syndrome distance d G (S, T ) between any two stabilizer generators S, T ∈ S to be the graph distance in G, i.e., the length of the shortest path in G between the nodes corresponding to S and T .This can be extended to the syndromes σ, τ ⊆ S in the obvious way: d G (σ, τ ) = min S∈σ,T ∈τ d G (S, T ).
Lemma 1 (sweep rule properties).Let σ ∈ im ∂ be a syndrome of the causal code ((V, ), Q, S, ∂).Suppose that the sweep rule is applied simultaneously at every location in V at time steps T = 1, 2, . .., and the syndrome is updated at each time step as follows: σ (T +1) = σ (T ) +∂ϕ (T ) , where ϕ (T ) is the set of qubits returned by the rule.Then, 1. (support) the syndrome at time T , σ (T ) stays within the causal diamond of the original syndrome, i.e.
2. (propagation) the syndrome distance between σ and any S ∈ σ (T ) is at most T , i.e.
3. (removal) the syndrome is trivial, i.e. σ (T ) = 0, for The above lemma is analogous to Lemma 2 from Ref. [39], but is not limited to codes defined on geometric lattices; rather, it now applies to more general causal codes.We defer the proof until Section IV.

B. Rhombic dodecahedral toric codes
In this section, we examine an example of a causal code: the 3D toric code defined on the infinite rhombic dodecahedral lattice.Toric codes defined on this lattice are of interest because they arise in the transversal implementation of CCZ in 3D toric codes [16,18,32].Consider the tessellation of R 3 by rhombic dodecahedra, where a rhombic dodecahedron is a face-transistive polyhedron with twelve rhombic faces.One can construct this lattice from the cubic lattice, as follows.Begin with a cubic lattice, where the vertices of the lattice are the elements of Z 3 .Create new vertices at all half-integer coordinates (x/2, y/2, z/2), satisfying x + y + z = 0 mod 2 and xyz = 1 mod 2. These new vertices sit at the centres of half of all cubes in the cubic lattice.For each such cube, add edges from the new vertex at its centre to the vertices of the cube.Finally, delete the edges of the cubic lattice.The remaining lattice is a rhombic dodecahedral lattice.Figure 3 gives an example of this procedure.
We denote the infinite rhombic dodecahedral lattice by L ∞ , and we denote its vertices, edges, and faces by L ∞ 0 , L ∞ 1 , and L ∞ 2 , respectively.In the notation of the previous section, Let ω ∈ R 3 be a vector (a sweep direction) that is not perpendicular to any of the edges of L ∞ .Such a sweep direction induces a partial order over L ∞ 0 , as we now explain.Let (u : v) denote a path from one vertex v ∈ L ∞ 0 to another vertex u ∈ L ∞ 0 , where (u : v) = {(u, w 1 ), . . ., (w n , v)} is a set of edges.We call a path from u to v causal (denoted by (u v)) if the inner product ω • (w i , w i+1 ) has the same sign for all edges (w i , w i+1 ) ∈ (u v).We write u v, if u = v or there exists a causal path, (u v), and ω • (w i , w i+1 ) > 0 for all edges in the path.
We now verify that the rhombic dodecahedral toric code equipped with a sweep direction is a causal code.We choose a sweep direction that is parallel to one of the edges directions of the lattice, ω = (1, 1, 1).First, consider the causal diamond condition.One can prove by induction that any finite subset of vertices of the lattice has an infimum and supremum, and therefore has a unique causal diamond.Figure 2 shows an example of the future of a vertex and the causal diamond of a subset of vertices.By definition, the qubits and stabilizer generators are associated with faces and edges, which are finite subsets of locations (vertices), so the locations condition is satisfied.Next, consider the qubit infimum conidition.The faces of the lattice are rhombi, and as ω is not perpendicular to any of the edges of the lattice, each face contains its infimum.
Next, consider the syndrome evaluation condition.We consider vector spaces C 1 and C 2 with bases given by e ∈ L ∞ 1 and f ∈ L ∞ 2 , respectively.This allows us to define the linear boundary operator ∂ : C 2 → C 1 , which is specified for all basis elements f ∈ C 2 as follows: ∂f = e∈f e.In words, for each face, ∂ returns the sum of the edges in the face.The syndrome of an error ⊆ L ∞ 2 is then ∂ .This syndrome evaluation procedure is local.Now, we consider the final causal code condition: the trailing location condition.The rhombic dodecahedral lattice has two types of vertex: one type is degree four and the other is degree eight.Given our choice of sweep direction, one can easily verify that the trailing location condition is satisfied at all the vertices of L ∞ , as illustrated in Fig. 2c.

C. Sweep decoder for toric codes with boundaries
In this section, we consider the extension of the sweep rule to 3D toric codes defined on a family of rhombic dodecahedral lattices L with boundaries, with growing linear size L. We discuss the problems that occur when we try to apply the standard sweep rule to this lattice.Then, we present a solution to these problems in the form of a modified sweep decoder.
We construct a family of rhombic dodecahedral lattices with boundaries from the infinite rhombic dodecahedral lattice, by considering finite regions of it.We start with a cubic lattice of size (L−1)×(L+1)×L, with vertices at integer coordinates (x, y, z) To construct a rhombic dodecahedral lattice, we create vertices at the centre of cubes with coordinates (x/2, y/2, z/2) satisfying x + y + z = 0 mod 2 and xyz = 1 mod 2. Then for each vertex at the centre of a cube, we create edges from this vertex to all the vertices (x, y, z) of its cube satisfying 0 < y < L + 1 and 0 < z < L. Finally, we delete the edges of the cubic lattice and all the vertices (x, y, z) of the cubic lattice with y = 0, L + 1 or z = 0, L. Figure 3 illustrates the construction of the rhombic dodecahedral lattice L for L = 3.
We denote the vertices, edges, and faces of the lattice L by L 0 , L 1 , and L 2 , respectively.As in the previous section, we associate qubits with the faces of the lattice and we associate X stabilizer generators with the edges.We define a local region of L to be a region of L with diameter smaller than L/2.In particular, there are no non-trivial logical Z operators supported within a local region.The boundary map ∂ is defined in the same way as the infinite case, except for an important caveat.Some faces in L only have one or two edges (see Fig. 3), so ∂ can return the sum of fewer than four edges.In the bulk of the lattice, syndromes must form closed loops.As illustrated in Fig. 3b, the lattices in our family have two types of boundaries: rough and smooth.Open loops of syndrome may only terminate on the rough boundaries.For a chosen sweep direction, some vertices on the boundaries of L will not satisfy the trailing location condition (see Fig. 3d for an example).This means that some syndromes near the boundary are immobile under the action of the Sweep rule.Clearly, this poses a significant problem for a decoder based on the Sweep rule, as there are some constant weight errors whose syndromes are immobile.Fortunately, there is a simple solution to this problem: periodically varying the sweep direction.We pick a set of eight sweep directions where each ω ∈ Ω is parallel to one of the eight edge directions of L. The rule for each direction is analogous to that shown in Fig. 2c.For our set of sweep directions, there are no errors within a local region whose syndromes are immobile for every sweep direction.To make this statement precise, we need to adapt the definition of a causal diamond to lattices with boundaries.As L is a subset of the infinite rhombic dodecahedral lattice L ∞ , the causal diamond of U ⊆ L 0 is well defined in L ∞ for any ω ∈ Ω, but it may contain subsets of vertices that are not in L. Roughly speaking, we define the causal region of U with respect to ω, R ω (U ), to be the restriction of the causal diamond in L ∞ (with respect to ω) to the finite lattice L.More precisely, it is a subset of the elements of the causal diamond, whose vertices belong to L, i.e.R ω (U ) = 2 ♦ ω (U )∩L0 , where ♦ ω (U ) is the causal diamond with respect to ω.We now state a lemma that is sufficient to prove that a decoder based on the Sweep rule has a non-zero error threshold for rhombic dodecahedral lattices with boundaries.Lemma 2. Let Ω be a set of sweep directions and σ ∈ im ∂ be a syndrome, such that R ω (σ) is contained in a local region of L for all ω ∈ Ω.Then there exists a sweep direction ω * ∈ Ω such that the trailing location condition is satisfied at every vertex in R ω * (σ).
We defer the proof of Lemma 2 until Section IV.We now give a pseudocode description of a modified sweep decoder that works for 3D toric codes defined on lattices with boundaries.
while T ≤ Tmax do Apply the sweep rule with sweep direction ω simultaneously to every vertex of L to get ϕ (T ) ⊆ L2, the set of qubits returned by the rule.
The decoder can fail in two ways.Firstly, if the syndrome is still non-trivial after |Ω| × T max applications of the sweep rule, we consider the decoder to have failed.Secondly, the decoder can fail because the product of the correction and the original error implements a non-trivial logical operator.We can now state our main theorem.
Theorem 1.Consider 3D toric codes defined on a family of rhombic dodecahedral lattices L, with growing lin-ear size L.There exists a constant p th > 0 such that for any phase-flip error rate p < p th , the probability that the sweep decoder fails is O (p/p th ) β1L β 2 , for some constants β 1 , β 2 > 0.
We provide a sketch of the proof here, and postpone the details until Appendix A. Our proof builds on [33,39,46,47] and relies on standard results from the literature [46,48].
Proof.First, we consider a chunk decomposition of the error.This is a recursive definition, where the diameter of the chunk is exponential in the recursion level.Next, we use the properties of the sweep rule (Lemma 1) to show that the sweep decoder successfully corrects chunks up to some level m * = O (log L).To accomplish this, we first show that the sweep decoder is guaranteed to correct errors whose diameter is smaller than L, in a number of time steps that scales linearly with the diameter.Secondly, we rely on a standard lemma that states that a connected component of a level-m chunk is well separated from level-n chunks with n ≥ m, which means that the sweep decoder corrects connected components of the error independently.Finally, percolation theory tells us that the probability of an error containing a level-n chunk is O (p/p th ) 2 n , for some p th > 0. As the decoder successfully corrects all level-n chunks for n < m * = O (log L), the failure probability of the decoder is O (p/p th ) β1L β 2 .

D. Numerical implementation and optimization
We implemented the sweep decoder in C++ and simulated its performance for 3D toric codes defined on rhombic dodecahedral lattices, with and without boundaries.The code is available online [49].We study the performance of the sweep decoder for error models with phaseflip and measurement errors.Specifically, we simulate the following procedure.

Definition 2 (Decoding with noisy measurements).
Consider the 3D toric code with qubits on faces and X stabilizers on edges.At each time step T ∈ {1, . . ., N }, the following events take place: 1.A Z error independently affects each qubit with probability p.
2. The X stabilizer generators are measured perfectly.
3. Each syndrome bit is flipped independently with probability q = αp, where α is a free parameter.
4. The sweep rule is applied simultaneously to every vertex, and Z corrections are applied to the qubits on faces returned by the rule.
After N time steps have elapsed, the X stabilizer generators are measured perfectly and we apply Algorithm 1. Decoding succeeds if, and only if, the product of the errors and corrections (including the correction returned by Algorithm 1) is a Z-type stabilizer.
We note that measuring the stabilizers perfectly after N time steps may seem unrealistic.However, this can model readout of a CSS code, because measurement errors during destructive single-qubit X measurements of the physical qubits have the same effect as phase-flip errors immediately prior to the measurements.
We first present our results for lattices with periodic boundary conditions i.e. each lattice is topologically a 3torus.Although changing the sweep direction is not necessary for such lattices, we observe improved performance compared with keeping a constant sweep direction.We consider error models with phase-flip error probability p and measurement error probability q = αp, for various values of α.For a given error model, we study the error threshold of the decoder as a function of N , the number of cycles, where a cycle is one round of the procedure described in Definition 2. For a range of values of N , we estimate the logical error rate, p L , as a function of p for different values of L (the linear lattice size, or equivalently the code distance of the toric code).We estimate the error threshold as the value of p at which the curves for different L intersect.We find that the error threshold decays polynomially in N to a constant value, the sustainable threshold.The sustainable threshold is a measure of how much noise the decoder can tolerate over a number of cycles much greater than the code distance.We use the following numerical ansatz to model the behaviour of the error threshold as a function of N , where γ and p sus (the sustainable threshold) are parameters of the fit.For an error model with α = q/p = 1, we find a sustainable threshold of p sus ≈ 2.1%, with γ = 1.06 and p th (1) = 21.5% (as shown in Fig. 1).We observe that the decoder has a significantly higher tolerance to measurement noise as opposed to qubit noise, as shown in Fig. 1.We find that the maximum phase-flip error rate that the decoder can tolerate is p ≈ 2.9% (for q = 0), compared with a maximum measurement error rate of q ≈ 8% (for p → 0 + ).Our results show that the sweep decoder has an inbuilt resilience to measurement errors.To understand why this is the case, let us analyse the effect of measurement errors on the decoder.First, consider measurement errors that are far from phase-flip errors.A single isolated measurement error cannot cause the decoder to erroneously apply a Pauli-X operator.To deceive the decoder, two measurement errors must occur next to each other, such that a vertex becomes trailing.Second, measurement errors in the neighbourhood of phase-flip errors can interfere with the decoder, and prevent it from applying a correction.Thus, to affect the performance of the decoder, a single measurement error either has to occur close to a phase-flip measurement error.This explains why the sweep decoder has a higher tolerance of measurement errors relative to phase-flip errors.
We also simulated the performance of the decoder for lattices with boundaries.We consider toric codes defined the family of rhombic dodecahedral lattices with boundaries that we described in Section II C. We find that the sustainable threshold of toric codes defined on this lattice family is p sus ≈ 2.1%, for an error model where α = q/p = 1.This value matches the sustainable threshold for the corresponding lattice with periodic boundary conditions, as expected.
A natural question to ask is whether applying the sweep rule multiple times per stabilizer measurement improves the performance of the decoder.Multiple applications of the rule could be feasible if gates are much faster than measurements, as in e.g. in trapped-ion qubits [50].We found that increasing the number of applications of the rule per syndrome measurement significantly improved the performance of the decoder for a variety of error models (including error models where α = q/p > 1); see Fig. 4 for an example.Improving the performance of the sweep decoder applied to the toric code on the rhombic dodecahedral lattice (with boundaries) by applying the rule multiple times per syndrome measurement.We set α = q/p = 1 and we fix N = 2 10 error correction cycles.We plot the logical error rate pL as a function of p for different linear lattice sizes L. We applied the rule three times per syndrome measurement and we observe an error threshold of p th ≈ 3.2%, an improvement of over the corresponding error threshold of p th ≈ 2.17% when we applied the rule once per syndrome measurement (see the inset of ??).We use 10 4 Monte Carlo samples for each point.
The ability to change the sweep direction gives us parameters that we can use to tune the performance of the decoder.They are: the frequency with which we change the sweep direction and the order in which we change the sweep direction.We investigated the effect of varying both of these parameters.The most significant parameter is the direction-change frequency.Our simulation and p = q = 0.021.We achieve the best performance when we change sweep direction every ∼ log L cycles.We use 10 4 samples for each point.
naturally divides into two phases: the error suppression phase where the rule applied while errors are happening, and the perfect decoding phase where the rule is applied without errors.In the error suppression phase, we want to prevent the build-up of errors near the boundaries so we anticipate that we may want to vary the sweep direction more frequently.We find that changing direction after ∼ log L sweeps in the error-suppression phase and L sweeps in the perfect decoding phase gave the best performance, as shown in Fig. 5.We find that the order in which we change the sweep direction does not appreciably impact the performance of the decoder.In addition, we find that the performance of the regular sweep decoder was superior to the greedy sweep decoder introduced in [39].Finally, we evaluated the performance of the sweep decoder against a simple correlated noise model, finding a reduced error threshold (see Appendix C).

III. DISCUSSION
In this article, we extended the definition of the sweep rule CA to causal codes.We also proved that the sweep decoder has a non-zero error threshold for 3D toric codes defined on a family of lattices with boundaries.In addition, we benchmarked and optimized the decoder for various 3D toric codes.
We now comment on the performance of the sweep decoder compared with other decoding algorithms.Recall that in Table I, we list the error thresholds obtained from numerical simulations for various decoders applied to toric codes defined on the cubic lattice (see Appendix B for details on the sweep decoder numerics).Although the sweep decoder does not have the highest error threshold, it has other advantages that make it attractive.Firstly, as it is a CA decoder, it is highly parallelizable, which is an advantage when compared to decoding algorithms that require more involved processing such as the RG decoder introduced in Ref. [44].In addition, whilst neural network decoders such as [43] have low complexity once the network is trained, for codes with boundaries the training cost may scale exponentially with the code distance [51].Also, the sweep decoder is the only decoder in Table I that exhibits single-shot error correction.In contrast, using the RG decoder it is necessary to repeat the stabilizer measurements O (L) times before finding a correction, which further complicates the decoding procedure.Finally, we note there is still a large gap between the highest error thresholds in Table I and the theoretical maximum error threshold of p th = 23.180(4)%, as predicted by statistical mechanical mappings [52][53][54][55].
The sweep decoder could also be used in other topological codes with boundaries.Recently, it was shown that toric code decoders can be used to decode color codes [56].Therefore, we could use the sweep decoder to correct errors in d ≥ 3-dimensional color codes with boundaries, as long as the toric codes on the restricted lattices of the color codes are causal codes.
We expect that the sweep decoder would be wellsuited to (just-in-time) JIT decoding, which arises when one considers realizing a 3D topological code using a constant-thickness slice of active qubits.In this context, the syndrome information from the full 3D code is not available, but we still need to find a correction.The sweep decoder is ideally suited to this task, because it only requires local information to find a correction.Let us consider the JIT decoding problem described in [32] as an example.We start with a single layer of 2D toric code.Then we create a new 2D toric code layer above the first, with each qubit prepared in the |0 state.Next, we measure the X stabilizers of the 3D toric code that link the two 2D layers.Then, we measure the qubits of the lower layer in the Z basis.We iterate this procedure until we have realized the full 3D code.
The X stabilizer measurements will project two layers of 2D toric code into a single 3D toric code, up to a random Pauli Z error applied to the qubits.This error will have a syndrome consisting of closed loops of edges.The standard decoding strategy is simply to apply an Z operator whose boundary is equal to the closed loops.However, when measurement errors occur, the syndrome will consist of broken loops.We call the ends of broken loops breakpoints.To decode with measurement errors, one can first close the broken loops (pair breakpoints) using the minimum-weight perfect matching algorithm, before applying an Z correction.However, in the JIT scenario, some breakpoints may need to be paired with other breakpoints that will appear in the future.In [32], Brown proposed deferring the pairing of breakpoints until later in the procedure, to reduce the probability of making mistakes.However, given the innate robustness of the sweep decoder, instead of using the 'repair-thencorrect' decoder outlined above, we could simply apply the sweep decoder at every step and not worry about the measurement errors.Given the results presented in Section II D, we anticipate that the sweep decoder would be effective in this case, and so provides an alternative method of JIT decoding to that is worth exploring.
We finish this section by suggesting further applications of the sweep decoder, such as decoding more general quantum LDPC codes, e.g.hypergraph product codes [57], especially those introduced in [58].The abstract reformulation of the sweep rule CA presented in Section I provides a clear starting point for this task.In addition, we would like to prove the existence of a nonzero error threshold when measurements are unreliable.From our investigation of this question, it seems that the proof technique in Appendix A breaks down for this case.

IV. METHODS
In this section, we prove Lemma 1, which concerned the properties of the sweep rule in an abstract setting.In addition, we show that the sweep rule retains essentially the same properties for rhombic dodecahedral lattices with boundaries.We require these properties to prove a non-zero error threshold for the sweep decoder (see Appendix A).We begin with a useful lemma about causal diamonds, which we will use throughout this section.
Lemma 3. Let V be a partially ordered set such that for any finite subset U, W ⊆ V , there exists the causal diamond ♦ (U ).If U ⊆ W , then Proof.We recall that ♦ (U ) = ↑(inf U ) ∩ ↓(sup U ).As both ↑(inf U ) and ↓(sup U ) contain U , their intersection also contains

A. Proof of sweep rule properties
Proof of Lemma 1. First, we prove the support property by induction.At time step T = 1 (before the rule is applied), this property holds.Now, consider the syndrome at time T , σ (T ) .Let U (T ) denote the set of trailing locations of the syndrome at time step T .Between time steps T and T + 1, for each trailing location u ∈ U (T ) , the sweep rule will return a subset of qubits ϕ (T ) (u) with the property that [∂ϕ (T ) (u)]| u = σ (T ) | u .Therefore, the syndrome at time step T + 1 is By assumption, ♦ (∂ϕ(u)) = ♦ σ (T ) | u , and ♦ (σ) (T ) ⊆ ♦ (σ).Making multiple uses of Lemma 3, we have Next, we prove the propagation property, also by induction.The property is true at time step T = 1.Now, we prove the inductive step from time step T −1 to T .As long as σ (T ) = 0, for every S ∈ σ (T ) , either S ∈ σ (T −1) or there exists an edge in the syndrome graph between the node corresponding to S and a node corresponding to S ∈ σ (T −1) .By invoking the triangle inequality, we conclude that To prove the removal property, we define a function In words, f σ (T ) is the length of the longest chain between any location v ∈ σ (T ) and the supremum of the original syndrome, sup σ.If σ (T ) = ∅, then we set f σ (T ) = 0. We now show that f σ (T ) is a monotonically decreasing function of T .At time T , any location v ∈ σ (T ) that maximizes the value of f (T ) will necessarily be trailing.Between time steps T and T + 1, a subset of qubits ϕ (T ) (v) ∈ ↑(v) will be returned, and the syndrome will be modified such that v / ∈ σ (T +1) .Instead, there will be new locations u ∈ σ (T +1) , where every u v, which implies that f σ (T + 1) < f σ (T ).We note that because every qubit Q ∈ Q contains its unique infimum, it is impossible for a qubit to be returned multiple times by the rule in one time step.
The removal property immediately follows from the monotonicity of f σ (T ).
As we consider lattices with a finite number of locations, f σ (1) = max v∈ σ max N ∈N (v,sup σ) (N ) will be finite.And between each time step, f σ (T ) decreases by at least one, which implies that σ (T ) = 0 for all T > max v∈ σ max N ∈N (v,sup σ) (N ).

B. Sweep rule properties for rhombic dodecahedral lattices with boundaries
In this section, we show that the sweep rule retains the support, propagation and removal properties for rhombic dodecahedral lattices with boundaries, with some minor modifications.
We recall that we use a set of eight sweep directions Ω = (±1, ±1, ±1).By inspecting Fig. 2, one can verify that no ω ∈ Ω is perpendicular to any of the edges of the rhombic dodecahedral lattice, so the partial order is always well defined.In Section II C, we neglected a subtlety concerning causal regions.Consider the causal region of U ⊆ L 0 with respect to ω, R ω (U ) = 2 ♦ ω (U )∩L0 .For a given U , causal regions with respect to different sweep directions may not be the same.Therefore, we must modify the definition of the causal region.Let { ω 1 , ω 2 , . . ., ω 8 } be an ordering of the sweep directions ω j ∈ Ω.We recursively define the causal region of U to be i.e. to compute R (U ), we take the causal region of U with respect to ω 1 , then we take the causal region of R ω1 (U ) with respect to ω 2 , and similarly until we reach ω 8 .The first step in showing that the sweep rule has the desired properties is to prove Lemma 2. This lemma is sufficient for proving the removal property of the rule.
Proof of Lemma 2. Any vertex not on the boundaries of L satisfies the trailing location condition for all ω ∈ Ω, so we only need to check the vertices on the boundaries.
First, we consider the rough boundaries.On each such boundary, there are vertices that do not satisfy the trailing vertex condition for certain sweep directions.Let us examine each rough boundary in turn.First, consider the vertices on the top rough boundary, an example of which is highlighted in Fig. 6a.For these vertices, the problematic sweep directions are those that point inwards, i.e. ω = (x, y, −1), x, y = ±1.Similarly, the problematic sweep directions for the vertices on the bottom rough boundary are ω = (x, y, 1), x, y = ±1.Next, consider the vertices on the right rough boundary (see Fig. 6b for an example).The problematic sweep directions for these vertices are also those that point inwards, i.e. ω = (−1, y, z), y, z = ±1.Analogously, the problematic sweep directions for the vertices on the left rough boundary are ω = (1, y, z), y, z = ±1.Therefore, the satisfying sweep directions for vertices on the rough boundaries are those that point outwards, as shown in Figure 7. Now, consider the smooth boundaries.We have already analysed the vertices which are part of a rough boundary and a smooth boundary.For certain sweep directions, some vertices in the bulk of the smooth boundary do not satisfy the trailing vertex condition because of a missing face (see Fig. 3d for an example).For each such vertex, there are two problematic directions (both of which point outwards from the relevant smooth boundary).In Fig. 3d, these directions are ω = −(1, 1, 1) and ω = (1, −1, 1).However, for each smooth boundary there are four sweep directions (the ones that point inwards) for which every vertex in the bulk of the boundary satisfies the trailing vertex condition.Figure 7 illustrates the satisfying directions for each smooth boundary.
We recall that a local region of L has diameter smaller than L/2.Any such region can intersect at most two rough boundaries and one smooth boundary e.g. the The constraints on the sweep directions ω = (x, y, z) ∈ {(±1, ±1, ±1)} such that all vertices on the highlighted boundary satisfy the trailing vertex condition.
boundaries highlighted in Figs.7a, 7c and 7e.For this combination of boundaries, there is only one sweep direction for which all vertices satisfy the trailing vertex condition: ω = (1, 1, 1).This sweep direction will also work for a local region that intersects any two of the above boundaries, and any region that intersects any one of the above boundaries.There are eight possible combinations of three boundaries that can be intersected by a local region (corresponding to the eight corners of the cubes in Fig. 7).Therefore, by symmetry, the set of sweep directions required for the Lemma to hold are exactly Ω = {(±1, ±1, ±1)}.
We now explain how to modify the proof of Lemma 1 such that it applies to our family of rhombic dodecahedral lattices with boundaries.First, we note that the proof of the support property is identical, except we replace ♦ (σ) by R (σ).The proof of the propagation property is essentially the same, except that there may be some time steps where the syndrome does not move, as there are some sweep directions for which certain syndromes are immobile.However, this does not affect the upper bound on the propagation distance of any syndrome: it is still upper-bounded by T , the number of applications of the rule.We note that in Lemma 1, the propagation distance refers to path lengths in the syndrome graph.However, one can verify that there will always be an edge linking any syndrome σ (T ) and its corresponding syndrome at the following time step σ (T +1) in L. Therefore, the upper bound on the propagation distance also applies to the distance defined as the length of the shortest path between two vertices of L.
Finally, the removal property also holds for any syndrome σ with R (σ) contained in a local region, but with a longer required removal time.Suppose that we use the ordering { ω 1 , ω 2 , . . ., ω 8 } and apply the sweep rule for T * time steps using ω 1 , followed by T * applications using ω 2 , and so on until we reach ω 8 , where i.e. the longest causal path between the infimum and supremum of R (σ), maximized over the set of sweep directions.
By Lemma 2, there will always exist a sweep direction such that the trailing location condition is satisfied at every vertex in R (σ).Therefore, one can make a similar argument to the one made in the proof of Lemma 1 to show that there exists a monotone for at least one sweep direction, ω, f (T ) = max v∈σ (T )   |(v sup σ (T ) )|, (18) which decreases by one at each time step the sweep rule is applied with direction ω.By the support property f σ (T ) ≤ T * for all T , so if we apply the rule T * times with sweep direction ω, then the syndrome is guaranteed to be removed.But a priori we do not know which sweep direction(s) will remove a given syndrome.Therefore, to guarantee the removal of a syndrome, we must apply the sweep rule T * times in each direction, which gives a total removal time of |Ω| × T * .
the  FIG. 9. Sustainable threshold of the sweep decoder applied to the toric code on cubic lattice (with boundaries).We plot p th (N ), the error threshold as a function of the number N of error correction cycles, for an error model with α = q/p = 1.The inset shows the data for N = 2 10 , where we use 10 4 Monte Carlo samples for each point.We observe a sustainable threshold of psus ≈ 1.7%, with γ = 0.92 (see Eq. ( 10) for the fit).
qubits experiences an error with probability p, where the error is drawn randomly from {ZI, IZ, ZZ}.In addition, each stabilizer measurement outcome is flipped with probability q = p.To compare the performance of the decoder for this error model against the iid phase-flip error model described in Definition 2, we cannot simply use the same values of p, as the parameter has different meanings in each model.Instead, we use an effective error rate [51] p ef f , which is the marginal probability that a given qubit experiences a phase-flip.In the iid phase-flip error model, p ef f = p, but in the correlated error model p ef f = 2p − 8p 2 /3 + O p 3 .Using the effective error rate as our parameter, we find that behaviour of p th (N ) for correlated noise is analogous to the iid phase-flip case, except with a lower sustainable threshold of p sus ≈ 0.8%.Figure 10 shows the data.FIG. 10.Sustainable threshold of the sweep decoder applied to the toric code on the rhombic dodecahedral lattice (with boundaries) against correlated errors.We plot p th (N ), the error threshold as a function of the number of error correction cycles.The inset shows the data for N = 1, where we use 10 4 Monte Carlo samples for each point.We observe a sustainable threshold of psus ≈ 0.8%, with γ = 0.95 (see Eq. ( 10) for the fit).

FIG. 2 .
FIG. 2. The sweep rule in the rhombic dodecahedral lattice.The sweep direction ω = −(1, 1, 1) is indicated by the arrow.(a) The future ↑(v) of v (the blue vertex), is the power set of the black vertices and the blue vertex.(b) The causal diamond of U , where U is the set of blue vertices.The red vertices are sup U and inf U , and ♦ (U ) is the power set of the red, black and blue vertices.(c) In the rhombic dodecahedral lattice, there are two types of vertices: one type is degree four (red and black)and the other is degree eight (blue).The red (blue) shaded faces are the qubits that the rule may return, depending on the syndrome at the highlighted red (blue) vertex.The rule returns nothing at the black vertices because there are no syndromes whose restriction to a black vertex is in the future of that vertex.

FIG. 3 .
FIG. 3. A family of rhombic dodecahedral lattices with boundaries.(a) Construction of the L = 3 lattice from the cubic lattice.We show the initial cubic lattice as well as the final rhombic dodecahedral lattice.(b) The L = 3 lattice.The front and back boundaries are smooth (syndromes must form closed loops) and the other boundaries are rough (open loops of syndrome can terminate).(c) An example of a open loop of syndrome terminating on one of the rough boundaries (light yellow edges).(d) A syndrome on the smooth boundary (light yellow edges).With the sweep direction ω = −(1, 1, 1), the ringed vertex does not satisfy the trailing location condition.

Algorithm 1 .
Sweep Decoder Input: Error syndrome σ ∈ im ∂, set of sweep directions Ω, runtime per direction Tmax Output: Correction FIG.4.Improving the performance of the sweep decoder applied to the toric code on the rhombic dodecahedral lattice (with boundaries) by applying the rule multiple times per syndrome measurement.We set α = q/p = 1 and we fix N = 2 10 error correction cycles.We plot the logical error rate pL as a function of p for different linear lattice sizes L. We applied the rule three times per syndrome measurement and we observe an error threshold of p th ≈ 3.2%, an improvement of over the corresponding error threshold of p th ≈ 2.17% when we applied the rule once per syndrome measurement (see the inset of ??).We use 10 4 Monte Carlo samples for each point.

41 FIG. 5 .
FIG.5.Optimizing the direction-change frequency for the sweep decoder applied to the toric code on the rhombic dodecahedral lattice (with boundaries).We plot the logical error rate pL as a function of the direction-change period for various values of L. The number of error correction cycles is N = 2 10 and p = q = 0.021.We achieve the best performance when we change sweep direction every ∼ log L cycles.We use 10 4 samples for each point.

FIG. 6 .
FIG. 6. Vertices on the rough boundaries that do not satisfy the trailing vertex condition.In (a), we highlight such a vertex, v, in blue on the top rough boundary.Consider the highlighted qubit (blue face) and its syndrome (light yellow edges).For the sweep directions ω = (1, −1, −1) and ω = (−1, 1, −1), v does not satisfy the trailing vertex condition because the blue face is not in ↑(v).In (b), we highlight a vertex in red on the right rough boundary that does not satisfy the trailing vertex condition for the same reason as (a), where the problematic sweep direction is ω = (−1, −1, 1).

FIG. 8 .
FIG. 8. (a) Constructing the L = 3 cubic toric code lattice.We illustrate how the lattice (dark blue edges and green faces) is a sublattice of the infinite cubic lattice (represented by light blue edges).The L = 3 cubic toric code lattice.We show all the vertices, edges and faces of the lattice.In particular, we note that some faces on the boundary have only two or three edges.(c) The action of the sweep rule at the vertices of the cubic lattice.The sweep direction ω = −(1, 1, 1) points from the red vertex v into the centre of the cube.The shaded red faces are the faces that can be returned by the rule from v.
Department of Innovation, Science and Economic Development Canada and by the Province of Ontario through the Ministry of Colleges and Universities.Whilst at UCL, M.V. was supported by the EPSRC (grant number EP/L015242/1).D.E.B. acknowledges funding provided by the EPSRC (grant EP/R043647/1).We acknowledge use of UCL supercomputing facilities (https://www.ucl.ac.uk/research-it-services/ services/research-computing-platforms).