Topological and subsystem codes on low-degree graphs with flag qubits

In this work we introduce two code families, which we call the heavy hexagon code and heavy square code. Both code families are implemented by assigning physical data and ancilla qubits to both vertices and edges of low degree graphs. Such a layout is particularly suitable for superconducting qubit architectures to minimize frequency collisions and crosstalk. In some cases, frequency collisions can be reduced by several orders of magnitude. The heavy hexagon code is a hybrid surface/Bacon-Shor code mapped onto a (heavy) hexagonal lattice whereas the heavy square code is the surface code mapped onto a (heavy) square lattice. In both cases, the lattice includes all the ancilla qubits required for fault-tolerant error-correction. Naively, the limited qubit connectivity might be thought to limit the error-correcting capability of the code to less than its full distance. Therefore, essential to our construction is the use of flag qubits. We modify minimum weight perfect matching decoding to efficiently and scalably incorporate information from measurements of the flag qubits and correct up to the full code distance while respecting the limited connectivity. Simulations show that high threshold values for both codes can be obtained using our decoding protocol. Further, our decoding scheme can be adapted to other topological code families.


I. INTRODUCTION
Fault-tolerant quantum computing with quantum error correcting codes (QECC) [1][2][3] is a scalable way to achieve universal quantum computation which will be capable of performing quantum algorithms that offer significant advantages over classical algorithms. With the rapid development of quantum computing platforms such as superconducting circuits and ion traps in the past decade, the path towards achieving logical qubits with O(100) physical qubits and demonstrating fault tolerance in near term devices looks very promising.
Leading candidates of QECC in the near term include topological stabilizer codes such as the surface code [1,2] and subsystem codes such as the Bacon-Shor code [4,5]. These codes belong to the class of quantum low-densityparity-check (LDPC) codes, and hence error-correction consists of measuring low-weight Pauli operators whose size is independent of the code distance. The standard schemes to implement these codes typically choose a square lattice which is motivated by minimizing the depth of the syndrome measurement circuits while allowing syndrome measurements to be performed using nearest neighbor interactions.
For implementations with superconducting circuits, promising architectures include fixed-frequency transmon qubits coupled via the cross resonance (CR) gates [6,7], tunable-frequency transmons coupled via the controlled-phase gate [8,9], systems using tunable couplers [10,11] and so on. In the context of the CR gates, C.C. and G.Z. were the main contributors of this work. * mathematicschris@gmail.com † guanyu.zhu@ibm.com the relative stability of microwave control as opposed to flux drive/tuning results in high fidelity gates which have achieved error rates below 1% [12] and hence approaching the surface code error threshold. Demonstrations of syndrome measurements and fault-tolerant protocols using post-selection in small scale devices has also been achieved [13][14][15][16]. However, to implement the standard surface code within this architecture requires data and syndrome measurement qubits placed on a square lattice, where each vertex has degree four (with four neighboring qubits). Therefore, a minimum of five distinct frequencies is required for the experimental implementation to ensure individual addressability of the CR gates and the avoidance of crosstalk [17]. This imposes a significant challenge to the device fabrication process which has to avoid possible frequency collisions limiting the code performance. Similar problems of crosstalk also exist in other superconducting architectures such as those using the controlled-phase gates.
In this paper, we design codes on low-degree graphs which can minimize the possibility of frequency collisions and optimize the hardware performance within superconducting qubit architectures. In particular, we have designed a family of subsystem codes on a "heavy hexagon" lattice with a mixture of degree-two and degree-three vertices, which can be considered as a hybrid surface/Bacon-Shor code, and a family of modified surface codes on a "heavy square" lattice with a mixture of degree two and four vertices. These codes reduce the distinct number of frequencies to only three in the bulk. The price of reducing the degree is to introduce more ancilla qubits mediating the entanglement for the syndrome measurement, which results in the increase of the depth of the syndrome extraction circuits and hence potentially increases the logical error rate. On the other hand, the extra ancil-2 las can also become resources for the decoding process. In particular, we have designed a protocol using the ancillas as flag qubits [18][19][20][21][22][23][24], which allows errors to be corrected up to the full code distance and hence significantly suppresses the logical error rate (thoughout the manuscript, unless specified otherwise, the term ancilla will be used for both syndrome measurement and flag qubits). When implementing the flag decoder, the heavy square code can achieve an error threshold of approximately 0.3% for both X and Z errors, while the heavy hexagon code achieves a threshold of approximately 0.45% for X errors. Both of them are close to the standard surface-code threshold (approximately 0.67%) with the added benefit of being suitable for superconducting hardware which significantly reduces issues arising from frequency collisions. Our schemes are optimized for architectures using the CR gates, but are also similarly useful for other architectures such as those using the controlled-phase gates. Note that for the heavy hexagon code, since Z errors are corrected using a Bacon-Shor type decoding scheme, there is no threshold for such errors. However, low logical errors were observed for the code distances that were considered (d ≤ 13).
More generally, our work here extends the previous fault-tolerant quantum computation schemes with flag qubits, which were mainly in the context of small-size codes, to the realm of topological and subsystem codes. The decoding scheme that we introduce is scalable and can be efficiently implemented for large code distances. We have also proved that there exists topological stabilizer codes with flag qubits defined on a general genus-g surface with gapped boundaries and holes, such that our flag decoder can achieve fault tolerance up to the full code distance.
The paper is organized as follows. In Sections II A and II B we give a complete description of the heavy hexagon and heavy square codes by describing the gauge generators to be measured and their construction. In addition, we describe the two dimensional layout and decoding graphs of both code families and provide a scheduling for the CNOT gates which minimizes the circuit depths for the X and Z-type parity measurements. A more detailed analysis of how edge weights for the Bacon-Shor and Surface-code type decoding graphs are calculated is provided in Appendix A. In Section II C we discuss the implementation of the heavy hexagon and heavy square codes using the cross resonance gate and discuss how frequencies can be assigned to different qubits to increase the yield during the fabrication process. Numerics comparing the average number of frequency collisions for the heavy hexagon, heavy square and rotated surface code are provided. In Section III we provide a detailed description of the decoding algorithm for topological codes which makes use of information from flag qubit measurement outcomes to correct errors. We also discuss how the decoder can be applied to topological codes on a highgenus surface and topological codes with hole defects (more details are provided in Appendices B 1 and B 2).
In Section IV, we provide numerical results for the logical failure rates of the heavy hexagon and heavy square codes and provide an estimate of their threshold values. Lastly, in Section V we summarize our results and provide directions for future work.

II. HEAVY HEXAGON AND HEAVY SQUARE CODES
FIG. 1. Reduction of a degree four vertex to two vertices of degree three. The vertices represent ancillas and data qubits of some topological code. By adding an additional ancilla qubit and entangling with the original ancilla, the degree of the connectivity can be reduced by one.
Suppose that we have a family of topological codes where the qubits and ancillas are represented as vertices of some graph and the edges of the graph represent the connectivity between the qubits and ancillas. Given a vertex of degree four, it is always possible to reduce the degree to three by adding additional ancilla qubits as shown in Fig. 1. By reducing the degree of the connectivity of a given graph, we will show below that this can potentially reduce the number of frequency collisions that can occur when applying two qubit gates using a cross-resonance interaction 1 .

A. Heavy hexagon code
In this subsection we describe a code family, the heavy hexagon code, encoding one logical qubit and defined on a heavy hexagonal lattice. The adjective "heavy" is used to say that qubits are placed on both the vertices and edges of a hexagonal lattice. About 60% of the qubits are therefore degree-2 (i.e. can interact with just two other qubits), while the rest are degree-3. The average qubit degree is then just 12/5, a large improvement over the degree-4 square lattice traditionally used for the topological code standard, the surface code. This is also an improvement over the degree-3 connectivity required to implement the Bacon-Shor code on a hexagonal lattice (see e.g. the Bacon-Shor layout in Appendix C of [25]). An illustration of the distance five heavy hexagon code, along with the scheduling of the CNOT gates for syndrome extraction, is shown in Fig. 2. The data qubits The data qubits are represented by yellow vertices, white vertices are the flag qubits and dark vertices represent the ancilla to measure the X-type gauge generators (red areas) and the Z-type gauge generators (blue areas). In the bulk, products of the two Z-type gauge generators at each white face forms a Z-type stabilizer. The right of the figure provides a circuit illustration of the heavy hexagon code with the scheduling of the CNOT gates used the measure the X-type and Z-type gauge generators.
(yellow vertices) in this code, which are used for the encoding of the logical information, reside on an effective square lattice. Hence, the data qubits can be labeled by row and column indices (i, j). The heavy hexagon code is a subsystem stabilizer code [4,5,26]. In this case, the logical information is encoded and protected in a subsystem with Hilbert space H L lying inside a larger Hilbert space, H=(H L ⊗ H G ) ⊕ H R , where H G describes the additional gauge subsystem not necessarily protected against noise and H R the rest of the full Hilbert space.
The gauge group of the heavy hexagon code is (with i, j = 1, 2, · · · , d − 1, m = 1, 2, · · · , d−1 2 , and the constraint that i + j is even for the second term), which is generated by weight-two Z-type gauge generators (blue areas), weight-four X-type gauge generators (red areas) in the bulk, and weight-two X-type gauge generators (red areas) on the upper and lower boundaries, as illustrated in Fig. 3(a). Here, d is the code distance, and is taken to be odd throughout the paper in order to optimize the logical error rate. The Z-type and X-type gauge generators are used to correct bit-flip and phase errors respectively.
The stabilizer group which specifies the logical subspace H L is the center of the gauge group or, explicitly, (with the constraint i + j is odd for the first term).
Here, Z i,j Z i,j+1 Z i+1,j Z i+1,j+1 is a weight-four surfacecode type stabilizer in the bulk, which can be measured via taking the product of the measured eigenvalues of the two weight-two gauge generators Z i,j Z i+1,j and Z i,j+1 Z i+1,j+1 . As will be seen below, the way Z-stabilizers can be factorized greatly reduces the circuit depth for syndrome measurements, and hence significantly suppresses the error propagation. In addition to the bulk stabilizers, weight-two surface-code type stabilizers lie on the left and right boundaries. On the other hand, i X i,j X i,j+1 is a Bacon-Shor type stabilizer [4,5], where the Pauli-X operators are supported on a two-column vertical strip, as illustrated in Fig. 3(b). It can be measured via taking the product of the measured eigenvalues of all the weight-four bulk X-type gauge generators and weight-two boundary X-type gauge generators lying inside the strip. All the operators inside the gauge group G commute with the stabilizers in the group S, which are themselves mutually commuting. However, the overlapping gauge operators with different Pauli types do not necessarily commute. Therefore, only the stabilizer eigenvalues are used to infer the errors. The heavy hexagon code can be considered as a hybrid surface/Bacon-Shor code, where the X and Z errors can be corrected respectively with the surface-code type and Bacon-Shor type decoding procedure respectively. The surface-code part corresponding to the X-error correction is a classical topological code 2 , and we will show that the flag qubit measurement outcomes can be used to ensure that the code can correct errors up to the full code distance (see Section III). We note that in [27], compass codes, which are defined as gauge-fixes of Bacon-Shor codes, were studied for the purpose of dealing with asymmetric noise models. Such codes include rotated surface codes and Bacon-Shor codes. Thus ignoring the extra ancilla qubits of the heavy hexagonal lattice, the heavy hexagon code can be viewed as belonging to the compass code family.
In general, a distance d version of the code will have d data qubits along each row and each column of the hexagonal lattice so that the code parameters are given by [[d 2 , 1, d]]. In addition, a distance d implementation of the code requires a total of d+1 2 (d − 1) syndrome measurement qubits and d(d − 1) flag qubits. Hence the total number of qubits in the implementation of the code is . Complementing the righthand side of Fig. 2, an illustration of the circuits for measuring the X and Z-type 2 A classical topological code stores a classical logical bit string Z supported on a non-trivial homological equivalence class of strings, e.g. connecting two boundaries or form a noncontractible loop around a genus. In particular, the logical string can be deformed to a homologically equivalent one by multiplying the Z-stabilizers. Ref. [25] has the definition of a classical toric code as an example, which is also the relevant one for the X-error correction of the heavy hexagon code.
gauge generators is given in Fig. 4. The CNOT scheduling was chosen to minimize the total number of error locations for one round of syndrome measurements. Such a scheduling is implemented in 11 time steps, which includes qubit initialization and measurement. Although the circuit depth of the heavy hexagon code is larger than that of rotated surface code (which requires a total of six time steps for the X and Z stabilizer measurements) [2,28], the flag qubits can be used to correct weight-two errors arising from a single fault during the weight-four X-type gauge measurements. In Section III, we provide a new decoding algorithm which uses information from the flag measurement outcomes to correct errors up to the full distance of the code 3 .
An important ingredient in the implementation of minimum weight perfect matching using Edmond's method [29] is the matching graphs used to correct X and Z-type Pauli errors with appropriate edges and edge weights. We illustrate such two-dimensional graphs for the distancefive heavy hexagon code in Fig. 5. The graphs are constructed by assigning an edge to each data qubit and vertices for the ancilla qubits used to measure the Xtype gauge generators (Fig. 5a) and Z-type stabilizer generators (Fig. 5b). The blue edges are boundary edges which have zero weight. In general, edge weights are given by w E = − log P E where P E is the total probability of error configurations resulting in an error at the edge E (see [30] for examples of optimizations performed on the surface code and Appendix A for edge weight calculations of the heavy hexagon and heavy square code). Correctable Z-type errors will result in highlighted vertices of the graph in Fig. 5a while correctable X-type errors will result in highlighted vertices of the graph in Fig. 5b. If an odd number of vertices are highlighted, a square vertex (chosen at random) is highlighted to ensure that the total number of highlighted vertices is always even. Note that for one round of syndrome measurements, the matching graph for X-type stabilizers is one dimensional since a vertex along a column is highlighted if the sum of the measured eigenvalues of all X-type gauge generators along a strip is odd.To detect measurement errors, the gauge measurements must be repeated d times [1,2,31]. Thus the matching graph consists of d copies of the matching graph for one round of gauge measurements with vertices connected by vertical edges. For the X-type gauge measurements, we obtain a twodimensional graph whereas for the Z-type stabilizers, we obtain a three-dimensional graph. In addition, diagonal edges connecting the graphs from two consecutive measurement rounds must be added to ensure that any single fault in the circuits of Fig. 4 corresponds to an edge in the final graph. Minimum wight perfect matching is then applied on the subgraph of highlighted vertices.
In this subsection, we present a mapping of the surface code onto the heavy square lattice. In the implementation of the rotated surface code in [28], each qubit in the bulk, both data and syndrome measurement qubits, interacts with four qubits. By adding two flag qubits to each stabilizer measurement in the bulk, the rotated surface code can be mapped onto a heavy square lattice as shown in Fig. 6 where now the average qubit degree is 8/3. The distance d code belonging to the family has parameters [[d 2 , 1, d]] with d 2 data qubits and 2d(d − 1) flag and syndrome measurement qubits. Hence the total number of qubits required for the implementation of the code is 3d 2 − 2d. In what follows, the code family will be referred to as the heavy square code. With the addition of the flag qubits, it can be seen that the degree of both ancilla and data qubits has been reduced to two in the bulk, at the cost of having flag qubits with degree four. In Section II C, more details will be provided showing that the heavy square code does reduce the number of frequency collisions relative to the standard implementation of the surface code.
The circuit for measuring the X and Z stabilizers of the heavy square code in the bulk, following the CNOT scheduling of Fig. 6, is illustrated in Fig. 7. It can be seen that the total number of time steps required to perform the stabilizer measurements is 14, compared to 11 for the heavy hexagon code. The increase in the number of time steps compared to the heavy hexagon code is due to the fact that both X and Z stabilizers have weight four compared to the weight-two Z-type gauge generators of the heavy hexagon code. Examples of the matching graphs for the d = 5 heavy square code is given in Fig. 8. An illustration of the possible weight-two errors arising from a single fault along with the flag qubit outcomes is given in Fig. 9.
We conclude this section with an important remark regarding the role of the flag qubits for the heavy square code. The logical X operator of the heavy square code has minimum support on d qubits along each column of the lattice. From the CNOT scheduling of Fig. 6, a weight-two X error arising from a single fault (which will result in a non-trivial flag measurement outcome) will be orthogonal to X since its support will remain in one column. On the other hand, a logical Z operator of the heavy square code will have support on each row of the lattice. A weight-two Z error arising from a single fault will thus be parallel to Z (since just like for X errors, its support will be along a single column). For the surface code, this problem can be avoided by finding a scheduling (see [28]) such that weight-two errors arising from a single fault are always orthogonal to the logical operator of the same type. Performing an exhaustive numerical search, such a scheduling is not possible for the heavy square code when the flag qubits are used to reduce the degree of data and syndrome measurement qubits. Hence if the flag measurement outcomes were omitted when decoding 6 Minimum weight matching graphs for the heavy square code Figure : Example of the minimum weight matching graph for 5 rounds the X-type gauge operator measurements (red regions) of the distance five heavy square code. Diagonal edges are necessary to correct space-time correlated errors arising from CNOT gate failures.

Figure :
Example of the minimum weight matching graph for 1 round the Z-type stabilizer measurements (blue regions) of the distance five heavy hexagon code.
Minimum weight matching graphs for the heavy square code Figure : Example of the minimum weight matching graph for 5 rounds the X-type gauge operator measurements (red regions) of the distance five heavy square code. Diagonal edges are necessary to correct space-time correlated errors arising from CNOT gate failures.

Figure :
Example of the minimum weight matching graph for 1 round the Z-type stabilizer measurements (blue regions) of the distance five heavy hexagon code.
Example of the minimum weight matching graph for five rounds the X-type gauge measurements of the d = 5 heavy hexagon code. Since only the stabilizer measurements are used to correct errors, the graph is one-dimensional for one measurement round. Diagonal edges connecting two consecutive one-dimensional graphs are necessary to correct space-time correlated errors arising from CNOT gate failures. The weights and directions of the diagonal edges depends on the CNOT gate scheduling and are chosen such that a single fault in the measurement circuits corresponds to an edge in the final graph. Labels m, b1, bu, d1, d 1 and d2 correspond to edges with different weights computed based on the probabilities of occurrence for a given edge. The edge d 1 is a bulk feature that only appears in odd columns excluding the first and last column (for instance, columns three and five in the d = 7 graph would contain edges d 1 ). More details are given in Appendix A. (b) Example of the minimum weight matching graph for one round of the Z-type stabilizer measurements of the d = 5 heavy hexagon code. The full graph for d rounds of Z-type stabilizer measurements is three-dimensional. Cross edges are given by dashed lines since they are only present in the presence of non-trivial flag measurement outcomes (during the X-type gauge measurements) represented by green circles. More details are provided in Section III. (c) Diagonal edges connecting two-dimensional graphs are added to ensure that a single fault in the measurement circuits corresponds to an edge in the final graph.
Heavy square distance 5 lattice   the heavy square code, the effective distance of the code d eff would satisfy d eff < d. In Section III, we provide a decoder that uses the flag measurement outcomes allowing such weight-two Z errors arising from a single fault (which are parallel to Z) to be corrected. We will show that with such a decoder, the code can correct any error arising from at most (d − 1)/2 faults so that d eff = d.

C. The cross resonance gates and frequency collision reduction
The designs of the heavy hexagon and heavy square codes are motivated by the experimental implementa-Z-stabilizer graph heavy square (a) Z-stabilizer graph heavy square X-stabilizer graph heavy square FIG. 8. Example of the graphs used to implement minimum weight perfect matching for the d = 5 heavy square code for (a) Z-type stabilizer measurements and (b) X-type stabilizer measurements. The green vertices in (a) correspond to flag measurement outcomes during X-stabilizer measurements. Similarly, the green vertices in (b) correspond to flag measurement outcomes during Z-stabilizer measurements. In (c) we illustrate the graph associated with Z-stabilizer measurements with 3D diagonal and vertical edges connecting the two-dimensional graphs.
|+i |+i FIG. 9. Flag outcomes arising from a single fault resulting in a weight-two data qubit error during the measurement of a weight-four operator. In this example the flag qubits are prepared in the |+ state and measured in the X basis. Starred measurements give a nontrivial outcome due to the errors.
tion of fault-tolerant quantum computation with a superconducting architecture. The low-degree property of the graphs significantly mitigates the issues of frequency collision and crosstalk and is applicable to a wide range of architectures including cross-resonance (CR) gates [6,7], controlled phase gates [8,9], and systems with tunable couplers [10,11]. In this section, we show that our codes are optimized for a CR gate architecture.
The CR gate implements a CNOT between a control and a target qubit, using only microwave pulses and not the magnetic flux drive needed in other gate types [8][9][10][11]. When employed to couple fixed-frequency transmon qubits via microwave-resonant buses, this architec-ture is hardware-efficient and insensitive to the chargenoise-induced dephasing noise source. [13,14]. The current fidelity of the gate exceeds 0.99 in a 2-qubit setup [12], approaching the error threshold for the surface code. Small-scale multi-qubit demonstrations of fault-tolerant protocols has been achieved recently [13][14][15][16].
In the CR gate, a drive tone at the target qubit's resonance frequency is applied to the control qubit. This requirement can produce 'frequency collisions' among nearby qubits whose energies are degenerate. As transmon qubits are weakly anharmonic, the |0 → |1 , |1 → |2 and |0 → |2 transitions are all relevant. Two nearest-neighbor qubits must not have degenerate ω 01 , nor one qubit's ω 01 degenerate with another's ω 12 or ω 02 /2. Among next-nearest-neighbor qubits joined to a common control qubit of the CNOT gate, degeneracies of ω 01 and ω 12 are also forbidden, as is a control qubit's ω 02 being degenerate with the summed ω 01 of two of its nearest neighbors. On the other hand, if a control and target's ω 01 frequencies are too far apart, the gate rate becomes too slow [32]. To avoid all these collision conditions, we designate each qubit to have one of a minimal set of distinct frequencies according to a defined pattern. The relative frequencies of nearest-neighbor qubits therefore fix the CNOT direction among each pair. In order to reverse certain CNOT directions to implement the measurement circuits in the codes developed above, we can conjugate the existing CNOT by Hadamards on the control and target qubits. Since the single-qubit errors on current superconducting architectures are at least an order of magnitude lower than the two-qubit gate fidelities, the errors due to these extra Hadamards are negligible.
In Fig. 10 we show the qubit frequency assignments of the heavy hexagon and heavy square codes respec- tively. The solid black lines indicate the connections and CNOT gates on the actual device. The control qubits are represented by black dots assigned with frequency f 1 , while the target qubits in the bulk are represented by green and white dots corresponding to frequency f 2 and f 3 . In addition, in both codes, there are additional boundary target qubits with frequency f 4 represented by blue dots (shown in the left panels). In both the heavy hexagon and heavy square codes, the controls reside on the degree-two vertices of the graph, such that they only have at most two neighboring targets. With this configuration, there are only three distinct frequencies (f 1 , f 2 and f 3 ) in the bulk, which greatly reduces the possibility of frequency collisions. We note that the extra frequency f 4 from the boundary targets are due to the modification/simplification of the heavy hexagon and heavy square lattice structure on the boundaries in order to shorten the circuit depth of the boundary gauge or stabilizer generators. If we recover the original heavy hexagon and heavy square lattice structure on the boundaries at the price of introducing additional ancillas and increase the depth of the measurement circuits (as shown on the right panels of Fig. 10), we will again have only three distinct frequencies (i.e., removing all the blue dots). By contrast, a rotated surface code architecture, in which all qubits reside on degree-four vertices, must have five distinct frequencies in order to avoid all collision conditions. [17] For practical implementations, a code with its graph and set of frequencies must be robust against the disorder that develops among dozens of transmon qubits prepared together on a single chip. This disorder, arising from imperfections in fabrication, may be characterized by the parameter σ f , the standard deviation in frequency of a population of fixed-frequency transmons. For typical multi-qubit devices, whose transmons have f 01 ∼ 5 GHz and f 12 − f 01 ∼ −330 to −340 MHz (similar to [12] or [33]), achieving σ f < 50 MHz requires all device parameters to be controlled with precision better than 1%, not a simple task when the transmons incorporate nanoscale tunnel junctions and capacitances of tens of fF. We seek therefore to find a lattice and code for which the transmons may have the largest possible imprecision σ f while still avoiding frequency collisions. For a quantitative comparison among the lattices and frequency patterns of Fig. 10, we perform Monte Carlo simulations in which we populate these lattices and related designs with a random disorder in frequency characterized by σ f . Taking 'collisions' as described above, we forbid regions of frequency space where we expect the resulting gate errors to exceed other typical causes [12,32,33]. In Fig. 11 we show the mean number of collisions found among various lattices as a function of σ f , each case derived from at least 10 3 Monte Carlo repetitions [34]. While this model does not quantify gate errors, it does enable us to compare frequency-crowding in different graphs using consistent means. As a practical matter, we seek to achieve < 1 average collision. We see that in any case this goal is achievable only for precisions σ f < 30 MHz. For all three types of codes, i.e., the heavy hexagon code, heavy square code, and the rotated surface code, we plot the mean number of collisions vs σ f for both dis- A highlighted cross edge corresponds to X or Z data qubit errors on edges e1 and e2 (which is equivalent to two data qubit errors on edges labeled e3 and e4 up to a stabilizer). Such edges will be referred to as boomerang edges due to the shape of the highlighted area.  Fig. 10(a). Note that the behavior of the two types of designs at d = 5 are similar, with the 4-frequency design having slightly more collisions, which is expected since the lattice shape differs only on the boundary. For the heavy square code, we show the 4-frequency design for both d = 3 (red dashed line) and d = 5 (red solid line) corresponding to the right panel of Fig. 10(b). We can conclude that the heavy hexagon and heavy square codes behave similarly for each code distance (red vs blue lines). Each of these is, however, distinctly better than the rotated surface code with degree-four and a five-frequency pattern (black dashed and straight lines). Although the rotated surface code requires 10 to 20% fewer qubits than the other two codes at each distance d, it requires qubits to be prepared nearly twice as precisely in order to eliminate frequency collisions. Or put another way, for a given distance (d = 3 or d = 5) and fabrication precision σ f , the rotated surface code exhibits roughly an order of magnitude more frequency collisions than do the heavy hexagon or heavy square codes. Therefore, the design of error correcting codes on a low-degree graph indeed improves the fabrication of the hardware significantly.

III. DECODING THE HEAVY HEXAGON AND HEAVY SQUARE CODES USING FLAG QUBITS
In what follows, when a flag qubit has a non-trivial measurement outcome, we will say that the flag qubit flagged. We also assume the following depolarizing circuit level noise model : 1. With probability p, each single-qubit gate location is followed by a Pauli error drawn uniformly and independently from {X, Y, Z}.
2. With probability p, each two-qubit gate is followed by a two-qubit Pauli error drawn uniformly and independently from {I, X, Y, Z} ⊗2 \ {I ⊗ I}.

With probability 2p
3 , any single qubit measurement has its outcome flipped.
5. Lastly, with probability p, each idle gate location is followed by a Pauli error drawn uniformly and independently from {X, Y, Z}.
When measuring the weight-four Pauli operators in Figs. 4 and 7, we have already discussed how a single fault can lead to a weight-two data qubit error while at the same time resulting in a flag 4 (see Fig. 9). In Figs. 5 and 8, we illustrated the matching graphs corresponding to Z and X-type stabilizer measurements of the heavy hexagon and heavy square code by adding green vertices representing the flag measurement outcomes. For the heavy hexagon code, faults resulting in X errors during the X-type gauge measurements can result in nontrivial flag outcomes, and the syndrome of the resulting data qubit errors is measured during the Z-type stabilizer measurements. Flag outcomes for the heavy square code have an analogous representation but are present for both X and Z stabilizer measurements. In Fig. 12, edges (data qubits) that can be afflicted by an error from a single fault resulting in a flag are shown. Due to the shape of the highlighted area, we will refer to such edges as boomerang edges. Each diamond has two green vertices (which we refer to as left or right flags) since two flag qubits are used to measure the weight-four operators of the heavy hexagon and heavy square code. Note that flags can also arise from measurement errors. Therefore flag qubits can flag without the presence of data qubit errors. However, by analyzing the circuits of Figs. 4 and 7, it can be shown that a single fault which results in both left and right flags cannot induce data qubit errors. Thus when both left and right flags are highlighted, information from the flag qubit measurement outcomes is ignored.
The goal of this section is to present a new decoding algorithm which integrates the flag qubit measurement outcomes into the minimum weight perfect matching algorithm to ensure that errors arising from at most (d−1)/2 faults are always corrected 5 . The decoder should be efficient so that it can be implemented via Pauli frame updates [3,36]. In order to do so, we make the following observations. Note that a single fault resulting in a left or right flag occurs with probability O(p). In general, m left or right flags, each arising from a single fault, will occur with probability O(p m ). Having both m flags in addition to l errors outside boomerangs is an O(p m+l ) event.
Since data qubit errors within boomerang edges occur with probability O(p), weights of edges E outside of the boomerangs are renormalized so that w E = − log p m P E whereas the weights of edges within the boomerangs are computed based on the leading order error configurations giving rise to those edges. More formally, the decoding protocol using the flag qubit measurement outcomes is given as follows: Decoding protocol using flag qubits: Consider a distance d heavy hexagon or heavy square code. After performing d rounds of error syndrome measurements, suppose there are a total of m left or right flag outcomes associated with the graph G.

Leave all edge weights inside the boomerangs corre-
sponding to left or right flag outcomes unchanged.

Let E be an edge outside a highlighted boomerang
and P E the probability of all error configurations resulting in an error on edge E. Replace P E by P E = p m P E .
3. Replace the edge weight w E of E by w E = − log P E .
4. Define G to be the graph G with new edge weights computed from the previous steps. 5. Vertices in G are highlighted if the corresponding X-or Z-type stabilizer outcomes change in two consecutive rounds. If an odd number of vertices are highlighted, highlight a boundary vertex.
6. Implement the minimum weight perfect matching algorithm on the graph G to identify all pairs of highlighted vertices to be matched.
7. Find the minimum weight path connecting all pairs of matched vertices of G .
8. If G is a d-dimensional graph, the highlighted edges in G are mapped to edges in the corresponding d − 1 dimensional planar graph added modulo two.
9. The correction is applied to the remaining highlighted edges.
Note that the probabilities assigned to edges outside of the boomerang's do not always correspond to the correct probability distribution for such edges. As an example, suppose there are m flags and two data qubit Z errors outside the boomerang's for a graph associated with the X-stabilizer measurements. Assume that the Z errors result in two highlighted vertices as for example, in Fig. 13 (where one flag qubit flagged). The assigned probability for the path connecting the two vertices will be O(p 2(m+1) ) instead of the actual probability O(p m+2 ) and will thus have a higher weight. One could be concerned that the high preference to edges within a boomerang could distort paths such that a correctable error configuration (under standard minimum weight perfect matching) would go uncorrected. However as we show below, the decoder described above can correct error configurations arising from at most (d − 1)/2 faults and is thus fault-tolerant.
Consider the worst case scenario where m 1 > 0 flags occur which are all caused by measurement errors so that paths within boomerangs contain no data qubit errors. In addition, suppose there are m 2 consecutive X or Z data qubit errors (whether it is X or Z is irrelevant as long as all errors are of the same type) which result in two highlighted vertices. We are interested in the case where m 1 + m 2 ≤ (d − 1)/2 so that the total number of data qubit errors is correctable by the code. Thus the number of edges α 1 and α 2 connecting the two highlighted vertices to the nearest boundary of the graph satisfies α 1 + α 2 ≥ (d + 1)/2 . An illustration is provided in Fig. 14.
Clearly, the path which corrects all the data qubit errors is one which goes through all the diamonds shown in Fig. 14 which does not contain a boomerang (the edges belonging to the correct path are highlighted in red). However each edge E along such path will have weight w E = − log p m1 P E compared to the edges E in the boomerangs which will have weight w E = − log P E . For the boomerangs to distort the minimum weight path connecting the highlighted vertices in such a way that a logical fault occurs, the path would need to connect the highlighted vertices to the boundary of the graph. But since m 1 + m 2 ≤ (d − 1)/2 , there must be at least (d + 1)/2 edges along such a path that does not belong to a boomerang and thus has weight w E = − log p m1 P E . Consequently, such a path would have weight w 1 ≥ − log p m1 (d+1)/2 E P E compared to the path which corrects the errors which has weight w 2 < − log p m1 (d−1)/2 E P E which has smaller weight 6 . Therefore the minimum weight path will correct the errors as required.
We point out that in [37], information from flag qubit measurement outcomes were used in a neural network decoder to decode topological color codes resulting in improved thresholds. However the scheme is not scalable as it requires an exponential increase in training data as a function of the code distance.
Although the above discussion applies to heavy square/hexagon codes and more generally to topological stabilizer codes with open boundaries, it also applies to the cases when these codes are defined on a closed surface (no boundaries) with nonzero genus g. The above analysis can be straightforwardly adopted to the g = 1 case, i.e., codes defined on a torus, which can be constructed by identifying the opposite edges of the square patch (periodic boundary condition) in Fig. 14. In the general genus-g case, the code distance d is given by the systole of the entire surface, i.e., the shortest non-contractible loop. The logical operators correspond to the non-contractible loops on the surface characterized by the first homology group H 1 = Z 2g 2 . In order to distort the minimum-weight path to form a non-contractible loop corresponding to a logical error, as illustrated by Fig. 15(a), the distorted path again needs to have at least (d + 1)/2 edges outside boomerang edges which has higher weight than the actual error path with length (d − 1)/2 . Similarly, the same proof also applies to the case where logical information is encoded using holes with gapped boundaries [2,38] 7 , as illustrated by Fig. 15(b), as well as the most general case where all of these encoding schemes coexist [40]. We hence reach the following theorem: Theorem 1. There exists topological stabilizer codes with flag qubits defined on a genus-g surface with p open boundaries, q holes such that the flag decoding scheme achieves fault tolerance with the full code distance (g, p, q ∈ {0, N + }).
< l a t e x i t s h a 1 _ b a s e 6 4 = " y 6 p t g U R m K 4 8 3 M N 8 U I K 2 3 j a D + r q o = " > A A A B 6 H i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B b B U 0 m q o M e C F 4 8 t 2 l p o Q 9 l s J u 3 a z S b s b o R S + g u 8 e F D E q z / J m / / G b Z u D t j 4 Y e L w 3 w 8 y 8 I B V c G 9 f 9 d g p r 6 x u b W 8 X t 0 s 7 u 3 v 5 B + f C o r Z N M M W y x R C S q E 1 C N g k t s G W 4 E d l K F N A 4 E P g S j m 5 n / 8 I R K 8 0 T e m 3 G K f k w H k k e c U W O l Z t g v V 9 y q O w d Z J V 5 O K p C j 0 S 9 / 9 c K E Z T F K w w T V u u u 5 q f E n V B n O B E 5 L v U x j S t m I D r B r q a Q x a n 8 y P 3 R K z q w S k i h R t q Q h c / X 3 x I T G W o / j w H b G 1 A z 1 s j c T / / O 6 m Y m u / Q m X a W Z Q s s W i K B P E J G T 2 N Q m 5 Q m b E 2 B L K F L e 3 E j a k i j J j s y n Z E L z l l 1 d  In this paper, we have proved the existence with the explicit construction of the heavy-square topological code, which has essentially the same topology-dependent logical encoding as the conventional toric code (e.g., both corresponding to the homology group H 1 = Z 2g 2 on a genus-g surface). The explicit construction of (1) the heavy-square code on a high-genus surface by gluing two layers of punctured surfaces [41] and (2) the heavy-square code with hole defects [2,38] are shown in Appendix B. We note that the methods described above apply to arbitrary constructions of high-genus surfaces with stabilizers of weight at most four, while the bilayer construction is the simplest one with local connectivity. We caution that more general constructions such as highergenus hyperbolic surfaces will typically require stabilizer measurements of weight greater than four [42][43][44][45] and thus the methods described above do not directly apply. However, with more flag qubits, it is possible to adapt the edge-weight renormalization scheme described in this work [35]. The heavy-hexagon subsystem code, on the other hand, is "half-topological" (corresponding to the Z-stabilizers) as mentioned above 8 and it turns out that the flag decoding scheme also achieves faulttolerance with the full code distance. Lastly, we point out that for codes with stabilizer generators of weight w > 4, depending on the support of logical operators, one could potentially require v-flag circuits to measure the stabilizer generators where v = w 2 −1 (see [20] for the definition of a v-flag circuit). If a v-flag circuit is required (with v > 1), then edges should be renormalized based on the number of faults that resulted   16. (a) Logical X error rates and (b) logical Z error rates for the heavy hexagon code. The asymptotic threshold for logical X errors is approximately p th = 0.0045. Since Z errors are corrected using Bacon-Shor type stabilizers, there is no threshold for Z errors.  in a particular flag outcome. For instance, if two faults resulted in a particular flag outcome, then edges with support on the data qubits that could have errors resulting from the flags should be renormalized by p, and edges not in the support should be renormalized by p 2 . Thus to guarantee the correction of errors arising from up to (d − 1)/2 faults, extra flag qubits could be required to distinguish how many faults resulted in a particular flag outcome.

IV. NUMERICAL RESULTS
Using the decoding protocol with flag qubits and the edge weights given in Appendix A, we computed the logical error rates of the heavy hexagon and heavy square codes for odd distances 3 ≤ d ≤ 13. Error rates were computed by performing 10 7 Monte Carlo simulations given the noise model described in Section III. Logical X and Z error rates 9 for both codes are given in Figs. 16 and 17. For the heavy hexagon code, since Z errors are corrected using Bacon-Shor type stabilizers, there is no threshold for logical Z errors (see Fig. 16b). However for physical error rates close to 10 −4 , it can be seen that the logical error rate does decrease significantly for the code distances that were considered. X-type errors are cor-   18. (a) Logical X error rates and (b) logical Z error rates for the heavy square code when flag qubit information is ignored. The threshold for logical X errors is approximately p th = 0.002, half the value obtained when flag information is used to correct errors. Further, due to the error propagation properties of the heavy square code, logical Z error rates are about an order of magnitude worse than compared to those obtained when flag information is kept.
rected using a surface-code type decoding scheme. The X-error rate threshold was found to be p th = 0.0045 which is fairly competitive with results obtained for the surface code [2,8,30,31].
Similarly to logical X error rates of the heavy hexagon code, the heavy square code also exhibits high thresholds even though the circuit depth for the stabilizer measurements are 14 compared to 6 for the surface code. For both logical X and Z errors, the computed asymptotic threshold is found to be approximately p th = 0.003.
A large reason for the high threshold values obtained (despite the large circuit depths) is due to our new decoding scheme which uses information from the flag qubit measurement outcomes. We already proved in Section III that the full code distance can be achieved. To further support our claims, we also computed the logical error rates for the heavy square code ignoring the flag qubit measurement outcomes and using standard minimum weight perfect matching methods used for the surface code. The plots are given in Fig. 18. As we discussed in Section II B, weight-two Z errors arising from a single fault are parallel to the logical Z operator of the heavy square code. It is thus not surprising to see that when flag information is ignored, the logical Z error rates in Fig. 18b are about an order of magnitude higher than those in Fig. 17b. Further, the threshold for logical X errors in Fig. 18a is approximately p th = 0.002 which is less than half the value obtained when flag information is used to correct errors.

V. CONCLUSION
In this work we introduced two families of codes which we called the heavy hexagon code and heavy square code.
The heavy hexagon code (where qubits are located on a heavy hexagonal lattice) is a hybrid surface/Bacon-Shor code where weight-four X-type gauge generators form Bacon-Shor type stabilizers and products of weight-two Z-type gauge generators form surface code type stabilizers. The heavy square code is a family of surface codes mapped onto a heavy square lattice. For superconducting qubit architectures using the CR gate, both code families achieve the goal of reducing the number of frequency collisions as compared to surface code devices. For a code of distance d, heavy square and heavy hexagon implementations require 10 to 20% more qubits than a rotated surface code. However when considering the practical effect of fabrication-related disorder σ f in the qubits' frequencies, for a given distance d the heavy square and heavy hexagon codes achieve nearly an order of magnitude fewer frequency collisions than the rotated surface code, and can accept roughly twice the disorder while remaining collision-free.
One of the key ingredients in the fault-tolerant implementation of the above codes were the use of flag qubits for the weight-four X and Z-type gauge and stabilizer measurements. We provided a scalable decoding scheme which makes use of the flag qubit information and can correct errors up to the full code distance. Performing Monte Carlo simulations for a depolarizing noise model, we showed that the heavy square code exhibits competitive threshold values (approximately p th = 0.003) with the surface code. Since Z errors are corrected via Bacon-Shor type decoding schemes for the heavy hexagon code, there is no threshold for Z errors (although low logical error rates can be achieved for physical error rates in the order of 10 −4 ). However the heavy hexagon code achieves a threshold of approximately p th = 0.0045 for X errors.
In this work we also showed how our flag-qubit de-coding scheme can be applied to codes defined on a surface with nonzero genus g. An interesting avenue for future work is to apply the flag-qubit decoding scheme to topological codes with stabilizer generators of weight greater than four (such as the color code) to ensure that errors are corrected up to the full code distance. Such an approach could result in thresholds which are closer to thresholds obtained for surface codes. When including the overhead cost of performing a universal gate set, such codes with flag qubit decoders could be a preferred alternative to the surface code. Another interesting avenue would be to extend the ideas presented in this work to topological codes with twist defects [39] and to more general subsystem codes. We also point out that in the presence of m flags, instead of renormalizing edge probabilities for edges outside boomerangs by p m P E , numerical optimizations could be performed to find the optimal coefficient α (potentially using machine learning techniques) such that edge probabilities would be renormalized by p α P E . Such optimizations will inevitably be highly dependent on the underlying noise model afflicting the stabilizer measurement circuits.
Lastly, in Ref. [46] it was shown how some families of subsystem codes achieve better error correcting capabilities compared to the surface code in the presence of leakage errors. An interesting direction for future work would be to analyze the performance of codes defined on low degree graphs in the presence of leakage errors to see if such codes also have favorable error correcting capabilities compared to more standard implementations such as in the surface code.

VI. ACKNOWLEDGEMENTS
We thank Jay Gambetta and Jerry Chow for useful discussions and for bringing the fabrication difficulties related to frequency collisions to our attention. We thank Easwar Magesan for explaining the conditions that lead to frequency collisions. We thank John Smolin for discussions and the help with parallel computing. We also thank Mike Newman and Ken Brown for useful discussions.

Appendix A: Edge weights calculations for the matching graphs
In this appendix we provide examples of how to compute the weights of the edges for the graphs of Figs. 5 and 8. We then give the edge weights for all edges in the graphs used for correcting X and Z Pauli errors.
Consider the circuit containing the scheduling of the CNOT gates of the heavy hexagon code in Fig. 2. In what follows, we focus on CNOT gates in the bulk of the lattice. An error of the form XX occurring after the CNOT gate implemented at time step 8 for a Z-type parity measurement will result in a X error on the corresponding data qubit, which will then propagate through the CNOT gate implemented in the ninth time step. Thus both Z-type parity measurements interacting with a bulk data qubit will detect the X error in one measurement round and will contribute to the edge weight of 2D TLBR (see Fig. 19). The full list of errors which contribute to the weight of 2D TLBR are {XX, Y Y, XY, Y X} for CNOT's at the eight time step, {XI, XZ, Y I, Y Z} for CNOT's at the ninth time step (on the lower right of a white face), {IX, ZX, IY, ZY } for CNOT's at the third time step and fourth time step (lower left of the X-type gauge measurement) and data qubit X and Y errors. From the noise model defined in Section III, the total probability (to leading order in p) for an error to result in an edge E of type 2D TLBR is given by On the other hand, an error of type XI occurring after a CNOT at the eight time step (where X is on the control qubit of the CNOT) will introduce a data qubit error which will propagate through the CNOT applied at the ninth time step. Hence for the measurement round at which the error occurred, only one of the two syndrome measurement qubits in the Z-type parity measurements will be highlighted. In the next measurement round, the data qubit will have an X error so that both of the syndrome measurement qubits of the Z-type parity measurement will be highlighted. Therefore, such an error will result in the edge 3D TLBR of Fig. 19. The types of errors leading to such an edge are {XI, XZ, Y I, Y Z} for CNOT's at the eight time step and {XX, Y Y, XY, Y X} for CNOT's at the ninth time step (bottom right of a white face in Fig. 2). Hence to leading order in p, the probability associated with the edge 3D TLBR is given by P E = 8p 15 (1 − 4p 15 ). The probabilities associated with the other edges of Fig. 19 can be computed using similar methods as the ones described above.
Using the same methods as above, we computed the edge weights for the edges corresponding to the X-type gauge measurements of the heavy-hexagon code (Fig. 5a). However one important difference is that only the odd parity of a configuration of errors are relevant when decoding Bacon-Shor type codes. Taking into account all odd configurations of errors giving rise to particular edge types, we obtain Z-gauge operator graph edge types and associated probabilities (distance d heavy hexagon code): < l a t e x i t s h a 1 _ b a s e 6 4 = " 4 2 0 i I V C z 0 w k I E K I A S j q o I l 5 P u B U = " > A A A C a H i c f Z H Z S g M x G I U z 4 1 b r N m 6 I e B N a h I p Y J m 1 d b g R R B C 8 r 2 i p 0 a s m k m R q a W U g y Q h k G 3 9 E 7 H 8 A b n 8 J 0 O h d 1 w R 9 C D u f L n + X E j T i T y r b f D X N m d m 5 + o b B Y X F p e W V 2 z 1 j f a M o w F o S 0 S 8 l A 8 u l h S z g L a U k x x + h g J i n 2 X 0 w d 3 e D X m D y 9 U S B Y G 9 2 o U 0 a 6 P B w H z G M F K W z 3 r t d l L r l N 4 D h 1 P Y J K g k y h N 0 H E K n U s 2 g B U E j 3 L Q m P I P n u r Z X I H o a E J r m t Z z C A / h t P n / R o 2 e V b a r d l b w t 0 C 5 K I O 8 m j 3 r z e m H J P Z p o A j H U n a Q H a l u g o V i h N O 0 6 M S S R p g M 8 Y B 2 t A y w T 2 U 3 y Y J K 4 b 5 2 + t A L h R 6 B g p k 7 3 Z F g X 8 q R 7 + q V P l b P 8 i c b m 3 + x T q y 8 s 2 7 C g i h W N C C T g 7 y Y Q x X C c e q w z w Q l i o + 0 w E Q w f V d I n r H O Q + m / K e o Q 0 M 8 n / x b t W h X V q 7 X b R v n i L o + j A P Z A C V Q A A q f g A t y A J m g B A j 6 M J W P L 2 D Y + T c v c M X c n S 0 0 j 7 9 k E 3 8 o s f Q H F m b N Y < / l a t e x i t > P E = 16p 15 x z z 0 1 y Y g e M C m m a X 5 q + t L y y u p Z a T 2 9 s b m 3 v G L t 7 N e G H H J M q 9 p n P G z Y S h F G P V C W V j D Q C T p B r M 1 K 3 B w 8 j v f 5 O u K C + 9 y q H A W m 7 q O d R h 2 I k F d U x P i q d 6 D G G d 7 D l c I S j U h B H 1 k 0 M W / e 0 B 7 P Q g l e J U J w W c m 8 F e L n Q 8 Z 9 h v E 3 P m 7 b l O k b G z J v j g v P A S k A G J F X p G J + t r o 9 D l 3 g S M y R E 0 z I D 2 Y 4 Q l x Q z E q d b o S A B w g P U I 0 0 F P e Q S 0 Y 7 G a c X w X D F d 6 P h c L U / C M T v t i J A r x N C 1 V a e L Z F / M a i N y k d Y M p V N q R 9 Q L Q k k 8 P D n I C R m U P h x F D 7 u U E y z Z U A G E O V V 3 h b i P V B p S f V B a h W D N P n k e 1 A p 5 6 z p f e C 5 m y i 9 J H C l w D M 5 A F l j g F p T B E 6 i A K s D g W z O 0 Q + 1 I + 9 E P 9 B P 9 d N K q a 4 l n H / w p / e I X y F i z + g = = < / l a t e x i t > P E = 8p 15 ⇣ 1 4p 15 ⌘ < l a t e x i t s h a 1 _ b a s e 6 4 = " V S c D e G E v n u q m + B C K + g 5 9 a n j d L 9 Y = " > A A A C H n i c b V D L S s N A F J 3 U V 6 2 v q E s 3 g 0 W o C 0 t S W + x G K I r g s q J 9 Q B P C Z D p p h 0 4 e z E y E E v I l b v w V N y 4 U E V z p 3 z h t s 6 i t B y 4 c z r m X e + 9 x I 0 a F N I w f L b e y u r a + k d , (A1)

Hole defects
A more experimentally feasible way is to encode multiple logical qubits into a single-layer planar code with hole defects [2,38]. As shown in Fig. 21, we can construct two types of hole defects equivalent to the smooth defect (Z-cut qubit) and rough defect (X-cut qubit) in the standard surface codes respectively [2]. As shown in Fig. 21(b), the smooth defect (Z-cut) has only X-type weight-two stabilizers on the hole boundary, while the rough defect (X-cut) has only Z-type weight-two stabi-lizers on the hole boundary. In this example, we show a "double Z-cut qubit" on the left and a "double X-cut qubit" on the right. The double Z-cut qubit has the logical Z-string going around the holes, while the logical X-string connecting the two wholes, with length 6 and 3 respectively. On the other hand, the double X-cut qubit has the logical X-string going around the holes, while the logical X-string connecting the two wholes. The code distance in this case is d = 3, i.e. the length of the shortest logical string. Again, the flag decoder can correct up to (d − 1)/2 faults in this case as well. Braiding of a Z-cut defect around another X-cut defect implements a logical CNOT gate.