Morphing quantum codes

We introduce a morphing procedure that can be used to generate new quantum codes from existing quantum codes. In particular, we morph the 15-qubit Reed-Muller code to obtain a $[\![10,1,2]\!]$ code that is the smallest known stabilizer code with a fault-tolerant logical $T$ gate. In addition, we construct a family of hybrid color-toric codes by morphing the color code. Our code family inherits the fault-tolerant gates of the original color code, implemented via constant-depth local unitaries. As a special case of this construction, we obtain toric codes with fault-tolerant multi-qubit control-$Z$ gates. We also provide an efficient decoding algorithm for hybrid color-toric codes in two dimensions, and numerically benchmark its performance for phase-flip noise. We expect that morphing may also be a useful technique for modifying other code families such as triorthogonal codes.

The techniques of quantum error correction seem to be indispensable in the quest to build a large-scale quantum computer. Not only do we need to protect fragile qubits from environmental noise, but we also need to perform quantum circuits fault-tolerantly. The celebrated threshold theorem [1][2][3] proves that scalable faulttolerant quantum computation is possible in principle, and moreover fault-tolerance can be achieved with constant overhead for particular families of quantum errorcorrecting codes [4,5]. However this is not the end of the story, as these asymptotic results can hide large constant factors and the requirements of quantum error correction [6][7][8][9][10] are still beyond the capabilities of today's hardware [11][12][13][14][15]. Therefore, it is imperative to develop new quantum codes that are more efficient, more resilient to noise, and more tailored to hardware.
We introduce a theoretical tool for modifying quantum codes, called morphing, that allows us to systematically construct new codes from existing codes. Morphing does not change the number of logical qubits encoded into a code, however it changes other properties of a code including the number of physical qubits, and may also change the code distance, the stabilizer weights, and the implementation of logical gates. Consequently, morphing enables us to trade off different code parameters against each other in order to satisfy the constraints of a particular hardware platform, e.g., the number of physical qubits can be decreased at the cost of complicating the implementation of some logical gates.
We apply morphing to the 15-qubit Reed-Muller code thereby constructing a [ [10,1,2]] code with a fault-tolerant T gate. To our knowledge, this is the smallest known stabilizer code with a fault-tolerant implementation of this gate. We investigate the performance of the [ [10,1,2]] code in magic state distillation (MSD), finding that it may lead to advantages over previous MSD protocols based on small codes [16,17]. Our [ [10,1,2]] protocol is the first example of an MSD protocol mixing different input magic states, and we expect that our approach may be used to improve other MSD protocols.
By morphing the color code [18][19][20], we construct a family of hybrid color-toric (HCT) codes, which inherit the fault-tolerant logical gates of the color code. Starting from an initial color code, we can construct HCT codes with different stabilizer weights, qubit connectivity, and logical gate implementations, allowing us to construct codes tailored to a particular hardware platform or fault-tolerant protocol. In three or more dimensions, our HCT code family includes codes with fault-tolerant non-Clifford gates. In particular, our family subsumes previous examples of toric codes with transversal non-Clifford gates [21][22][23].
Lastly, we study the problem of efficient decoding for the family of the HCT codes. We propose a decoding algorithm that connects two distinct decoders: the minimum-weight perfect matching (MWPM) toric code decoder [24,25] and the color code restriction decoder [26]. We benchmark our algorithm for twodimensional (2D) HCT codes subject to phase-flip noise. Our decoder achieves good performance across the entire family, and recovers previous results in the toric code and color code limits.
The remainder of this manuscript is structured as follows. We begin by introducing morphing and discussing a simple example in Section I. Then, in Section II, we present our first application: morphing the 15-qubit Reed-Muller code. Next, we apply morphing to color codes in Section III to produce a family of HCT codes. We examine the decoding problem for HCT codes in Section IV, where we propose and benchmark a decoder for 2D HCT codes. Finally, in Section V we summarize our results and suggest future applications of morphing.

I. MORPHING QUANTUM CODES
Our key observation is that for a subset of the physical qubits of a stabilizer code [27], the stabilizer group induces a (smaller) stabilizer code on the qubits in the subset. Consider some stabilizer code C with the stabi-  [10,1,2]] code obtained by morphing (c) with R comprising the qubits in the yellow cell, where the corresponding child code is an [ [8,3,2]] code with logical qubits1,2 and 3. The stabilizer group of the [ [10,1,2]] code is generated by X1X2X4X5X1, Z1Z2Z4Z5, Z4Z5Z2, and the analogous operators for the red and green faces. To implement T we apply T ±1 to the light/dark grey qubits and CCZ to the white qubits.
lizer group S. Let Q denote the set of physical qubits of C and let R ⊆ Q. We define S(R) to be the group generated by all the stabilizer generators of S that are fully supported within R, i.e., Since S(R) is a subgroup of S, it is itself an abelian subgroup of the Pauli group not containing −I, and therefore defines a stabilizer code, C(R), with physical qubits R.
We refer to C as the parent code and C(R) as the child code. As a stabilizer code, C(R) has a Clifford encoding circuit that can be implemented with depth O(|R|) using a simple gate set of {H, S, CN OT } [27], where |R| is the size of R. Suppose that we implement the inverse of this encoding circuit. Then the logical qubits of C(R) will still be entangled with the rest of the parent code, but the remaining qubits of C(R) will be in a fixed (product) state and are free to be discarded [28] (assuming we were originally in the codespace of C). In effect, we have produced a new code C \R whose physical qubits are the union of Q \ R and the logical qubits of C(R). We call this procedure morphing, we call the inverse of the encoding circuit a morphing circuit and we call C \R the morphed code. Note that we do not necessarily anticipate implementing morphing circuits in a real device, rather we use morphing as a systematic procedure to generate new quantum codes.
The morphed code C \R clearly has fewer physical qubits than C. But crucially, the number of logical qubits in both codes is the same, as morphing decreases the number of physical qubits by the same amount as the number of independent stabilizer generators. However, the implementation of a subset of the logical operators of C \R may be different to the implementation of the corresponding operators in C. As S(R) ⊆ S, the logical operators of the parent code act as logical operators in the child code (when restricted to R). Therefore, given the logical Pauli operators of C(R), we can compute the transformation of the logical operators of C under morphing. This highlights an important degree of freedom inherent in morphing: the choice of the logical Pauli operators of the child code. All choices are equally valid, but different choices can lead to different implementations of the logical operators of C \R ; see Appendix B.
We note that the code distance of C \R may be smaller than that of C and by the same reasoning the weight of some stabilizers of C \R may be smaller than the corresponding stabilizers in C. Less obviously, morphing can simplify the decoding problem of the parent code; see Section IV.
In general, morphing gives us the ability to modify quantum codes, trading off various code properties against each other in order to construct a code that is suited to the constraints of a particular quantum computing platform. We now make the above discussion concrete by considering a simple example which nevertheless demonstrates many of the changes induced by morphing. In an MSD protocol [16,31], one starts with some number of noisy magic states and distils these states into fewer magic states of higher quality. Magic states are used to implement challenging non-Clifford gates in fault-tolerant quantum computing architectures and (a) The [ [10,1,2]] MSD protocol, consisting of the encoding circuit, noisy application of the logical T gate, and measurement. The protocol is successful if the measurements give a trivial error syndrome. The labelling of the qubits is the same as in Fig. 1d. (b) The state injection circuits for implementing T and CCZ gates using input magic states. We assume that all components of the circuit are ideal except for the preparation of the magic states, which we model as ideal preparation followed by the noise channels implicit in Eqs. (3) and (4).
hence finding efficient MSD protocols is an ongoing area of research [32][33][34][35][36]. In this section, we use our morphing procedure to construct a family of codes with applications to MSD.

A. Morphing quantum Reed-Muller codes
Quantum Reed-Muller (QRM) codes [37,38] are a generalization of classical Reed-Muller codes [39]. We apply our morphing procedure to QRM codes of distance three, where the codes in this subfamily have parameters  [8,3,2]] code (the so-called 'smallest interesting color code' [21,40] In the 15-to-1 protocol [16], one distils fifteen |T states into one higher-quality |T state using the [ [15,1,3]] code. However, in the 10-to-1 protocol, we instead distill seven |T and one |CCZ states into one higher-quality |T state using the [[10,1,2]] code; see Fig. 2. To our knowledge, our 10-to-1 protocol is the first example of an MSD protocol with more than one type of magic state as input.
We proceed with the standard analysis [8,16,32,41] of the 10-to-1 protocol. We assume that the only noise in the protocol comes from the input magic states; see Fig. 2. This assumption is justified by the fact that the remaining parts of the protocol are Clifford circuits, preparation of Pauli eigenstates, and single-qubit measurements. It is usually straightforward to make these operations fault-tolerant using quantum error correcting codes.
We start with seven copies of a mixed one-qubit state ρ such that T | ρ |T = 1 − p and one mixed three-qubit state τ such that CCZ| τ |CCZ = 1 − p, where we refer to p as the input error. We assume that ρ is diagonal in the |T basis, i.e., The solid and dashed blue lines correspond to optimistic (Eq. (4)) and pessimistic ( [42]) noise models for the |CCZ state, respectively. (b) A plot showing the distillation cost C for different target error rates ptarg, assuming an input error rate of p = 0.01 and the optimistic noise model for |CCZ states. The cost for our MEK+ protocol (blue) is always smaller than the MEK protocol cost (orange), and even beats the triorthogonal protocol cost (magenta) for some values of ptarg.
which can always be accomplished using Clifford twirling. And we assume that τ has the following form, where |b| denotes the Hamming weight of We use this noise model because in many methods of preparing noisy |CCZ states errors such as ZII have a comparable probability to higher weight errors such as ZZZ [8]. In addition, as {Z b |CCZ : b ∈ {0, 1} 3 } is an orthonormal basis, we can express a |CCZ state subject to X and Z noise as a |CCZ subject to Z noise only. Furthermore, we can eliminate the off-diagonal terms in the density matrix via Clifford twirling to bring the noisy |CCZ state into the form shown in Eq. (4) (though the coefficients may be different).
The probability that the protocol succeeds (the syndrome is trivial) is When the protocol is successful, we obtain the output We refer to p out as the output error. The leading order prefactor in Eq. (6) is exceptionally small; in the 15-to-1 protocol the output error is 35p 3 +O(p 4 ) [16]. This is due to an unusual property of the [[10,1,2]] code. Namely, for each of the seven possible Z b errors on the input |CCZ state, there is only one logical Z operator that can be constructed by applying Z to one of the |T states.
In Fig. 3a we compare the performance of the 10-to-1 protocol with the 15-to-1 protocol. The success probability of the 10-to-1 protocol is always greater than or equal to the success probability of the 15-to-1 protocol, and for p ≥ 0.034 the 10-to-1 protocol has a smaller output error. The high success probability of the 10-to-1 protocol suggests it may be useful in early rounds of distillation, as part of a multi-round protocol. To test this hypothesis, we compute the distillation cost [32] C (the expected number of magic states required) to achieve a given target error rate p targ assuming an input error rate of p = 0.01, for a number of multi-round MSD protocols. Following [17], we define the Meier, Eastin, and Knill (MEK) protocol to consist of up to five rounds of distillation, where in each round either 15-to-1 [16] or 10-to-2 [17] distillation can be used. And we define the MEK+ protocol in the same way as the MEK protocol, except at each round we can choose between 15-to-1, 10-to-2 and 10-to-1 distillation. In Fig. 3b we compare the distillation costs of the MEK and MEK+ protocols with the cost of a protocol where at each round we can choose between distillation protocols based on triorthogonal codes [32]. We find that the MEK+ protocol distillation cost is always less than or equal to the MEK protocol cost, and even betters the triorthogonal protocol cost for p targ ∈ {10 −6 , 10 −9 , 10 −10 }; see Table II in Appendix H for the full data including the optimal distillation sequences.
One may question the reasonableness of the noise model assumed in Eq. (4) as it seems plausible that |CCZ states could be more difficult to prepare than |T states. One option for preparing |CCZ states is to use the circuit of Jones [42], which requires four |T states to produce a |CCZ state. Assuming the |T states are as in Eq. (3), the output error of the [[10,1,2]] protocol will be p out = 4p 2 +21p 3 +O(p 4 ). In this case, the distillation cost of the MEK+ protocol does not improve on the cost of the MEK protocol.
Definitively answering the question of which MSD protocol is preferable depends on the error model of quantum computing architecture under consideration, for example see [8,43]. However, often simpler MSD protocols using fewer qubits are preferable [6,43,44], which suggest that our [ [10,1,2]] protocol may transpire to be useful in practice. Furthermore, we have presented a single example of using morphing to modify an existing MSD protocol, but we conjecture that morphing could be fruitfully applied to other MSD protocols, e.g., those based on triorthogonal codes [32,36,45].

III. MORPHING THE COLOR CODE
In this section, we apply our morphing procedure to the color code [18][19][20], a family of topological codes. We first consider 2D color codes, before discussing the generalization to three and higher dimensions. Then we explain how morphing naturally leads to a family of HCT codes. Next we comment on the relation of our results to previous work relating the color code and the toric code. And lastly, we detail the fault-tolerant logical gates of HCT codes, which in three or more dimensions include non-Clifford gates.
A. Morphing color codes in two or more dimensions We use the dual lattice picture of color codes. In this picture, a 2D color code lattice L is a triangulation of a 2D manifold (possibly with boundary) whose vertices are three-colorable. That is, each vertex of the lattice can be assigned one of three colors (r, g, or b), such that any two vertices sharing an edge have different colors. Let L denote such a lattice and let L 0 , L 1 , and L 2 denote its vertices, edges, and faces, respectively. The edges and faces of the lattice inherit the colors of their vertices, e.g., an edge linking an r-vertex and a g-vertex is an rg-edge. The qubits of the code are on the faces of L and stabilizer generators are associated with interior vertices. That is, for each vertex v not on the boundary of L, we have the stabilizers X(v) = f ⊇v X f and Z(v) = f ⊇v Z f , where X f and Z f denote Pauli X and Z operators acting on the qubit on face f , respectively, and we are implicitly interpreting faces as subsets of vertices.
To apply our morphing procedure, we need to select subsets of the color code qubits. The subsets we choose are disk-like regions of L, but we refer to them as balllike in anticipation of generalization to three (and higher) dimensions. Namely, for each vertex v in L, we define the Morphing a ball-like region of a 2D color code. Qubits are on triangles and stabilizers are associated with vertices. On the left, we shade the ball-like region B v , which has an associated [ [6,4,2]] ball code. We also shade the support of an X-type and Z-type stabilizer in blue and green, respectively. On the right, we show the new lattice formed by morphing B v , replacing the original qubits with the four logical qubits of the ball code (blue and green edges). This changes the support of the highlighted stabilizers, as shown.

ball-like region
where d = 2. We define the color of a ball-like region B v to be the color of its central vertex v. We again use the notation B v 0 to refer to the vertices of B v etc. Restricting the stabilizer group to a ball-like region B v gives us a child code with parameters , as the code has two stabilizer generators that act on all the qubits. We call such codes ball codes. In the interests of brevity, we use the phrase 'morphing a ball-like region of a color code' as a shorthand for morphing a color code with the subset R of the physical qubits given by the qubits contained in a ball-like region of the code. Figure 4 shows an example of morphing a ball-like region of a 2D color code.
We now introduce a canonical geometric picture of morphing, which will prove especially useful when we consider decoding HCT codes in Section IV. The following corresponds to a particular choice of logical Pauli basis for ball codes, which we call the canonical basis (see Appendix A). We emphasize that other basis choices are equally valid and could be preferable in different contexts. Consider some ball-like region B v of a 2D color code lattice L. We note that the vertices on the boundary of B v always have two colors. When we morph B v we remove the faces of B v from L and add new edges as follows. For each boundary vertex color c, we choose one of the c-vertices on the boundary of B v and connect it via an edge to every other c-vertex on the boundary of B v , where we refer to the new edges as cc-edges. We place a qubit on each new cc-edge; these qubits are the logical qubits of the ball code. In this picture, morphing takes X-type stabilizers of the parent color code to operators consisting partly of color code X-type stabilizers and partly of toric code X-type stabilizers (and similarly for Z-type stabilizers). See Fig. 4 for an example. We defer a detailed discussion of the canonical geometric picture (including its generalization to higher dimensions) until Morphing a ball-like region of a 3D color code. Qubits are on tetrahedra, X/Z stabilizers are associated with vertices and edges, respectively. We shade a ball-like region (with an associated [ [24,11,2]] ball code) and show its transformation under morphing.

Appendix A.
Morphing higher dimensional color codes works in much the same way as the 2D case. We now briefly review the definition of the d-dimensional color code. Let L be a d-dimensional lattice formed by attaching d-simplices along their (d−1)-dimensional faces. We require that the vertices of L are (d + 1)-colorable. We place a qubit on each d-simplex of L and we associate X and Z-type stabilizer generators respectively with vertices and (d − 2)simplices not on the boundary of L. In 3D, qubits are on tetrahedra, X-type stabilizer generators are associated with vertices and Z-type stabilizers are associated with edges.
In much the same way as in 2D, in higher dimensions we again morph ball-like regions of the color code. For a given vertex v ∈ L 0 , the d-dimensional ball-like region B v consists of all simplices that contain v, alongside v itself; see Eq. (7). Figure 5 shows an example of such a balllike region in a 3D color code. Restricting the stabilizer group of the color code to a ball-like region B v gives us a d-dimensional ball code, which we characterize in the following lemma (whose proof we defer until Appendix A).
We note that the canonical geometric picture can be generalized to higher dimensions, see Fig. 5 and Appendix A.

B. Hybrid color-toric codes
We use morphing to construct a family of HCT codes in d-dimensions, for d ≥ 2. Given an initial color code defined on a lattice L, we obtain different HCT codes by morphing subsets of the ball-like regions of L. Concretely, suppose that L is a closed manifold and consider the case where we morph a fraction q ∈ [0, 1] of r ball-like regions (the choice of color is arbitrary). For q = 0 we of course have the original color code and for q = 1 we obtain d copies of the toric code (up to adding/removing ancilla qubits). Let L denote the HCT code lattice produced from L via morphing. For q = 1, qubits will be exclusively associated with edges as all the original color code qubits were contained in some r ball-like region of L. As we show in Appendix A, the X and Z-type stabilizers of L can be partitioned into d subgroups such that each subgroup only contains operators acting on cc-edges, where c is any of the d + 1 colors except for r. In 2D, each of these subgroups defines a toric code but in higher dimensions to obtain toric codes we need to introduce ancillas, unless we consider lattices with special structure (see Appendix D). We can also consider the case where we morph a fraction q of all the ball-like regions in L, but then we need to be careful because ball-like regions of different colors can overlap; see Section IV.
In d ≥ 3 dimensions color codes have transversal non-Clifford gates [19,21,[46][47][48][49], which our HCT codes inherit. As we show in Appendix B, if a d-dimensional color code has a transversal non-Clifford logical operator L implemented by R ±1 d gates, then HCT codes obtained from this code will have a fault-tolerant logical operator L implemented by R ±1 d and multi-control-Z gates. We recall that R d = exp( iπ 2 d Z) and that the d-qubit multicontrol-Z gate is specified by its action on the states in the computational basis, namely We now consider some examples of HCT codes with fault-tolerant non-Clifford gates. The [ [10,1,2]] code introduced in Section II A is one such example as the [ [15,1,3]] code fits into the color code family [47]. Furthermore, we can construct a HCT code with a fault-tolerant logical R d gate from any color code defined on a cellulation of a d-simplex. Another example is given by the family of hypercubic color codes [21], which we illustrate in Fig. 6. Hypercubic color codes have transversal logical M CZ gates and therefore HCT codes obtained from these codes have fault-tolerant logical M CZ gates.
We now briefly discuss how our results relate to previous work. In Ref. [21], the authors proved that the d-dimensional color code is local-Clifford equivalent to d copies of the d-dimensional toric code. Their argument was non-constructive, i.e., they showed that for a d-dimensional color code defined on a lattice L, there exists a Clifford isometry that transforms the color code into d copies of the toric code. Furthermore, the isometry has the following form where V u is a Clifford isometry acting on the physical qubits of the color code in the neighborhood of the vertex u. Morphing can be understood as giving an explicit implementation of the local Clifford isometry V , as each morphing circuit is a Clifford isometry applied in the neighborhood of a vertex. In Refs. [50] and [22], the authors show that one can obtain color codes by concatenating multiple toric code with small error-detecting codes. This is a special case of morphing, but in reverse. In Refs. [22] and [23], the authors present constructions of 3D and 4D toric codes with transversal logical M CZ gates. We can use morphing to recover these results, as we explain in Appendix D.

IV. DECODING HCT CODES
In this section, we propose an efficient decoding algorithm for 2D HCT codes, and we numerically benchmark its performance. Remarkably, our decoder reduces to the MWPM decoder [24,25] in one limit and to the restriction decoder in the opposite limit. We recall that the restriction decoder is an efficient decoder of the color code in d ≥ 2 dimensions that builds upon the ideas in Refs. [51] and [52].

A. Decoding algorithm
We consider phase-flip noise as the correction of bitflips is analogous and can be done separately. Let L denote a 2D HCT code lattice, produced from a color code lattice L (without boundary) by morphing some subset of its ball-like regions. We label the three colors of the vertices by r, b, and g. We use the canonical geometric picture from Section III A, so qubits in L are associated with rgb-faces, i.e., faces f ∈ L 2 ∩ L 2 and cc-edges, i.e., edges e ∈ L 1 \ L 1 . And X-type stabilizer generators are associated with vertices v ∈ L 0 . We emphasize that L should not be treated as a topological object but rather as a combinatorial object. We also make use of a well-known concept in color code decoding: restricted lattices [18,26]. Let L c1c2 be the lattice formed from L by deleting all vertices of color c = c 1 = c 2 , along with all edges and faces that contain these vertices.
We can now state our decoding problem: given an error syndrome σ ⊆ L 0 caused by an unknown phase-flip error . Decoding is successful if ζ and differ by a stabilizer.
Our decoding algorithm consists of the following three steps.
1. Matching: we use MWPM to pair up the vertices of σ in the restricted lattices L rg and L rb . That is, we obtain a set of edges E rg ⊆ L rg 1 whose boundary is exactly σ ∩ L rg 0 (and similarly for L rb ). In a slight abuse of terminology, we call such a set of edges a matching.
2. Local Modification: we modify the matchings as follows, focusing on E rg (for E rb exchange g ↔ b below). For each rr-edge e ∈ E rg , we find the color c of its corresponding ball-like region B v in L. If c = g, we remove e from the matching. Let u 1 and u 2 be the endpoints of e. We find two vertices are contained in L 2 for some v ∈ L 0 . Then we find a path (e 1 , . . . , e m ) from w 1 to w 2 consisting of gg-edges. We add the edges (u 1 , w 1 ), (u 2 , w 2 ), e 1 , . . . , e m to the matching.
3. Local Lift: first, we add each cc-edge in the combined matching E rg ∪E rb to the correction ζ. Then, for each r-vertex v ∈ e such that e ∈ E rg ∪ E rb we apply a local lift. For regions of L that are the same as the corresponding regions L, the local lift is the color code lift described in [26]. In the morphed regions of L, the local lift must be modified to account for the changes due to morphing; see Figure 7 illustrates our algorithm via and example, and a C++ implementation of our algorithm (utilizing Blossom V [53]) is available online [54]. We can now explain our earlier statement that morphing can simplify the decoding problem. Morphing (applied judiciously) transforms a color code into copies of the toric code, changing the decoding problem from color code decoding to the simpler toric code decoding problem. In particular, the local lift in the toric code regions is trivial, compared with the local lift in the color code regions. Therefore one can argue that the decoding problem is simplified in the regions of the lattice that have been morphed. Our algorithm has runtime complexity O(N 3 ) (see Appendix G), where N is the number of physical qubits in the code, due to the MWPM subroutine. As with the restriction decoder, MWPM can be replaced with any algorithm for 2D toric code decoding. For example, replacing MWPM with union-find [55] would give our algorithm almost linear time complexity. We note that our decoder is an instance of the 'decoding using emergent symmetries' paradigm, which underlies many topological code decoders [26,56,57]. As in the color code, the emergent symmetries in our case are the products of all stabilizers of the same color.
One example application for our decoder is color codetoric code lattice surgery [58]. There can be advantages to preparing magic states in a color code before transferring them to a toric code [59]. This transfer is accomplished via lattice surgery, during which the color code and toric code will be temporarily merged to form an HCT code that must be decoded as part of the lattice surgery protocol. For our decoder to be directly applicable to this situation, we would need to modify our algorithm to work for codes with boundaries, but we expect that this modification would proceed in a similar way to the restriction decoder [60].

B. Numerics
We investigate the performance of our decoding algorithm using Monte Carlo simulations. We begin with the family of 2D color codes defined on L × L triangular tilings where six triangles meet at each vertex. We use periodic boundary conditions, i.e., we identify the coordinates (x, y) = (x + L, y) = (x, y + L) = (x + L, y + L).
From this starting point, we explore three ways of constructing HCT codes. We investigate the performance of our decoder as a function of q for each of the above methods. In each case, we use an error model where iid Z errors affect the qubits with probability p and stabilizer measurements are perfect. We use Monte Carlo simulations to estimate the logical error rate p fail as a function of p, L, and q; see Fig. 8a. For each value of q > 0, we randomly generate 100 HCT code lattices for each L, and for each value of p we carry out 1000 Monte Carlo trials per lattice. For each value of q, we estimate the error threshold p th (q) using finite-size scaling methods [61], as illustrated in Fig. 8b.
For Method A1, we reproduce the known color code error threshold of p fail (0) ≈ 0.085 [52] and the known toric code threshold of p fail (1) ≈ 0.103 [62]. The threshold monotonically increases from q = 0 to q = 1; see Fig. 8c. For Method A2 we observe an increased threshold of p fail (1) ≈ 0.105; see Fig. 8c This is not surprising, as by picking the logical Pauli basis randomly we are highly unlikely to produce the standard square lattice toric code for q = 1.
For Method B, we observe similar results to the case where we morphed only r ball-like regions using random logical Pauli bases. And for Method C, we find that the error threshold does not vary with q and is approximately equal to the color code error threshold of p fail (0) ≈ 0.085. The data for these cases are shown in Fig. 8c.

V. CONCLUSION
In this manuscript we introduced morphing as a systematic method for modifying quantum codes. By applying morphing to quantum Reed-Muller codes, we obtained a family of codes with fault-tolerant non-Clifford gates and applications in MSD. We found that in the case of the color code, morphing allows us to change the implementation of fault-tolerant logical gates, reduce the weight of stabilizers and the number of physical qubits (at the cost of also reducing the code distance), and simplify the decoding problem. One can apply morphing to tetrahedral color codes [19,46,49] to construct HCT codes with a fault-tolerant logical T gate. The [ [10,1,2]] code is actually the smallest example of this family, which is thoroughly explored in [63,64].
We examined the decoding problem for 2D HCT codes and we detailed an efficient decoding algorithm based on existing toric and color code decoders. Our decoding algorithm achieves good performance across the whole family and we expect that our approach should generalize to higher dimensions. A natural next step would be to study more realistic noise models that include measurement errors. We expect that in this case standard techniques such as repeating the stabilizer measurements [65,66] would work for HCT codes. In addition, it would be interesting to investigate the optimal error threshold of 2D HCT codes using tensor network decoders [67,68]. We expect that the optimal threshold will interpolate between the optimal thresholds of the color code and the derived toric codes. This would potentially explain why the optimal threshold of the color code defined on the triangular lattice [69] matches the optimal threshold of the toric code defined on the square lattice [70][71][72], as the latter can be obtained from the former via morphing.
Morphing can be straightforwardly generalized to stabilizer subsystem codes [73]. We again select a subset of the physical qubits of the subsystem code and consider the code generated by all the stabilizers of the subsystem code that are fully supported within the subset. We remark that we cannot instead choose gauge operators supported within the subset as then some of the logical operators of the subsystem codes may not act as logical operators in the child code. We expect that it may be interesting to apply morphing to, e.g., the gauge color code [46,47] in order to define a HCT code family inter-polating between the gauge color code and the recently introduced 3D subsystem toric code [74].
Lastly, we expect that morphing could be fruitfully applied to triorthogonal codes [32] and pin codes [75], two families of codes that generalize color codes in different ways. We conjecture that morphing may allow us to improve the performance of MSD protocols based on triorthogonal codes (especially when mixing different input magic states), and to modify pin codes in much the same way as we did in the case of color codes. In this appendix, we explain how to morph d-dimensional color codes. We begin by fixing the notation and reviewing the definitions of the toric code and the color code (Appendix A 1). Then, in Appendix A 2, we examine the regions of the color code to which we apply our morphing procedure: colorable d-balls. Finally, in Appendix A 3 we introduce a family of HCT codes, which we construct by morphing the color code.

Preliminaries
A d-dimensional lattice L can be constructed by attaching d-dimensional cells to one another along their (d − 1)dimensional faces. We denote the k-cells of a lattice L by L k . We say that an m-cell µ ∈ L m is contained in a k-cell κ ∈ L k and write µ ⊆ κ, if the vertices of µ are a subset of the vertices of κ (where m ≤ k). And we define the n-star of a k-cell κ ∈ L k to be St n (κ) = {ν ∈ L n | κ ⊆ ν}.
The lattices we consider may have a boundary, denoted by ∂L, which comprises all (d − 1)-cells of L that are contained in a single d-cell, along with all k-cells contained in these (d − 1)-cells, for 0 ≤ k ≤ d − 2. We denote the interior of a lattice by L • = L \ ∂L and we denote the internal k-cells by L • k = L k ∩ L • . We often consider lattices whose cells are simplices and whose vertices are (d + 1)-colorable, i.e., one can introduce a function col : such that for any two vertices u and v sharing an edge, col(u) = col(v), and we use the shorthand [n] = {1, 2, . . . , n}. Such a lattice is called a d-colex [76]. We abuse the notation and write col(κ) = v⊆κ col(v) for some k-simplex κ, i.e., the color of κ is the set of the colors of its vertices. We denote the subset of k-cells in L of color c by L c k = {κ ∈ L k | col(κ) = c}. Given two simplices µ ∈ L m and ν ∈ L n , we define their join µ * ν to be the smallest simplex in L that contains them both. If no such simplex exist, then we define their join to be empty.
Anticipating the definition of the color code, we now introduce generalized boundary operators. Given a lattice L, let C k (L) be a vector space over F 2 with a basis given by the k-cells of L. Subsets of k-cells are consequently isomorphic to vectors in C k (L). For all k = n, we define the generalized boundary operator ∂ k,n as a linear map specified for every basis element κ ∈ L k as ∂ k,n κ = ν⊆κ ν, for k > n, ν⊇κ ν, for k < n. (A2) We note that the 'standard' boundary operator ∂ k = ∂ k,k−1 is a special case of the generalized boundary operator.

a. Toric codes and color codes
We now review the definition of the toric code [24,77,78] in d-dimensions, where d ≥ 2. Let L be a d-dimensional lattice with boundary ∂L. We divide ∂L into two subsets, the 'rough' boundaries ∂L (R) and the 'smooth' boundaries where X(v) = e⊇v X e , Z(f ) = e⊆f Z e , Z e denotes a Pauli Z operator acting on the qubit on edge e, and X e denotes a Pauli X operator acting on the qubit on edge e. For a face f adjacent to a rough boundary, the set of edges contained in f may include edges with no associated qubits. In this case we define Z e to be the identity.
The other important family of codes for us are color codes [18,21,76]. Let L be a (d ≥ 2)-colex, with boundary ∂L. The color code defined on L has qubits on d-cells, X-type stabilizer generators associated with internal vertices, and Z-type stabilizer generators associated with internal (d − 2)-simplices. That is, the stabilizer group of the code is where U (κ) = δ∈St d (κ) U δ and U δ means U applied to the qubit on the d-simplex δ ∈ L d . This notation clashes with the notation used for toric codes above, but it should always be clear from context what kind of code we are referring to.

Ball codes
Let L be a d-colex and pick a vertex v ∈ L 1 . We define the colorable d-ball B v centred at v to be i.e., B v is the union of all k-simplices in L that contain v. We define the boundary of B v as follows, Namely, ∂B v consists of all the k-simplices of L that are contained in a d-simplex of B v , but are not themselves contained in B v . We use B v k to denote the set of k-simplices contained in B v , with the obvious extension to ∂B v . And we define the color of a colorable d-ball B v to be col(v). Figure 9 shows some example colorable d-balls in 2D and 3D.
When we morph a color code, we pick the subset of qubits R (see Section I) to be the qubits contained in a colorable d-ball B v . The corresponding code has the stabilizer This is exactly the stabilizer group of a color code defined on a d-colex B v ∪ ∂B v with boundary ∂B v (recall Eq. (A4)). We call such a code a 'ball code'. We now come to our first lemma about ball codes.

Lemma 2. The ball code defined on the d-dimensional ball-like region B v has parameters
Proof. As the ball code defined on B v is a color code, we immediately have N = |B v d |. To find K, we first observe that one can define a (d − 1)-dimensional color code on ∂B v , which we call the boundary code. In the boundary code, qubits are on (d − 1)-simplices, X-type stabilizers are associated with vertices, and Z-type stabilizers are associated with (d − 3)-simplices. There is an isomorphism between the k-simplices of B v and the (k − 1)-simplices of ∂B v , for 1 ≤ k ≤ d. We have κ ∼ = τ for κ ∈ B v k and τ ∈ ∂B v k−1 , if κ = τ * v. Furthermore, the Z-type stabilizers of the ball code and the boundary code have the same support, because St d (κ) = St d (τ ) for κ = τ * v. In particular, independent Z-type stabilizer generators of the ball code correspond to independent Z-type stabilizer generators of the boundary code.
As the boundary code is a color code defined on a (d − 1)-colex that is homeomorphic to a (d − 1)-sphere, it encodes no logical qubits. Let S Z B v and S Z ∂B v denote the Z-type stabilizer groups of the ball and boundary codes, respectively (and analogously for the X-type stabilizer groups). We have Solving for k, we obtain as rank S Z B v = rank S Z ∂B v and rank S X B v = 1. The X-type stabilizer generators of the boundary code are associated with the vertices of ∂B v , and every (d − 1)simplex of ∂B v contains exactly d vertices, each with a different color. Consequently, we have (d − 1) independent relations between subsets of X-type stabilizer generators, namely where we assume without loss of generality that col(v) = 1. This gives rank S X ∂Bv = |∂B v 0 | − (d − 1) and substituting into Eq. (A9) gives the desired result.
Finally, we come to the code distance D. As ball codes are CSS codes [29,79], we need only consider logical operators that are tensor products of X and I or tensor products of Z and I. We note that X(e) is a logical X operator of the ball code, where e ∈ B v 1 . This operator is clearly not a stabilizer, but it commutes with the stabilizers of the ball code. To see this, consider a Z-type stabilizer generator Z(µ) where µ ∈ B v d−2 . The overlap of X(e) and Z(µ) (the qubits they both act non-trivially on) is given by St d (µ * e). The join of µ and e is either empty, equal to µ (if e ⊆ µ), or equal a (d − 1)-simplex of B v . In each case, | St d (µ * e)| = 0 mod 2; see the (Even Support) Lemma 4 in Ref. [47].
The ball code has a single X-type stabilizer acting on all its physical qubits, so any weight-two Z operator commutes with the stabilizers of the ball code. Consider the operator Z(λ), where λ ∈ B v d−1 . Z(λ) has weight two as each (d−1)simplex of B v is contained in exactly two d-simplices. For any such operator, we can always find a logical X operator X(e) such that e * λ = δ ∈ B v D , i.e., Z(λ) and X(e) anticommute. Therefore, Z(λ) is a logical Z operator and consequently the ball code has a Z-distance of two. The X-distance is also at least two as each qubit is in the support of two or more Z-type stabilizers.
We now specify a canonical generating set for the logical Pauli operators of a ball code defined on B v . Following on from the proof of Lemma 2, we choose the following generating set for the logical X operators, where e * c is some edge of color c that we are free to choose. Namely, our generating set consists of operators X(e) for each edge e in B v , except for one edge, e * c , of each color c = col(v). We choose each operator X(e) in our generating set to act on a single logical qubit, and we define the color of a logical qubit to be the color of its associated edge. This implies that the operator X(e * c ) implements a logical X on all logical qubits of color c. The set Z = {Z(λ) | λ ∈ B v d−1 } generates the logical Z operators of the ball code (see Lemma 2). The action of these operators is fixed via commutation. Concretely, the logical operator Z(λ) acts non-trivially on the logical qubits with associated logical operators X(e) such that | St d (λ) ∩ St d (e)| = 1 (or equivalently λ * e = δ ∈ B v d ). We now examine some examples of ball codes. The ball code defined on the colorable 2-ball shown in Fig. 9a is a [ [6,4,2]] code. And the ball code defined on the colorable 3-ball shown in Fig. 9b is an [ [8,3,2]] code. This code is exactly the so-called 'smallest interesting color code' [40,47], and it is part of a family of color codes, which we call hyperoctahedron codes.
Example 3 (Hyperoctahedron codes). A hyperoctahedron (also called a cross-polytope) is the d-dimensional generalization of the octahedron and can be constructed as follows. In d-dimensional Euclidean space, place vertices at all the permutations of (±1, 0, 0, . . . , 0). The d-hyperoctahedron is the convex hull of these vertices. We remark that the k-cells of the d-hyperoctahedron are k-simplices, for 0 ≤ k < d. Let O denote the d-hyperoctahedron, which we transform into a colorable d-ball as follows. First we create a vertex v in the centre of O. Next, for each k-simplex κ of O we add the k-simplex κ * v, for 1 ≤ k ≤ d. The result is a colorable d-ball, with B v comprising the simplices that contain v and ∂B v consisting of the original simplices of O. The hyperoctahedron code is then simply the ball code defined on B v . Hyperoctahedron codes generalize the [[4,2,2]] code [30] and the aforementioned [ [8,3,2]] code (the dual of a d-hyperoctahedron is a d-hypercube). The parameters of the d-hyperoctahedron code are [[2 d , d, 2]], as can be derived from Eq. (8) and the fact that a d-hyperoctahedron has 2d vertices and 2 d (d − 1)-cells. We note that for d-hyperoctahedron codes there is no freedom in the choice of canonical logical Pauli basis, as there is only one logical qubit of each color.
Example 4 (3D ball codes). One can construct colorable 3-balls by taking the dual of Archimedean solids whose faces all have an even number of sides. The polyhedra satisfying these restrictions are the truncated octahedron, the truncated cuboctahedron, and the truncated icosidodecahedron. The corresponding ball codes have parameters [ [24,11,2]] (this is the code shown in Fig. 5), [[48,23,2]] and [[120,59,2]], respectively. Each of these codes will have logical CCZ-type gates (see Theorem 5) implemented by physical T ±1 gates, and could therefore be used to distill magic states. The associated MSD protocol has asymptotic average overhead O(log γ (1/ )) as the output error → 0, where γ = log(n/k)/ log(d). The ball codes described above have γ values close to one, especially the [[120, 59,2]] code where γ = 1.02. This is significant as it was previously conjectured that γ ≥ 1 for all MSD protocols [32], and the only known protocols with γ < 1 require either many (≈ 2 58 ) qubits [34] or large (41) local qudit dimension [80].

Hybrid color-toric codes
Using our morphing procedure, we construct a family of HCT codes. Namely, we start with a color code and morph a subset of its colorable d-balls to obtain an HCT code. We note that we use the phrase 'morphing a colorable d-ball' as a shorthand for morphing a color code with the subset R of the physical qubits given by the qubits contained in a colorable d-ball. The HCT code family contains the color code and copies of the toric code, but also contains codes with regions of toric code and regions of color code. We now explain how the parameters of an HCT code change when we morph a colorable d-ball B v , which allows us to derive the parameters of any HCT code (by starting from the parent color code). Suppose that the initial HCT code has parameters [[N,K,D]]. Then after morphing the colorable d-ball B v , the resultant code has parameters We now briefly justify Eq. (A12). The value for N follows directly from Lemma 2. As we discussed in Section I, the number of encoded qubits remains the same as we lose the same number of physical qubits and independent stabilizer generators. Finally, the code distance decreases because some logical operators (acting on two or more physical qubits) of the ball code will be mapped to single-qubit operators by morphing. The highest-weight generator of the logical Pauli group of the ball code defined on B v is the logical X operator of highest weight (the Z operators are weight two), i.e., X(e * ) where e * = arg max e∈B v 1 | St d (e)|. Importantly, for color codes max e∈B v 1 | St d (e)| is a constant that does not scale with the size of the code, so the code distance remains macroscopic.
In the remainder of this section, we introduce a geometric picture of morphing and we show that the HCT code family contains toric codes.

a. Geometric picture of morphing
We begin by introducing a canonical geometric picture of morphing, which will enable us to see the connection to toric codes more clearly. Let B v be a colorable d-ball of a d-colex L, and assume that col(v) = d + 1. When morphing B v , we represent our choice of logical Pauli basis pictorially by removing B v from L and creating new edges linking vertices of the same color in ∂B v . Let u ∈ ∂B v 0 be the endpoint of the edge e * c (recall Eq. (A11)) on the boundary of B v . We add edges connecting u to all the other vertices of color c on the boundary of B v , and we place physical qubits on these new edges. We refer to these new qubits as edge qubits and we refer to the original color code qubits as simplex qubits. We use L to denote the HCT code lattice produced from L according to the above procedure. Also, we note that we must modify the generalized boundary operators to reflect the changes to the lattice structure; see Appendix G for a concrete example of this. This geometric picture enables us to continue to associate the X-type stabilizer generators of an HCT code with vertices. Concretely, the X-type stabilizer associated with a vertex u ∈ L 0 is where c = col(u), δ ∈ L d , and e ∈ L 1 has an associated edge qubit. This last point is guaranteed by the condition that col(e) = {c, c}, as, unlike the edges of L, the edges created during morphing connect vertices of the same color. Figure 10 shows the intersection of a color code X-type stabilizer with a colorable 3-ball. The Z-type stabilizers of a HCT code can also be understood using our geometric picture, though the definition is more obscure. We continue to associate HCT code Z-type stabilizer generators with (d − 2)-cells, as follows where δ ∈ L D , and c = col(u). To unpack Eq. (A14), we note that ∂ d−2,d−1 µ comprises the (d − 1)-simplices of L that contain µ and ∂ d−1,0 ∂ d−2,d−1 µ consists of the vertices contained in an odd number of these (d − 1)-simplices.

b. Toric codes as HCT codes
In this section, we sketch an argument that the HCT code family contains copies of the toric code. Let L be a d-colex defined on a closed manifold. Suppose we morph every colorable d-ball of color r = d + 1 in L. In the resultant HCT code no stabilizer generators will be associated with r-vertices and the only physical qubits will be edge qubits, as all simplex qubits will have been removed during morphing. The X-type stabilizers of the HCT code can be partitioned into disjoint subgroups X(v) | v ∈ L 0 : col(v) = c , for c ∈ [d]. This is because each generator X(v) now acts exclusively on edge qubits of color {c, c}.
As there are no remaining r-vertices, given a (d − 2)-cell µ ∈ L d−2 , the color of any (d − 1)-cell λ ∈ L d−1 such that λ ⊇ µ is fixed. Therefore, the Z-type stabilizers of the HCT code can also be partitioned into disjoint subgroups indexed by c ∈ [d], where the operators in each subgroup only act on qubits of color {c, c}. To summarize, for c ∈ [d], the stabilizer group of the HCT code can be partitioned into d disjoint subgroups of the form When restricted to the cc-edges of L, the X-type stabilizer generators of the c-subgroup have the form X(v) = e⊇v X e , i.e., they are toric code X-type stabilizers (recall Eq. (A3)). Now consider some Z-type stabilizer Z(µ) in the c-subgroup. Recalling Eq. (A14), we first write ∂ d−2,d−1 µ = {λ 1 , λ 2 , . . . , λ m }. In L, each λ i must have been contained in the boundary of two colorable d-balls of color d + 1, otherwise the λ i would have been removed during morphing. Therefore, λ i = µ * u i , where col(u i ) = c. Suppose that we permute our labelling of the λ i such that, in L, λ i and λ i+1 (evaluated modulo m + 1) were on the boundary of the same colorable d-ball B v , where col(v) = r. Then either (u i , u i+1 ) is in the support of Z(µ) or (u i , w) and (w, u i+1 ) are in the support of Z(µ) for some w that was also contained in ∂B v . Consequently, the support of Z(µ) is a cycle of cc-edges, i.e., it has the form of a toric code Z-type stabilizer (recall Eq. (A3)). In 2D we can see that the HCT code family contains toric codes by inspection, e.g., by applying the transformation shown in Fig. 4 to all r colorable 2-balls. In higher dimensions generic examples become more complex, excepting a family of HCT codes derived from color codes with special structure, which we examine in Appendix D.
Appendix B: Non-Clifford gates in d-dimensional HCT codes Color codes have a multitude of transversal logical gates implemented R d gates, including non-Clifford gates in d ≥ 3 dimensions [18,19,21,[46][47][48][49]. To describe the implementation of these gates, we note that the qubits of a color code are bipartite in the following sense. We can divide the d-simplices of a d-colex into two disjoint sets, such that any two d-simplices that share a (d − 1)-simplex are in different sets. We denote these sets by T and T c , and for a single-qubit unitary U we write U (T ) to denote the application of U to all of the qubits in T . Every d-dimensional color code has a transversal logical gate implemented by The logical action of this gate depends on the topology of the colex. For example, in tetrahedral color codes R 3 implements a logical R 3 gate [19,46,49]. And in the family of hypercubic color codes (see Fig. 6), R d implements the logical d-qubit M CZ gate [47], which we denote by C d .
HCT codes inherit the logical gates of their parent color codes. To find the implementation of a non-Clifford gate in an HCT code, we investigate how morphing changes the implementation of the corresponding color code logical gate. This entails understanding the transversal logical gates of ball codes, which is the topic of the next section.

M CZ gates in ball codes
As ball codes are color codes, they have transversal logical gates that are implemented by R d gates. Any unitary can be expanded in the Pauli basis, so in principle we can compute the logical action of any transversal gate in a ball code by expanding the transversal gate in the Pauli basis and then grouping terms by logical Pauli. However, this is cumbersome to do in practice so instead we characterize the transversal logical gates of the ball code family. First we introduce some notation. Let κ ∈ B v k be a k-simplex of a colorable d-ball B v , where 0 ≤ k ≤ D. We write The group commutator of two unitary operators A and B is defined to be K[A, B] = ABA † B † . We note the identities Theorem 5. Let B v be a colorable d-ball with an associated ball code, where d ≥ 2, and let The operator R k (κ) implements a logical C k gate on all k-tuples of logical qubits whose corresponding edges e j ∈ B v 1 have the following property: i.e., the join of the edges and κ is a d-simplex of B v .
Proof. We prove the theorem by induction on k.
Base case (k=1): Suppose we apply the operator R 1 (λ) for some λ ∈ B v d−1 . Up to an unimportant global phase, R 1 (λ) is a logical Z operator of the ball code. Consider a single-qubit logical X operator X(e), where e ∈ B v 1 . Inductive step: Suppose we apply the operator R k+1 (µ), where µ ∈ B v d−k−1 . We first show that R k+1 (µ) preserves the stabilizer. We only need to check the single X-type stabilizer X(v), as R k+1 (µ) trivially commutes with the Z-type stabilizers. Consider the group commutator We can partition the support of R k as follows where  *  µ), as every d-simplex that contains µ and e must also contain their join. Therefore where (e * µ) = κ ∈ B v d−k . By the inductive assumption, R k (κ) implements a logical C k gate on all k-tuples of logical qubits whose corresponding edges e j ∈ B v 1 are such that (e 1 * . . . * e k * κ) = δ ∈ B v d . This completes the proof, as the group commutator of C k+1 and a single-qubit X is C k . We remark that if we choose k = d in Theorem 5, we obtain a logical circuit consisting of d-qubit M CZ gates, implemented by R d (v), i.e., the gate acts on all the physical qubits of the code. Figure 11 shows some example logical circuits implemented by R 2 for the [[6,4,2]] code. A particularly simple application of Theorem 5 is to hyperoctahedron codes. For the d-dimensional hyperoctahedron code, it can be easily verified that R d (v) implements a C d gate on the d logical qubits of the code. Moreover for k ∈ [d] and κ ∈ B v d−k , R k (κ) implements a C k gate on the k logical qubits of color c col(κ).
Theorem 5 allows us to characterize the implementation of the logical HCT code gates that are inherited from the parent color code. If the parent color code has a logical gate implemented by R d , then HCT codes derived from this code will have the same logical gate implemented by R d , R † d , and C d gates. For each morphed colorable d-ball, Theorem 5 tells us the specific C d circuit to apply. More concretely, for a ball code with parameters [[N, K, D]], the C d circuit will have depth at most N d . As the size of any ball-like region is bounded, the implementation of the logical HCT code gate will be constant-depth and hence fault-tolerant. In Appendices C to F, we consider families of HCT codes where the C d circuits for each ball-like region have simple structure.

Appendix C: Further details on morphed QRM codes
We begin this Appendix by briefly reviewing the color code construction of distance-three QRM codes [47]. We start with a d-simplex and place another d-simplex inside of it. We color the vertices of each simplex with colors c ∈ [d + 1] such that each vertex of the same simplex has a different color. For each vertex v of the internal simplex, we connect v to all vertices of the external simplex whose color is different from col(v). The d-dimensional color code defined on this lattice is the d-dimensional QRM code of distance three. Figure 12 shows the lattices for the 2D and 3D codes. Now, suppose we morph a colorable d-ball of QRM(d). We observe that all ball codes in QRM(d) are dhyperoctahedron codes. This is because a given internal vertex v has d neighbors in the internal simplex and d neighbors in the external simplex, where there are exactly two neighbors of each color, and all neighbors are connected to each other except for those of the same color. Therefore the (d − 1)-dimensional surface of any internal colorable d-ball in QRM(d) is exactly a d-hyperoctahedron. For MSD protocols of the type discussed in Section II B, the leading order term in the output error is ap D , where D is the distance of the code and a is the number of logical Z operators of weight D. For QRM(d), a = (1 − 2 d+1 )(1 − 2 d )/3 whereas in the corresponding morphed QRM code a = d (as we prove shortly), so there is an exponential separation between the leading order prefactors as the spatial dimension increases. correspond to three reflecting hyperplanes r1, r2, and r3 (labelled left-to-right). In the figure the reflecting hyperplanes are the sides of the black triangle (the fundamental region). As specified by the diagram, r1 and r3 have dihedral angle π/2 whereas r1 and r2 have dihedral angle π/4 (as do r2 and r3). We show a subset of the (infinite) reflections of the fundamental region and we label some of these reflections in terms of r1, r2, and r3. From the figure we see that (r1r3) 2 = 1 and (r1r2) 4 = 1, matching the Coxeter diagram.
edge. To form a weight two logical Z operator, the only possible choice for the second qubit is the d-simplex spanned by the internal vertex of color c and the vertices on the boundary whose colors are not equal to c. To see this, observe that the Pauli Z acting on the edge qubit anticommutes with the X-type stabilizer generator associated with the internal endpoint of the edge. The only other qubit that is contained in the support this X-type stabilizer generator and no other X-type stabilizer generators is the one described above, as all other d-simplices contain internal vertices of color not equal to c. Therefore any other choice will lead to more unsatisfied stabilizers. And any weight two Z operator acting exclusively on edge qubits will not satisfy two stabilizers (associated with the internal endpoints of the edges). In the morphed QRM(d) code there are d edges with associated qubits, so there are d corresponding logical Z operators of weight two.
Appendix D: Constructing color codes and toric codes from Coxeter diagrams In this appendix we describe a construction of color codes and toric codes from Coxeter diagrams [81]. Such an approach has been employed before in [75,82] and is a generalization of the Schläfli symbol construction used in [23,[83][84][85]. Coxeter diagrams are used to represent Coxeter groups, which describe the symmetries of polytopes and tessellations in terms of reflections. A tessellation is a gapless covering of a manifold by uniform polytopes such that each adjacent pair of polytopes share a facet (a (d − 1)-cell). We say that a tessellation is uniform if all of its vertices are identical, i.e., there is the same combination of polytopes at each vertex. And we say that a tessellation is regular it is uniform and all the polytopes are identical. A Coxeter group is defined by the group presentation r 1 , r 2 , . . . , r m : (r i r j ) pi,j = 1 , where p i,i = 1 (as the r i are reflections), p i,j ≥ 2 for i = j, and p i,j = ∞ implies that the relation is ignored. Each Coxeter group has an associated graph called a Coxeter diagram, which describes the spatial relations between a collection of reflecting hyperplanes. There is a reflecting hyperplane (the r i in Eq. (D1)) for each vertex of the diagram and the edges represent the dihedral angles between different reflecting hyperplanes (corresponding to the p ij in Eq. (D1)). Unmarked edges correspond to dihedral angles of π/3 whereas edges marked by p > 3 correspond to dihedral angles of π/p. Vertices that are not connected by edges have dihedral angles of π/2. Figure 13 gives an example using the Coxeter diagram 4 4 . Given a Coxeter diagram, one can build uniform tilings using Wythoff's construction [81]. Consider the kaleidoscope corresponding to a given Coxeter diagram (see Fig. 13 for an example). We mark a subset of the vertices of a Coxeter diagram by ringing them. We then place a generating vertex inside the fundamental domain of the kaleidoscope, where the generating point is equidistant from all the reflecting hyperplanes that correspond to the ringed vertices. If a vertex is unringed, then the generating point lies on the corresponding reflecting hyperplane. The uniform tessellation is then the reflection of the generating point in all of the reflecting hyperplanes. Figure 14 shows some examples of Wythoff's construction applied to (a) 4 4 (b) 4 4 (c) 4 4 (d) 4 4 FIG. 14. Examples of Wythoff's construction applied to the Coxeter diagram 4 4 . (a) The Coxeter kaleidoscope described in Fig. 13. The fundamental region is highlighted in black. (b) Ringing the first vertex of the Coxeter diagram corresponds to placing the generating point at one of the corners of the fundamental region (red circle). The resultant tessellation is a square tiling. (c) By symmetry, ringing the third vertex of the diagram also leads to a square tiling. (d) Ringing all three vertices of the Coxeter diagram corresponds to placing the generating vertex at the centre of the fundamental region (equidistant from each reflecting hyperplane). In the resultant tessellation, two octahedra and one square meet at each vertex. The useful thing about Coxeter diagrams in our context is that the kaleidoscope corresponding to a particular Coxeter diagram is exactly a d-colex, where d is the number of vertices of the diagram minus one. To see this, note that a Coxeter diagram naturally describes a simplicial complex. Furthermore, the complex will be (d + 1)-vertex colorable as we can pick (d + 1) colors for the vertices of the fundamental region such that no two vertices have the same color, and the rest of the tessellation is formed by reflections of this fundamental region. In 2D we have the following (affine) Coxeter diagrams: 4 4 , and 6 ; each of which describes an affine Coxeter group and hence an infinite 2-colex. Furthermore, in certain cases different markups of a Coxeter diagram correspond to toric code lattices that are related to the colex via morphing. As an example, consider again 4 4 . As shown in Fig. 14, 4 4 and 4 4 correspond to square tilings. These are exactly the lattices we obtain if we morph the colorable 2-balls with associated 2-hyperoctahedron codes in the color code lattice described by 4 4 . Let us consider another example, this time in 3D. In Fig. 15 we illustrate the tessellation corresponding to the Coxeter diagram 4 . This diagram gives a 3-colex, whose dual is a uniform tessellation where one square, one truncated octahedron and two truncated cuboctahedra meet at every vertex (a tessellation called the cantitruncated cubic honeycomb). In this case, the markups 4 , 4 and 4 give the cubic honeycomb and two tetrahedraloctahedral honeycombs (see Fig. 15). These are exactly the toric code lattices that are produced by morphing the  colorable 3-balls with associated 3-hyperoctahedron codes in the color code lattice described by 4 . Furthermore, these are exactly the toric codes (with the appropriate boundary conditions) that have a transversal logical C 3 gate [22]. One may ask how general the Coxeter diagram approach illustrated in the previous two examples is. Whilst the markups of Coxeter diagrams are generically related to restricted color code lattices, the most elegant examples are color codes whose structure is described by Coxeter diagrams that are star graphs, e.g., 4 4 and 4 . The fundamental region of a Coxeter group corresponding to such a diagram is a right-angled simplex, i.e., a simplex where all facets except one meet at right-angles at one vertex (see the fundamental regions in Figs. 13 and 15). In such cases, all the colorable d-balls of one color will have associated d-hyperoctahedron codes. Therefore, we can morph these colorable d-balls to obtain d toric codes with a transversal gate implemented by C d .
In 4D, there is a single affine Coxeter diagram with the required star graph structure: . This diagram describes a 4-colex dual to a tessellation where four truncated octaplexes and one tesseract meet at each vertex. An octaplex (or hyper-diamond) is a regular 4-polytope described by the ringed Coxeter diagram 4 , where six octahedra meet at each vertex of the polytope and three meet at each edge. From , we can construct , a regular tessellation where every cell is a 4-hyperoctahedron, and three 4-cells meet at each face. Morphing the colorable 4-balls with associated 4-hyperoctahedron codes in produces four toric codes defined on tessellations with a transversal gate implemented by C 4 . With appropriate boundary conditions, these are the 4D toric codes with a transversal logical C 4 gate detailed in [23].
There are no further affine Coxeter diagrams in higher-dimensional Euclidean space with the required star graph structure. However, Coxeter groups also describe tessellations in hyperbolic space, and there are hyperbolic Coxeter groups with star graph Coxeter diagrams in 2D and 3D [86,87]. In 3D hyperbolic space, we have the Coxeter diagram 5 . The color code defined on this 3-colex has stabilizer weights of 120, 24, 10, 8, 6, and 4. Wythoff's construction gives us the tessellations detailed in Table I. We expect that morphing the colorable 3-balls with associated 3-hyperoctahedron codes in 5 would give toric codes with a transversal gate implemented by C 3 gates. As hyperbolic toric codes are finite rate, this may be an interesting set of codes to explore.  [20,4,3]] and [ [25,5,3]], respectively. We show the primal lattice in light grey for ease of comparison with [89]. In (b) and (d) we show the corresponding morphed codes, with parameters [ [12,4,2]] and [ [15,5,2]]. We note the central vertex has no associated stabilizer, which we indicate by making it hollow. For odd s, the color code colorability condition is unsatisfied, indicating the presence of a twist defect. We represent this pictorially by blended r/b vertices and edges.
(as in [88]) this gate will implement a logical R 3 gate.

Appendix F: Morphing stellated color codes
In this appendix we apply our morphing procedure to stellated color codes [89]. We focus on distance three stellated color codes based on the 4.8.8 tessellation, though we expect our results would generalize to the entire code family. Following [89], we parametrize the codes by an integer s ≥ 3, the order of the rotational symmetry of the code. The codes in the sub-family we consider have parameters [[5s, s, 3]]. We explain the construction of distance-three stellated color codes via examples in Fig. 17. We note that when s is odd, the stellated codes contain twist defects [89,90].
We now apply our morphing procedure to distance-three stellated color codes. We morph all colorable 2-balls with associated [ [4,2,2]] codes, giving a family of stellated HCT codes with parameters [[3s, s, 2]]. These codes have a high encoding rate and inherit the tranversal gates of the stellated color codes. In particular, for even s stellated color codes have a logical S ⊗s = S. In the morphed stellated color codes, the logical S ⊗s gate is implemented by S and S † on the color code qubits (as before) and by C 2 gates on the pairs of toric code qubits arising from each [ [4,2,2]] code.
One interesting avenue to explore is the generalization of these results to higher dimensions. It seems plausible that stellated color codes could exist in 3D, and we expect these codes would have fault-tolerant logical R 3 gates.

Appendix G: HCT code decoder details
In this appendix, we explain the local lift step of our 2D HCT code decoder, and we comment on the overall time complexity of our decoder. Let L be a 2-colex and let L be an HCT code lattice produced from L by morphing a subset of the colorable 2-balls of L. And let µ ⊆ L 1 be the matching produced in the second step of our decoding algorithm (see Section IV A). We use µ| v = {e ∈ µ : v ⊆ e} to denote the restriction of µ to the neighborhood of a vertex v. In the color code regions of L, for each r-vertex v in the matching, local lift returns a set of faces ϕ ⊆ L 2 ∩ St 2 (v), such that (∂ 2,1 ϕ)| v = µ| v . In the toric code regions of L, we first work out which faces local lift would return if it were to be applied in L with the same matching. For a given r-vertex v on the boundary of a morphed colorable 2-ball, this set of faces will be equal to the support of a logical Z operator of the ball code. Local lift then simply returns the edge qubits acted on by this logical operator. Figure 18 shows an example.
We claim that our decoder has time complexity O(N 3 ), where N is the number of physical qubits in the code.   TABLE II. Distillation costs for various MSD protocols to achieve target error rates ptarg assuming an input error rate of p = 0.01. The MEK+ protocol (CMEK+) equals or betters the original MEK protocol [17] (CMEK) and betters the triorthogonal protocol [32] (C∆) for ptarg ∈ {10 −6 , 10 −9 , 10 −10 }. The 'Sequence' column shows the sequence of distillation protocols used in the MEK+ protocol, where 5 is 10-to-2, 10 is 10-to-1, and 15 is 15-to-1; p actual is the output error rate achieved by the sequence. For certain values of ptarg, we find that the cost of our 10-to-1 protocol is lower than the cost of the 15-to-1 protocol, where (o) and (p) refer to the optimistic and pessimistic noise models for CCZ states described in Section II B, respectively.