A circuit-level protocol and analysis for twist-based lattice surgery

Lattice surgery is a measurement-based technique for performing fault-tolerant quantum computation in two dimensions. When using the surface code, the most general lattice surgery operations require lattice irregularities called twist defects. However, implementing twist-based lattice surgery may require additional resources, such as extra device connectivity, and could lower the threshold and overall performance for the surface code. Here we provide an explicit twist-based lattice surgery protocol and its requisite connectivity layout. We also provide new stabilizer measurement circuits for measuring twist defects which are compatible with our chosen gate scheduling. We undertake the first circuit-level error correction simulations during twist-based lattice surgery using a biased depolarizing noise model. Our results indicate a slight decrease in the threshold for timelike logical failures compared to lattice surgery protocols with no twist defects in the bulk. However, comfortably below threshold (i.e. with CNOT infidelities below $5 \times 10^{-3}$), the performance degradation is mild and in fact preferable over proposed alternative twist-free schemes. Lastly, we provide an efficient scheme for measuring $Y$ operators along boundaries of surface codes which bypasses certain steps that were required in previous schemes.


I. INTRODUCTION
The surface code is a quantum error correcting code with a high threshold and which can be realised with twodimensional hardware [1,2].Other codes have been observed to have comparable thresholds for toy noise models [3][4][5][6][7][8], but when considering realistic circuit-level noise their performance (relative to the surface code) drops appreciably.The surface code's high threshold can be partially attributed to the simplicity of its stabilizers and the circuits used to measure them.Realising the surface code requires measurements of pure X-type and Z-type stabilizers involving no more than four qubits.These measurements can be performed using a depth-four sequence of two-qubit gates; the minimum we can hope for.Furthermore, choosing the right gate schedule can make the stabilizer measurement circuits immune to "hook" errors that effectively reduce the code distance.The moral here is that careful, circuit-level analysis of the microscopic details is crucial for a full understanding of the best route to fault-tolerant quantum computing.
Logical operations in two-dimensional surface code architectures can be performed by code deformation where the code stabilizers change over time, such as through braiding [2,9] or lattice surgery [10][11][12], with the latter being more resource efficient [13,14].The basic primitive in lattice surgery is a logical multi-qubit Pauli measurement, which when combined with logical ancilla states can be used to fault-tolerantly perform logical Clifford operations in addition to logical non-Clifford gates by teleportation.When measuring logical Paulis composed of X and Z operators, the code is deformed with several surface code patches merged into a large patch, though locally the code stabilizers are unchanged.However, more generally, measurements involving Pauli Y operators are needed.Such measurements can be realised with twist-based lattice surgery [11], though this requires some weight-five measurements in addition to long range multiqubit gates.The proposed twist-based approaches were presented abstractly, ignoring circuit-level implementation details and any related performance impacts.
Our work gives the first proposal for a circuit-level implementation of twist-based lattice surgery and numerically benchmarks the performance.In twist-based lattice surgery, we need to measure some longer range stabilizers that we call elongated rectangles and twist defects.To perform these measurements without increasing the circuit-depth (which would significantly degrade performance), we assume the hardware connectivity illustrated in Fig. 1.We say two qubits are connected when a twoqubit gate can be performed between these qubits.Standard surface code implementations have each qubit connected to four other qubits.In this work, we assume a minimal extension where some qubits are connected to eight other qubits.The cat-qubit based architecture of Ref. [15] naturally provides this connectivity, and it could be produced in other architectures, though at the risk of additional cross-talk.Yoder and Kim proposed a twist-based scheme with lower weight measurements [16], but they required a substantial change to the underlying surface code [16] and did not use a homogeneous (translationally invariant) hardware.We leave open the question of whether twist-based lattice surgery can be realised using less connectivity within a homogeneous twodimensional architecture.
To benchmark twist-based lattice surgery, we perform Monte Carlo simulations with a minimum-weight perfect matching (MWPM) decoding protocol (following the method of Ref. [17]) of Y ⊗ Y and Z ⊗ Z measurements.

arXiv:2201.05678v1 [quant-ph] 14 Jan 2022
We perform our simulations for biased noise and rectangular surface codes since this enables us to perform larger simulations and these noise models are of recent interest [15,[18][19][20][21][22].We observe that the measurement of a logical Y ⊗ Y operator has a higher logical failure rate relative to a comparable Z ⊗ Z measurement of the same area.We attribute such differences to the presence of twist defects and elongated checks.The logical failure probability of these measurements is exponentially suppressed in the number of stabilizer measurement rounds used.Therefore, we can ask how many more rounds (and therefore time cost) is needed for a Y ⊗ Y measurement to achieve the same logical fidelity as a Z ⊗ Z measurement.We find, well below threshold (p CNOT ≤ 0.1%), the use of twists incurs only a small multiplicative time cost (less than 1.2× for one of the studied noise models and ancilla qubits (grey) with two example gate schedules.Thick, solid grey lines show the connectivity needed to perform a standard weight-four check as shown here for a blue Z ⊗4 stabilizer.To perform a check along an elongated rectangle (such as the red check shown in the figure) additional connectivity can be used which we illustrate as dashed grey lines.
For the elongated X ⊗4 check, the two grey ancilla qubits are prepared in a GHZ state which is used to perform the desired stabilizer measurement.Examples of gate schedulings and circuits used to measure stabilizers are shown (numbers indicate the time step for each two-qubit gate) and further circuit details are given in Appendix A. The first and last time steps are used for state preparation and measurement and so are both labeled as time step 1.In subsequent figures, we will sometimes just provide numerical labels when the type of gate is clear from the context.
when p CNOT = 10 −3 ) since the twists are a small fraction of all possible fault locations.However, the twist defects are the weakest point and thus fail with a higher probability compared to other fault locations.Consequently, we find these multiplicative time costs increase as we approach the threshold.In previous work [17], we proposed an alternative twistfree lattice surgery scheme that replicated the computational power of Pauli Y measurements without the need for twist defects.However, this alternative strategy came with its own ∼ 2× time cost.Therefore, a key conclusion of this work is that twist-based approaches outperform twist-free alternatives when operating comfortably below threshold, and under our connectivity assumptions along with the biased noise model used for the simulations.Twist-free lattice surgery may still prove useful in connectivity limited hardware or very close to threshold.Hardware afflicted by a different noise model than considered in this work might also benefit from twist-free lattice surgery.

II. LATTICE SURGERY WITH TWIST DEFECTS IN THE BULK
In this section, we describe our protocol for performing twist-based lattice surgery.In Section II A, we provide a gate scheduling that can be used to measure an arbitrary number of Pauli Y operators using twist defects in the bulk.Fault-tolerant circuits for measuring stabilizers at twist defects are provided in Appendix A. In Section II B, we will then compare the performance of a lattice surgery protocol for measuring P = Y ⊗ Y to a P = Z ⊗ Z protocol that does not require twist defects in the bulk.The Pauli Z ⊗ Z is chosen for comparison since the measurement of both Y ⊗ Y and Z ⊗ Z require domain walls between the logical patches and the routing space.In what follows, the surface code encoding a logical qubit will be referred to as a logical patch.The extra space required to perform lattice surgery will be referred to as the routing space.

A. Gate scheduling for twist-based lattice surgery
Recall that in a lattice surgery protocol, mutli-qubit Pauli measurements between logical patches are performed by measuring a set of operators in the routing space between the logical patches.Such measurements (which correspond to gauge fixing [12]) merge the logical patches into one large surface code patch, and a subset of the stabilizers of the merged patch encode the parity of the logical multi-qubit Pauli measurement.A simple example for a Z ⊗ Z and Y ⊗ Y measurement is provided in Fig. 2.
Let P = P 1 ⊗ P 2 ⊗ • • • ⊗ P k be a multi-qubit Pauli operator that is to be measured using a lattice surgery protocol.If P j ∈ {X, Z} for all j ∈ {1, • • • , k}, then As explained in Appendix C, the Y ⊗ Y measurement can be done directly without first extending the logical patches so that logical Y operators can be expressed along their respective horizontal boundaries.When performing the gauge fixing step, weight-five stabilizers illustrated by yellow plaquettes (referred to as twist defects) must be measured, in addition to elongated X and Z-type stabilizers.The measurements of both twist defects and elongated stabilizers require the use two ancilla qubits prepared in a GHZ state with the assumed hardware connectivity constraints described in Section I. Lastly, we remark that in addition to the A and B gate schedules, the Y ⊗ Y also requires the use of the C schedule.
the standard surface code gate scheduling can be used to measure all the stabilizers during the lattice surgery protocol [23].For instance, see the scheduling used for a logical Z ⊗ Z measurement performed by lattice surgery in Fig. 2. With such a scheduling, all two-qubit gates can be applied in four time steps thus minimizing the number of idling qubit locations.One of the important features of the standard surface code gate scheduling circuits is that a weight-two error arising from a single fault will be perpendicular to the relevant logical operator thus preserving the surface code distance (i.e. the code will be guaranteed to correct any error arising from at most (d − 1)/2 faults).By relevant logical operator, we mean that if the weight-two data-qubit error arising from a single fault is of the form E X = X q1 ⊗ X q2 and the minimum-weight representatives of X L form vertical strings, then E X will have support along horizontal strings.Similarly, E Z will have support along vertical strings since the minimumweight representatives of Z L form horizontal strings.Now suppose there exists at least one j ∈ {1, • • • , k} such that P j = Y .In Fig. 2d of Ref [14], Litinski proposed measuring the Y operators as follows.First, logical patches are extended using qubits in the routing space such that the logical Y L operator of the logical patch can be expressed along a horizontal boundary.The logical Y  operator is then given by (1) where d x and d z are the minimum weights of the logical X and Z operators of the logical patch.The Y operator can then be measured via gauge fixing by performing Z and X-type stabilizer measurements between the extended logical patch and qubits in the routing space.The gauge-fixing step requires the measurement of mixed X ⊗ X ⊗ Z ⊗ Z stabilizers which we refer to as domain walls.In addition, it requires the measurement of a weight-five operator operator containing a physical Y term.Such weight-five operators are referred to as twist defects.An important feature of our scheme is that when measuring multi-qubit Pauli's involving Y operators, such measurements can be done directly, without first extending the logical patches.Using an extension step doubles the implementation time and uses additional routing space, thus making our direct approach more efficient.Further, we show in Appendix C that our direct approach for measuring Pauli Y operators is faulttolerant using the gauge fixing formalism of Ref. [12].
The presence of twist defects reduces the set of gate scheduling solutions that can be used for a twist-based lattice surgery protocol with minimal circuit depth.A valid gate scheduling for the measurement of P = Y ⊗ Y via lattice surgery is shown in Fig. 2. The chosen gate scheduling ensures that all two-qubit gates can be applied in four time steps.Three different gate schedules are used, which are labelled A, B and C. The C schedule is only used in the routing space to the right of the twist defects.Note that the A, B and C schedules must follow a set of rules for how they can be tilled on the lattice in order to avoid scheduling conflicts or invalid schedules for performing the stabilizer measurements1 .For instance, a stabilizer measured using an A schedule cannot be adjacent to a stabilizer measured using a C schedule in the horizontal direction.If they were, qubits shared by both stabilizers would interact with two-qubit gates in the same time steps.On the other hand, C and A schedules can be adjacent to each other in the vertical direction (see the legend at the bottom of Fig. 2).
Unlike the standard surface code gate scheduling where all X-type stabilizers use the A schedule and Z-type stabilizers use the B schedule (or vice-versa), the gate scheduling for measuring Y ⊗ Y includes some regions where the A schedule is applied uniformly.Consequently, there will be single failures resulting in weight-two data qubit errors which are parallel to the logical X L or Z L operators of the merged patch.For a given quantum algorithm, the d x and d z distances of logical patches are chosen such that a single logical data qubit error is very unlikely during the course of the entire computation.It is important to note that the merged lattices of a twistbased protocol with distances d x and d z for measuring Y operators will have d x ≥ d x and d z ≥ d z .In other words, the distances of the merged patches will be larger than the distances required for the logical patches prior to the merged.Therefore, even though our gate scheduling has the property that some weight-two errors arising from single failures will be parallel to X L or Z L logical operators, the increased effective distances during lattice surgery protocols will ensure that d x and d z distances of the un-merged logical patches remain unchanged when performing twist-based lattice surgery, which we observe numerically.There are, however, some subtleties when performing twist-based lattice surgery that affect the minimum required value of d x (see Appendix B for details).
We now provide a generalization of the gate scheduling shown in Fig. 2 used for twist-based lattice surgery.In Fig. 3, we illustrate the gate scheduling required to measure the logical Pauli operator The inclusion of a second pair of Y operators has the feature that all stabilizers of the merged patch in the routing space between the four twist defects are measured using the C schedule.As was the case in Fig. 2, the presence of twist defects requires the measurement of Example layout of 16 logical patches with routing overhead used for performing arbitrary multi-qubit Pauli measurements via lattice surgery.In the top figure, we illustrate the logical patches prior to performing the Pauli measurements.We illustrate 4 unit cells, with each unit cell (shown with a dashed line) containing 4 surface code patches and some routing space.Some additional edge padding (shown in green) is also need for routing space.In the bottom figure, we illustrate the merged patch that is obtained after measuring a logical Y ⊗ Y ⊗ X ⊗ Y ⊗ X ⊗ Z Pauli operator.The gate scheduling presented in Fig. 3 can be used for performing the three Y measurements.elongated stabilizers along vertical strips located between the twist defects in the routing space.In order to respect the nearest neighbor connectivity constraints imposed by many quantum hardware architectures, additional ancilla qubits need to be used to measure the elongated stabilizers and weight-five operators.However, an important feature of the circuit in Fig. 3 is that the gate schedul-ing imposes the need for different syndrome measurement circuits for the twist defects on the left strip compared to those on the right strip.More details are provided in Appendix A with the circuits shown in Fig. 7.
We remark that the gate scheduling shown in Fig. 3 can be extended to measure arbitrary multi-qubit Pauli operators such as the one shown in Fig. 4. In particular, Fig. 4 provides the minimal routing space requirements to perform arbitrary multi-qubit Pauli measurements for logical patches placed on a two-dimensional grid with qubits afflicted by a biased noise model.We assess the routing overhead by considering an individual unit cell of 4 logical patches shown in Fig. 4.Each unit cell uses 8d x d z physical qubits (which includes yellow and grey vertices) for the four logical patches and contains a total of 2(3d x + 2)(2d z + d x + 4) physical qubits.The factor 3d x +2 is the height of the unit cell.The factor 2d z +d x +4 is the width of the unit cell.Note with the width factor needs 2(d z + 1) to account for the two patches and d x + 2 for the routing space between patches.It suffices to use a distance proportional to d x (rather than d z ) because when merging our lattice surgery patches, the effective distance is maintained.This leads to a multiplicative routing overhead of where the approximation holds for large asymmetric codes d z d x 4. Eq. ( 2) corresponds to the asymptotic routing overhead since there is extra routing space required shown as green edge padding in Fig. 4.However, the cost of edge padding (as a fraction of total costs) vanishes with the number of logical qubits.The routing overhead can be reduced further if not every logical qubit is ready to participate in lattice surgery (e.g.see the core-cache model of Ref. [17]).

B. Performance comparison between twist-based and twist-free lattice surgery
Suppose we wish to measure a multi-qubit Pauli operator P using lattice surgery.The parity of the multi-qubit Pauli measurement is given by a product of stabilizers in the routing space.For instance, for the P = Y ⊗Y ⊗Y ⊗Y measurement in Fig. 3, the parity of the measurement is given by the product of all X-type stabilizers and twist defects in the routing space, in addition to domain wall stabilizers with the X-component of the operator incident to the routing space.In what follows, we will refer to timelike failures as a collection of failure mechanisms which can result in the wrong parity outcome of a multi-qubit Pauli measurement implemented via lattice surgery.A logical timelike failure occurs when the incorrect parity of a multi-qubit Pauli is obtained after performing error correction over the full syndrome history of a lattice surgery protocol.
Due to timelike failures in addition to spacelike failures resulting in data qubit errors which anticommute with P , the measurement of stabilizers in the routing space needs to be repeated d m times where d m is determined from the noise model and size of the computation.In particular, in a Pauli-based computation requiring the measurement of multi-qubit Pauli operators [17] it was shown that d m can be chosen to satisfy µLa(bp) (dm+1)/2 ≤ δ where we require each multi-qubit Pauli measurement to fail with probability no greater than δ.Here L is the worst case area of the routing space used for lattice surgery, {a, b} are constants and p quantifies the failure probability of all physical operations on the qubits.
The goal of this section is to quantify the relative performance of twist-based lattice surgery to a lattice surgery protocol free of twist defects.Such a comparison will allow us to quantify the extra algorithm runtime costs associated with twist defects.In particular, the weight-five stabilizers and elongated stabilizers have more fault locations compared to the weight-four stabilizers of the surface code and will thus make timelike failures more likely when measuring multi-qubit Pauli operators containing Y terms.In performing the comparison, we use the following biased circuit-level depolarizing noise model 1.Each single-qubit gate location is followed by a Pauli Z error with probability p 3 and Pauli X and Y errors each with probability p 3η .
2. Each two-qubit gate is followed by a {Z ⊗ I, I ⊗ Z, Z ⊗ Z} error with probability p/15 each, and a 3. With probability 2p 3η , the preparation of the |0 state is replaced by |1 = X|0 .Similarly, with probability 2p  3 , the preparation of the |+ state is replaced by |− = Z|+ .

With probability 2p
3η , a single-qubit Z basis measurement outcome is flipped.With probability 2pα 3 , a single-qubit X-basis measurement outcome is flipped.
5. Lastly, each idle gate location is followed by a Pauli Z with probability p 3 , and a {X, Y } error each with probability p 3η .
In performing our simulations, we consider two regimes for X-basis measurement errors.The first is for α = 1 and the second is for α = 10.All simulations are performed using η = 100, so that Z errors are one hundred times more likely than X and Y errors.In what follows, we use a MWPM algorithm [24] on graphs with weighted edges to correct errors arising on the logical patches and in the routing space during a lattice surgery protocol.In particular, we use the decoding algorithm described in Section III of Ref. [17].
For the twist-free simulation of lattice surgery, we consider a P 1 = Z ⊗ Z measurement due to the presence of domain walls at the boundaries of the logical patches and routing space.To gain some intuition on the expected scaling of the timelike logical failure rate (i.e.  6).Our fits closely match the data for physical error rates p 7 × 10 −3 .Larger values of p require the inclusion of higher order contributions to the polynomials in Eqs. ( 3) and ( 4).
failures which result in the wrong interpretation of the parity of the P 1 measurement), suppose that the stabilizers of the merged patch for measuring Z ⊗ Z via lattice surgery are measured d m times.Suppose further that starting in the first syndrome measurement round of the merged patch, a string of (d m + 1)/2 consecutive measurement errors occur on one of the stabilizers in the routing space encoding the parity of the Z ⊗ Z measurement.Since the series of measurement errors begin in the first round, the inferred parity of the P 1 will be incorrect.Further, the minimum-weight path connecting the highlighted vertices 2 will not pass through the parity vertices in the first syndrome round thus resulting in a logical timelike failure (see Ref. [17] for more details).
Additionally, the number of fault locations where timelike failures can occur is proportional to the area of the qubits in the routing space.As such, we propose the following ansatz for the timelike logical failure rate of a Z ⊗ Z measurement: where d z r s is the area of the routing space between the two domain walls (see Fig. 2), and {a 1 , b 1 } are constants.
For the measurement of the operator P 2 = Y ⊗ Y , we expect a similar scaling to the one provided in Eq. (3).However, as can be seen in Figs. 2 and 3, measuring logical Y operators using twist defects results in narrow verti- of the matching graph used to perform MWPM encodes the parity of the measurement outcome of a given stabilizer g j in round k.The vertex v (k) j is highlighted if the measurement outcome of g j changes between consecutive syndrome measurement rounds k − 1 and k.
cal strips of length r s which contain elongated stabilizers.Given the extra fault locations of both twist defects and elongated stabilizers, we consider the following ansatz for timelike logical failures In Eq. ( 4), P ZZ L (p) is given by Eq. (3) with r s dz replaced by the area of the routing space used for the Y ⊗ Y measurement.In other words, the additional "cost" of performing twist-based lattice surgery is an additive error contribution proportional to the height r s containing twist defects and elongated stabilizers.For a multi-qubit Pauli measurement P = P 1 ⊗ P 2 ⊗ • • • ⊗ P k containing t ≤ k Y terms, we expect the timelike failure probability to scale as for some constants {a 2 , b 2 } where P = Z 1 ⊗Z 2 ⊗• • •⊗Z k .In Eq. ( 5), we assume that the merged surface code patch for the P measurement has the same area as the merged surface code patch for the P measurement.
Performing full circuit-level simulations using the biased noise model and decoding algorithm described above, we obtained the following best fit polynomials describing the timelike logical failure rates using the ansatzes of Eqs. ( 3) and ( 4) and The first term in Eqs. ( 6) and ( 7) can be used to extract the best fit polynomials for Z ⊗ Z lattice surgery with a routing space area given by r s (d x + d z ).In Fig. 5, we show how the polynomial in Eq. ( 6) fits the data obtained from our Monte Carlo simulations for various values of d z , d m and r s (with fixed d x = 7).Now suppose that we wish to implement a quantum algorithm so that all lattice surgery operations fail with probability no more than δ.Hence we must have that P (P ) L ≤ δ which will fix the required value of d m for each multi-qubit Pauli measurement.Using the results of Eqs. ( 6) and (7), in Fig. 6, we plot the ratios d  First, the ratio d m (Z) is highly insensitive to the chosen values of d x , r s and d z .As such, the plots in Fig. 6 were obtained by fixing d z = 31 and d x = r s = 7.We chose the value d x = 7 since for the biased noise model considered here, it was shown in Ref. [17] that d x = 7 was sufficient to implement the Hubbard model [25,26] for lattice sizes L ≤ 32.
Second, comparing the results in Fig. 6a to those in Fig. 6b, it can be seen that higher measurement failure rates increase the runtime for performing lattice surgery with twist defects.Further, for physical noise rates p ≈ 10 −3 , the ratio d m (Z) increases fairly quickly as p approaches the 10 −2 regime which is near the threshold for logical timelike failures.
It can be seen in Fig. 6b that the ratio d     m (Z) decrease.Lastly, we remark that for multi-qubit Pauli measurements requiring more than two Y terms, the ratios m (Z) obtained in Fig. 6 would only increase in a meaningful way for very large values of t when using the result of Eq. ( 5) due to the exponential scaling of the second term.As such, for the noise rates considered in Fig. 6, there could be rare cases where a multi-qubit Pauli measurement containing a very large number of Y terms would benefit from a twist-free approach such as the one considered in [17].

III. CONCLUSION
In Ref. [17], the twist-free scheme for measuring multiqubit Pauli operators containing Y terms results in an approximately 2× slowdown in algorithm runtime due to the need to sequentially measure multi-qubit Pauli operators containing pure X terms, followed by a multi-qubit Pauli measurement containing pure Z terms.Our results thus suggest that, assuming a hardware architecture satisfying the connectivity constraints described in Fig. 1, twist-based lattice surgery will outperform the twist-free version for physical noise rates p 5 • 10 −3 .However, for noise rates close to the threshold value ∼ 10 −2 , we expect twist-free based lattice surgery to achieve lower algorithm runtime relative to lattice surgery protocols using twist defects to measure Y operators.An open question is whether high threshold surface code implementations are possible using homogeneous architectures and less connectivity as was assumed in Fig. 1.
The above conclusions also depend on the noise model.For instance, comparing Figs.6a and 6b, it is clear that higher measurement failure rates results in longer Y ⊗ Y measurements compared to Z ⊗ Z measurements with an identical area.As such, for noise models where measurement and two-qubit gate failures are very high relative < l a t e x i t s h a 1 _ b a s e 6 4 = " 3 K u u G d s u 9 u P 4 Z l S a r 9 c T |+i < l a t e x i t s h a 1 _ b a s e 6 4 = " J 8 S h 0 z G j m m + y z z B J W K p c S U l S y I s = " > A A A B 6 n i c b V B N S w M x E J 3 U r 1 q / q h 6 9 B I v g q e x K U Y 8 FIG. 7. (a) Circuit used to measure the weight-five stabilizers of the twist defects located on the left vertical strip of Fig. 3. GHZ state is prepared, and the parity of the stabilizer measurement outcome is given by the product of the two X-basis measurement outcomes.(b) Second type of circuit used to measure the weight-five stabilizers of the twist defects located on the right vertical strip in Fig. 3.In this case, the X-basis measurement outcome gives the parity of the stabilizer measurement.A correction P m 1 1 (or equivalently P m 1 2 ) is applied based on the m1 Z-basis measurement outcome.For both circuits, P1P2 is the stabilizer being measured.
to other failure mechanisms, runtimes of twist-free lattice surgery protocols could potentially be smaller compared twist-based lattice surgery protocols.

Appendix A: Stabilizer measurement circuits for twist defects in the bulk
In this appendix, we describe the two types of circuits used to measure elongated checks and the weight-five stabilizers corresponding to twist defects on both the left and right vertical strips in the routing space of Fig. 3.We presented one such example in Fig. 1 and here give a more general procedure.Such circuits are shown in Figs.7a and 7b, where |ψ is the encoded state protecting the data during lattice surgery.P 1 and P 2 are Pauli operators with P 1 P 2 corresponding to the stabilizer being measured.
Without loss of generality, assume the data qubits is in an eigenstate of P 1 P 2 so that P 1 P 2 |ψ = ±|ψ .For the circuit in Fig. 7a, it is straightforward to show that the state prior to the measurements is given by |ψ f = (|0, 0 ± |1, 1 )/ √ 2|ψ .The ancilla state (|0, 0 ± |1, 1 )/ √ 2 is a eigenstate of X ⊗ X with eigenvalue ±1.As such, the product of the two X-basis measurement outcomes of the ancilla qubits gives the stabilizer measurement outcome.
For the circuit in Fig. 7b, the state prior to the mea-surement is given by which we can express as Therefore, measuring the second ancilla qubit in the X basis will reveal the desired ±1 eigenvalue.However, we also have a P 1 Pauli correction required depending on the value of the first ancilla qubit measured the Z basis.Lastly, we point out that using flag based methods [7,[27][28][29][30][31][32][33][34][35][36][37][38][39] to measure the elongated checks and weightfive twist defects would require an extra two-qubit gate between the ancillas instead of a single CNOT.As such, an extra idling time would be required resulting in slower algorithm runtimes.In this appendix, we show that twist-based lattice surgery protocols require extra padding to correct arbitrary X errors arising from (d x − 1)/2 failures.
An example of a weight-one X error being indistinguishable from a weight-two X error (both arising from a single failure with probabilities proportional to p) for a lattice surgery protocol measuring Y ⊗ Y is shown in Fig. 8.The lattices in Fig. 8 to the standard representatives for Y L1 and Y L2 ).
The merged state of Fig. 9(b) illustrates the stabilizers S new during the merge step (having skipped any extension step).Multiplying the stabilizers with white vertices gives our representative for Y L1 ⊗Y L2 from the initial configuration and therefore these lattice surgery operations do measure the desired logical operator.If we had not included the single-qubit Z operators in S old , we would not have measured Y L1 ⊗ Y L2 , so this is the key formal trick to prove fault-tolerance.
Lastly, Ref. [12] prescribes that we consider the sub-system code with stabilizer S = S old ∩ S new and gauge group G = S old , S new .The protocol is then (phenomenologically) fault-tolerant provided that this subsystem code retains the distance of the initial code.We illustrate the local generators for S in Fig. 9(c).The logical operators for the sub-system code must commute with the stabilizer group and not be contained in the gauge group.Examining Fig. 9(c) one finds that the code distance is indeed maintained at d z for pure Z errors and at least d x for all other types of errors.

FIG. 1 .
FIG. 1. Connectivity diagram between data qubits (yellow)and ancilla qubits (grey) with two example gate schedules.Thick, solid grey lines show the connectivity needed to perform a standard weight-four check as shown here for a blue Z ⊗4 stabilizer.To perform a check along an elongated rectangle (such as the red check shown in the figure) additional connectivity can be used which we illustrate as dashed grey lines.For the elongated X ⊗4 check, the two grey ancilla qubits are prepared in a GHZ state which is used to perform the desired stabilizer measurement.Examples of gate schedulings and circuits used to measure stabilizers are shown (numbers indicate the time step for each two-qubit gate) and further circuit details are given in Appendix A. The first and last time steps are used for state preparation and measurement and so are both labeled as time step 1.In subsequent figures, we will sometimes just provide numerical labels when the type of gate is clear from the context.

FIG. 2 .
FIG.2.Illustration of a Z ⊗ Z and Y ⊗ Y measurement performed by lattice surgery.The left most figure shows two dx = 3 and dz = 9 logical patches prior to the measurements.The qubits (yellow and grey vertices) in between the two patches are part of the routing space.The middle figure shows the measurement of Z ⊗ Z by gauge fixing, i.e. measuring the appropriate stabilizers in the routing space such that a Z ⊗ Z measurement is performed along the logical Z boundaries of the surface code patches.Red plaquettes correspond to X-type stabilizers, blue plaquettes to Z-type stabilizers.Gradient colour plaquettes correspond to domain walls that measure mixed X and Z-type stabilizers.The labels A, B and C describe particular gate schedulings.Stabilizers with white vertices encode the parity of the logical Z ⊗ Z measurement.The rightmost figure illustrates a logical Y ⊗ Y measurement implemented by lattice surgery.As explained in Appendix C, the Y ⊗ Y measurement can be done directly without first extending the logical patches so that logical Y operators can be expressed along their respective horizontal boundaries.When performing the gauge fixing step, weight-five stabilizers illustrated by yellow plaquettes (referred to as twist defects) must be measured, in addition to elongated X and Z-type stabilizers.The measurements of both twist defects and elongated stabilizers require the use two ancilla qubits prepared in a GHZ state with the assumed hardware connectivity constraints described in Section I. Lastly, we remark that in addition to the A and B gate schedules, the Y ⊗ Y also requires the use of the C schedule.

2 FIG. 3 .
FIG. 3. Lattice and valid gate scheduling for measuring the multi-qubit Pauli operator P = Y ⊗ Y ⊗ Y ⊗ Y via lattice surgery.The A, B and C gate schedules are described in Fig. 2. The chosen gate scheduling imposes the need for different ancilla states used to measure twist defects on the left strip compared to twist defects on the right strip.More details are provided in Appendix A.

3 p = 2 . 5 * 10 - 3 p = 5
FIG. 6.(a) Ratio of d (α) m (Y )/d (α) m (Z) for α = 10 and various values of the target logical error rate δ such that both P (Y Y ) L;α (p) ≤ δ and P (ZZ) L;α (p) ≤ δ.The area of the routing space of the Z ⊗ Z measurement is taken to be identical to that of the Y ⊗ Y measurement.(b) Same as (a) but with α = 1.All values were obtained by fixing rs = dx = 7 and dz = 31.For large dz, the results have very little senstivity to the chosen values of dx, dz and rs.

( 1 )
m (Z) + 1 to achieve the desired target logical failure rates.As such, the fraction d (1) m (Y )/d (1) m (Z) is larger when the absolute values of d (1) m (Y ) and d (1) 7 L 3 k W 5 c l s p V e + y O P J w B M d w C h 5 c Q h V u o A Z 1 Y B D B M 7 z C m 6 O c F + f d + Z i 3 5 p x s 5 h D + w P n 8 A b V 9 k G o = < / l a t e x i t > t e x i s h a 1 _ b a s e 6 4 = " 3 K u u G d s u 9 u P 4 Z l S a r 9 c T c i C d R k M = " > A A A B 6 n 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 k q M e C F 4 + V 2 g 9 o Q 9 l s N + 3 S z S b s T o Q S + h O 8 e F D E q 7 / I m / / G b Z u D t j 4 Y e L w 3 w 8 y 8 I J H C o O t + O 4 W N z a 3 t n e J u a W / / 4 P

1 < 2 <
b L g p T S T A m 8 7 / J U G j O U E 4 t o U w L e y t h Y 6 o p Q 5 t O y Y b g r b 6 8 T t p X V e + 6 W n u o V e r N P I 4 i n M E 5 X I I H N 1 C H e 2 h A C x i M 4 B l e 4 c 2 R z o v z 7 n w s W w t O P n M K f + B 8 / g D W v I 2 S < / l a t e x i t > P l a t e x i t s h a 1 _ b a s e 6 4 = " Y f C d Z s E g J 5 2 t d V P l s 5 R J 9 5 1 D AP w = " > A A A B 6 n 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 l K U Y 8 F L x 4 r t b X Q h r L Z b t q l m 0 3 Y n Q g l 9 C d 4 8 a C I V 3 + R N / + N 2 z Y H b X 0 w 8 H h v h p l 5 Q S K F Q d f 9 d g o b m 1 v b O 8 X d 0 t 7 + w e F R + f i k Y + J U M 9 5 m s Y x 1 N 6 C G S 6 F 4 G w V K 3 k 0 0 p 1 E g + W M w u Z 3 7 j 0 9 c G x G r B 5 w m 3 I / o S I l Q M I p W a j U H t U G 5 4 l b d B c g 6 8 X J S g R z N Q f m r P 4 x Z G n G F T F J j e p 6 b o J 9 R j Y J J P i v 1 U 8 M T y i Z 0 x H u W K h p x 4 2 e L U 2 f k w i p D E s b a l k K y U H 9 P Z D Q y Z h o F t j O i O D a r 3 l z 8 z + u l G N 7 4 m V B J i l y x 5 a I w l Q R j M v + b D I X m D O X U E s q 0 s L c S N q a a M r T p l G w I 3 u r L 6 6 R T q 3 p X 1 f p 9 v d J o 5 X E U 4 Q z O 4 R I 8 u I Y G 3 E E T2 s B g B M / w C m + O d F 6 c d + d j 2 V p w 8 p l T + A P n 8 w f Y Q I 2 T < / l a t e x i t > P l a t e x i t s h a 1 _ b a s e 6 4 = " l h d 9 S P U l k E H 8 t d 1 k l k V / N F V d 3 8 w = " > A A A B 8 H i c b V D L S g N B E O y N r x h f U Y 9 e B o M g C G F X g n o M e P E Y 0 T w k W c L s p D c Z M j u 7 z M w 8 1 j e m 1 G C f k T 7 k o e c U W O l h 6 e z j q K y L 7 B b L L l l d w a y T L yM l C B D r V v 8 6 v R i l k Y o D R N U 6 7 b n J s Y f U 2 U 4 E z g p d F K N C W V D 2 s e 2 p Z J G q P 3 x 7 O A J O b F K j 4 S x s i U N m a m / J 8 Y 0 0 n o U B b Y z o m a g F 7 2 p + J / X T k 1 4 5 Y + 5 T F K D k s 0 X h a k g J i b T 7 0 m P K 2 R G j C y h T H F 7 K 2 E D q i g z N q O C D c F b f H m Z N M 7 L 3 k W 5 c l s p V e + y O P J w B M d w C h 5 c Q h V u o A Z 1 Y B D B M7 z C m 6 O c F + f d + Z i 3 5 p x s 5 h D + w P n 8 A b V 9 k G o = < / l a t e x i t > |+i " < l a t e x i t s h a 1 _ b a s e 6 4 = " l h d 9 S P U l k E H 8 t d 1 k l Appendix B: Minimum distance requirement of twist-based lattice surgery

FIG. 9 .
FIG.9.Illustration showing an efficient protocol for measuring Y ⊗ Y fault-tolerantly.In (a), we illustrate the stabilizers for the initial configuration of the logical patches including single qubit Z for |0 states.In (b), we show the stabilizers of the merged patched obtained via lattice surgery.In (c), we show the stabilizers of the sub-system code that (a) and (b) can be regarded as a gauge fixing of.
Plot of the timelike logical failure rates of a Y ⊗ Y measurement implemented by lattice surgery with twist defects for various values of dz, dm and rs with α = 10.The results are obtained by preforming 10 7 Monte Carlo simulations using the noise model described in Section II B. The solid lines correspond to the best fit polynomial of Eq. (