Code deformation and lattice surgery are gauge fixing

,


I. INTRODUCTION
Quantum computers can implement algorithms which are much faster than their classical counterparts, with exponential speedup for problems such as prime factorisation [1], and polynomial speedup for many others [2].The main obstacle to constructing a large-scale quantum computer is decoherence, which partially randomizes quantum states and operaa These authors have made equal contributions to the research discussed herein.arXiv:1810.10037v2[quant-ph] 13 Nov 2018 tions.Although state-of-the-art coherence times are now appreciably longer than gate times [3,4], they remain too short for useful quantum computation.
To counter the effect of decoherence on quantum states which are stored or manipulated imperfectly, we can encode logical qubit states into several physical qubits, and perform nondestructive multi-qubit measurements of the resulting system to extract information about which errors have occurred, called the syndrome.The spaces of multi-qubit states used to encode these logical states are called quantum error-correcting codes, and their ability to correct errors is measured by the distance d, which is the number of independent errors (or error weight) necessary to alter the state of the logical qubits without being detected.In order to use one of these codes in practice, it is also necessary to account for the effect of decoherence on operations.For example, a syndrome measurement may involve a sequence of entangling gates, and the error caused by a faulty gate on a small set of qubits in the beginning of the circuit may propagate onto many qubits, producing a high-weight error, increasing the likelihood of a logical error.Measurement results can also be corrupted by decoherence, so syndrome extraction often has to be repeated.In order to prevent error propagation during repeated measurement, syndrome extraction circuits must be designed such that a small number of faults (from imperfect gates or memory errors on data qubits) will result in a small number of errors on the physical qubits, which can be corrected using noisy syndromes.Given a family of codes of different distances, we can determine a threshold error rate, the rate beneath which codes with higher distance produce lower logical error probabilities.
Several such families of quantum error-correcting codes have been developed, including concatenated codes [5,6], subsystem codes such as Bacon-Shor codes [7], and 2D topological codes.The most prominent 2D topological codes are surface codes [8] derived from Kitaev's toric code [9], which we will focus on in the remainder of this manuscript.2D topological codes can be implemented using entangling gates which are local in two dimensions, allowing fault-tolerance in near-term devices which have limited connectivity.In addition, 2D topological codes generally have high fault-tolerant memory thresholds, with the surface code having the highest at ∼ 1% [10].
These advantages come at a cost, however.While other 2D topological codes permit certain single-qubit logical operations to be implemented transversally, the surface code does not.
In addition, the constraint that computation be carried out in a single plane does not permit two-qubit physical gates to be carried out between physical qubits in different code blocks, precluding the two-qubit gates which, in principle, can be carried out transversally.
These two restrictions have led to the design of measurement-based protocols for performing single-and two-qubit logical gates by making gradual changes to the underlying stabilizer code.Measurement-based protocols that implement single-qubit gates are typically called code deformation [11], and protocols that involve multiple logical qubits are usually called lattice surgery [12].A separate measurement-based technique, called gauge fixing [13], can be applied to subsystem codes, which have operators which can be added to or removed from the stabilizer group as desired, the so-called gauge operators.During gauge fixing, the stabilizer generators of the subsystem code remain unchanged, and can be used to detect and correct errors; so decoding is unaffected by gauge fixing.This is in contrast to code deformation and lattice surgery, where it is not a priori clear which measurement results to incorporate into decoding, or how to process them.Recently, many different code deformation and lattice surgery techniques have been devised, most of which use tailor-made analysis or decoding techniques, see e.g.[14][15][16][17][18][19][20][21].
In this paper, we phrase existing lattice surgery and code deformation protocols as special cases of gauge fixing, showing that the underlying subsystem code dictates the fault-tolerance properties of the protocol.This perspective can simplify the analysis of new measurementbased protocols, provided that they are based on stabilizer codes whose distances can be easily calculated.Also, knowing the stabilizer of the underlying subsystem code results in clear guidelines for decoding using the measurement results produced by such a protocol.The remainder of this paper is organised as follows.In Section II, we review the ideas behind code deformation and lattice surgery.In Section III, we review the formalism of gauge fixing.Following this, in Section IV, we formulate lattice surgery and code deformation operations as gauge fixing, demonstrating that fault-tolerant code deformation protocols are in fact based on high-distance subsystem codes.We also show this explicitly using both wellknown and novel protocols.In Section V, we numerically determine the performance of these protocols.We conclude and discuss potential future research in Section VI.
In all figures in this paper, qubits are located on the vertices of the drawn lattice.We refer to the local generators of the stabilizer group of the surface code as stabilizers or checks.In the figures, black regions signify X-stabilizers and light grey regions Z-stabilizers, with no stabilizers measured on white plaquettes.

A. Code Deformation
Code deformation is a technique to convert one code into another by making a series of changes to the set of stabilizer generators to be measured in each round of error correction.
Typically, these protocols use ancillae prepared in entangled and/or encoded states as a resource.Also, a typical code deformation sequence proceeds gradually, first expanding the code into a large intermediate code by entangling the original code block with the ancillae, then disentangling some of the qubits (which may include some or all of the original data qubits), producing a final code which can then be used for further computation.The initial and final code may differ in their logical operators, in which case the deformation performs a logical operation.Also, the initial and final code may differ in their position or orientation within a larger quantum computer.
For example, consider the proposed fault-tolerant procedure for lattice rotation of surface codes shown in Figure 1, similar to the one presented in [22].One can see five steps which gradually modify the surface code patch starting at the bottom right of Figure 1a and ending at the top left of Figure 1e in a different orientation.First, three ancillary patches are prepared in fixed states, and placed near the upper left corner of the target patch.
Then, the patch undergoes a two-step growing operation, followed by a two-step shrinking operation.Advancing one step is done by measuring the operators corresponding to the new stabilizers, some of which anti-commute with the old ones.Measurement of these new stabilizers will return ±1 values at random.This means that additional corrections, unrelated to errors that may have occurred, are needed in order to enter the new code space (the mutual +1-eigenspace of all new stabilizers).Moreover, to account for noisy operations, one must simultaneously perform error correction.After one is confident that the encoded state is in the new code space, one can proceed to the next step.
In Section IV, we will demonstrate that, following these five steps, one can fault-tolerantly protect the logical information at all times with a distance-5 code.We also show that the distance would be reduced to 3 if one were to omit step (b), going directly from (a) to (c), as one would do when directly adapting the established surface code rotation method from [12] to rotated surface codes.This type of code deformation does not, in itself, perform logical operations, but can be used to move patches of code or to convert between codes where different gates are transversal [16].Other code deformation procedures such as moving holes or twists do perform unitary logical Clifford operations [18,23,24].In the next section, we present another similar procedure which executes a logical measurement.

B. Lattice Surgery
Lattice surgery is a particular measurement-based procedure that acts non-trivially on logical information.By going through two steps of deformation, it implements a joint measurement of logical operators, typically X 1 X 2 or Z 1 Z 2 , where X j and Z j denote the logical operators of the logical qubit j.We will focus on the Z 1 Z 2 measurement and review the protocol used for the surface code [12,15].
Consider two patches of L × L rotated surface code, as in Figure 3a.Each has a Z along the boundary which faces the other patch.In the merge step, one measures the intermediary Z-plaquettes (in pink in Figure 3b).These plaquettes are such that the product of all outcomes is the outcome of the Z 1 Z 2 measurement, but any subset of these outcomes produces a random result when multiplied together.This ensures that the only non-stabilizer operator whose eigenvalue can be inferred from these measurements is Z 1 Z 2 .These measurements do not commute with the weight-2 X stabilizers at the joint boundary (in Figure 3a).The Gottesman-Knill theorem [25] prescribes how to update the stabilizer after such measure- ments, namely we only retain elements in the original stabilizer group which do commute with the newly measured stabilizers.This implies that the code becomes a 2L × L patch of surface code, apart from some minus signs on the newly-measured Z-checks.This merge step is very similar to the rotation presented before, except that some logical information is gained in the process and the additional corrections which fix the state into the new code space may involve one of the original logical operators (when the number of intermediary plaquettes with −1 eigenvalues is odd).To finish the protocol, the original code space must be restored by performing a splitting operation, measuring the original stabilizers of the two separate patches instead of the intermediary Z-plaquettes.Those Z-plaquettes, as in the merge step, anticommute with the boundary X-stabilizers, and will be removed from the stabilizer group.Their product, equal to Z 1 Z 2 , does commute, and will remain as a stabilizer of the final state.In addition, the boundary X-plaquettes will have random ± signs which are perfectly correlated between facing pairs.Therefore, one can eliminate these ± signs by applying some of the former stabilizers (those supported on the intermediary Z-plaquettes).
One can check (see the algebraic proof in Appendix A) that depending on the outcome (±1) of the logical Z 1 Z 2 measurement, the merge and split operations, respectively M ± and S ± can be expressed as They are related to the projections, P ± , onto the ±1 eigenspace of Z 1 Z 2 by composition: In particular, lattice surgery allows us to implement the measurement-based cnot gate [26] in a 2D layout with only local operations as shown in Figure 4. We note that a more general set of operations which can be implemented by lattice surgery can be constructed using the relation between the merge and split operations considered here and the three-legged nodes of the ZX-calculus [27].For the purposes of this work, however, we will limit our discussion to cnot gates.

III. GAUGE FIXING
Gauge fixing [13] is an approach which has been used to implement universal fault-tolerant gate sets in subsystem codes [28].A subsystem code is equivalent to a stabilizer code in which some of the logical qubits are not used to carry any logical information.These logical qubits are called gauge qubits and they can be acted on or measured without disturbing the states of the other logical qubits, which are used to store and process quantum information.Then, one way to formally define a subsystem code, C, is to define a subgroup of the Pauli group, called the gauge group G, containing all the Pauli stabilizers as well as the Pauli operators defining the gauge qubits.This subgroup is non-Abelian as it contains anti-commuting Pauli operator pairs which represent the gauge qubit logical operators.The stabilizer group, S, can be derived from G as its center, denoted Z(•), i.e. containing all elements in G which mutually commute where C(G) denotes the centralizer of G in the Pauli group, i.e. all elements in the Pauli group with commute with all elements in G. Elements in G which are not in S are the Pauli operators acting non-trivially on the gauge qubits: this is the set of gauge operators L g Following this, one can define operators for the actual logical qubits which by definition are elements in C(S) \ S. If these operators act trivially on the gauge qubits, we call these bare logical operators.Bare logical operators can be multiplied by elements in L g to become dressed logical operators which also act on the gauge qubits.We can write Note that with this definition we have, L bare ⊂ L dressed .The distance of the subsystem code C is the smallest weight of any of its logical operators, One advantage of subsystem codes is that to measure stabilizers, one is free to measure any set of checks in the gauge group as long as this set generates the stabilizer group.By measuring elements in the full gauge group, one can put the gauge qubits in specific states, permitting different sets of transversal logical gates.This act of putting the gauge qubits in a specific state is called gauge fixing.The idea is to measure a commuting subset of gauge operators (all the Z-type gauge operators, for example), obtaining ±1 outcomes and applying the anticommuting, or conjugate partner operator (an X-type gauge operator in the example), wherever a −1 outcome has been obtained.In the example, this would fix all gauge qubits to the |0 state.While the gauge is fixed in this way, the Z-type gauge operators become elements of the stabilizer group, so S is augmented to some larger Abelian subgroup of G. Appendix B shows an example of how code conversion between the 7, 1, 3 Steane code to the 15, 7, 3 Reed-Muller code can be viewed as gauge fixing.

IV. FAULT-TOLERANCE ANALYSIS WITH GAUGE FIXING
In this section, we show how both code deformation and lattice surgery can be viewed as gauge fixing operations and therefore, one can use gauge fixing to analyze the fault-tolerance of these operations.
We consider the QEC codes before and after an deformation step, denoted as C old and C new , with stabilizer groups S old and S new , respectively.Both codes are fully defined on the same set of qubits.The logical operators of each code are defined as The intuition we follow is to see the two stabilizer codes as two different gauges of the same subsystem code.The first step, then, is to define a joint subsystem code, C, whose gauge group, G, is generated by both S old and S new , G = S old , S new .
The generated group, G, is not necessarily Abelian, since it contains elements of S old which may anti-commute with some elements of S new .
The stabilizer group, S, defined as in Eq. ( 3), can be characterised as follows: Elements in the center of G also have to be in the centralisers of S old and S new .Moreover, being in both centralisers and in G is sufficient to be in the center, or See Figure 5a for a representation of S as a Venn diagram.Note that, in addition to containing S old ∩ S new , S can also contain some logical operators from either L old or L new .This is the case for the merge operation of lattice surgery where the logical but also in S old and therefore in S.
As defined above, this subsystem code C indeed admits S old and S new as two distinct Abelian subgroups of G. Therefore the codes S old and S new correspond to fixing two different sets of states for the gauge qubits of G.However, for this to function as a subsystem code, one would have to be stabilized at all times by S and thus be able to measure all values of the stabilizers of S. This is not the necessarily the case when S contains some elements of L old or L new , and we have to further modify G to a gauge group G whose center is solely How The names M prep and M meas are chosen to represent their respective roles in the deformation procedure.In such a procedure one starts from a system encoded in C old , i.e. stabilized by S old , and then one measures the new stabilizers, S new .When S new contains some elements of L old , then in general these elements will not stabilize the state of the system, since it can be in any logical state at the beginning of the procedure.Measuring these operators will return information about the logical state and cannot return information about errors.Thus, by switching to S new one also performs a logical measurement of the elements in M meas .
It is also possible for S old to contain some elements of L new .In that case, the state of the system is initially stabilized by these elements, and remains so, since we only measure operators commuting with them.In this sense, the deformation procedure will prepare the logical +1 state of elements in M prep .
We denote the code underlying the code deformation step as C. differently, only the elements of L g which are in the blue-green dotted region in Fig. 5 will be fixed, one can also view these as elements of M fix ≡ G \ S old .

A. Fault-Tolerance of Code Deformation
Given an underlying subsystem deformation code C, one can ensure the fault-tolerance of a code deformation operation by checking three criteria: 1. Code distance: The distance of the subsystem code, C, must be large enough for the desired protection.Ideally it matches the distances of C old and C new so the degree of protection is not reduced during the deformation step.

Error correction:
The error correction procedure follows that of the subsystem code C through the code deformation step.

Gauge fixing:
To fix the gauge, one has to use operators exclusively from L g = G\S.
More specifically, criterion 2 means that to perform error correction, one has to reconstruct from the measurements of S new the syndrome given by S. Importantly, criteria 2 and 3 demonstrate that the processes of error correction and that of gauge fixing are two separate processes with different functionality.Both processes require the application of Pauli operators (in hardware or in software) to make sure that stabilizer measurements are corrected to have outcome +1.The error correction process does this to correct for errors, while the gauge-fixing process does this to move from C old to C new .
This description holds for one step of deformation, so that for each step in a sequence of deformations one has to examine the corresponding subsystem code C and its distance.
Depending on the sequence, Figure 5b illustrates why skipping steps could lead to poor distance and poor protection against errors.This discussion also assumes that stabilizer measurements are perfect; the effect of noisy stabilizer measurements is considered in the following section.

Noisy Measurements
When one considers noisy syndrome measurements, one needs to ensure that both the stabilizer outcomes and the state of the gauge qubits can be learned reliably.For 2D stabilizer codes such as the surface code this is simply done by repeating the measurements.To pro-cess this repeated measurement information for the surface code, one no longer uses the syndrome but the difference syndrome: the difference syndrome is marked as non-trivial (we say that a defect is present) only when the syndrome value changes from the previous round of measurement.This difference syndrome or defect gives information about both qubit errors as well as measurement errors.we can place defects when the found syndrome changes from what it was expected to be based on the last round of measurements with S old .S new also contains a subset of elements in L g , namely the blue-green dotted region M fix in Fig. 5a.Some of these elements are also contained in L old (down-right-dashed area in Fig. 5a), i.e. they are elements of M meas .The eigenvalues of these elements in M meas depends on the logical state and are therefore not a proper syndrome for S old .So only after one more round of QEC with S new one can mark whether the syndrome for these elements in M meas changes, and either place a defect or not.
In addition, the eigenvalues of the gauge operators in the remaining blue-green dotted region take random ±1 eigenvalues (since they anticommute with some elements in S old ): for these checks, like for the elements in M meas , there is no previous record to construct a difference syndrome right away.Again, only after one round of QEC with S new one can again mark whether the syndrome changed, placing a defect for an element or not.In processing these new syndromes of S new to do error correction, we should also allow them to be matched with virtual defects placed beyond the past-time boundary T d .For example, a measurement error in the first step when the syndrome is randomly +1 or −1, followed by many rounds without measurement error, produces a single defect and should be interpreted as the first measurement being incorrect.In this sense, there is only one layer of time where the defects are those of S as indicated on the right in Fig. 6.Given all defect syndromes, minimum-weight matching can be used to decode (see Fig. 6), to infer some errors as they have occurred in a window of time before and after T g and T d (one may use a sliding window as in [22]).Let us then imagine that by matching defects in a window which goes beyond a so-called gauge-fixing time T g , one infers a set of measurement and data errors.These errors are projected forwards to the time-slice T g and they are used to do three things.One is to correct the value of elements in M meas (if any), so that the logical measurement has been completed and properly interpreted.The second is to determine or fix the gauge, i.e. determine the outcome of elements M fix in the blue-green dotted region of Fig. 5.As we have argued, these gauge values may be ±1 at random and hence Pauli gauge-fixing corrections can be added in software to make the outcomes all +1 if one wishes to work with the frame where all elements in S new have +1 eigenvalue.These Pauli gaugefixing corrections are not error corrections and any set of Pauli operators can be chosen as long as they solely fix the values of the elements in M fix .Thirdly, the projected errors provide the usual update of the Pauli frame for the code S, so together with the gauge-fixing corrections, for the code S new .The whole procedure is represented schematically in Fig. 6; at time T g , the code deformation step is finished.
Note that, after T d , the elements in M prep are no longer measured, but their fixed values before the code deformation now represent logical states prepared by code deformation.
Typically, for 2D stabilizer codes, the time window between T g and T d needs be of size O(d) in order to fix the gauge, where d is the distance of code C. In some cases, the measurements contain enough redundant information about the gauge operators so that T g can be equal to T d (e.g. in single-shot error correction schemes based on redundancy of the checks).For example, this is the case when performing the logical measurement of a patch of code by measuring every single qubit in the Z basis.This is also the case for the logical measurement step of the plain surgery technique explained below.
In the remainder of this section, we apply this formalism to the code deformation and lattice surgery operations discussed earlier.Gauge fixing, when applied to the growing operations of Figure 1 and Figure 2, reveals an underlying subsystem code with a small number of widely-spaced holes and large boundaries, resulting in a high distance.The stabilizer group, S, as well as the gauge operators, L g , for the subsystem code C which governs the deformation from Figure 1a to Figure 1b, are shown in Figure 7.

B. Code Deformation Examples
In all figures of this paper, light blue and light red patches individually represent X-type and Z-type gauge operators, and bright blue and bright red qubit chains are X and Z operators respectively.The grow operation is changing the gauge from one in which the gauge operators not overlapping between the initially separate patches are fixed, denoted as {X 1 , X 2 , Z 3 , Z 4 } in Figure 7b, to one in which the overlapping ones are fixed, denoted as {Z 1 , Z 2 , X 3 , X 4 } in Figure 7b.The distance of C is still 5, matching the distance of the initial code.
Now consider what happens if we would go directly from Figure 1a to Figure 1c.The stabilizers and the gauge operators for this operation are shown in Figure 8.Similarly, one fixes the gauge going from separate patches to a single patch.The distance of the subsystem code for this operation is only 3. Indeed one of the minimum-weight dressed logical operators is the Z on the qubits in the green box in Figure 8b.That means that, in order to preserve the code distance, one should perform the intermediary step.
The operators of the subsystem code for the one-step grow operation from Fig. 1a to Fig. 1c, skipping Fig. 1b: (a) The stabilizers which generate S and (b) the whole gauge group, G, with highlighted gauge operators and logical operators.
2. The merging and splitting operations In this section, we interpret the joint measurement of ZZ by lattice surgery in Figure 3b as gauge fixing.The stabilizer group S is generated by all the stabilizers in Figure 9a.The gauge operators, L g , of the gauge group are given by three representatives of the logical X of the top patch and the intermediary Z plaquettes that anti-commute with them.They are denoted as X 1 , Z 1 , X 2 , Z 2 , X 3 , Z 3 in Figure 9b.Representatives of the bare logical operators, X, Z ∈ L bare , are the logical Z of the bottom patch and the logical X of the merged patch (joining the very top to the very bottom), see Figure 9b.The merge and split operations are realised by fixing some gauge operators of L g , resulting in new codes C merged or C split , respectively.Note that the weight of X of the subsystem code, C, is only d and not 2d which is the distance for X of the merged code.Indeed, by using the gauge operators like X 1 and stabilizers, one can construct a dressed logical X of weight d.Another way of seeing this is by realizing that one cannot distinguish between two errors of weight d /2 depicted in Figure 9c and Figure 9d.In the first one, the logical measurement outcome is −1 and there is a string of d /2 X-errors from the bottom to the middle of the bottom patch.In the second one the logical measurement outcome is +1 and there is a string of d /2 X-errors from the middle of the bottom patch and the middle (changing the observed logical measurement outcome to −1).Note also that when performing the splitting operation, one wants to correct the −1 outcomes for some of the intermediary X stabilizers.They are gauge operators equivalent to, say X 1 X 2 .They have to be corrected using the Z gauge operators, say Z 1 in this case.Otherwise one would introduce a logical Z error.One can see that the distance is guaranteed by the offset between the two blocks.The distance of the separate surface codes is 11, and the distance of the subsystem code is 4.
We now introduce a new technique with the same goal as lattice surgery, namely performing joint measurements of logical operators, but following a different procedure.The difference between lattice surgery and the new procedure, plain surgery, will be that the logical measurement is performed with redundancy, so that this part of the protocol can be made more robust to noise, at the cost of qubit overhead.
The idea is to separate the merging and logical measurement of lattice surgery into two distinct steps.The first step deforms the two separated blocks into a single code block where the joint logical operators can be measured redundantly.Since this step merges the codes, but leaves the logical information unchanged, we call it a plain merge.In the second step, we measure the desired logical operator destructively, similar to the standard logical measurement of a surface code block.A final deformation step can be used to return to the original code space.
The layout for the plain merge operation is shown in Figure 10a.The patches are placed with an overlap of approximately 2d /3, the X-boundary of one facing the Z-boundary of the other.Then they are merged into a single patch with 3 X-boundaries and 3 Z-boundaries, so two logical qubits.Logical operators far away from the interface are left unchanged, and the logical information is untouched.When looking at the subsystem code for this deformation, shown in Figure 10d, one can see that the distance is guaranteed by the offset between the two patches.Then, in this new code, the logical operator X 1 X 2 is given by a string starting from the top boundary of the top patch and ending on the right boundary of the bottom patch.So, by measuring qubits in the X basis in a region away from the third X-boundary, one can learn This measurement procedure is depicted in Figure 11.One can check that the associated subsystem code has a distance of at least half the overlap between the patches, ∼ d /3.The amount of redundancy in the measurement is also ∼ d /3, which makes this procedure costly in qubit overhead but as we show in the next section, it offers a better threshold than the standard lattice surgery technique.

V. NUMERICS
To numerically evaluate the fault-tolerance of quantum computation on rotated planar surface codes, we simulate logical measurement, rotation, logical cnot, and plain surgery, using the Gottesman-Knill formalism [25].These simulations are carried out using two different error models, the phenomenological model and the circuit-based model.The phenomenological error model inserts independent X and Z errors on data qubits with equal probability p, and measurements output the wrong classical value with probability p.The circuit error model inserts errors with probability p after each operation of the error correction circuit as follows: each single-qubit gate is followed by a X, Y , or Z with probability p /3, each two-qubit gate is followed by an element of {I, X, Y, Z} 2 \{II} with probability p /15, and each measurement returns the wrong result with probability p.In this work, except when stated otherwise, the initial logical qubits are prepared without errors when simulating these logical operations.
In section IV A, we have introduced how to construct defects (difference syndromes) for a code deformation step and how to process these defects to infer errors and fix gauge operators (Figure 6).For a realistic implementation of logical operations, a decoder will infer errors in a time window which may include T d or T g , by processing the defects within the window.This means the decoder should be able to match defects across time boundaries, e.g., the defects before and after code deformation time T d .In addition, it needs to construct matching graphs with edges whose endpoints are on different lattices, e.g., defects of S new may be matched to virtual defects beyond the past-time boundary T d .However, such a decoder is difficult to implement.In our simulations, we insert perfect measurement rounds after blocks of d rounds of measurement (Figure 12) for ease of implementation, where d is the distance of the underlying subsystem code.A decoder using the minimum-weight perfect matching (MWPM) algorithm is used and its performance for a fault-tolerant memory operation, that is, d noisy QEC cycles followed by 1 noiseless cycle, is shown in Figure 13.For each operation (except for plain surgery), 10 5 (10 4 ) iterations were run per point and confidence intervals at 99.9% are plotted in the figures.12: The simulated version of a code deformation procedure in Figure 6.A perfect round (a small time window from red to black dashed lines) is inserted after each block of noisy d rounds of stabilizer measurements.One processes the defects for S old and corrects errors before the code deformation step T d .Then the defects for S are constructed at time T d to time T g and the 'defects' for M fix are constructed one round of measurement later.At time T g , one processes error information to infer the value of the gauge operators and then fixes the gauge.
Single-qubit operations: Transversal operations (preparation, Pauli gates, measurement) are usually realised by performing qubit-wise physical operations.They are intrinsically fault-tolerant and their logical error rates will be only slightly higher than a logical identity gate (memory).Notably, a transversal M Z (M X ) measurement does not require quantum error correction cycles (i.e., T d = T g ) since error syndromes of Z(X)-stabilizers can be reconstructed from the measurement outcomes of data qubits, this is also the case for the logical measurement step of plain surgery.For instance, one can measure all the data qubits in the Z basis to realise a M Z on a planar surface code.Afterwards, one can compute the  Z-syndromes by multiplying the outcomes of corresponding data qubits of each Z-stabilizer and then correct the X errors and deduce the value of Z.The performance of a M Z measurement for planar surface codes is shown in Figure 14.In this simulation, we first prepare a logical qubit in state |0 without errors and then perform a M Z measurement on it with physical measurement error probability p.We further numerically simulate the proposed rotating procedure (Figure 1) and show the results in Figure 15.For the phenomenological error model, the error threshold of a rotation is slightly lower than the threshold of quantum memory.For the circuit-level error model, its threshold is similar to that of quantum memory.

Two-qubit operations:
We also simulate the measurement-based cnot circuits in Fig- ure 4a where the split operations of the first joint measurements are parallelised with the merge operations of the second joint measurements (see the decomposed circuits in Appendix C).The overall error rates and the error thresholds for a cnot gate by lattice surgery are shown in Figure 16.For each error model, the error threshold of cnot gates is similar to the threshold of quantum memory.Moreover, logical errors propagate through the measurement-based cnot circuits, leading to a disparity of logical error rates on control and target qubits, which is demonstrated numerically in Appendix C. In addition, we compare the joint M XX measurement using lattice surgery with the measurement using plain surgery.
Figure 17 shows that plain surgery achieves a higher error threshold than lattice surgery, but with higher logical error rates as a consequence of the increased lattice size required to achieve a given code distance.

VI. DISCUSSION & CONCLUSION
We have illustrated how to describe current measurement-based operations in 2D topological quantum computing using the gauge fixing technique.We have shown that, by using the formalism of gauge fixing, the fault tolerance analysis of these code deformation and lattice surgery protocols is considerably simplified, their error correction and gauge fixing schemes also become clear.Furthermore, we numerically examined this method with examples on planar surface codes, including some well-known operations such as lattice-surgery-based cnot gates and some novel protocols such as lattice rotation and plain surgery.Although this gauge fixing formalism does not provide direct guidlines on how to design code deformation protocols for a desired logical operation, it does provide an easy way to check the fault-tolerance of protocols and search for new ones via iterations of trial and error.Moreover, this formalism applies not only to 2D topological codes, but more generally to any stabilizer code.In the general case (non-topological codes), the analysis of fault-tolerance in the presence of measurement errors becomes more involved, in particular with respect to how much repetition is really needed, see for example [29,30].We leave for future work how to obtain general and simple criteria for fault-tolerance.ment, we denote it as Then one fixes the gauge by applying the conjugate X-gauge operators to the Z(p) with m p = −1.Let's call c m L the set of qubits involved in this fixing operation.Note that when m L = +1 then the correction is equivalent to a stabilizer in S split whereas when m L = −1, the correction is equivalent to X 1 .Then, the full merge operation at the physical qubit level is easily written as Due to the definition of X(c m L ), commuting it through the Z projections eliminates the (−1) mp terms.
To determine the logical operation realised by this procedure, we use encoding isometries of C split and C merged , called E split and E merged , respectively.These isometries map unencoded logical states to code states in the full physical Hilbert space.Since C split contains two logical qubits and C merged contains only one, the isometries have the following signatures: Let Mm L be the operation on the logical level, which can be expressed as An important fact about encoding isometries E is that, if S is a stabilizer of the code and L a representative for the logical operator L, then where L is the corresponding physical operator.This means that Mm L , defined in Equation A1, simplifies to To show this, we use the fact that for all p ∈ I, Z(p) is a stabilizer of C merged and the correction X(c + ) is in S split whereas X(c − ) is a representative of X 1 in C split .
To show that the operation Mm L is equal to M m L , as defined in Eq. ( 1) and Eq. ( 2), one can analyse how Mm L acts on the computational basis, i.e. we track how it transforms the stabilizers of those states.For example, the state |00 is stabilized by Z 1 and Z 2 , this means that and therefore M+ |00 is stabilized by Z. Here, we have used the properties of the encoding isometries and the fact that a representative Z 1 for C split is also a representative Z for C merged .Doing the same with the other stabilizer, Z 2 , also yields Z as a stabilizer (so Z 1 Z 2 yields the identity).One can also verify that M+ |00 is not stabilized by −Z by reversing the previous equalities and therefore Z is the full stabilizer group of M+ |00 .Looking now at M− |00 one can see that Z 2 also yields Z but Z 1 will yield −Z, indeed Hence, M− |00 is both stabilized by Z and −Z, and is therefore the null vector.In other words, the state |00 will never give an outcome −1 for m L , which is what we expect.The full results (shown in Table I) indicate that for some non-zero complex numbers α ± and β ± .To complete the proof, we verify that there are no relative phases or amplitude differences between α ± and β ± .To see that, TABLE I: How M± transforms the computational basis states characterised by their stabilizer group.
one can look at the action of Mm L on the Bell states.For M+ we look at the Bell state for some non-zero complex numbers γ ± .By linearity of Mm L we can conclude that α + = β + = γ + and that α − = β − = γ − .In conclusion, we have shown that Mm L ∝ M m L , meaning that it performs the desired logical operation.

Split operation
For the Z-split operation one reverses the roles of C split and C merged .The starting point is the same as shown in Figure 3b, without ± terms in the middle.Then, in order to split the patch, one has to split each four-body X stabilizer in the middle row into a pair of two-body X stabilizers.Those stabilizers are shown with ± signs on Figure 3c.They commute with everything except for the central row of Z-plaquettes.One can see that measuring them will remove those Z-plaquettes from the stabilizer group, but keep the product of all those plaquettes, the logical Z 1 Z 2 of the two separate patches.Note that it is sufficient to measure only the top (or bottom) row of two-body X-checks as the bottom (or top) one is then the product of those and the previous four-body X-checks.This also means that the outcomes with six gauge Z operators fixed (see Figure 18 for the stabilizers and gauge operators that define these codes).The first, from Anderson et al [31], is based on the realisation that the The second scheme, from Colladay and Mueller [32], is not based on gauge fixing, and begins with the eight qubits needed for conversion initialised in the state |0 ⊗8 .This ensures that the initial checks anticommute with any potential X stabilizer supported on the final eight qubits, so that the only operators whose eigenvalues can be reconstructed from the measured operators are Z operators, preventing the correction of Z errors (see Figure 19 for a graphical comparison of these code conversion protocols).The difference in fault tolerance between these two protocols which accomplish the same task provides us with a good motive to incorporate subsystem codes into the analysis of code deformation and lattice surgery, considered in the main text.
Examining the Criterion 1 from section IV A, one can see that the Anderson scheme has to account for propagation of logical errors through measurement-controlled corrections.
In this toy model, identity gates result in an X or Z error with probability p (Y errors are assumed to occur with probability ∼ p 2 , since the minimum-weight Y operator has weight 2d − 1 in the surface code).The merge operations are modeled as ideal joint measurements, followed by an error of the form X ⊗ 1, 1 ⊗ X, Z ⊗ 1, or 1 ⊗ Z, each occurring with probability p, since these are the likeliest logical errors.If a logical Pauli error occurs, it propagates forward through the circuit, changing the measured eigenvalue for any measurement operator with which it anticommutes.For example, if an X ⊗ 1 error occurs after the M XX operation in Figure 4a (in which the ancilla begins in the |0 state), the measured value b will be mapped to 1 − b, causing an X operator to be incorrectly applied to the target qubit at the end of the cnot.It is easy to confirm that there are 7 such first-order errors which result in an X error on the target qubit, 6 errors which result in a Z error on the control qubit, and 3 errors which result in the other logical errors shown in Figures 21a   and 21c (a similar analysis holds for the error rates shown in Figures 21b and 21d).The biased logical error rates predicted by this simplified model are in good agreement with the logical error rates observed in simulation, shown in Figure 21.Preventing this bias from growing during the execution of a long algorithm, by appropriate selection of decomposition for cnots, is likely an important step in the design of high-performance fault-tolerant circuits for quantum computation.

FIG. 1 :
FIG. 1: Fault-tolerant procedure for rotating a surface code by 90 • and reflecting it about the x axis (see [12, Figure 10] for the corresponding protocol using smooth/rough boundaries).(a) Initial layout where the 5 × 5 lattice is to be rotated, the three 3 × 4 patches are ancillas in fixed states, fully specified by the stabilizers shown.(b) Intermediate lattice, this step is required to expand the lattice fault-tolerantly.(c) Fully expanded lattice.(d) and (e) Splitting operations performed to shrink the lattice.(f) By using the two steps from (a) to (c) at the same time on all corners, one can grow a lattice from distance d to 3d − 4. The surrounding ancillary patches have (d − 2) × (d − 1) qubits each.

FIG. 2 :
FIG. 2: A procedure to flip a lattice using code deformation.(a) The lattice to be flipped, and the physical qubits prepared in |+ states.(b) The flip operation is realised by merging the original lattice with the physical qubits below.(c) Subsequently measuring the physical qubits at the top in the X basis finishes the flip operation.

FIG. 3 :
FIG. 3: Lattice surgery for the rotated surface code.Grey plaquettes show Z-stabilizers, black plaquettes represent X-stabilizers.A '±' label indicates a random sign for the corresponding plaquette in the stabilizer group.(a) Initial layout, two rotated surface codes.(b) The merged lattice, which is a surface code with random ± signs on the newly-measured (red) plaquettes.(c) The split lattices, in which the original stabilizers are measured again.Random ± signs are produced on the boundary X-stabilizers.

FIG. 4 :
FIG. 4: (a) Two equivalent measurement-based circuits for the cnot gate.(b) The qubit layout for a cnot gate between two surface-code qubits.C is the control qubit, T is the target qubit, and A is a logical ancilla.

FIG. 5 :
FIG. 5: Venn diagrams depicting the relations between the different sets of Pauli operators concerning the gauge group G of interest, see main text.(a) For one step, the yellow-green set represents the old stabilizer group, S old , and the blue-green set the new group, S new .Both are surrounded by the logical operators, L old and L new respectively.The gauge group generated by both, G = S old , S new , has S as its center, shown by the down-left-dashed region.The gauge group of interest, G, is outlined in purple and has S, in the down-right-dashed region as its center.The set of gauge operators defining the gauge qubits, L g , is the dotted region.When switching from S old to S new one fixes the gauge for the elements in the blue-green dotted region M fix = G \ S old .(b) One possible scenario for two successive steps of deformation.Doing it in two steps, i.e. from S 0 → S 1 , and then from S 1 → S 2 permits to use successively the stabilizer groups S 01 and then S 12 for error correction.Skipping the intermediary steps, one can only use S 02 which might offer less protection.

FIG. 6 :
FIG.6: Schematic drawing of a code deformation procedure with repeated noisy measurements, with time increasing upwards.T d designates the time step at which the code deformation (the switch from measuring the checks of S old to those of S new ) is performed.T g is the time at which one is confident enough about the state of the gauge qubits, taking into account errors, to fix their states.This means that, after T g , another logical computation can be performed.(Right) The first round of measurement of S new at time T d does not have a previous value to compare to in order to construct a difference syndrome, i.e. one can only construct defects for S. Immediately after this step, one can derive the difference syndrome of the full S new , placing defects accordingly.Using defects before and after T d , one processes error information to infer the value of the gauge operators in M fix at time T g , thus fixing the gauge at T g .

. 7 :
FIG. 7: Description of the subsystem code, C, which holds during the first step of the grow operation depicted in Figures 1a and 1b.(a) Generators for the stabilizer group, S, of C. (b) Generators for the whole gauge group G of C. Highlighted in red and blue, respectively, are gauge operators, elements of L g , of Z-type and X-type, respectively.The logical operators, X, Z ∈ L bare , are also represented in brighter colours.

FIG. 9 :
FIG. 9: The operators of the subsystem code, C, for the joint measurement ZZ.(a) The generators of stabilizer group S. (b) The highlighted operators are either gauge operators in L g or logical operators in L bare .We start in the gauge where the products X 1 X 2 and X 2 X 3 are fixed, and end in the gauge where Z 1 , Z 2 , and Z 3 are fixed.The distance of the subsystem code is 5, since one can construct a logical X with this weight by multiplying it with X gauge operators.(c) and (d) Two different scenarios with errors of weight d /2 with the same observed measurements.

FIG. 10 :
FIG. 10: (a) and (b) The qubit layouts before and after the plain merge operation.The number of logical qubits is kept constant during this merge operation.(c) The stabilizers of the subsystem code.(d) The gauge operators and logical operators of the subsystem code.

FIG. 11 :
FIG. 11: (a) The layout where the qubits in the region highlighted are each to be measured in the X basis.(b) The stabilizers of the underlying subsystem code C. (c) The gauge operators (in pink) and logical operators of the code.One can see that the distance is guaranteed by the amount of overlap between the two blocks.The distance of the subsystem code is 4.
FIG.12:The simulated version of a code deformation procedure in Figure6.A perfect

7 FIG. 15 :
FIG. 15: Numerical simulations of the rotation procedure in Figure 1 without a final flip operation.(a) and (b) The logical error rates of the rotation procedure with phenomenological error model (The error threshold is around ∼ 2.5%) and circuit error model (The error threshold is around ∼ 0.45%), respectively.

7 FIG. 16 :
FIG. 16: Numerical simulations of a measurement-based cnot gate by lattice surgery (The top circuit in Figure 4a).(a) Total error rates for cnot gates with the phenomenological error model near the threshold (∼ 2.7%).(b) Total error rates for cnot gates with the circuit-level error model near the threshold (∼ 0.45% ).

5 FIG. 17 :
FIG. 17: Numerical comparison of the M XX joint measurements by lattice surgery (LS) and plain surgery (PS), near the points where the two lowest-distance implementations of the two protocols produce the same logical error rate.The logical error rates of M XX with the (a) phenomenological error model ((b) circuit-level error model) by LS with a crossing between the d = 3 and d = 5 near the physical error probability ∼ 2.2% (∼ 0.25%)) and by PS with a crossing between the d = 4 and d = 6 near the physical error probability ∼ 3.2% (∼ 0.65%).

1 √ 2 (
FIG. 18: stabilizers of the Steane and Reed-Muller codes, and Z gauge operators of the Reed-Muller code.Red tinting on a face or volume indicates the presence of a Z operator on the vertices which make up that face or volume.For example, there are six Reed-Muller gauge operators of the form Z ⊗4 , supported on the red-tinted quadrilaterals seen on the right.Green tinting indicates the presence of both an X and a Z stabilizer operator.

FIG. 20 :
FIG. 20: The decomposed circuits (a) and (b) of the top and bottom measurement-based cnot circuits in Figure 4a.

FIG. 21 :
FIG. 21: X and Z error rates on the control and qubits for lattice-surgery-based cnot operations at distance 5. (a) and (b) correspond to the phenomenological error (c) and (d) correspond to the circuit-based error model.The disparity in error rates is explained by error propagation through the measurement-based circuit implementing the cnot.
do we obtain G from G? This new gauge group, G will be generated by S old and S new in addition to (anti-commuting) conjugate partners of elements in the sets M prep = S old ∩ L new and M meas = S new ∩ L old .More precisely, one views M prep as a subset of L new , and for each independent logical operator contained in M prep adds a chosen conjugated partner within L new .One operates similarly for M meas by viewing it as a subset of L old .If we then consider the center of G, we see that all elements in M prep and M meas are excluded from it since they anti-commute with some elements in G.This means that the center of G is reduced to