Trellis Decoding For Qudit Stabilizer Codes And Its Application To Qubit Topological Codes

1, 2, 2, 3, 4, 5, Eric Sabo, ∗ Arun B. Aloshious, † and Kenneth R. Brown ‡ 1School of Mathematics, Georgia Institute of Technology, Atlanta, GA 30332, USA 2Department of Electrical and Computer Engineering, , Durham, NC 27708, USA 3School of Chemistry and Biochemistry, Georgia Institute of Technology, Atlanta, GA 30332, USA 4Department of Physics, Duke University, Durham, NC 27708, USA 5Department of Chemistry, Duke University, Durham, NC 27708, USA We further develop the theoretical framework for the quantum trellis decoder proposed by Ollivier and Tillich in 2006. We show that while conceptually different, certain results from the theory of trellis decoding for classical linear block codes have quantum analogies. We compare and contrast the two theories throughout. The decoder works for any stabilizer code S and separates into two parts: an expensive, one-time, offline computation which builds a compact, graphical representation of the normalizer of the code, S⊥, and a quick, parallel, online query of the resulting vertices using the Viterbi algorithm. Mathematical results about the trellises are obtained for prime-dimension qudit codes . We demonstrate the effectiveness of this approach numerically by natively decoding the rotated surface code and the 4.8.8/6.6.6 color code families on qubits for moderate distances without any concept of homology. Code capacity thresholds for all three families are found to be between 10-11% for distances up to 17-21 under a Z-only noise model. Computational limitations and open problems are discussed. We additionally use the developed framework to promote a new, quantitative metric describing the fundamental difficulty of decoding a given stabilizer code. We apply this to show that, for example, the color code families are more difficult to decode than the rotated surface code family. We also investigate CSS codes under this framework and use this metric to quantitatively discuss the computational savings of decoding X- and Z-errors independently.

I. INTRODUCTION

Quantum error correction allows for the in principle preservation of quantum information in the presence of noise by encoding the information into a larger quantum system. The utility of any quantum error correction approach relies not only on the code parameters but also the existence of good decoders. There are presently few generic decoders applicable to random quantum error correcting codes. This is not without reason; quantum decoding is known to be computationally more difficult than classical decoding [1, 2]. Most decoders developed so far are specifically tailored to a given code family based on intuitive, visual, or physical arguments. Many decoders and decoding schemes in the literature are unique to the simulation they are presented with while others, especially those for topological codes, have enjoyed widespread use, study, and success. For topological codes, such as toric, rotated surface, and color codes, the full decoding problem is typically reduced to that of finding a minimum-weight (pure) error, usually under an uncorrelated noise model, and is modeled as a perfect matching for the non-zero syndrome. The Blossom V implementation of Edmond’s minimum-weight perfect matching (MWPM) algorithm is most often used [3, 4] but other approaches such

arXiv:2106.08251v1 [quant-ph] 15 Jun 2021 as greedy matching have also been applied [5]. These are applicable to topological codes whenever the syndrome and errors have a string-like pattern. Despite the deceptive similarities to the surface codes, applying the same techniques to the color codes results instead in a hypergraph matching problem [6], which has no efficient algorithm. To get around this, some color code decoders first map the problem to two or more copies of a toric code which are then decoded and the information pieced back together to form a correction for the original code [7–11]. The union find decoder [12–15] has been successfully applied to surface codes and homological product codes but a color code or more general stabilizer code implementation has still yet to be developed. Other popular decoders for topological codes include those based on cellular automata [16–18], integer programing [19], and renormalization [20–22]. Topological codes

[email protected][email protected][email protected] 2 are often simulated on infinite lattices or finite lattices with periodic boundary conditions, and decoders sometimes require structural features such as locality and translational invariance. Of particular interest are decoders which apply to multiple families of codes with little to no modification up to input data. Belief propagation [23, 24], tensor network [25–30], and machine learning (ML) [31–36] based decoders generally fall into this category. Belief propagation is useful when codes satisfy specific sparsity properties but is inherently more difficult for quantum than classical codes. Recent work has improved this by introducing a common classical post processing step to prevent the decoder from getting stuck in loops [37, 38]. Tensor network decoders are theoretically exact maximum likelihood decoders but remain practically limited by computation with finite resources. As with much of machine learning, ML decoders trade good performance with a thorough understanding of its decisions and the theoretical guarantees that come with it. One benefit to general decoding techniques is that they remove things such as geometric or topological constraints that complicate algorithms. Ollivier and Tillich introduced a decoding algorithm in 2006, called trellis decoding, which is applicable to any qubit or qudit stabilizer code S [39]. This is a port of a highly successful and well-understood classical decoder, and works by building a highly compact and efficient graphical representation of the algebraic structure of the normalizer of S, S⊥, called a trellis. The trellis contains all valid combinations of logical operators and stabilizer generators that will return the system to its code space. This is a time-consuming offline step which only needs to be completed once. Decoding proceeds by globally searching and finding the minimal weight path in the trellis corresponding to the measured syndrome. This is performed efficiently in exactly n major steps for an [[n, k, d]] stabilizer code, although the amount of work required in each step varies with respect to a predictable, code-dependent formula and can be significant depending on the amount of available resources. Beyond the brief introduction in [39], this decoder was discussed in [40, 41] for quantum convolutional codes and a portion of the algorithm was improved in [42]. Many fundamental questions and theoretical properties remain unanswered. Here we expand on the previous literature by fully developing the theoretical foundations of the decoder and performing numerical simulations on the rotated surface and color code families. Notably, the color codes (with boundary) are natively decoded without reference to other codes or notions of color, homology, matching, boundaries, lifting, projections, restrictions, charges, excitations, strings, and/or mappings. Nu- merical results for Z-only noise match that of MWPM for the surface codes and exceed the current best thresholds in the literature for the color codes, although we only simulate codes up to distance 21. Given the runtime of the proposed implementation, we conclude that MWPM is more appropriate for surface codes while trellis decoding is more appropriate for color codes of low distance. We also use these new theoretical tools to make comments about decoding general stabilizer codes, and CSS codes in particular. The ability to reach the optimal threshold and apply to general codes allows us to make observations and comparisons between code families that are decoder independent. We begin by presenting the definition and construction of the main object, the trellis graph, in Section II. We also define a specific choice of stabilizer generators, called the trellis-oriented form, which allow properties of the trellis to be determined with ease, and then finally introduce the decoding algorithm for the trellis, the Viterbi algorithm. The algorithm itself is fairly simple and an example implementation is provided in Algorithm 1 in Appendix B. Starting in Section III we derive theoretical guarantees on the structure of the graph, the trellis-oriented form, and the Viterbi algorithm. We show that out of all possible trellis graphs one could construct for the code, the construction here is minimal with respect to several important metrics. The ways in which quantum trellis decoding are more complicated than the classical theory are elaborated, and in Section III C we propose a quantitative metric for the difficulty of decoding a given stabilizer code which makes this precise. This allows us to show that the color codes are fundamentally more difficult to decode than the rotated surface codes and the 4.8.8 color code is more difficult to decode than the 6.6.6 color code. We also make quantitative arguments as to exactly how much easier it is to decode a CSS code using independent X- and Z-decoders versus a single decoder for the full code. Although not unique to trellis decoding, we show that large gains are made when splitting the trellis into X- and Z- parts with no loss of information. Numerical results for code capacity simulations are presented in Section V. Finally, we conclude with a discussion of open problems in Section VI. Non-binary (qudit) stabilizer codes are less explored and understood than qubit codes, yet potentially offer significant computational advantages. Of particular interest here is that qudit codes offer improved error thresholds over their qubit counterparts [43–46]. Non-binary decoders are lacking as many standard qubit decoders are not applicable to even direct generalizations of qubit codes without significant modification, if at all possible [43–48]. Qudit codes are not simulated in this work, although the results of Section III are 3 given for any prime dimension. The trellis decoder hence applies uniformly to both qubit and qudit codes without modification.

II. THE SYNDROME TRELLIS

c a b Let p be a prime and Fp the finite field of cardinality p. Denote by P(1, p) = hX,Zi = {ω X Z : a, b, c ∈ Fp}, where ω is a pth root of unity, the generalized Pauli group on one qudit of dimension p and by

n c a b n P(n, p) = P(1, p)⊗ = {ω X Z : a, b ∈ Fp , c ∈ Fp} the generalized Pauli group on n qudits. We will refer to elements in the form IXXIXZY as Pauli strings to distinguish them from their numerical representations. By stabilizer code we mean an Abelian subgroup S ≤ P(n, p) defined with respect to some nice error basis, here the standard X and Z qudit Pauli operators. 2n This is typically followed by a map to Fp but we will not utilize this at the moment and will come back to this differentiation later. See [49] for details. Defined as such, S is a classical code which corresponds to a n quantum stabilizer code, Q = Q(S) = {v ∈ Cp | P v = v, ∀P ∈ S}, for which S is the stabilizer group. In what follows, suppose S is the stabilizer group of a quantum stabilizer code with dim Q > 1. The center c of P(n, p), Z(P(n, p)) = {ω : c ∈ Fp}, is the set of elements which commute with all other elements of P(n, p). The centralizer of S in P(n, p), C (n,p)(S), is all the elements of P(n, p) that commute with all elements of S. The dual of S is defined to beP the set of all elements of P(n, p) which have zero (symplectic) ∼ inner product with all the elements of S, i.e., S⊥ = C (n,p)(S)/Z(P(n, p)). The dual hence contains all stabilizers and all logical Pauli operators for Q and has dimensionP n + k. Trellises are a strict structure in graph theory defined with respect to a semiring of vertex and/or edge labels. It suffices here to ignore this generalization and present only the exact trellis we will need for quantum decoding, called the syndrome trellis. As there are currently no other trellises defined in quantum error correction, we will drop the “syndrome” label and simply refer to the “trellis”. The interested reader is referred to the tutorial piece [50] for a more general discussion of the semiring structure of trellises. The quantum trellis we will construct is closest in analogy to the Bahl-Cocke-Jelinek-Raviv (BCJR) trellis of classical [51], which is of course now known to be isomorphic to the Wolf [52] and Forney- Muder [53, 54] trellises. The first paper to define a quantum trellis [39] referred to this construction as the Wolf trellis. Recall that a directed edge, e, in a graph goes from source, s(e), to terminus, t(e). Definition II.1 ((Quantum) Syndrome Trellis) A trellis for an [[n, k, d]]p stabilizer code Q is a directed multigraph with vertex set, V , and edge set, E, such that

(i) there are n + 1 disjoint sets of vertices Vi with V = V0 t ... t Vn and |V0| = |Vn| = 1;

(ii) there are n disjoint sets, Ei, of directed edges from Vi 1 to Vi with E = E1 t ... t En; −

(iii) each vertex v ∈ Vi has a unique label given by an (n − k)-tuple of syndromes, although the same label may be present in multiple Vi;

a b (iv) each edge e ∈ Ei is a unique triple of the form (s(e), P, t(e)), where P is a label of the form X Z for a, b ∈ Fp;

(v) each edge is assigned a weight, wt(e) ∈ R− ∪ {−∞}.

Following the classical literature, vertices are referred to as states, the Vi as state spaces, and Vi is said to be at depth i. The edge sets Ei are referred to as the ith section and the edges as branches. The condition that edge labels must be unique between a fixed pair of source and terminus vertices means our trellises are proper. Trellises which do not satisfy this condition are called improper and are not considered in this work. 4

0000 0000 0000 I X 1000 0010 0010 0000 0000 Z 0000 Y 0100 0100 0001 0001

1100 0110 0011

(a) 0000 0000 0000 I X 1000 0010 0010 0010 0000 Z 0011 Y 0100 0100 0001 0011

1100 0110 0011

(b)

FIG. 1: (a) The trellis for the [[5, 1, 1]] code with stabilizers {ZXIII,XZXII,IXZXI,IIXZX} demonstrated in [39]. Measuring the syndrome s = (0, 0, 1, 1), we determine Ps = IIIZZ. Adding π0(Ps) = π1(Ps) = π2(Ps) = π3(Ps) = (0, 0, 0, 0), π4(Ps) = (0, 0, 1, 0), and π5(Ps) = (0, 0, 1, 1) to the appropriate Vi produces (b), the trellis found in Figure 2 of [39]. The presence of the parallel edges in E5 demonstrate that this code cannot tell the difference between I/X5 and Y5/Z5.

A. Construction

To construct the syndrome trellis, define the projection operator πi : P(n, p) → P(n, p), ( I . . . I i = 0, πi(P ) = (1) P1 ...PiI...I 1 ≤ i ≤ n, choose a set of stabilizer generators {S1,...,Sn k} for the stabilizer group S, and fix this set throughout. To avoid ambiguities with ωcXIII = XII(ωcI) and− the projection, without loss of generality, the presentation c n k here assumes ω = 1. Let σi : P(n, p) → Fp− be the map from a Pauli string to its syndrome,

σi(P ) = (hS1, πi(P )i,..., hSn k, πi(P )i), (2) − where h·, ·i is an appropriate inner product, and let Ps be a Pauli string with syndrome s with respect to the chosen generators, s = σn(Ps). Compute S⊥ and then PsS⊥. Since everything in S⊥ has zero syndrome, everything in PsS⊥ has syndrome s. The vertices in each set are labeled by the values σi(P ) for all P ∈ PsS⊥,

Vi = {σi(P ) : 1 ≤ j ≤ n − k, P ∈ PsS⊥}. (3)

A directed edge is created from the vertex σi 1(P ) ∈ Vi 1 to the vertex σi(P ) ∈ Vi and labeled with the ith component of P , − −

Ei = {(σi 1(P ),Pi, σi(P )) : P ∈ PsS⊥}. (4) −

The weight of an edge with label Pi is defined to be the log-likelihood − log Pr (Pi), where this probability comes from the assumed error channel. Duplicate edges, which have the same source, label, and terminus, are not allowed, although they will often appear during the construction. Parallel edges, which have the same source and terminus but different labels, are allowed and imply the existence of a weight one stabilizer or 5

error for the code. These will generally not appear, but we will consider them in this work for completeness. The example trellis of Figure 1 has parallel edges in E5. Equations (3) and (4) define the syndrome trellis of [39]. Algorithmically, it is customary to reduce the number of multiplications by observing that each Vi may be calculated from Vi 1 by simply adding − σi(I...IPiI...I) to the previous label set using the appropriate modular arithmetic. This reduces con- struction time for a serial implementation but may be slower than a parallel one based on (3). As written, the trellis is dependent on Ps and must be recomputed for every measured syndrome, which is computationally infeasible for a practical implementation. Since for P ∈ PsS⊥, σi(P ) = σi(Ps) + σi(P 0) for P 0 ∈ S⊥, the trellis with respect to syndrome s is simply a shift of the trellis with respect to the zero syndrome. Since σi(Ps) is a single value, the set {σi(Ps) + σi(P 0)} is unique when {σi(P 0)} is unique so |Vi| remains invariant. Likewise, the map (σi 1(P 0),Pi0, σi(P 0)) 7→ (σi 1(Ps) + σi 1(P 0),Ps iPi0, σi(Ps) + σi(P 0)) − − − is an isomorphism permuting edge labels via the action of Ps i. It follows that one may pre-compute the trellis for the zero syndrome then update each Vi with the syndrome of πi(Ps), updating edges accordingly. See Figure 1 for an example. Theoretically, this has the advantage of trading the affine space PsS⊥ with the vector space S⊥.[55] This is convenient as some mathematical objects are not well-defined over affine spaces and working with the associated vector space allows for easier proofs that more closely mimic their classical counterparts. We tackle this in Section III. Computationally, this has the advantage of pre-allocating the data structure, albeit it must now remain mutable, and trading many multiplications for faster additions. The complexity of the construction lies in computing Ps and S⊥, the latter of which is a one-time computation and may easily be done with existing quantum coding theory libraries such as the one in MAGMA [56]. Further computational aspects, including the generation of S⊥, are discussed in Section VI. In this work, we take the “base” trellis for S⊥ as the fundamental object and the general decoding scheme proceeds as follows: 1) construct the trellis, 2) measure a syndrome and shift the base trellis with respect to it, 3) decode the shifted trellis, 4) repeat steps 2) and 3). No edge weights are assigned until the shifting procedure, so the base trellis is independent of any measured syndromes or error model. The runtime of this scheme is heavily concentrated in step 1), but this is an offline procedure while only 2) and 3) are online. Since |V | ≤ |E|, shifting the trellis is Θ(|E|) in time but the procedure is easily parallelized. As we will see later, decoding is also Θ(|E|) and may also be parallelized.

B. Trellis-Oriented Form

The term “trellis-oriented” was introduced in passing in an appendix by Forney [53] and wasn’t thoroughly defined until seven years later by Kschischang and Sorokine [57]. Here we adapt the latter approach to the quantum setting, as did [39], but we will stick closer to the classical notation than that of [39]. The term “minimal-span” is preferred by some authors in the literature. Let P ∈ P(n, p) be an arbitrary Pauli string with components Pi at index i. Definition II.2 (i) The left index of P , L(P ), is the smallest index such that Pi =6 I and the right index of P , R(P ), is the largest index such that Pi =6 I. (ii) The span of P is the index set {L(P ),L(P ) + 1,...,R(P )} and the span length of P is the cardinality of the span of P , R(P ) − L(P ) + 1. The span of the identity string is defined to be {} and the corresponding span length to be 0. (iii) Say P is active at depth i if i − 1 and i are in the span of P , i.e., L(P ) ≤ i − 1 and R(P ) ≥ i.

Classically, one can always put the generator matrix of a code into reduced row echelon form but in quantum one cannot remove a power of X with a power of Z, so the best we can do is allow only one power of each in each column. The next definition is intended to be applied to a set of generators and not the entirety of its span. Definition II.3 (Trellis-Oriented Form) A set of Pauli strings is said to be in trellis-oriented form (TOF) if the sum of the span lengths of the elements is as small as possible. The use of the trellis-oriented form will become apparent in Section III B. 6

C. Decoding - The Viterbi Algorithm

With the edge weights prescribed above, the desired correction is given by the minimum-weight path from V0 to Vn. We refer to this in the following as the “optimal path”. The Viterbi algorithm is an example of forward dynamical programming and is the most common trellis-based decoder [58] The idea is as follows. Choose an arbitrary vertex v ∈ Vi for some i =6 0 or n and suppose that the optimal path travels through v. Then the optimal path can be split into two parts: the optimal path going from V0 to v and the optimal path going from v to Vn. Compute the optimal path from V0 to v and repeat for all v. Once the optimal paths are computed for every vertex in Vi 1, the optimal path for a vertex in Vi is chosen by finding the minimum value of the sums of the incoming− edge weights plus the weight of the optimal path for each edge’s source vertex in Vi 1. The weight at V0 is arbitrary but is convenient to initialize to zero. Having completed this for all vertices,− the Pauli correction may be read off the trellis by taking the edge labels for the optimal path connecting V0 to Vn. See Appendix A for a visual example of the Viterbi algorithm run on Figure 1. An example implementation is provided in Algorithm 1 in Appendix B. Typically, the optimal path to each vertex is stored at each vertex along with its minimal value and is available immediately upon reaching Vn. Such an approach carries significant overhead for large codes, hence, Algorithm 1 contains the extra steps of building a linked list of paths and then efficiently traversing it upon completion. The Viterbi algorithm is often described in a manner in which vertices with no outgoing edges are removed from the system. This creates nicer diagrams but actual deletion steps can be algorithmically expensive and should be ignored as in Figure 1. Also note that the partial syndromes, or vertex labels, make no appearance in the algorithm and may be safely removed after the construction phase, also ignoring vertices in the shifting phase. The partial syndromes of the distance 15 rotated surface code are 224 bits long, for example, and not storing them, even in a more efficient fashion, leads to large savings in storage. The Viterbi algorithm is sometimes confused with other standard minimum-path graph algorithms, but it is distinct and more efficient given the strict edge and vertex dependencies required in the definition of a trellis. Underlying the success of this algorithm is the implicit assumption that the trellis behaves as a Markov chain with each Vi only depending on the result at Vi 1. In particular, at each Vi, all the information regarding the correction of all previous qudits has already been− processed. The behavior of the decoder depends strongly on the assumed error model. If all Pauli operators are equally likely, as in the standard depolarizing noise model, the Viterbi algorithm acts as a minimum Hamming-weight decoder and may run into a significant number of ties which may be broken arbitrarily. For a biased noise model, the decoder is able to differentiate between, say, X and Z, and is able to make a more informed choice.

III. PROPERTIES

Throughout this section we denote the vertex with zero syndrome by 0. Dimension will always refer to the number of generators of an object, and | · | will be reserved for cardinality. A Pauli string will be denoted by P , whereas p will be a prime number. We first show several properties of the syndrome trellis then we turn to trellis-oriented forms before finally discussing the Viterbi algorithm. Many, but not all, of the results here have classical analogies, and we attempt to provide original citations to the best of our knowledge for those which are not typically discussed in textbooks. Classically, however, codes are vector spaces whereas here we consider stabilizer codes as groups. This changes the techniques, but we try to maintain the same overall direction of the proofs if possible. We consider it a strength of the theory that a single framework can handle both classical and quantum trellises. The closest classical work to this is that of Forney and Trott on convolutional group codes [59].

A. Syndrome Trellis

The first result was understood and implicitly used in [39] and [42] but was never explicitly stated. It is perhaps obvious, but we include a proof here for completeness. Proposition III.1 There is a one-to-one correspondence between Pauli strings in S⊥ and length-n paths in the trellis. 7

Proof. It is clear that by construction every Pauli string in S⊥ corresponds to a length-n path in the trellis. It remains to show that every length-n path in the trellis corresponds to a Pauli string in S⊥ and that all such paths are unique. Let (0,P1, σ1(P1I...I)) ∈ E1 be an edge with label P1, then pick an arbitrary edge (σ1(P1I...I),P2, σ2(P1P2I...I)) ∈ E2. Continuing this process, we end with an edge (σn 1(P1 ...Pn 1I),Pn, σn(P1 ...Pn)) ∈ En. This last terminus is the zero syndrome by construction, hence, − − concatenating the edge labels in the path, the Pauli string P1P2 ...Pn has zero syndrome and is therefore an element of S⊥ by definition. Since each vertex can only have a unique outgoing edge with a given label, this string uniquely identifies a path in the trellis and no other path can have the same label.

Corollary III.2 Let vi ∈ Vi and vi+1 ∈ Vi+1 be arbitrary. If there is a Pauli element, Pi, which takes vi to vi+1, then (vi,Pi, vi+1) ∈ Ei.

Proof. Let vi ∈ Vi, vi+1 ∈ Vi+1, and suppose concatenating a Pauli element Pi to a path with terminus vi changes the syndrome of vi to the syndrome of vi+1. Let V0vi and vi+1Vn be a path from V0 to vi and vi+1 to Vn, respectively. Then the Pauli string represented by the path V0viPivi+1Vn has a length-n and zero syndrome, and is hence an element of S⊥. The result then follows from the previous proposition.

In the previous section we attempted to stick to the notation of the preceding literature, following [39]. At this point, we make some adjustments which we find necessary to simplify the proofs and discussion. The main reason for this is that S and S⊥ are groups whereas Vi and Ei are vector spaces. Promoting the Pauli strings to vectors or the vector spaces to groups provides for a more coherent argument. Choosing Pauli strings over their symplectic representation, we henceforth introduce the following notation. We begin with a rather general definition for completeness; however, our goal and use case throughout this paper is the rather natural splitting of the qudit indices into a “past” and “future”, which is defined later in Definition III.5. Definition III.3 • Let J ⊂ {0, . . . , n} be an index set and define A to be the set of Pauli strings in a subgroup A ≤ P(n, p) whose Pauli operators are equal to the identityJ on the complement of J , J c := {0, . . . , n}\J .

• Denote by A J the set of length-|J | Pauli strings constructed from Pauli strings in A whose elements c| c at indices J have been deleted. Alternatively, A J is image of A whose elements at indices J have been set to the identity. |

The alternative definition of A J is useful to keep all Pauli strings the same length. |

Remark: If C is a classical code, then C and C J are the shortened and punctured codes of C with respect to J , respectively. The concepts of shorteningJ | and puncturing are a bit more complicated for quantum codes [60], so we refrain from using this terminology here.

Example 1. Let J = {0, . . . , i}. Then A is the set Pauli strings which naturally have identity elements J in indices {i+1, . . . , n} and A J = im πi(A) is the set of Pauli strings whose elements in indices {i+1, . . . , n} have been projected to the identity| regardless of their initial value.

Definition III.4 Let π : P(n, p) → P(n, p) be the map which projects all Pauli operators at indices J c to the identity. J In the notation of the previous section, πi = π 1,...,i . This overriding of π provides a group homomorphism { } c since π (PP 0) = π (P )π (P 0) for P,P 0 ∈ P(n, p). Then ker π (A) = A c and ker π (A) = A J , and J J J J |J J | A J c E A and A J E A as all kernels are normal. The product group A J A J c is also normal, and as | c | | | J ∩ J = ∅, A J A J c = A J × A J c E A. In keeping with| the| standard| trellis| literature, we introduce the following further terminology. Definition III.5 Fix an index i ∈ {0, . . . , n}. Then the past and future, with respect to i, are defined to be the index sets pi := {0, . . . , i} and fi := {i + 1, . . . , n}, respectively.

In particular, we will utilize the sets of Pauli strings S , S , S , S , and likewise for S⊥. See Figure 2 pi fi pi fi for a summary of the relationships between the groups. Note that| the| literature varies on which set includes 8

π π pi fi A| A A| pi fi

π π pi fi Api Api × Afi Afi

π π fi pi 1 Api Afi 1

1

FIG. 2: A summary of the relationships between the groups and the maps (Figure 5 of [59]).

. .

P p Sp⊥ P f Sf⊥ | i i | i i V0 v Vn

. .

FIG. 3: Grouping all paths from V0 to v into a single line, the trellis may be seen as the depicted set of cosets. As is clear in the diagram, each vertex has a unique past and future. the index i. In this work we index the qudits on {1, . . . , n} but it is necessary to include zero for the theory, keeping Equation (1) in mind. These subgroups depend only on the set A and not the choice of generators, although S and S⊥ may have different subgroups at the same index. Lagrange’s theorem restricts their cardinality to powers of p. (In fact, this was a motivation for promoting V and E to groups instead of dealing with less-constrained vector n subspace dimensions.) Initially, Af0 = A and monotonically decreases in size as i goes to n, Afn = {I⊗ }. n Likewise, Ap0 = {I⊗ } and monotonically increases in size as i goes to n, Apn = A. For a fixed i, sort the elements of S into sets S , S , and S , where the “active” set, denoted by a, ⊥ p⊥i f⊥i a⊥i contains the remaining elements neither wholly in the past nor future. Include the identity in Sa⊥i to give ∈ these trivial intersection. An element of S⊥ may hence be decomposed in the form PpPaPf, where Pp Sp⊥i , P ∈ S , and P ∈ S . An element P ∈ S is of the form P = (P ) (P ) , and similarly for the a a⊥i f f⊥i p ⊥ p pi ai | i pi | i pi |pi n  o | n  o | future. Thus S⊥ = span S⊥ , S⊥ and S⊥ = span S⊥, S⊥ . Fix a Pauli string P ∈ S⊥ and p pi ai f fi ai ai | i |pi | i |fi let v be the vertex generated by P in Vi. Then every length-i path from V0 to v is generated by the coset

P p Sp⊥ . Likewise, every path from v to Vn is generated by an element of the coset P f Sf⊥. Putting these | i i | i i together, every path from V to V may be viewed as a coset P S⊥ P S⊥ with respect to v. See Figure 3 0 n pi pi fi fi for a visual summary. | | The syndrome trellis of Section II A was developed in [39] with the benefit of hindsight, but there are historically numerous definitions of trellises in the classical literature. It was therefore important to determine whether some are “better” than others, leading to the concept of a minimal trellis (defined below). We will see below that our trellis is minimal. The following proposition takes us in this direction and holds for any (reasonable) definition of a trellis for a stabilizer code. Proposition III.6 (Lemma 1 [39]) Given a stabilizer code S, any trellis for S must satisfy

⊥ ⊥ ⊥ dim S dim Sp dim Sf |Vi| ≥ p − i − i , ⊥ ⊥ ⊥ dim S dim Sp dim Sf |Ei| ≥ p − i−1 − i . 9

Proof. Every path from V0 to Vn must go through some vertex v ∈ Vi. The set of all Pauli strings in S⊥ which map to the vertex v under σi is a subset of the cosets described in Figure 3 and hence has cardinality bounded above by |S ||S |. The trellis can be written as a union of paths passing through v over all v ∈ V , p⊥i f⊥i i so the number of such cosets is |Vi|. Using Proposition III.1, we then have

| | ≤ | || || | S⊥ Vi Sp⊥i Sf⊥i .

Likewise, every path in the trellis contains one edge in section Ei. Since edges are of the form (s(e), P, t(e)), a similar argument gives

| | ≤ | || || | S⊥ Sp⊥i−1 Ei Sf⊥i .

Definition III.7 A trellis that meets the lower bounds of Proposition III.6 is minimal.

Remark: Non-minimal trellises will not be discussed in this work. As a trivial example, one could define a trellis where each element of S⊥ consists of its own path from V0 to Vn without intersecting any other path. The number of vertices at each depth would then be |S⊥|. We refer the reader to [50] for further (classical) examples. The concept of a minimal trellis comes from [54].

While the edges of the trellis encode S⊥, the vertices do not take the logicals operators into account and are determined by S, an important point in sharp contrast with the classical case whose vertices and edges are both constructed relative to the same object: the code. For the vertices, fix i, let P be an arbitrary element of S⊥, and let Sj be a fixed generator of S. If

Sj ∈ Spi then hSj, πi(P )i = 0 since Sj is the identity at indices {i + 1, . . . , n} and these will commute with any elements of P at these positions. Thus, the syndrome of P with respect the generator Sj has already

been completely determined (and is zero since P ∈ S⊥). Likewise, if Sj ∈ Sfi then hSj, πi(P )i = 0 since Sj

is the identity at indices {1, . . . , i}, which, again, commute with πi(P ). Only generators Sj ∈ Sai can have nonzero syndromes. Theorem III.8 (Quantum Space Theorem(s)) The syndrome trellis of Section II A is minimal, i.e., (i) (Quantum State Space Theorem, Lemma 2 [39])

⊥ ⊥ ⊥ dim S dim Sp dim Sf |Vi| = p − i − i (5)

(ii) (Quantum Branch Space Theorem)

⊥ ⊥ ⊥ dim S dim Sp dim Sf |Ei| = p − i−1 − i (6)

Proof. Let i be fixed.

(i) The vertices are the image of S⊥ under σi. By the above comments, the past and the future have zero syndrome therefore, V = σ (S ) ∼ S /S × S by the first isomorphism theorem for groups. i i ⊥ = ⊥ p⊥i f⊥i

(ii) The kernel of the map from S⊥ to Ei are the Pauli strings which map to (0,I, 0), i.e.,

ker σi 1(S⊥) ∩ {P ∈ S⊥ | Pi = I} ∩ ker σi(S⊥) = Sp⊥ × Sf⊥ ∩ {P ∈ S⊥ | Pi = I} ∩ Sp⊥ × Sf⊥ − i−1 i−1 i i × = Sp⊥i−1 Sf⊥i .

n n Remark: The sequences {|Vi|}i=0 and {|Ei|}i=1 are often referred to as the state space and branch space complexity profiles, respectively. The quantity maxi dim Vi is the state complexity, maxi dim Ei the branch complexity, and |E| the edge complexity. We will not utilize these in this work. 10

Lemma III.9 The set of edges in Ei with terminus vertex 0 is a subgroup of Ei.

Proof. The proof of Theorem III.8 shows that Ei is a group. Clearly the identity edge exists and closure follows since if (s1,P1, 0), (s2,P2, 0) ∈ Ei, then (s1,P1, 0)(s2,P2, 0) = (s1 · s2,P1P2, 0) ∈ Ei, where · is the appropriate group (or vector space) binary operation on the vertices. It remains to show that E0 contains inverses. Let (a, b, 0) ∈ E0 and (c, d, e) be its inverse in Ei. The group operation on Ei forces e = 0. Corollary III.10 For 1 ≤ i ≤ n, every vertex v ∈ Vi has incoming degree

dim S⊥ dim S⊥ p p −1 degin(v) = p i − i , (7)

and for 0 ≤ i ≤ n − 1, every vertex v ∈ Vi has outgoing degree

dim S⊥ dim S⊥ f f +1 degout(v) = p i − i . (8)

Proof. Let v ∈ Vi and denote by Ein(v) the set of edges with terminus v, Ein(v) = {e ∈ Ei | t(e) = v}. By definition, degin(v) = |Ein(v)|. By Lemma III.9, Ein(v) is a coset of Ein(0) in Ei. In particular, |Ein(v)| = |Ein(0)|. Since there are |Ei| total edges equally divided among |Vi| vertices, degin(v) = |Ei|/|Vi|. The result follows from Theorem III.8. An identical proof gives the second equality with degout(v) = |Ei+1|/|Vi|. Lemma III.11 Let A = S or S⊥ and appropriate i be fixed. Then

0 ≤ dim Afi − dim Afi+1 ≤ 2,

0 ≤ dim Api − dim Api−1 ≤ 2.

Proof. We show the result for the first inequality and the remaining proof is identical. An easy counting 2 argument shows that the number of I’s in the ith column of Afi are either |Afi |, |Afi |/p, or |Afi |/p . These 2 are the elements which are also in Afi+1 , so |Afi+1 | ≥ |Afi |/p . The dimension change is therefore no more than two. Corollary III.12 2 For appropriate i, degin/out(v) ∈ {1, p, p }. Equivalently, for 1 ≤ i ≤ n, dim Vi ≤ dim Ei ≤ dim Vi + 2. Table I records this result graphically for the special case p = 2. It is well-known in classical trellis theory that the dimension change in Lemma III.11 is bounded by one [61]. This is due to classical codes only having one symbol alphabet instead of the two, hXi and hZi, which allows one to completely row reduce to a single pivot per column. Any configuration in Table I with a two is therefore unique to the quantum setting. The next theorem shows that these are the only possible configurations. No corresponding proof exists in the classical literature. Theorem III.13 Consider an arbitrary edge e = (s(e),Pi, t(e)) ∈ Ei and define Ii = {v ∈ Vi | ∃e0 ∈ Ei, t(e0) = t(e)} and Ii+1 = {v ∈ Vi+1 | ∃e0 ∈ Ei, s(e0) = s(e)}. Then the vertices of Ii and Ii+1 form a completely-connected bipartite graph and no other elements of Vi\Ii or Vi+1\Ii+1 are connected to the vertices in Ii+1 and Ii, respectively. If there exists a parallel edge in Ei then all edges in Ei are parallel with the same number of edges in parallel.

Proof. From Corollary III.2 and Lemma III.9, it suffices to show this for the edge (0,I, 0) ∈ Ei, as all edge configurations are a shift of this one. Choose an arbitrary vi ∈ Ii and vi+1 ∈ Ii+1. By definition there exists Pauli labels Ps and Pt such that (vi,Ps, 0), (0,Pt, vi+1) ∈ Ei. Hence, (vi,PsPt, vi+1) ∈ Ei. This works for any pair of vertices in Ii and Ii+1, proving the first statement. Now suppose, without loss of generality, there exists a vi0+1 ∈ Vi+1\Ii+1 connected to a vi ∈ Ii via (vi,P 0, vi0+1) but is not part of the 1 bipartite graph. As a subgroup, the inverse syndrome to vi, vi− , exists with some edge label Pi. Then 1 (vi− ,Pi, 0)(vi,P 0, vi0+1) = (0,PiP 0, vi0+1) ∈ Ei, a contradiction to the fact that vi0+1 6∈ Ii+1. To prove the last statement, pick a source/terminus pair vi ∈ Vi and vi+1 ∈ Vi+1 with parallel edges uniquely labeled by {P1,...,Pk}. We will show that every other edge must also have k parallel 11

∆ dim S ∆ dim S E ∆ dim S ∆ dim S E ∆ dim S ∆ dim S E p⊥i f⊥i i p⊥i f⊥i i p⊥i f⊥i i

0 0 1 0 2 0

0 1 1 1 2 1

0 2 1 2 2 2

TABLE I: The various possible edge configurations for p = 2. Since ∆dim S and ∆dim S are bounded p⊥i f⊥i by one in classical theory, any configurations with a two is unique to the quantum setting. edges; hence it suffices, without loss of generality, to assume that both syndromes are 0. Now choose 1 any other edge (vs0 ,P 0, vt0) ∈ Ei with vs0 and vt0 not both 0. By Lemma III.9, (0,P1− , 0) exists and 1 1 1 1 (vs0 ,P 0, vt0)(0,P1− , 0)(0,Pj, 0) = (vs0 ,P 0P1− Pj, vt0) for some 1 < j ≤ k. Since P 0P1− Pj1 = P 0P1− Pj2 implies Pj1 = Pj2 , a contradiction, there are k − 1 additional parallel edges between vs0 and vt0 of this form. Since 1 the same idea works when P1− is replaced with any other of the k labels, the number of parallel edges from vs0 to vt0 is greater than or equal to k. Running the argument backwards shows that for each edge between vs0 to vt0 there is a corresponding edge from 0 to 0. Since the number of these is k, we have that the number of parallel edges from vs0 to vt0 is exactly k.

At first glance, Equation (5) should be viewed with skepticism. It is common for dim Spi = dim Sfi = 0 n+k (see Example 4) and if the same holds true for S⊥, then |Vi| = p which is notably greater than the n k number of total possible syndromes, p − . Applying the classical formula for Vi or using the logic above, one would expect dim Vi = dim S − dim Spi − dim Sfi , and in fact this also works. The inclusion of the logicals therefore always forces dim S + dim S ≥ 2k. The various formulas throughout this subsection p⊥i f⊥i may therefore be written with this alternative view of dim Vi, but this leads to a lack of cancellation of terms and an unpleasant factor of 2k floating around whose lack of obvious effect on the results requires justification. Corollary III.14 For 0 ≤ i ≤ n, dim S + dim S ≥ 2k. p⊥i f⊥i Proof. Starting with dim S = n + k and repeatedly applying Lemma III.11 gives dim S ≥ n + k − 2i and, f⊥0 f⊥i ≥ − likewise, dim Sp⊥i n + k + 2i. Combining these two equations gives the desired result.

The same proof applied to S instead of S⊥ shows dim Spi + dim Sfi ≥ 0. The next result says that for a fixed qubit ordering the choice of stabilizer or logical generators is irrelevant. Lemma III.15 Any two minimal trellises for the same stabilizer code are isomorphic.

Proof. Since dim Sp⊥ and dim Sf⊥ are invariant, we know from Corollary III.10 that any trellises satisfying Theorem III.8 have the same vertex degrees and are hence structurally isomorphic. It remains to specify the mapping. Let there be two minimal trellises for the code with sets V,E and V 0,E0, respectively. Fix a v ∈ Vi and consider its past coset (see Figure 3). Pick a Pauli string in S⊥ in this coset and determine its 12

terminus v0 ∈ Vi0. The map f : V → V 0, f(v) = v0 is clearly an isomorphism. It immediately follows that the edge isomorphism is given by (s(e),Pi, t(e)) 7→ (f(s(e)),Pi, f(t(e))).

B. Trellis-Oriented Form

We now turn to the trellis-oriented form (TOF). Recall Definition II.2. Definition III.16 (Left-Right Property) A set of Pauli strings is said to have the left-right property if no two elements with the same left or right index have more than one power of X or Z. Proposition III.17 A set of Pauli strings is in TOF if and only if it has the left-right property.

Proof. Suppose a set of Pauli strings is in TOF but does not have the left-right property. Then there exists two elements of the set, P˜ and P˜0 such that L(P˜) = L(P˜0) or R(P˜) = R(P˜0). Without loss of generality, assume L(P˜) = L(P˜0) and R(P˜) > R(P˜0). One can always replace any power of X or Z with the first power by repeatedly applying it to itself since p is prime and any power generates the cyclic group hpi. Assume p 1 p 1 this is done for P˜ and replace the power of X or Z in P˜0 by X − or Z − , P˜ 7→ P and P˜0 7→ P 0. Then PP 0 has lower span length than P˜, a contradiction to the fact that the set is in TOF. Now suppose the set has the left-right property but is not in TOF. The only way to reduce the span length of the set is to increase a left index or decrease a right index. But this is impossible since there is only a single power of X or Z at these indices by the left-right property. Hence the set already has the lowest total span length.

Example 2. The generators for the rotated surface and color codes naturally have the left-right property. The canonical form of the stabilizer generators of the [[5, 1, 3]] code as cyclic shifts of XZZXI may be put into TOF as follows:

S1 = X Z Z X I S1 = X Z Z X I S1 = X Z Z X I S = I X Z Z X S = Z X I X Z S S S = Z Y Y Z I 2 7→ 4 7→ 1 3 4 . S3 = X I X Z Z S2 = I X Z Z X S2 = I X Z Z X S4 = Z X I X Z S1S3 = I Z Y Y Z S1S3 = I Z Y Y Z

The left and right indices for each row are, in order, {[1, 4], [1, 4], [2, 5], [2, 5]}, where we have used the notation [L(P ),R(P )]. It is customary, and sometimes included in the definition, to rearrange the strings by increasing left index when viewing them in a matrix-like format, similar to a row-reduced matrix, but this is not strictly necessary.

The procedure used in the previous example is quite simple: after reducing the left side from top to bottom, the right side is reduced from bottom to top and the upper stabilizer is always replaced instead of the lower (see Algorithm 2 in Appendix B). This prevents the multiplication of the stabilizers from changing the left indices. The key to automating this is considering Pauli strings as length-n vectors over Fp2 and using appropriate operations in this field. This should be compared with the complex algorithm given in [42] for obtaining the TOF using the symplectic representation over Fp. The quantum TOF is more complicated than in classical theory. To gain some intuition for this consider a b a set of Pauli strings in TOF. A quantum index, either left or right, is of the form X Z , where a, b ∈ Fp. 0 0 Given two indices XaZb and Xa Zb with all exponents nonzero, one can only eliminate the other to produce an identity if and only if they are scalar multiples of each other in Fp, i.e., (a0, b0) ∈ h(a, b)i ∈ Zp × Zp. In the more general case, by repeated application of the string to itself, a and b can individually be made to take any value in Fp, i.e., Pauli strings are linear over Fp. In particular, −a0 ∈ hai = Zp since p is a prime, and likewise for b. So, one of a0 or b0 may always be eliminated. An index X cannot eliminate an index Zb and vice versa. To summarize, the possibilities for left or right indices for qubit codes are {{X,I}, {Z,I}, {Y,I}, {X,Z}, {Y,X}, {Y,Z}}. This is in stark contrast to the classical case where a matrix can always be put into reduced-row echelon form. 13

Let P and P 0 be two strings with the left-right property and span [L, R], then PP 0 also has span [L, R]. This is often referred to as the predictable span property. If P and P 0 have span [L, R1] and [L, R2], respec- tively, with R1 < R2, then PP 0 has span [L, R2], and likewise for [L1,R] and [L2,R]. These two cases are not possible classically.

Example 3. The first two stabilizers for the TOF of the following [[8, 2, 3]] code [62] have the same left index but different right indices:

YZZZXIII ZIIXIYII IXZZYXYI . IZYIYYXI IIXYXZYZ IIZIIIYX

If we start with a generating set for A, the resulting TOF still generates A. Each generator has order p and generates p − 1 nonidentity strings with the same span. Suppose two generators P and P 0 have spans [L1,R1] and [L2,R2], respectively, and both R1,R2 ≤ i ∈ {1, . . . , n}. Then all products of the p elements generated by P and the p elements generated by P 0 also have right index less than or equal to i. If there are no other generators with right index less than or equal to i, then these are all of the elements of Api . Extending this argument shows the following. Proposition III.18 Let A be a set of Pauli strings with generators Ai in TOF. Then

dim Api = | {Ai | R(Ai) ≤ i} | (9)

dim Afi = | {Ai | L(Ai) ≥ i + 1} |. (10)

Unfortunately, the previous argument also shows that the TOF is not unique since a generator may be replaced by any of its p − 1 multiples. (In Example 2, replace S1S3 with, for example, S1S2S3). However, in light in of Theorem III.8 and Corollary III.10, the entire structure of the trellis may be read-off directly from the generators of S⊥ when put into TOF. Proposition III.18 also provides trivial proofs of results such as Lemma III.11 by merely counting the number of possible new generators obtained when shifting indices in TOF.

Example 4. The stabilizers of the [[5, 1, 3]] code appear in Example 2. The generators of S⊥ have a different TOF,

XYXII ZXZII IXYXI . IZXZI IIXYX IIZXZ

Applying Proposition III.18 to both sets we get Table II. These may be compared with the trellis diagram for the code given in [42]. Remark: As discussed in the previous section, the structure of the trellis is invariant with respect to a change of stabilizers. The stabilizers need not be measured in their TOF, but the form must be computed in order to apply Proposition III.18.

C. The Viterbi Algorithm

It is worth clarifying exactly which decoding problem the trellis solves. Let E ∈ P(n, p) be a Pauli error acting on a quantum stabilizer code Q with stabilizer group S = hS1,...,Sn ki. The syndrome, s = − 14

[[5, 1, 3]] i dim S dim S dim S⊥ dim S⊥ |V | |E | in out pi fi pi fi i i 0 0 4 0 6 1 − − 4 1 0 2 0 4 4 4 1 4 2 0 0 0 2 16 16 1 4 3 0 0 2 0 16 64 4 1 4 2 0 4 0 4 16 4 1 5 4 0 6 0 1 4 4 −

TABLE II

(s1, . . . , sn k), is the ordered tuple of commutation relations of E with the stabilizer elements, sj = hSj,Ei, where the− inner product is chosen appropriately. Logical and stabilizer operators commute with all elements of the stabilizer and therefore have trivial syndrome. It follows that an error can be decomposed as

E = LST,˜ (11)

˜ where L ∈ C (n,p)(S)\S is a logical operator, S ∈ S, and T ∈ P(n, p)\C (n,p)(S) is a pure error. One can P P always write down a pure error T0 given a syndrome s, so   ˜   Pr L, S, s, T0 ˜ Pr (E | s) = Pr L, S | s, T0 = X  . (12) Pr L, S,˜ s, T0 L,S˜

Since elements of the stabilizer do not affect the code state by definition, only L needs to be determined. The quantum (degenerate) maximum a posteriori (MAP) decoding problem is therefore

Lˆs = argmax Pr (L | s), (13) L C (S)/S ∈ P(n,p)   P ˜ where Pr (L | s) = S˜ S Pr L, S | s . It is generally not known how to develop decoding algorithms that ∈ take the degeneracy of the logical operators into account; instead, (13) is typically relaxed to

Tˆs = argmax Pr (T | s), (14) T (n,p) ∈P which is equivalent to the classical decoding problem. After measuring a syndrome, the trellis encodes all combinations (11) for a given T and solves

Eˆs = argmax Pr (E = LST˜ | s) E (n,p) ∈P = argmin wt(E = LST˜ | s). (15) E (n,p) ∈P Note that this is not Hamming weight nor minimum-weight perfect matching; it is the optimal minimum weight decoder but not a maximal likelihood decoder. While this incorporates all of the information of the logical operators, it is technically not the degenerate decoder (13). One however can construct a “degenerate” trellis to solve (13). Pelchat and Poulin give the procedure for this in their investigation of trellis decoding for quantum convolutional codes [41]. Proposition III.19 The Viterbi algorithm correctly computes the minimum weight correction (15) for uncorrelated, i.i.d. noise models.

Proof. Let µ(v) be the value of the optimal (minimum weight) path at vertex v, initialize µ(0) = 0 at V0, and denote by wt(e) the weight of edge e (see Algorithm 1). We proceed by induction on the depth i. By construction, all paths from V0 to v ∈ V1 consist of a single edge. The optimal path V0 to v is given by the 15

minimum weighted edge from V0 to v. By Algorithm 1, µ(v) = min {µ(0) + wt(e)} = wt(e) for the edge e E1 t(∈e)=v e ∈ E1 of minimum weight, which is correct. Now assume the Viterbi algorithm correctly computes the optimal path for all depths 1 to i and let v ∈ Vi+1. Then

µ(v) = min {µ(s(e)) + wt(e)} = min {wt(path) + wt(e)} = min {wt(path)}. e Ei e Ei e Ei t(e∈)=v t(e∈)=v t(e∈)=v path:V0 s(e) path:V0 t(e) → →

Every path from V0 to v is of this form. As mentioned at the end of Section II A, the full decoding procedure consists of finding a pure error, shifting the trellis, and then the Viterbi algorithm. The shifting procedure requires at most n symplectic inner products followed by |V | + |E| shifts. Fortunately, this operation is embarrassingly parallel, and the runtime may be significantly reduced depending on the implementation and available resources. For a potentially large computational speedup, one may skip shifting the vertices, as they play no role in the Viterbi algorithm. It is clear from Algorithm 1 that every edge incurs a single addition followed by incoming- degree comparisons for every vertex. For large codes, the vertices of Vi may be processed independently in parallel. The Viterbi algorithm may also be run simultaneously in a “forward pass” from V0 to some Vi and a “backwards pass” from Vn to Vi+1. The choice of the optimal splitting depends highly on the left-right balance of the trellis. Further optimizations such as those based on the coset structure of the code (vertical symmetry) are generally code specific. Theorem III.20 (Theorem 2.10 [50]) The Viterbi algorithm requires Θ(|E|) arithmetic operations.

Proof. It suffices to characterize the operations of line 14 in Algorithm 1. For each vertex v ∈ Vi for 1 ≤ i ≤ n, degin(v) additions are preformed:

n X X total additions = degin(v). i=1 v V ∈ i For simplicity we take a computational model where x − 1 minimums are computed for a list of size x. From this we then have

n n X X X X total minimums = degin(v) − 1. i=1 v V i=1 v V ∈ i ∈ i The first term in this sum is equal to the total number of edges, |E|, and the second term is total number of vertices minus V0, |V | − 1:

total additions = |E| total minimums = |E| − |V | + 1.

Therefore,

total number of arithmetic operations = total additions + total minimums = 2|E| − |V | + 1.

Since the trellis is connected, |E| − |V | + 1 ≥ 0, so 2|E| − |V | + 1 ≥ |E|. The total number of arithmetic operations is hence upper bounded by 2|E| and lower bounded by |E|.

Theorem III.8 shows the syndrome trellis minimizes |Vi| and |Ei|, but in light of the previous proof it would be useful to show that it also minimizes the quantity |E|−|V |+1. That is, the syndrome trellis minimizes the number of algorithmic operations. Classically, Muder first showed that the analogous trellis minimizes |V | [54], McEliece showed it minimizes |E| [50, 63], and Vardy and Kschischang showed it minimizes |E|−|V |+1 [64]. The proof of this follows for the quantum case with minor modifications (Proposition III.23) and we include it here in Theorem III.24 for completeness. We first establish a geometric interpretation of this quantity. 16

The quantity |E| may be further resolved using the edge configurations in Table I. While these are drawn for the special case p = 2, here we will use them to represent the corresponding diagrams for higher p. One may check that substituting p = 2 produces the correct coefficients in the formula below. We have, !   !   |E| = 1 · #( ) + p · # + p2 · #   + p · # + p · #

      ! ! 2 2 3   2 2 + p · # + p · # + p · #   + p · #   + p · # (16)

      ! 3   2 3 4   + p · #   + p · # + p · # + p · #   .

Similarly, ignoring V0 and counting the right hand sides, !   !   |V | − 1 = 1 · #( ) + 1 · # + 1 · #   + p · # + 1 · #

      ! ! 2   2 + p · # + p · # + p · #   + p · #   + 1 · # (17)

      !   2   + p · #   + 1 · # + p · # + p · #   .

Definition III.21 A vertex v with degout(v) > 1 is called an expansion and a merger if degin(v) > 1. The number of mergers is graphically given by !       M = (p − 1) · + (p2 − 1) ·   + (p − 1) · + p(p − 1) ·

    ! ! 2   2 2   + p(p − 1) · + p (p − 1) ·   + (p − 1) · + p(p − 1) ·   (18)

    ! 2 2 2 2   + (p − 1) · + p(p − 1) · + p (p − 1) ·   .

Subtracting (17) from (16) shows that this is exactly |E| − |V | + 1 [65], as expected from the proof of Proposition III.20. To match the classical proof in [64] we switch to from mergers to expansions E. Repeating the arguments of the proof with degin(v) in place of degout(v) shows E = |E|−|V |+1 as well. This is intuitively clear from the fact that the trellis both starts and ends with a single vertex. Writing a similar expression to (18) for expansions and setting E = M, the diagrams which share a left-right symmetry cancel leaving only an equality of total asymmetric edge configurations. Returning to our goal, it is clear from Section III that the number of paths from V0 to any vertex in Vi ⊥ dim S⊥ dim Sp |p is p i and the total number of paths from V0 to all of Vi is p i . Furthermore, for any trellis, the ⊥ ⊥ dim S dim S| number of paths is at most p pi and the total number of paths is at least p pi . 17

Lemma III.22 (Lemma 5 [64]) X Let Pi(v) denote the number of paths from V0 to v ∈ Vi and Pi = Pi(v) be the number of paths from v V ∈ i V0 to all vertices in Vi. Then

i 1 X− X Pi = 1 + Pj(v) (degout(v) − 1) . j=0 v V ∈ j

Proof. We proceed by induction. For i = 1, P1 = degout(0), as desired. Now suppose the formula is true for some i. Then X Pi = Pi 1(v) degout(v) − v V −1 ∈ i X X = Pi 1(v) (degout(v) − 1) + Pi 1(v) − − v V −1 v V −1 ∈ i ∈ i i 2 X X− X = Pi 1(v) (degout(v) − 1) + 1 + Pj(v) (degout(v) − 1) − v V −1 j=0 v V ∈ i ∈ j i 1 X− X = 1 + Pj(v) (degout(v) − 1) . j=0 v V ∈ j

The next result is used but not proved in [64]. We present the proof for the quantum case; the proof of − ≤ { } their original expression follows from this by restricting to dim Sp⊥i dim Sp⊥i+1 1. Recall that dim Sp⊥i is an increasing sequence whose value changes when a new right index is encountered in the TOF. Let {Ri} be the locations of the right indices. The idea behind the following proof is to divide the index set {0, . . . , n} into intervals of constant past dimension and then make arguments about the locations {Ri}. To be explicit, in this notation dim S⊥ < dim S⊥ and dim S⊥ = dim S⊥ if and only if Ra ≤ i < Ra+1. The proof is pRi pRi+1 pi pRa purely algebraic. Proposition III.23 Let unprimed quantities be with respect to the syndrome trellis and primed quantities be with respect to any other trellis for the same code. Denote by X Ej = (degout(v) − 1) v V ∈ j the number of expansions at depth j and likewise for the primes, and define

i 1 X− dim S⊥ pj  ∆i := p Ej0 − Ej . j=0

Then for Rκ < i ≤ Rκ+1,

i 1 κ X− dim S⊥ X pi−1  p Ej0 − Ej = ∆i + pκ,a(pa − 1)∆Ra j=0 a=1

⊥ ⊥ ⊥ ⊥ dim Sp dim Sp dim S dim S Ra − Ra−1 pR pR where pa = p and pκ,a = p κ − a . Proof. We proceed by induction on κ. For κ = 1,

R1 < i ≤ R2,

dim S⊥ = 0, pR0 18

dim S⊥ = dim S⊥ , pi−1 pR1 dim S⊥ dim S⊥ pR pR p1,1 = p 1 − 1 = 1, dim S⊥ dim S⊥ dim S⊥ pR pR pR p1 = p 1 − 0 = p 1 . Then,

i 1 R1 1 i 1 X− dim S⊥ X− dim S⊥ X− dim S⊥ pi−1  pi−1  pi−1  p Ej0 − Ej = p Ej0 − Ej + p Ej0 − Ej j=0 j=0 j=R1

R1 1 i 1 dim S⊥ X− X− dim S⊥ pR  pj  = p 1 Ej0 − Ej + p Ej0 − Ej j=0 j=R1

R1 1 R1 1 ⊥ ⊥ − ⊥ − ⊥ dim Sp dim Sp X dim Sp X dim S R1 − R0 R0  pj  = p p Ej0 − Ej − p Ej0 − Ej j=0 j=0

R1 1 i 1 X− dim S⊥ X− dim S⊥ pj  pj  + p Ej0 − Ej + p Ej0 − Ej j=0 j=R1

R1 1 R1 1 i 1 ⊥ ⊥ ⊥ X− dim S X− dim Sp X− dim S pj  Rj  pj = p1 p Ej0 − Ej − p Ej0 − Ej + p (Ej0 − Ej) j=0 j=0 j=0

R1 1 X− dim S⊥ pj  = (p1 − 1) p Ej0 − Ej + ∆i j=0

= p1,1(p1 − 1)∆R1 + ∆i. Assume the result is true for κ − 1. We wish to show that

i 1 κ X− dim S⊥ X pi−1  p Ej0 − Ej = ∆i + pκ,a(pa − 1)∆Ra , j=0 a=1 where

Rκ < i ≤ Rκ+1, ⊥ ⊥ dim Sp dim Sp pκ,a = p Rκ − Ra , ⊥ ⊥ dim Sp dim Sp Ra − Ra−1 pa = p . We have,

i 1 Rκ 1 i 1 X− dim S⊥ X− dim S⊥ X− dim S⊥ pi−1  pi−1  pi−1  p Ej0 − Ej = p Ej0 − Ej + p Ej0 − Ej j=0 j=0 j=Rκ

Rκ 1 i 1 X− dim S⊥ X− dim S⊥ pR  pR  = p κ Ej0 − Ej + p κ Ej0 − Ej j=0 j=Rκ

Rκ 1 i 1 ⊥ ⊥ ⊥ ⊥ dim Sp dim Sp X− dim Sp X− dim S Rκ − Rκ−1 Rκ−1  pj  = p p Ej0 − Ej + p Ej0 − Ej j=0 j=Rκ κ 1 ! i 1 ⊥ ⊥ ⊥ dim Sp dim Sp X− X− dim S Rκ − Rκ−1 pj  = p ∆Rκ + pκ 1,a(pa − 1)∆Ra + p Ej0 − Ej − a=1 j=Rκ

⊥ ⊥ ⊥ ⊥ κ 1 ⊥ ⊥ dim Sp dim Sp dim Sp dim Sp X− dim Sp dim Sp Rκ − Rκ−1 Rκ − Rκ−1 Rκ−1 − Ra = p ∆Rκ + p p (pa − 1)∆Ra a=1 19

i 1 X− dim S⊥ pj  + p Ej0 − Ej j=Rκ κ 1 i 1 − ⊥ ⊥ − ⊥ X dim Sp dim Sp X dim Sp  Rκ − Ra j = pκ∆Rk − ∆Rk + ∆Rk + p (pa − 1)∆Ra + p Ej0 − Ej a=1 j=Rκ

Rκ 1 κ 1 i 1 X− dim S⊥ X− X− dim S⊥ pj  pj  = (pκ − 1)∆Rκ + p Ej0 − Ej + pκ,a(pa − 1)∆Ra + p Ej0 − Ej j=0 a=1 j=Rκ κ 1 i 1 X− X− dim S⊥ pj  = pκ,κ(pκ − 1)∆Rκ + pκ,a(pa − 1)∆Ra + p Ej0 − Ej a=1 j=0 κ X = pκ,a(pa − 1)∆Ra + ∆i. a=1

Theorem III.24 (Theorem 6 [64]) Let |E| and |V | be with respect to the syndrome trellis and |E0| and |V 0| be with respect to any other trellis for the same code. Then |E0| − |V 0| + 1 ≥ |E| − |V | + 1. Proof. Let unprimed quantities be with respect to the syndrome trellis and primed quantities for the other trellis. For the syndrome trellis,

i 1 i 1 X− X X− dim S⊥ X pj Pi = 1 + Pj(v) (degout(v) − 1) = 1 + p (degout(v) − 1) , j=0 v V j=0 v V ∈ j ∈ j and for any other trellis,

i 1 i 1 X− X X− dim S⊥ X pj Pi0 = 1 + Pj0 (v0) (degout(v0) − 1) ≤ 1 + p (degout(v0) − 1) . j=0 v0 V 0 j=0 v0 V 0 ∈ j ∈ j

Since Pi0 ≥ Pi, subtracting the two expressions gives ∆i ≥ 0. Then

n 1 X−  (|E0| − |V 0| + 1) − (|E| − |V | + 1) = Ej0 − Ej j=0 n 1 − ⊥ 1 X dim Sp  = p n−1 E0 − E dim S⊥ j j p −1 p n j=0 n 1 ! 1 X− = ⊥ ∆n + pn 1,a(pa − 1)∆Ra dim Sp − p n−1 a=1 ≥ 0,

where the last line follows because every term in the sum is positive. Since the syndrome trellis is a minimal representation of the code that is invariant with respect to the generators, following Theorems III.20 and III.24, it is often argued in the classical literature that the quantity |E| should be regarded as a fundamental description of how hard it is to decode a given code, rivaling in importance with n, k, and d. Adopting this philosophy shows, for example, that the color codes are fundamentally more difficult to decode than the rotated surface code of the same distance without invoking projections or hypergraph matching. We provide quantitative data on this in Example 7 in the next section after introducing the CSS splitting of trellises. Proposition III.1 shows that the trellis essentially functions as a compact lookup table for S⊥. The key to the efficiency of the Viterbi algorithm is its ability to make decisions about all of the elements of this 20 set without computing every path individually. For a given v ∈ Vi, edge sharing in the trellis enables the algorithm to simultaneously check every element in S⊥ ending at v. When it discards all outgoing edges |pi for v, a total of |S | elements are eliminated from S for further consideration (see Figure 3). f⊥i ⊥ Assuming |E| scales at least cubically in n, the cost of the Viterbi algorithm also dominates that of finding the pure error T given the syndrome. Finding the minimal weight pure error given the syndrome is difficult but finding any solution is not. First note that as long as the number of errors is less than b(d − 1)/2c then T is unique up to products LS. The trellis decoder may use any valid T since the minimum weight solution is an element of the set LST enumerated by the paths of the trellis and will hence be found by the Viterbi algorithm. Given a potentially high-weight pure error, decoding may therefore be interpreted as a refinement process to the minimum weight solution. Here, we use pseudoinverses for the syndromes to find T .

IV. CSS CODES

Calderbank-Shor-Steane (CSS) codes have the property that the generators of S (S⊥) split into those with only powers of X or only powers of Z. It is common in quantum error correction to decode each set of generators independently then combine the results into a single correction. This has the advantage of reducing decoding complexity and enabling parallelization at the expense of ignoring potential X-Z correlations. The same technique can, of course, be used with trellises. As a first example, consider the trellis diagrams in Appendix C. Figure 7c shows the trellis diagram of the distance three rotated surface code and Figures 7a and 7b show the effect on the trellis of considering the X- and Z-stabilizers separately. Figure 8 shows the same for the distance three color code. The reduction in trellis and decoding complexity is immediately apparent even for these small examples. An immediate consequence of decoding the X- and Z-stabilizers separately is that moving from left-to- right in the TOF, the past (future) can only increase (decrease) by a maximum of one stabilizer generator: dim S − dim S ≤ 1 and dim S − dim S ≤ 1. Thus, in contrast to Corollary III.10, none of the f⊥i f⊥i+1 p⊥i p⊥i−1 more complicated edge configurations in Table I with a two are allowed and the edge configurations with the highest contribution of edges do not occur, i.e., ! !     |VX/Z | − 1 = 1 · #( ) + 1 · # + p · # + 1 · # + p · # , (19) and ! !     2 |EX/Z | = 1 · #( ) + p · # + p · # + p · # + p · # . (20)

Thus, stabilizer CSS codes which have unit dimension change in the TOF of the X- and Z- stabilizers at the same index i will have higher dimension changes and hence more edges and will therefore be more difficult to decode than those which do not. It follows that self-dual codes are more difficult to decode than non-self-dual codes of the same parameters. Note that applying E = M to CSS trellises gives [65] ! ! # = # .

Let S be a stabilizer code given by the CSS construction with C1 = [n, k1, d1]p, C2 = [n, k2, d2]p, and T C2 ⊆ C1. Denote by Gi and Hi the generator and parity-check matrices for Ci, respectively. The stabilizers of the quantum code are given, in symplectic form (X | Z), by

H 0  1 . 0 H2

The set S⊥ is generated by the corresponding normalizer matrix [66–68]

 0 G  1 . G2 0 21

The trellis for the X-(Z-) stabilizers only in a CSS code is therefore determined by the classical trellis whose paths are in one-to-one correspondence with the codewords of G1 (G2). Edge labels for CSS trellises should be restricted to I and Z or I and X with weights − log Pr (I) − log Pr (X) and − log Pr (Y ) − log Pr (Z) for X- and similarly for the Z-stabilizers. It is well-known in classical trellis theory that the dimension of Vi is equal to the dimension of the n k k corresponding Vi for the dual code. Since one has p − possible syndromes and the other p , we immediately get the following. Corollary IV.1 (Wolf Bound For CSS Codes [52]) min k1,n k1 Let Ci be as above. Then for the X-stabilizer trellis, |VX,i| ≤ p { − }, and for the Z-stabilizer trellis, min k2,n k2 |VZ,i| ≤ p { − }. Example 5. The distance three color code is equivalent to the well-known [[7, 1, 3]] Steane code. This is a min 3,4 CSS code constructed with the [7, 4, 3] binary Hamming code and its dual. Hence, |VX/Z,i| ≤ p { } = 8, which agrees with Figure 8. It is perhaps not surprising that the full trellis for a CSS code turns out to be a product of the two trellises of its component codes. For example, the active generators of the full code are the active generators of the X-code and the active generators of the Z-code. Thus,

dim SX,a+dim SZ,a dim SX,a dim SZ,a |Vi| = p = p p = |VX,i||VZ,i|.

Definition IV.2 (Trellis Product [57]) The trellis product of two trellises with vertices V , V 0 and edges E, E0, respectively, is denoted by ×i and has vertices

n [ V ×i V 0 = Vi × Vi0 i=0 and edges

n [ E ×i E0 = Ei × Ei0, i=0

= {((vi, vi0),PP 0, (vi+1, vi0+1)) | (vi, P, vi+1) ∈ Ei, (vi0,P 0, vi0+1) ∈ Ei0}. Remark: This is sometimes called the Shannon product [69] for historical reasons after who first described the product of two channels operating at the same time and is distinct from the numerous other standard graph products in the mathematical literature, including those also denoted by ×. It was pointed out in [57] that the trellis product may or may not give a minimal trellis. For example, the trellis product of Figure 1 with itself gives an improper trellis with degout(v0) = 16 over a symbol alphabet of size four. In all cases considered in this work, the trellis products will be minimal.

Example 6. Using shorthand (∆dim S , ∆dim S ) = (m, n) for edge configurations in Table I, it may p⊥i f⊥i be checked that (m, n) ×i (m0, n0) = (m + m0, n + n0). Such configurations occur in the full trellis as graph products of lower dimensional configurations in the CSS trellises. The vertices of Figure 7c are ordered by the trellis product of Figure 7a by Figure 7b and the vertices of Figure 8 (b) by the trellis product of (a) with itself. Lemma IV.3 Let S be a CSS code with X-stabilizers, SX , and Z-stabilizers, SZ . Let VX , EX , degin,X , and degout,X denote the appropriate quantities for the trellis of SX , and likewise for SZ . Then the trellis for S is given by the trellis product of the trellises for SX and SZ . Furthermore,

(i) |Vi| = |VX,i||VZ,i|,

(ii) |Ei| = |EX,i||EZ,i|,

(iii) degin,i = | degin,X,i || degin,Z,i |,

(iv) degout,i = | degout,X,i || degout,Z,i |. 22

The proof of the enumerated parts of this lemma follow from Definition IV.2 and the larger claim is a restatement of the well-known fact that X- and Z-errors may be decoded independently for CSS codes. A rigorous proof is fairly trivial and we leave it to the reader. Theses results may be demonstrated with the diagrams in Appendix C. Note that the Space Theorems III.8 do not hold for CSS splittings. Following the proof of the theorem, the number of vertices is isomorphic to S⊥/ ker σi but now the kernel with respect to SX includes SX⊥ as well as the past and future elements of SZ⊥:

⊥ ⊥ ⊥ ⊥ ⊥ ⊥ ⊥ dim S dim SZ,p dim SZ,f dim SX dim SZ dim SZ,p dim SZ,f |VX,i| = p − i − i − = p − i − i . (21)

Similar equations hold for |VZ,i| and the edges. The same idea holds for counting vertices and edges for an arbitrary subset of generators of S. This split trellis idea may be used in more generality. The proof of the following with the clear associativity of the trellis product implies the main part of the lemma above. Theorem IV.4 For S = hs1, . . . , sn ki, the minimal trellis for S is given by the trellis product of the minimal trellises for − each si.

Proof. We show minimality, which is the the non-trivial part of the proof.

˜ We proceed by induction on the number of generators in the product. Let Si⊥ be the subset of generators of S⊥ (in TOF) which have trivial partial syndromes with respect to si. Let [L1,R1] and [L2,R2] be the spans of s1 and s2, respectively, and construct trellises for each following Section II A with vertex profiles   1 if i ∈ [0,L ) 1 if i ∈ [0,L )  1  2 1 dim S⊥ dim S˜⊥ 2 dim S⊥ dim S˜⊥ |Vi | = p − 1 if i ∈ [L1,R1) |Vi | = p − 2 if i ∈ [L2,R2) .   1 if i ∈ [R1, n] 1 if i ∈ [R2, n]

The vertex profile of the trellis product of the trellises for s1 and s2 are given by Lemma IV.3 (i) to be

1 if i ∈ [0,L )  1  1 |Vi | if i ∈ [L1,L2) 1,2  ⊥ ˜⊥ ⊥ ˜⊥ ⊥ ˜⊥ 1 2 (dim S dim S1 )+(dim S dim S2 ) dim S dim S1∩2 |Vi | = |Vi ||Vi | = p − − = p − if i ∈ [L2,R1) | 2| ∈  Vi if i [R1,R2)  1 if i ∈ [R2, n] dim S⊥ dim S⊥ dim S⊥ dim S˜⊥ = p − pi − fi − i ,

˜ ˜ ˜ where we have used that for sets A, B ⊂ C,(C\A)∪(C\B) = C\(A∩B), S1⊥ 2 := S1⊥∩S2⊥, the past and future ˜ ∩ are taken with respect to the generators s1 and s2, and the intersection Si⊥ depends on i. Having recovered the minimal form of Theorem III.8, assume the theorem holds for the trellis product of s1, . . . , sn k 1. It 1,...,n k 1 n k ˜ − − remains to show that the overlap |Vi − − ||Vi − | produces Equation (5). In this case S1⊥ ... n k = ∅ so ∩ ∩ − ⊥ ˜⊥ ⊥ ⊥ ⊥ 1,...,n k 1 n k 1,...,n k 1 dim S dim Sn−k dim S dim Sp dim Sf |Vi − − ||Vi − | = |Vi − − | p − = p − i − i .

The proof for the edges is similar.

This splitting idea may be used to decode in a similar manner to the CSS codes where each grouping of syndrome bits are corrected independently and then combined. The success of this approach is tied to finding an appropriate grouping of generators with respect to which the logical operators split “nicely” such that the combined corrections do not introduce a logical error not returned by the individual trellises. If we adopt the idea that |E| represents a fundamental description of how difficult it is to decode, then the two quantities of interest to compare are |EX | + |EZ | and |E|, where the latter is with respect to the full 2 stabilizer code. In particular, for a self-dual code 2|EX/Z | ≤ |EX/Z | . It follows that splitting the decoding of a self-dual CSS code is square-root easier than decoding the full code. A rather trivial bound on the more general case is immediate. 23

Proposition IV.5 Let |E| be the total number of edges in a trellis diagram for a CSS code whose X- and Z-codes have trellises with total number of edges |EX | and |EZ |, respectively. Then,

2 |EX | + |EZ | ≤ |E| ≤ |EX ||EZ | − p n(n − 1) (22)

Pn ξi Pn ηi Proof. Let ξi = logp EX,i and ηi = logp EZ,i such that |EX | = i=1 p and |EZ | = i=1 p , and recall that Pn ξi+ηi ξi, ηi ≥ 1. By Lemma IV.3, |E| = i=1 p . The left inequality is clear. For the right, we have

2 2 2 (|EX | + |EZ |) = |EX | + |EZ | + 2|EX ||EZ |   n ! n n 2 2  X ξi+ηi X X ξi+ηi  = |EX | + |EZ | + 2  p + p    i=1 i=1 j=1 j=i  6  n n 2 2  2 X X ξi+ηi 2 = |EX | + |EZ | + 2 |E| + p p −    i=1 j=1 j=i 6 2 2 2 ≥ |EX | + |EZ | + 2|E| + 2p n(n − 1),

where in the last line we have assumed that ξi = ηi = 1 for all i. The right-hand side of (22) is tight for the case that there are a minimal number of edges at each depth such that |Ei| = 4 for all i. This, of course, is rare, usually only occurring around the left and right ends of the trellis, and the more the trellis deviates from this value the worst this upper bound becomes. It would be more useful to obtain bounds on the number of edges in any of the diagrams with only the values n, k, and d. We leave this for future work and simply note that several classical trellis bounds could potentially be exploited for CSS codes. An easy one in particular worth mentioning is the case of classical maximum distance separable (MDS) codes where it is well-known that the sequence {|Vi|} has the following pattern [52]

2 min k,n k min k,n k 2 {1, p, p , . . . , p { − }, p { − }, . . . , p , p, 1}.

Combining this with the fact that Ei ≥ Vi, removing the contribution from V0 and summing the geometric series we get

min k,n k 2p { − } − p − 1 |E | ≥ , (23) X/Z p − 1

which is tight for (unrealistic) case that the outgoing degree at every i is one. Replacing p with p2 in (23) provides the corresponding bound on |E| for a self-dual CSS code. Combining the two loose bounds (22) and (23) does not appear useful. Example 7. Returning to the proposal that |E| represents a fundamental parameter for the code, vertex and edge counts for the 4.8.8 and 6.6.6 color codes, rotated surface codes, and their CSS splittings are given in the following tables. The non-CSS XZZX surface codes have the same values as the full rotated surface codes. A standard qubit numbering order was applied to the surface codes, but the qubit numbering for the color codes was assigned greedily to minimize the trellis. The difference in values between distances may become more consistent given more consistent numbering schemes. Note that the total vertex and edge counts for the CSS trellises are the sum of the X- and Z-counts. The difference in sizes between the X- and Z-trellises for the rotated surface code family is an artifact of the particular numbering system used in this work. Consider the X2X3 stabilizer in Figure 4. This is active only at depth two since at depth three its syndrome is already zero. On the other hand, the Z1Z6 stabilizer is active over five depths and hence contributes vertices over this entire range. Since the X- and Z-stabilizer measurements are independent, arranging the data with respect to two different numbering schemes will allow both the X- and the Z-trellises to be structurally isomorphic. This demonstrates the strong affect permutations have on the trellis. 24

3 5 7 9 11 13 15 17 19 21 4.8.8 122 4042 83402 2126282 8673370 108195242 2074018922 36433758250 618938698730 10475888643050 4.8.8 X/Z 26 230 1382 8198 20058 66710 327278 1498758 6610590 28827294 6.6.6 122 2522 49802 496010 4719242 54470282 604814042 5357974490 40005091802 326581575962 6.6.6 X/Z 26 170 974 3966 14414 48878 174170 617322 1728842 5102498 RSurf 74 1098 10058 73034 464202 2708810 14898506 78468426 399856970 1985303882 RSurf X 22 118 470 1590 4854 13814 37366 97270 245750 606198 RSurf Z 30 198 854 2998 9334 26870 73206 191478 485366 1200118

TABLE III: Vertex counts by distance for common codes.

3 5 7 9 11 13 15 17 19 21 4.8.8 232 7080 143272 3559336 14506536 175628968 3358695592 60870993576 1031533604008 17421128805544 4.8.8 X/Z 36 316 1884 11100 27084 89628 439100 2020188 8901500 38785916 6.6.6 232 4648 89512 832936 7708072 89669032 1007967784 8733820456 64652391976 532838443048 6.6.6 X/Z 36 236 1340 5372 19388 65852 234956 828556 2316044 6847020 RSurf 152 2152 19688 143336 913384 5341160 29425640 155189224 791674856 3934257128 RSurf X 30 172 700 2388 7316 20852 56436 146932 371188 915444 RSurf Z 44 284 1228 4332 13548 39148 106988 280556 712684 1765356

TABLE IV: Edge counts by distance for common codes.

While an analytical formula for the edge scaling is currently missing, we can gain some numerical insights from Table IV. Assuming |E| is a power of 2, we plot the exponents in Figure 5d. From the figure we find that the exponents are, perhaps surprisingly, roughly linear in the minimum distance d. To help see this we include graphs of the lines y = 2d (blue) and y = d (orange). The slight bend in the data points, most predominately seen for the CSS rotated surface codes, suggest a more complicated behavior. It is possible that the color codes also have the same trend but were not simulated to high enough distances to make this as visually apparent. It is also possible that the greedy algorithm used to assign qubits to the color code geometries was suboptimal enough to erase this effect.

Example 8. To further emphasize the affect permutations have on the trellis, draw the distance five and seven 4.8.8 color codes, choose an arbitrary boundary, and number the qubits from left to right, level by level. The minimum trellis for this configuration for the distance five code has |V | = 5, 242 and |E| = 9, 000 and has |V | = 177, 018 and |E| = 293, 928 for distance seven. Comparing to Tables III and IV, using this numbering scheme would increase the slope of the blue dots in Figure 5d, potentially limiting the ability to do large-scale simulations at a lower distance.

V. NUMERICAL RESULTS

Numerical simulations were performed in the Julia programming language with pre-simulation computa- tions in the MAGMA quantum coding theory library. Trellises for small distance codes (/ 7) were constructed by generating active elements of S⊥ until completed. This approach is rather inefficient, and a vanishingly small percentage of elements generated were actually used to add a new vertex or edge to the trellis. Trellises for larger distances (/ 21) were constructed by using active elements of S to generate Vi for all i. After the vertices have reached the theoretical bounds, the missing edges were added by checking if the remaining Pauli labels considered as an outgoing edge for the vertex have a terminus in Vi+1. The correctness on this approach follows from Corollary III.2. One hundred percent of generated elements were used to add a new element to the trellis in this approach. This scaled well for CSS trellises up to distance 21 but became rather slow for non-CSS trellises around distance 15. It’s possible one may improve runtimes by specializing the program to a given code instead of being fully generalized to arbitrary prime qudit dimension. For the specific implementation used in this work, storage requirements for the trellises were found to be reasonable but became unwieldy to use for large-scale simulations for the distance 21 color codes. For example, the CSS trellises for the 4.8.8 color codes were 4.1 MB, 13.59 MB, 66.55 MB, and 305.4 MB for distances 11 to 17, respectively. Removing the vertex labels for the last trellis reduced the file size to 281.4 25

1 2 3 4 5

6 7 8 9 10

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

FIG. 4: The distance five rotated surface code used in this work: X-stabilizers are given by grey (light) faces and Z-stabilizers by blue (dark) faces.

MB (they are a useful aid to the human eye but serve no role in decoding). Judging by Tables III and IV, these numbers represent the largest file sizes for the given distances by far. However, since the trellis searches all elements of S⊥, the proper comparison to make here is to the size of a lookup table for the same code. n+k Assuming the 2 elements of S⊥ are stored as length-n strings of character size 1 , a lookup table for the [[111, 1, 11]] code above would be on the order of ∼ 1017 exabytes. On the flip side, it would only take 12.43 kilobytes to store the 112 generators. Hence, trellises several gigabytes in size would still represent an acceptable middle ground. It is worth pointing out that the “largeness” of the file sizes above stem from the requirement that the trellis should only ever be computed once, ever. The edge weights are not assigned until the trellis is shifted for the measured syndrome and therefore the zero syndrome trellis crucially does not depend on any error model and may be continuously reused for any simulation. Fixing an error model, however, allows one to switch to a smaller representation in which the distance 21, 4.8.8 CSS trellises come out to around 300 MB in contrast to the roughly 2 GB file used here. This is a subject of ongoing research, and we plan to study these smaller representations further. Code-capacity (memory model) numerical simulations were carried out for three common code families, the (qubit) rotated surface and 6.6.6/4.8.8 color codes, under Z-only noise up to at least distance 17. Failure was taken with respect the logical operator. Assuming the correct scale invariant behavior is seen, thresholds are calculated by computing the crossing point of the highest two distances. Data was taken at intervals of size 0.0025 around the threshold to reduce the error caused by sampling and fitting. Results for distances three and five were computed exactly and served as a baseline check for our methods. Distances 7 - 21 were sampled to 500,000, 300,000, 100,000, 100,000, 50,000, 50,000, 30,000, and 30,000 non-trivial errors, respectively. Trends in the data suggest convergence around distance 15 for all code families with higher distances altering the values by fractions of a percent. For larger distance codes and low errors, the deviation in the error trend is expected due an insufficient number of samples. Depolarizing simulations were conducted using independent X- and Z-trellises with low-distance-only thresholds falling roughly 3/2 times the Z-only thresholds, as expected, and thus were not pursued any further due to the resources required to decode the higher distances. As expected from ignoring the X- and Z-correlations, the minimum-weight correction on the full trellis will not always match the minimum-weight X-correction combined with the minimum-weight Z-correction. For example, consider the error Y8Y13Y18 on the distance five rotated surface code of Figure 4. The full trellis will return the correction Y8Y13Y18, while the X- and Z-trellises will return Z3Z23 and X8X13X18, respectively; the latter of which is a logical error. Previous studies have reported a surface code Z-only threshold of 10.3% under minimum-weight perfect matching (MWPM) [70] and 10.9% using the tensor network decoder of [25]. The statistical mechanical threshold is estimated to be 10.9% [71] without correlations and 12.6% with X- and Z-correlations taken into account [72]. For Z-only error, the trellis decoder will perform equally as well as MWPM. For the combined error model, the trellis decoder will do at least as well as MWPM since the minimum weight correction given by this decoder also appears in the trellis, which will then determine whether or not it is the global minimum weight solution. The results of our simulations are shown in Figure 5a. The data supports a threshold around 10.25% for Z-only errors at these finite sizes. Given the previous literature, we believe 26

(a) (b)

(c) (d)

FIG. 5: (a) - (c) Threshold results for code capacity (memory model) simulations under Z-only noise. (d) The scaling of the total edge counts for the trellises listed in Table IV.

the gain in accuracy in ameliorating this would be nominal compared to the time required to complete the simulations. The Restriction Decoder of [11] achieves a Z-only threshold of 10.2% for the 4.8.8 color codes with periodic boundary conditions. This was modified to include boundaries in [73] which reports a full depolarizing noise threshold of 12.6% for the 6.6.6 lattice, which results in a Z-only threshold of roughly 8.4%. Reference [7] finds a Z-only threshold of roughly 8.7% for the 4.8.8 lattice. The statistical mechanical thresholds for both lattices are estimated to be 12.6% and 12.52% for the 6.6.6 and 4.8.8 families, respectively [72, 74]. The results of our simulations for the 6.6.6 and 4.8.8 families are shown in Figures 5b and 5c, respectively. The data for these families are much “tighter” than the surface code. The edge counts of Table IV thus provide a rough estimate for the feasibility of this technique for this kind of large-scale simulation. The data for the 6.6.6 family supports a threshold between 10.1-10.2%, closer to the latter than the former. It is possible this value might shift inside these bounds with the inclusion of higher distance data. The data for the 4.8.8 family appears quite conclusive at a threshold of 10.5(2)% up to distance 17. Further distances are not expected to change this estimate.

VI. DISCUSSION AND CONCLUSION

We hope to reinitiate interest in trellis decoding for stabilizer codes with this work. Starting from the basic construction in [39], we have provided a theoretical foundation required for any future analysis. In 27 doing so, we have detailed the use of, improved the runtime of, and demonstrated the effectiveness of trellis decoders. The qualitative metric we propose shed light on the difference between color codes and surface codes and CSS and non-CSS stabilizer codes. In particular, the trellis is a native color code decoder without relying on projections, restrictions, homology, charges, excitations, string nets, or boundaries. The decoding scheme splits into two pieces: offline and online. The runtime of the offline stage (building the trellis) grows nonlinearly, perhaps even exponentially, with the distance but only ever needs to be done once. It is possible this may be improved, but the appropriateness of using this decoder for larger distances remains questionable with the current implementation. A nature question to ask is whether or not this can be extended to a logical decoder by spending just a little bit more time in the offline stage. We believe the answer is “yes” and is the subject of current research. The runtime of the online stage (measuring, shifting, and decoding) strongly depends on the available resources. This step is embarrassingly parallel and given maxi |Vi| processors the shifting and decoding of a given depth can be done in O(1) (although the communication overhead would be enormous). Obviously this is unrealistic, but the fact remains that a careful use of a powerful, dedicated hardware system would increase the viability of using a trellis for realtime Pauli tracking for low distance codes. The numerical threshold estimates obtained in this work are competitive with, and sometimes even better than, current state-of-the-art decoders. We attribute this success to two main things. First, with the exception of organizing the data into logical cosets, the decoder is provided with close to the maximum amount of information possible of both the code and the error channel. Traditional decoders often only rely on a fraction of this information. Second, since every Pauli string represented by a path in the trellis has the same syndrome as was measured, any correction returned by the decoder will, at minimum, force the resulting state to have zero syndrome. If there are few or no logical operators of the weight of the true error, the decoder will therefore correct the majority of the correctable errors of that weight regardless of the minimum distance of the code. We observed near completely successful decoding in the weights immediately above the guaranteed decoding radius for all codes, the exact percentages depending on the family. At this current stage, it would be inappropriate to use trellis decoding over faster methods given similar thresholds. Trellis decoding is useful for small distances codes which either have no other known decoder or trellises provide a significant improvement in logical error rate over other known decoders which scale better. Theoretically provable thresholds for this decoder are of great interest and we leave a thorough threshold analysis to future work. The theoretical work here attempted to closely parallel classical trellis theory, yet also introduced new results unique to the quantum setting. Comparing this work with the remaining classical literature, a considerable number of open problems remain. In particular, many, if not most, fundamental results of the classical theory rely on the relationship between a code and its dual. The concept of duality is a bit tricker for stabilizer codes and we plan to address this in subsequent work. An important set of classical results missing quantum analogues are bounds for various quantities given only n, k, and d [54, 61, 65, 75–79]. This is easier in the classical setting as the minimum distance is related to the number of paths between a vertex in Vi and a vertex in Vi+j for some j. Here, this would be the minimum distance of S⊥ and not S⊥\S. A thorough analysis will also shed light on the critical open question of the scalability of trellis decoding, which is required to properly compare it with other decoding techniques. Having a complete answer to this question will allow for the analysis of the asymptotic trellis decoding behavior of various code families. The question then becomes at what point this scaling becomes too cumbersome for modern quantum controller hardware. In such cases, trellis pruning [80] or coset techniques may possibly be employed. Classically, trellis decoding becomes computationally more intensive as the encoding rate increases, since maxi |Vi| grows with k. While the code capacity results are promising, further numerical studies are needed to determine the behavior of this method under the more realistic and interesting phenomenological, circuit-level, and biased noise models. Incorporation into other paradigms such as flag-syndrome extraction and single-shot error correction are also interesting. Trellises are a hidden Markov model for the decoding process and it’s intriguing to consider whether a Markov chain with memory could be used to handle correlated error models. Trellises for codes with k > 1 were constructed to verify the various formulas but qudit codes were not investigated during this work. This is important to investigate as decoders for such codes are fewer in number and are not as well understood as their qubit counterparts. The treatment of CSS codes in this work may lead to further quantitative results for these codes. Along these lines, it is common in classical coding theory to exploit the coset structure of codes, which make a visual appearance in the trellis [81, 82]. The study of such trellis substructures may provide new insight into the structure of stabilizer codes. 28

ACKNOWLEDGEMENTS

E.S. would like to thank Evans Harrell and Benjamin Ide for helpful discussions. This work was supported by the Office of the Director of National Intelligence - Intelligence Advanced Research Projects Activity through an Army Research Office contract (W911NF-16-1-0082), the Army Research Office (W911NF-21-1- 0005) and the Army Research Office Multidisciplinary University Research Initiative (W911NF-18-1-0218). E.S. was also funded in part by the NSF QISE-NET fellowship through NSF award DMR-17474266.

[1] , Robert McEliece, and Henk Van Tilborg. On the inherent intractability of certain coding problems (corresp.). IEEE Transactions on , 24(3):384–386, 1978. [2] Pavithran Iyer and David Poulin. Hardness of decoding quantum stabilizer codes. IEEE Transactions on Information Theory, 61(9):5209–5223, 2015. [3] Austin G Fowler. Minimum weight perfect matching of fault-tolerant topological quantum error correction in average o(1) parallel time. arXiv preprint arXiv:1307.1740, 2013. [4] Ashley M Stephens. Fault-tolerant thresholds for quantum error correction with the surface code. Physical Review A, 89(2):022321, 2014. [5] James Wootton. A simple decoder for topological codes. Entropy, 17(4):1946–1957, 2015. [6] David S Wang, Austin G Fowler, Charles D Hill, and Lloyd Christopher L Hollenberg. Graphical algorithms and threshold error rates for the 2d colour code. arXiv preprint arXiv:0907.1708, 2009. [7] Hector Bombin, Guillaume Duclos-Cianci, and David Poulin. Universal topological phase of two-dimensional stabilizer codes. New Journal of Physics, 14(7):073048, 2012. [8] Nicolas Delfosse. Decoding color codes by projection onto surface codes. Physical Review A, 89(1):012317, 2014. [9] Ashley M Stephens. Efficient fault-tolerant decoding of topological color codes. arXiv preprint arXiv:1402.3037, 2014. [10] Arun B Aloshious, Arjun Nitin Bhagoji, and Pradeep Kiran Sarvepalli. On the local equivalence of 2d color codes and surface codes with applications. arXiv preprint arXiv:1804.00866, 2018. [11] Aleksander Kubica and Nicolas Delfosse. Efficient color code decoders in d ≥ 2 dimensions from toric code decoders. arXiv preprint arXiv:1905.07393, 2019. [12] Nicolas Delfosse and Naomi H Nickerson. Almost-linear time decoding algorithm for topological codes. arXiv preprint arXiv:1709.06218, 2017. [13] Shilin Huang, Michael Newman, and Kenneth R Brown. Fault-tolerant weighted union-find decoding on the toric code. Physical Review A, 102(1):012419, 2020. [14] Nicolas Delfosse and Matthew B Hastings. Union-find decoders for homological product codes. Quantum, 5:406, 2021. [15] Nicolas Delfosse, Vivien Londe, and Michael Beverland. Toward a union-find decoder for quantum ldpc codes. arXiv preprint arXiv:2103.08049, 2021. [16] Michael Herold, Earl T Campbell, Jens Eisert, and Michael J Kastoryano. Cellular-automaton decoders for topological quantum memories. npj Quantum information, 1(1):1–8, 2015. [17] Michael Herold, Michael J Kastoryano, Earl T Campbell, and Jens Eisert. Cellular automaton decoders of topological quantum memories in the fault tolerant setting. New Journal of Physics, 19(6):063012, 2017. [18] Aleksander Kubica and John Preskill. Cellular-automaton decoders with provable thresholds for topological codes. Physical review letters, 123(2):020501, 2019. [19] Andrew J Landahl, Jonas T Anderson, and Patrick R Rice. Fault-tolerant quantum computing with color codes. arXiv preprint arXiv:1108.5738, 2011. [20] Guillaume Duclos-Cianci and David Poulin. Fast decoders for topological quantum codes. Physical review letters, 104(5):050504, 2010. [21] Guillaume Duclos-Cianci and David Poulin. A renormalization group decoding algorithm for topological quantum codes. In 2010 IEEE Information Theory Workshop, pages 1–5. IEEE, 2010. [22] Pradeep Sarvepalli and Robert Raussendorf. Efficient decoding of topological color codes. Physical Review A, 85(2):022317, 2012. [23] David JC MacKay, Graeme Mitchison, and Paul L McFadden. Sparse-graph codes for quantum error correction. IEEE Transactions on Information Theory, 50(10):2315–2330, 2004. [24] David Poulin and Yeojin Chung. On the iterative decoding of sparse quantum codes. arXiv preprint arXiv:0801.1241, 2008. [25] Sergey Bravyi, Martin Suchara, and Alexander Vargo. Efficient algorithms for maximum likelihood decoding in the surface code. Physical Review A, 90(3):032326, 2014. 29

[26] Andrew J Ferris and David Poulin. Tensor networks and quantum error correction. Physical review letters, 113(3):030501, 2014. [27] Andrew S Darmawan and David Poulin. Tensor-network simulations of the surface code under realistic noise. Physical review letters, 119(4):040502, 2017. [28] Andrew S Darmawan and David Poulin. Linear-time general decoding algorithm for the surface code. Physical Review E, 97(5):051302, 2018. [29] David K Tuckett, Stephen D Bartlett, and Steven T Flammia. Ultrahigh error threshold for surface codes with biased noise. Physical review letters, 120(5):050505, 2018. [30] Christopher Thomas Chubb. General tensor network decoding of 2d pauli codes. arXiv preprint arXiv:2101.04125, 2021. [31] Giacomo Torlai and Roger G Melko. Neural decoder for topological codes. Physical review letters, 119(3):030501, 2017. [32] Paul Baireuther, Thomas E O’Brien, Brian Tarasinski, and Carlo WJ Beenakker. Machine-learning-assisted correction of correlated qubit errors in a topological code. Quantum, 2:48, 2018. [33] Christopher Chamberland and Pooya Ronagh. Deep neural decoders for near term fault-tolerant experiments. Quantum Science and Technology, 3(4):044002, 2018. [34] Paul Baireuther, Marcello D Caio, Ben Criger, Carlo WJ Beenakker, and Thomas E O’Brien. Neural network decoder for topological color codes with circuit level noise. New Journal of Physics, 21(1):013003, 2019. [35] Chaitanya Chinni, Abhishek Kulkami, Dheeraj MPai, Kaushik Mitra, and Pradeep K Sarvepalli. Neural decoder for topological codes using pseudo-inverse of parity check matrix. In 2019 IEEE Information Theory Workshop (ITW), pages 1–5. IEEE, 2019. [36] Nishad Maskara, Aleksander Kubica, and Tomas Jochym-O’Connor. Advantages of versatile neural-network decoding for topological codes. Physical Review A, 99(5):052351, 2019. [37] Pavel Panteleev and Gleb Kalachev. Degenerate quantum ldpc codes with good finite length performance. arXiv preprint arXiv:1904.02703, 2019. [38] Joschka Roffe, David R White, Simon Burton, and Earl T Campbell. Decoding across the quantum ldpc code landscape. arXiv preprint arXiv:2005.07016, 2020. [39] Harold Ollivier and Jean-Pierre Tillich. Trellises for stabilizer codes: definition and uses. Physical Review A, 74(3):032304, 2006. [40] David Poulin, Jean-Pierre Tillich, and Harold Ollivier. Quantum serial turbo codes. IEEE Transactions on Information Theory, 55(6):2776–2798, 2009. [41] Emilie Pelchat and David Poulin. Degenerate viterbi decoding. IEEE transactions on information theory, 59(6):3915–3921, 2013. [42] FangYing Xiao and HanWu Chen. Construction of minimal trellises for quantum stabilizer codes. Science China Information Sciences, 56(1):1–11, 2013. [43] Guillaume Duclos-Cianci and David Poulin. Kitaev’s Zd-code threshold estimates. Physical Review A, 87(6):062338, 2013. [44] Hussain Anwar, Benjamin J Brown, Earl T Campbell, and Dan E Browne. Fast decoders for qudit topological codes. New Journal of Physics, 16(6):063038, 2014. [45] Fern HE Watson, Hussain Anwar, and Dan E Browne. Fast fault-tolerant decoder for qubit and qudit surface codes. Physical Review A, 92(3):032309, 2015. [46] Arun B Aloshious and Pradeep Kiran Sarvepalli. Local equivalence of qudit color codes and toric codes. Physical Review A, 100(1):012348, 2019. [47] Adrian Hutter, Daniel Loss, and James R Wootton. Improved hdrg decoders for qudit and non-abelian quantum error correction. New Journal of Physics, 17(3):035017, 2015. [48] Jacob Marks, Tomas Jochym-O’Connor, and Vlad Gheorghiu. Comparison of memory thresholds for planar qudit geometries. New Journal of Physics, 19(11):113022, 2017. [49] Avanti Ketkar, Andreas Klappenecker, Santosh Kumar, and Pradeep Kiran Sarvepalli. Nonbinary stabilizer codes over finite fields. IEEE Transactions on Information Theory, 52(11):4892–4914, 2006. [50] Robert J McEliece. On the bcjr trellis for linear block codes. IEEE Transactions on Information Theory, 42(4):1072–1092, 1996. [51] Lalit Bahl, , , and Josef Raviv. Optimal decoding of linear codes for minimizing symbol error rate (corresp.). IEEE Transactions on information theory, 20(2):284–287, 1974. [52] . Efficient maximum likelihood decoding of linear block codes using a trellis. IEEE Transactions on Information Theory, 24(1):76–80, 1978. [53] G David Forney. Coset codes. ii. binary lattices and related codes. IEEE Transactions on Information Theory, 34(5):1152–1187, 1988. [54] Douglas J Muder. Minimal trellises for block codes. IEEE Transactions on Information Theory, 34(5):1049–1053, 1988. ⊥ n [55] Up until now we have considered S as a set of Pauli strings and not as a subset of Fp . One may define an equivalent vector space over the strings by defining scalar multiplication as the raising of a Pauli operator to a 30

power. [56] John Cannon, Wieb Bosma, Claus Fieker, and Allan Steel. Handbook of mamga functions: Volume 13 - coding theory and cryptography. 13, 2008. [57] Frank R Kschischang and Vladislav Sorokine. On the trellis structure of block codes. IEEE Transactions on Information Theory, 41(6):1924–1937, 1995. [58] G David Forney. The viterbi algorithm. Proceedings of the IEEE, 61(3):268–278, 1973. [59] G David Forney and Mitchell D Trott. The dynamics of group codes: state spaces, trellis diagrams, and canonical encoders. IEEE Transactions on Information Theory, 39(5):1491–1513, 1993. [60] Eric M Rains. Nonbinary quantum codes. IEEE Transactions on Information Theory, 45(6):1827–1832, 1999. [61] G David Forney. Dimension/length profiles and trellis complexity of linear block codes. IEEE Transactions on information theory, 40(6):1741–1752, 1994. [62] Markus Grassl. Bounds on the minimum distance of linear codes and quantum codes. Online available at http://www.codetables.de, 2007. [63] Robert J McEliece. The viterbi decoding complexity of linear block codes. In Proceedings of 1994 IEEE Inter- national Symposium on Information Theory, page 341. IEEE, 1994. [64] Alexander Vardy and Frank R Kschischang. Proof of a conjecture of mceliece regarding the expansion index of the minimal trellis. IEEE Transactions on Information Theory, 42(6):2027–2033, 1996. [65] Aaron B Kiely, Samuel J Dolinar, Robert J McEliece, Laura L Ekroot, and Wei Lin. Trellis decoding complexity of linear block codes. IEEE Transactions on Information Theory, 42(6):1687–1697, 1996. [66] Ruihu Li, Zongben Xu, and Xueliang Li. Standard forms of stabilizer and normalizer matrices for additive quantum codes. IEEE transactions on information theory, 54(8):3775–3778, 2008. [67] Mark M Wilde. Logical operators of quantum codes. Physical Review A, 79(6):062322, 2009. [68] Markus Grassl. Variations on encoding circuits for stabilizer quantum codes. In International Conference on Coding and Cryptology, pages 142–158. Springer, 2011. [69] Vladimir Sidorenko, Garik Markarian, and Bahram Honary. Minimal trellis design for linear codes based on the shannon product. IEEE Transactions on Information Theory, 42(6):2048–2053, 1996. [70] Chenyang Wang, Jim Harrington, and John Preskill. Confinement-higgs transition in a disordered gauge theory and the accuracy threshold for quantum memory. Annals of Physics, 303(1):31–58, 2003. [71] Eric Dennis, Alexei Kitaev, Andrew Landahl, and John Preskill. Topological quantum memory. Journal of Mathematical Physics, 43(9):4452–4505, 2002. [72] H´ectorBombin, Ruben S Andrist, Masayuki Ohzeki, Helmut G Katzgraber, and Miguel A Mart´ın-Delgado. Strong resilience of topological codes to depolarization. Physical Review X, 2(2):021004, 2012. [73] Christopher Chamberland, Aleksander Kubica, Theodore J Yoder, and Guanyu Zhu. Triangular color codes on trivalent graphs with flag qubits. New Journal of Physics, 22(2):023019, 2020. [74] Helmut G Katzgraber, H Bombin, and MA Martin-Delgado. Error threshold for color codes and random three- body ising models. Physical review letters, 103(9):090501, 2009. [75] Victor Vasilievich Zyablov and Vladimir Removich Sidorenko. Bounds on complexity of trellis decoding of linear block codes (in russian). Problemy Peredachi Informatsii, 29(3):3–9, 1993. [76] , Toyoo Takata, Toru Fujiwara, and Shu Lin. On complexity of trellis structure of linear block codes. IEEE transactions on information theory, 39(3):1057–1064, 1993. [77] Alec Lafourcade and Alexander Vardy. Lower bounds on trellis complexity of block codes. IEEE Transactions on Information Theory, 41(6):1938–1954, 1995. [78] A Lafourcade and Alexander Vardy. Asymptotically good codes have infinite trellis complexity. IEEE transactions on information theory, 41(2):555–559, 1995. [79] Øyvind Ytrehus. On the trellis complexity of certain binary linear block codes. IEEE transactions on information theory, 41(2):559–560, 1995. [80] Eric Bertrand and Fabrice Labeau. Simplified trellis decoding of block codes by selective pruning. In Conference Record of the Thirty-Eighth Asilomar Conference on Signals, Systems and Computers, 2004., volume 1, pages 1115–1119. IEEE, 2004. [81] Toru Fujiwara, Hiroshi Yamamoto, Tadao Kasami, and Shu Lin. A trellis-based recursive maximum-likelihood decoding algorithm for binary linear block codes. IEEE Transactions on Information Theory, 44(2):714–729, 1998. [82] Robert Morelos-Zaragoza, Toru Fujiwara, Tadao Kasami, and Shu Lin. Constructions of generalized concatenated codes and their trellis-based decoding complexity. IEEE Transactions on Information Theory, 45(2):725–731, 1999. 31

Appendix A: Viterbi Algorithm Example

0000 0000 0000 I X 1000 0010 0010 0000 0000 Z 0000 Y 0100 0100 0001 0001

1100 0110 0011

(a) Section 1 0000 0000 0000

1000 0010 0010 0000 0000 0000 0100 0100 0001 0001

1100 0110 0011

(b) Section 2 0000 0000 0000

1000 0010 0010 0000 0000 0000 0100 0100 0001 0001

1100 0110 0011

(c) Section 3 0000 0000 0000

1000 0010 0010 0000 0000 0000 0100 0100 0001 0001

1100 0110 0011

(d) Section 4 0000 0000 0000

1000 0010 0010 0000 0000 0000 0100 0100 0001 0001

1100 0110 0011

(e) Section 5

FIG. 6: The Viterbi algorithm applied to the example trellis of Figure 1 for the error model Pr (I) = 0, Pr (X) = Pr (Z) = 1, and Pr (Y ) = 2. Ties were broken in a manner to keep the result looking clean. The path from V0 to Vn provides the final correction, in this case IIIII - which is true since there was no error. 32

Appendix B: Algorithm Pseudocode

Algorithm 1: Viterbi Input: A vertex set, V , along with an edge set, E, corresponding to a valid trellis. Output: Pauli string 1 Struct Vertex contains 2 int prev . Final step acts as a linked list 3 float value 4 Edge edge . Initialized to null 5 end 6 Struct Edge contains 7 Vertex source 8 float weight 9 char label 10 end

11 V0 3 0.value ← 0 12 for i ← 1 to n do 13 foreach v ∈ Vi do 14 v.value ← min {e.source.value + e.weight} . For e which achieves minimum e∈Ei t(e)=v 15 v.prev ← e.source 16 v.edge ← e 17 end 18 end

19 v ← 0 ∈ Vn . Trace optimal path backward for correction 20 correction ← “” . Empty string 21 for i ← n to 2 by −1 do 22 correction ← v.edge.label + correction . Concatenate to left of string 23 v ← v.prev 24 end 25 return correction 33

Algorithm 2: Trellis-Oriented Form (Qubits) n Input: Set of Pauli strings A as elements of F4 with generator ω Output: A in trellis-oriented form 1 for i ← 1 to |A| − 1 do . Start with first element 2 Pj ← 0 3 L ← 1 4 for j ← 1 to n do . Find right index 5 if Ai[L] 6= 0 then 6 L ← j 7 Pj ← Ai[L] 8 break 9 end 10 end 11 for k ← i + 1 to |A| do . Eliminate 2 12 if Ak[L] = Pj or Ak[L] = ω then . If same Pauli or a Y 13 Ak ← Ak + Ai 14 end 15 end 16 end 17 Sort(A, by=L) . Sort by left index - if necessary 18 for i ← |A| to 2 by −1 do . Start with last element 19 Pj ← 0 20 R ← n 21 for j ← n to 1 by −1 do . Find right index 22 if Ai[R] 6= 0 then 23 R ← j 24 Pj ← Ai[R] 25 break 26 end 27 end 28 for k ← 1 to i − 1 do . Eliminate 2 29 if Ak[R] = Pj or Ak[R] = ω then . If same Pauli or a Y 30 Ak ← Ak + Ai 31 end 32 end 33 end 34 return A 34

Appendix C: Distance Three Rotated Surface And Color Code Diagrams

0000 0000

I 0000 1100 0000 0000 0000 0000 0001 0000 0000 0000 Z 1000 0100 1000 1000 0010 0010 0011 0010

1000 0010

(a) 0000 0000 0000 0000 0000 0000

I 0000 0100 0100 0100 0100 0001 0001 0000 0000 0000 X 1000 1100 1100 0110 0110 0011 0011 0001

1000 1000 0010 0010 0010 0010

(b)

00000000 00000000

00001100 00000001

00000100 00000011

00001000 00000010

11000000 00000000 00000000 00000000 00000000 00010000

11001100 00000100 00000100 00000100 00000001 00010001

00000000 11000100 00001100 00000110 00000110 00000011 00010011 00000000 I X 00001000 11001000 00001000 00000010 00000010 00000010 00010010 00000001 00000000 Z 00000000 Y 10000000 01000000 10000000 10000000 00100000 00100000 00110000 00100000

10001000 01001100 10000100 10000100 00100100 00100001 00110001 00100001

01000100 10001100 10000110 00100110 00100011 00110011

01001000 10001000 10000010 00100010 00100010 00110010

10000000 00100000

10001100 00100001

10000100 00100011

10001000 00100010 (c)

FIG. 7: Trellis diagrams for the distance three rotated surface codes: (a) X-stabilizers only, (b) Z-stabilizers only, (c) the full code with vertices organized by the trellis product of (a) with (b). It is common to collapse edge sections when degout = 1, combining labels with the section before it. This is called sectionalization and will not be discussed further in this work. It is known that sectionalization can reduce max |Vi| but not max |Ei| [61]. 35

000000

000111

000101

000010

000110

000001

000011

000100

111000

111111

111101

111010 000 111110 111 000 000 000 101 111001 I 000 010 010 010 000 010 111011 000 000 110 Z 100 110 110 001 001 111100 001 100 100 011 101000 011 100 101111

(a) 101101

101010

101110

101001

101011

101100

000000 000000 010000 000000

000010 000010 010111 000010

000110 000110 010101 000001

000100 000100 010010 000011

010000 010000 010110 010000

010010 010010 010001 010010

000000 010110 010110 010011 010001 000000 I X 000100 010100 010100 010100 010011 000001 000000 Z 000000 Y 100000 110000 110000 110000 001000 001000

100100 110010 110010 110111 001010 001001

110110 110110 110101 001001

110100 110100 110010 001011

100000 100000 110110 011000

100010 100010 110001 011010

100110 100110 110011 011001

100100 100100 110100 011011

001000

(b) 001111

001101

001010

001110

001001

001011

001100

011000

011111

011101

011010

011110

011001

011011

011100

100000

100111

100101

100010

100110

100001

100011

100100

FIG. 8: Trellis diagrams for the distance three color code: (a) X- (or Z-) stabilizers only, (b) the full code with vertices organized by the trellis product of (a) with itself.