Article | Open

# Fault-tolerant interface between quantum memories and quantum processors

• Nature Communications 8, Article number: 1321 (2017)
• doi:10.1038/s41467-017-01418-2
Accepted:
Published online:

## Abstract

Topological error correction codes are promising candidates to protect quantum computations from the deteriorating effects of noise. While some codes provide high noise thresholds suitable for robust quantum memories, others allow straightforward gate implementation needed for data processing. To exploit the particular advantages of different topological codes for fault-tolerant quantum computation, it is necessary to be able to switch between them. Here we propose a practical solution, subsystem lattice surgery, which requires only two-body nearest-neighbor interactions in a fixed layout in addition to the indispensable error correction. This method can be used for the fault-tolerant transfer of quantum information between arbitrary topological subsystem codes in two dimensions and beyond. In particular, it can be employed to create a simple interface, a quantum bus, between noise resilient surface code memories and flexible color code processors.

## Introduction

Noise and decoherence can be considered as the major obstacles for large-scale quantum information processing. These problems can be overcome by fault-tolerant quantum computation1,2, which holds the promise of protecting a quantum computer from decoherence for arbitrarily long times, provided the noise is below a certain threshold. Quantum error correction codes are indispensable for any fault-tolerant quantum computation scheme3. Among these, stabilizer codes4, building on classical coding theory, admit a particularly compact description. In particular, the subclass of topological stabilizer codes (TSCs)5 is promising since TSCs are scalable and permit a local description on regular D-dimensional lattices.

Two of the most prominent examples of TSCs in two dimensions are surface codes6,7 and color codes8. While surface codes support adaption to biased noise9 and have better error thresholds than comparable color codes10, they do not support a transversal phase gate. However, transversality is essential for any encoded quantum logic gate since it guarantees a straightforward implementation within a quantum error correction code. Gauge color codes, for example, were recently shown to support the transversal implementation of a universal set of gates in a three-dimensional (3D) layout11. It is hence desirable to store quantum information in surface code quantum memories while performing computation on color codes in two (and three) dimensions12.

Here we present a protocol that makes such hybrid computational architectures viable. We develop a simple, fault-tolerant conversion scheme between two-dimensional (2D) surface and color codes of arbitrary size. Our flexible algorithm for code switching is based on a formalization of lattice surgery13,14 in terms of operator quantum error correction15 and measurement-based quantum computation16. This introduces the notion of subsystem lattice surgery (SLS), a procedure that can be understood as initializing and gauge fixing a single subsystem code. The required operations act locally on the boundaries, preserve the 2D structure, and are generators of a topological code. As all generators of the resulting code have constant size, errors on any of their components only affect a constant number of qubits, making the protocol inherently fault-tolerant. As we explicitly show, this generalizes the methodology of lattice surgery to any combination of 2D topological subsystem stabilizer codes, with color-to-surface code switching as an example of particular interest. While we restrict ourselves to 2D topological codes for the better part of this paper, we show that the essential ingredients of SLS carry over to higher-dimensional codes. In fact, the procedure works even for non-topological codes at the expense of locality. Therefore, our results represent a significant step toward a fault-tolerant interface between robust quantum memories and versatile quantum processors, independently of which topological codes will ultimately prove to be most effective. The method proposed here hence has the prospect of connecting different components of a future quantum computer in an elegant, practical, and simple fashion.

## Results

### Stabilizer formalism

We consider a system comprised of n qubits with Hilbert space $H= C 2 ⊗ n$. The group of Pauli operators $P n$ on $H$ is generated under multiplication by n independent Pauli operators and the imaginary unit i. We write $P n = i , X 1 , Z 1 , . . . , X n , Z n ,$ where X j , Z j are single-qubit Pauli operators acting on qubit j. An element $P∈ P n$ has weight w(P) if it acts nontrivially on w qubits. We define the stabilizer group $S= S 1 , . . . , S s$ for s ≤ n as an Abelian subgroup of $P n$ such that the generators S i are independent operators i = 1, ..., s and $-1∉S$. $S$ defines a 2k-dimensional codespace $C=span ψ$ of codewords $ψ ∈H$ through the condition $S ψ = ψ ∀S∈S$, encoding k = n − s qubits. We denote the normalizer of $S$ by $N ( S )$, which here is the subgroup of $P n$ that commutes with all elements of $S$. That is, elements of $N ( S )$ map the codespace to itself. We write $L=N ( S ) ∕S$ for the (quotient) group of logical operators which induces a tensor product structure on $C$, i.e., $C= ⊗ i = 1 k H i$. This construction implies that different logical Pauli operators are distinct, non-trivial classes of operators with an equivalence relation given by multiplication of stabilizers.

The distance of an error correction code is the smallest weight of an error $E∈ P n$ such that E is undetectable. The code can correct any set of errors $E= E a a$ iff $E a E b ∉N ( S ) - i S$$∀ E a , E b ∈E$. A stabilizer code defined through $S$ has distance d iff $N ( S ) - i S$ contains no elements of weight less than d. Equivalently, any non-trivial element of $L$ is supported on at least d qubits. By the above error-correction condition, an error with weight at most (d−1)/2 can be corrected while an error E with weight d/2 ≤ w(E) < d can only be detected. From a slightly different perspective, codewords are degenerate ground states of the Hamiltonian $H=- ∑ i = 1 s S i$. Adopting this viewpoint, correctable errors are local excitations in the eigenspace of H since they anticommute with at least one generator $S i ∈S$, while logical operators map the degenerate ground space of H to itself.

### Subsystem stabilizer formalism

A subsystem structure can be induced on stabilizer codes by considering non-Abelian gauge symmetries15. The group of gauge transformations is defined as $G= L G ×S× i$ where $S$ is a stabilizer group and $L G$ is the group of operators in $N ( S ) - i S$ that are not in a non-trivial class of $L=N ( S ) ∕G$. This imposes a subsystem structure on the codespace $C= H L ⊗ H G$ where all operators in $G$ act trivially on the logical subspace $H L$17. While logical operators in $L$ define logical qubits in $H L$, operators in $L G$ define so-called gauge qubits in $H G$. That is, operations in $L$ and $L G$ both come in pairs of (encoded) Pauli X and Z operators for each logical and gauge qubit, respectively. We recover the stabilizer formalism if $G$ is Abelian, i.e., $L G =∅$. As before, a set of errors $E= E a a$ is correctable iff $E a E b ∉N ( S ) -G$$∀ E a , E b ∈E$. Errors can again be considered as local excitations in the eigenspace of a Hamiltonian $H=- ∑ i = 1 g G i ,$ where g is the number of generators $G i ∈G$.

### Topological stabilizer codes

Stabilizer codes $S$ are called topological if generators $S i ∈S$ have local support on a D-dimensional lattice. Here we focus on 2D rectangular lattices Λ = [1, L] × [$1$, L′] with linear dimensions L and L′ in the horizontal and vertical direction, respectively, where qubits are located on vertices (not necessarily all are occupied) but our discussion can be easily extended to arbitrary regular lattices. We call a generator $S i ∈S$ local5 if it has support within a square containing at most r2 vertices for some constant r, called interaction range or diameter. Moreover, we require of a TSC that its distance d can be made arbitrarily large by increasing the lattice size. In other words, the generators S i are not only local but also translationally invariant at a suitable scale18. This definition of TSCs can be extended straightforwardly to topological subsystem stabilizer codes (TSSCs)19 where we impose locality on the generators of $G$ instead of $S$. Then, generators of $S$ are not necessarily local.

### Logical string operators

An intriguing feature of 2D topological codes is that logical operators can be interpreted as moving point-like excitations around the lattice, i.e. logical operators form strings across the lattice. Specifically, for any 2D TSC or TSSC on a lattice with open boundaries there exists a quasi-1D string of tensor products of Pauli operators generating a logical Pauli operator whose support can be covered by a rectangle of size r × L5, i.e., a vertical strip of width at most r. If $S$ obeys the locality condition, logical operators can be implemented row-by-row by applying Pauli operations along paths connecting two boundaries such that excitations emerge only at its endpoints. If $S$ is not local, excitations might also emerge elsewhere since logical operators can anticommute with generators that act nontrivially on gauge qubits. Due to the translational invariance of generators with respect to the underlying lattice, one can always increase the code distance or choose the lattice such that there exists a logical Pauli operator whose support is covered by a vertical strip of maximal width r along the boundary (or at most a constant number of lattice sites away from it).

Since it is a general feature of topological codes to support logical string operators5, we can generalize the method of lattice surgery13,14 to such codes. To this end, we consider any two TSCs or TSSCs $G A$ and $G B$ on two 2D lattices, e.g., ΛA = [1, LA]2 and ΛB = [1, LB]2, with open boundaries that have distances dA and dB, respectively. We place the lattices such that their vertical boundaries are aligned. Let $P L A ∈ L A$ and $P L B ∈ L B$ be two logical operators defined along the aligned boundaries with maximal width rA and rB, respectively, where r I is the interaction range of code I = A, B. The logical operators act nontrivially on a set of qubits, say QA and QB, respectively. Let N I  = $Q I$ (for I = A, B) and N = max{NA, NB}. W.l.o.g. we assume NA = N. We order the sets Q I according to walks along paths5 on Λ I running, e.g., from top to bottom such that we can implement $P L I$ in a step-by-step fashion as described above. We write Q I  = {1, 2, ..., N I } for such an ordering. For ease of notation, we denote qubits in the support of $P L I$ by i = 1, ..., N I since the association of qubits to the sets Q I is clear from the context. Consequently, the logical operators take the form

$P L I = P L , 1 I ⊗ P L , 2 I ⊗...⊗ P L , N I I ,$
(1)

for single-qubit Pauli operators $P L , i I$ acting on qubits i with i = 1, ..., N I .

### Merging protocol and code splitting

Given the two codes $G A$ and $G B$ with respective logical Pauli operators $P L A$ and $P L B$ along boundaries, the goal is to achieve a mapping $G A × G B ↦ G A × G B × P L A ⊗ P L B$ that projects onto an eigenstate of $P L A ⊗ P L B$ (i.e., a Bell state). Therefore, we now define a fault-tolerant protocol that merges the two codes into one, similar to the method of lattice surgery, which has been developed for surface codes13 and extended to color codes14. As we will see, the merged code can then be split to realize the mapping described above. The merging procedure has the following four steps.

(i) Including ancillas. We introduce a set QC of N − 1 ancillas initialized in the +1 eigenstates of their respective Pauli X operators. The ancillas are placed on newly added vertices along a column between boundaries (Fig. 1a) and we order the set QC accordingly from top to bottom, i.e., QC = {1, 2, ..., N − 1}. More formally, including ancillas in $+$-states is equivalent to adding N − 1 single-qubit X stabilizers to $G A × G B$. Note that this step is not strictly necessary but it has been included here to highlight the similarity to lattice surgery. Nonetheless, this step is useful if one operates solely on TSCs (rather than TSSCs), since this can allow reducing the interaction range of the resulting merged code (see Methods section for details).

(ii) Preparing lattices. Redundant vertices are added to the lattices ΛA and ΛB without adding corresponding new qubits. This corresponds to a relabeling that increases the interaction range on both lattices and the distance between ancillas by at most a constant r2, where r = max{rA, rB}. This is done in such a way that horizontal strips of width (height) r contain the same number of qubits in QA, QB, and QC (Fig. 1b). Beyond the strip containing the last element of QB we only require the same number of qubits in QA and QC, except for the last strip, where QC contains one qubit less than QA. The lattices are then connected along their vertical boundary such that the resulting merged lattice ΛM has linear dimension LA + LB + 1 along the horizontal direction. This step guarantees that the merged code remains topological according to the definition above. If a different definition of locality is adopted for topological codes, step (ii) can be replaced by a stretching of the lattices to ensure that the merged code is topological in the same sense as well.

(iii) Merging codes. After combining the underlying lattices, the codes are merged. To this end, one measures N merging operators, which are defined on the new lattice ΛM as

$G i M = P L , i A P L , i B Z i C Z i - 1 C ∀i=1,...,N,$
(2)

where $Z i C$ acts on ancilla i with Z0 ≡ $1$ and Z N  ≡ $1$. Since NA ≥ NB, we identify $P L , i B ≡1$ for i > NB.

(iv) Correcting errors. In order to retain full fault tolerance, dmin = min{dA, dB} rounds of error correction are required on the merged code. For this purpose, the structure of the merged code can be deduced from the SLS formalism that is introduced and analyzed in Methods section.

We now formulate the following theorem.

Theorem 1. For any two TSCs (or TSSCs) defined on regular 2D lattices with open boundaries, the procedure described in steps (i)–(iv) fault-tolerantly projects onto an eigenstate of $P L A P L B$. Moreover, all operations in steps (iii) and (iv) correspond to generators of a TSSC defined on the merged lattice with potentially increased interaction range and distance no less than the minimum distance of the merged codes.

For the proof of Theorem 1, we refer to Methods section, where the required SLS formalism is described in full detail. In this approach, the merged code is effectively treated as a subsystem code and the original codes $G A$ and $G B$ are recovered by gauge fixing. Note that in the merged code, some stabilizers at the boundary are merged while others can generate new gauge qubits. More details on the merged code structure in the most general case and in the case of a specific TSSC can be found in the Methods section. After the merging procedure described in steps (i)–(iv), the two individual codes can be recovered by measuring all ancillas in the X-basis. In this case the merged code is split and the two logical subspaces are left in a joint eigenstate of their respective Pauli operators. Here it is important to note that error correction has to be performed on the separate codes in order to retain full fault tolerance13. Quantum information can then be teleported from one logical subspace to the other by measurement. This fault-tolerant way of transferring quantum states from one arbitrary TSC (or TSSC) to another provides a simple method that allows exploiting the advantages of different error correction codes. In particular, it can be used to realize an interface between a quantum memory (e.g., based on a surface code) and a quantum processor (using, for example, a color code). We will therefore now demonstrate our protocol for this crucial example of two TSCs.

### Color-to-surface code switching

The archetypical examples for TSCs are surface codes (SC) and color codes (CC). Surface codes6 are defined on 2-face-colorable regular lattices with qubits located on vertices. The two colors are identified with X- or Z-type generators $S p X , S p Z ∈ S SC$, respectively, acting as $S p P = ∏ v ∈ N ( p ) P v$, where $N ( p )$ is the set of vertices adjacent to the plaquette p and P = X, Z (Fig. 2a). Horizontal and vertical boundaries cut through plaquettes and can be associated with their respective colors. The lattice is constructed such that opposite boundaries are identified with the same color. The number of logical qubits can be obtained by a simple counting argument. It is given by the difference between the number of physical qubits and the number of independent stabilizers. For the SC, the former is equal to the number of vertices v, while the latter equals the number of faces f. Since v − f = 1, we find that the SC encodes a single logical qubit. Logical operators for SCs are strings connecting boundaries of the same color that are separated by a boundary of a different color. Note that, for any choice of SC, one such logical operator is guaranteed to be aligned with the chosen (e.g., the vertical) boundary5, but one may not be able to freely choose whether this logical operator is of Z- or X-type. 2D color codes8 are defined on 3-face-colorable regular lattices with qubits located on vertices. The generators of the corresponding stabilizer group $S CC$ are pairs of operators $S p X$ and $S p Z$, i.e., two independent stabilizers per plaquette. The lattice is constructed such that we can use three colors to distinguish three types of boundaries and plaquettes. That is, any two adjacent plaquettes have different colors from each other and from their adjacent boundary (Fig. 2). In the CC, the number of physical qubits is equal to the number of vertices, but there are two independent stabilizers for each face. A quick count then reveals that the CC encodes one (v − 2f = 1) logical qubit. Logical operators for CCs are string operators along the lattice connecting three boundaries of different colors. This implies that there exists a string along the boundary of one type that effectively connects all three boundaries.

As an example for the application of our protocol let us consider the situation shown in Fig. 2a, where the outcome of a quantum computation, encoded in an arbitrary logical state $ψ L =α 0 +β 1$ of a color code, is transferred to a quantum memory based on a surface code initialized in the state $+ L$. A circuit representation of this task is shown in Fig. 3. Since both initial codes in Fig. 2a have distance 3, we include two ancillas in the state $+$, as instructed in step (i). Step (ii) of the protocol can be omitted since the lattices in this example already have the desired structure. As laid out in step (iii) and illustrated in Fig. 2b, one then measures joint Z stabilizers across the boundary, projecting the two surfaces onto a single, merged surface (M) corresponding to an eigenstate of $Z L SC Z L CC$. That is, the merging procedure projects onto a merged code that contains $Z L SC Z L CC$ as a stabilizer. The reduced 2D logical subspace can be represented by $Z L M = Z L CC$ and a merged XL operator along both surfaces, e.g., $X L M = X SC ⊗ X CC$. Since both color and surface codes are TSCs, the merged code can be understood as a TSC (as opposed to a TSSC) and merging operators coincide with merging stabilizers. Then, as instructed in Fig. 2b, X-type stabilizers have to be extended onto ancillas while Z stabilizers remain unaffected. For details on the distinction between TSSCs and TSCs, we refer to the SLS formalism introduced in the Methods. Having obtained this merged code of distance 3, three consecutive rounds of error correction ensure fault tolerance as suggested in step (iv). Note that the merging procedure increases the bias toward X-type errors since the minimum weight of logical X operators is increased. However, note that increasing the weight (and interaction range) of X stabilizers on the boundary can cause a temporarily worse error correction performance w.r.t. Z errors for the merged code than for the individual codes.

Irrespective of this we can then proceed by splitting the codes. To this end, we simply measure ancillas in the X-basis, while refraining from further measurement of the merging stabilizers. This procedure projects onto the separate surfaces while entangling the logical subspaces. After another three rounds of error correction to preserve fault tolerance, measuring $X L CC$ teleports the information according to the circuit displayed in Fig. 3.

## Discussion

We have introduced the method of subsystem lattice surgery (SLS) as a generalization of lattice surgery13,14 to any pair of 2D topological codes, exploiting their similarities20. The applicability of our algorithm to all topological codes such that all topological features are preserved arises from their property to support logical string operators on the boundary5. Therefore, the relevance of our algorithm remains unchanged even if other topological codes, such as the subsystem surface code21 (see also the Methods section) or Bacon-Shor code22,23,24, are used as quantum memories or processors. Indeed, our method can even be generalized beyond 2D topological codes at the expense of the 2D layout or topological features (see Methods section for details).

In contrast to the method of code deformation18,25,26, where a single underlying lattice is smoothly deformed everywhere through multiple rounds of local Clifford transformations, we combine two initially separate lattices through operations within constant distance of their boundaries. To the best of our knowledge, other established methods for code conversion27,28,29 have either been applied solely to specific codes, or have not been generalized to subsystem codes.

To highlight the usefulness of incorporating SLS into future quantum computers, let us briefly assess the current contenders for fault-tolerant quantum computation. At present, one of the most promising techniques is SC quantum computation supplemented by magic state injection30 in order to promote it to a universal quantum computer. However, the overhead on magic state distillation is large6,7 and it is expected that more effort will be directed towards identifying more resource-efficient techniques. At the same time, other approaches to universal fault-tolerant quantum computation are significantly constrained by no-go theorems that prohibit a universal set of transversal gates in a single stabilizer code31 and transversal non-Clifford gates in 2D topological codes32,33. The former no-go theorem can be circumvented by gauge fixing11,34 or (subsystem) lattice surgery, and is hence no issue for our approach. The latter no-go theorem can be avoided in a 3D architecture or non-topological codes35,36,37. One potential replacement for magic state distillation is hence the 3D gauge color code11,38 which successfully sidesteps both no-go theorems. Even though the resource requirement is similar to that of quantum computation with the surface code38, 3D topological codes support other useful features such as single-shot error correction39. As we show in the Methods section, SLS can also be employed to switch between codes of different dimensions, as well as between topological and non-topological codes. This facilitates the circumvention of both no-go theorems in an elegant fashion. At this point it should also be pointed out that many non-topological codes supporting transversal non-Clifford gates35,36,37 have lower resource requirements than comparable 3D topological codes or magic state distillation. However, while all 2D (and some 3D) TSSCs (including the merged code that appears during SLS) with local stabilizers feature error thresholds19,38, the existence of error thresholds has not been proven for any of the mentioned non-topological codes. That is, in the case of non-topological codes it is not guaranteed that the storage time can be made arbitrarily large by enlarging the code distance. Codes have to be concatenated instead4.

In any of these cases, quantum computers can only be expected to operate as well as their weakest link. Here, this applies to the error correction code used. The clear advantage of SLS in this context is that the weakest link (i.e., code) may be employed on-demand only and can otherwise be avoided. For instance, in a distributed architecture a code for the implementation of, e.g., a non-Clifford operation can be called only when required. In this scenario, SLS is particularly beneficial since non-Clifford operations could also unfavorably transform errors present in the system36, while SLS does not carry such errors to other codes. SLS should thus not be seen as a stand-alone contender with other methods of realizing universal fault-tolerant quantum computation, but rather as a facilitator thereof, allowing to selectively combine and exploit the advantages of other methods. We hence expect lattice surgery to play a crucial role in future quantum computers, be it as an element of a quantum bus or for distributed quantum computing29.

Our findings further motivate experimental efforts to develop architectures that are flexible enough to implement and connect surface and color codes and/or other codes. For instance, ion trap quantum computers40 may provide a platform soon capable of performing lattice surgery between two distinct codes. In this endeavor, the inherent flexibility attributed to multizone trap arrays41 may be beneficial. Moreover, topological codes and our approach to code switching are obvious choices for fault-tolerant quantum computation with architectures requiring nearest-neighbor interactions in fixed setups, such as superconducting qubits42 or nitrogen-vacancy diamond arrays43. However, given the local structure of topological codes and the simplicity of our algorithm, the requirements for any architecture are comparatively low.

Despite the inherent fault tolerance of SLS, the codes on which it is performed are nonetheless subject to errors. Further investigations of error thresholds2,19 for (non-)topological codes and bench-marking44 are therefore required, in particular with regard to (subsystem) lattice surgery. Finally, our code switching method may find application in the design of adaptive error correction schemes45.

## Methods

### Subsystem lattice surgery

In the main text, we have introduced a subsystem lattice surgery (SLS) protocol that is applicable to arbitrary 2D TSSCs, and we have shown how it can be used to teleport quantum information between surface and color codes. In this Methods section, we explain how lattice surgery can be understood entirely within the subsystem stabilizer formalism. To this end, we define SLS by the fault-tolerant mapping $G A × G B ↦ G A × G B × P L A ⊗ P L B$, where the merging procedure as described in steps (i)–(iv) and formalized in Theorem 1 is an initialization of an intermediate, merged code $G M$ and the splitting fixes gauge degrees-of-freedom to obtain $G A × G B × P L A ⊗ P L B$ from $G M$.

To see this, we again consider two “standard” TSSCs, $G A$ and $G B$. Note that we thereby exclude certain pathological “exotic” codes as will be explained in the proof of Lemma 1. Adopting the previous notation, we assume that the lattices have been chosen such that the logical operators $P L I$ (I = A, B) along their boundaries have support on NA and NB qubits, respectively. For ease of presentation we further choose NA = NB = N. Now, let $G I$ with I = A, B be codes characterized by the tuples [[n I , k I , g I , d I ]], where n I are the numbers of physical qubits, k I the numbers of logical qubits, g I the numbers of gauge qubits, and d I are the distances, respectively. We choose the generating set ${ G 1 I , . . . , G s I + 2 g I I }$ for code $G I$, where s I  = n I  − k I  − g I is the number of independent stabilizer generators (or the number of stabilizer qubits in accordance with our previous terminology). The lattices are then aligned and prepared as in step (ii) of the algorithm described in the main text, but we omit including ancillas for now. We proceed by defining the merging operators

$G i M = P L , i A P L , i B ∀i=1,...,N$
(3)

on the merged lattice ΛM. From these merging operators, we then collect Δg ≤ N − 1 (where the meaning of this notation becomes apparent in the following section) inequivalent ones (w.r.t. $G A × G B × P L A ⊗ P L B$) in the set $W= G i M i = 1 , . . . , Δ g$, and call the group generated by these operators $M$. We refer to elements of $W$ as merging generators. This allows us to define the subsystem code

$G M := G 1 A , . . . , G s A + 2 g A A × G 1 B , . . . , G s B + 2 g B B ×M× i .$
(4)

Note that, technically, Eq. (4) specifies a subsystem stabilizer code only if the center of $G M$ is non-empty, such that a stabilizer subgroup $S M$ can be defined. That this is indeed the case follows from Lemma 2. As we will show next, the code $G M$ has the structure of the merged code discussed in Theorem 1. The essential features of this structure can be captured in the following Lemma.

Lemma 1. The code $G M$ defined in Eq. (4) is a TSSC on the merged lattice ΛM with distance no less than dmin = min({dA, dB}). In addition, $G M$ can be gauge fixed to $G A × G B × P L A ⊗ P L B$, effectively splitting the code into $G A$ and $G B$.

Proof. First, let us show that $G M$ obeys the locality condition for TSSCs. By definition, generators of the separated codes are also generators of the merged code. Their interaction range is increased by at most a constant along the vertical direction due to the relabeling in step (ii). Thereby, the interaction range of merging generators is also kept constant. The generators of the code $G M$ are hence all local.

Second, we verify that the distance of the merged code is at least dmin. Since $G A × G B × P L A ⊗ P L B$ is a subgroup of $G M$, the normalizer $N G M$ is a subgroup of $N G A × G B × P L A ⊗ P L B$. Then, note that there exist stabilizers $S∈ S A × S B$ that anticommute with some $G M ∈M$. If that was not the case, all $G M ∣ Q I$ would either be elements of the code $G I$ or undetectable errors. The latter option can be ruled out in accordance with the argument in the proof of Lemma 2. The former option, $G M ∣ Q I ∈ G I$$∀ G M ∈M$, would imply that $P L I$ is not a logical operator. In a quantum error correction code, such mutually anticommuting operators act either on the logical subspace or on gauge qubits. However, any stabilizer of the separate codes is also contained in $G M$ according to the definition of the merged code in Eq. (4). Now recall that if $G M$ is a subsystem stabilizer code, it can be decomposed as $G M = L G M × S M × i$, as explained in the main text. Therefore, the aforementioned anticommuting stabilizers S must act on gauge qubits and we can hence identify S as belonging to $L G M$. Later, we will further elaborate on the structure of $G M$. Since $S A × S B$ contains elements that are not in the stabilizer of $G M$ but not vice versa, $S M$ must be a subgroup of $S A × S B × P L A ⊗ P L B$. Consequently, any equivalence class of $N G M ∕ S M$ is contained in an equivalence class of $N G A × G B × P L A ⊗ P L B ∕ S A × S B × P L A ⊗ P L B$.

The quotient group $N ( G ) ∕S$ defines so-called bare logical operators that do not act on gauge qubits. Generally, $N ( G ) ∕ i S$ contains all information about the logical operators but not about all undetectable errors. At the same time, undetectable errors are related to bare logical operators, since $N ( S ) ∕G≃N ( G ) ∕ i S$ for any subsystem stabilizer code $G$19. To conclude then that the distance of $G M$ is dmin, we have to verify that deformations (i.e., multiplications) of any non-trivial, logical operators $P∈N G M ∕ S M$ by operators in $G M$ yield operators of weight at least dmin. Since any such P is also contained in $L A × L B$ this is true for deformations by operators in $G A × G B$. But we still need to confirm this for operators in $G M - G A × G B$. Specifically, we have to consider deformations under $G i M i = 1 , . . . , N$. In principle, these merging operators can reduce the weight of operators P below dmin. However, this can only happen under rather exotic circumstances. That is, only for logical operators of the form P = PA PB, where $P I ∈ L I$ (I = A, B) and $P I ≁ P L I$ acts as $P L I$ on a region K I Q I such that for the complementary regions $K ̄ I$ (with $K ̄ I ∪ K I$ being the set of all qubits on lattice Λ I and $K ̄ I ∩ K I = K I - K Ī$) the weights of these operators satisfy $0 independently of the system size. Here we make use of the fact that QA and QB have been labeled equally (cf. main text) and write with a slight abuse of notation $K ̄ I ∩ K I = K I - K Ī$ (where $Ī=B$ if I = A and vice versa). In the scenario described above, one could define the logical operator $P A ⊗ P B ⊗ ∏ i ∈ K A ∩ K B G i M$ with weight $0. At the same time, this also constricts $P L I$ since PI must be such that $w ( P I ⊗ P L I ) ≥ d min$. Since this describes extremely restricted cases that (to the best of our knowledge) do not feature in any practical scenario, we will exclude codes with such properties from our construction.

Note that we can also exclude cases where $w ( P A ∣ K ̄ A ) +w ( P B ∣ K ̄ B ) =0$. In such cases at least two logical operators $P A , P B ∈ L A × L B$ with $supp ( P I ) ⊂supp ( P L I )$ (I = A, B) exist. However, we are only interested in projecting onto the joint eigenstate of any two logical operators $P L A$ and $P L B$ along the boundary. Therefore, we can always exclude the aforementioned case by choosing $P L A$ and $P L B$ such that there does not exist a logical operator that has support on a subset of Q I . In the case of TSSC with non-local stabilizers, such logical operators may have support on disconnected regions of a lattice19. Then, these regions have to be connected using local generators to obtain proper string operators. Then, any non-trivial logical operator of the merged code has support on at least dmin qubits. The distance of the merged code is hence at least dmin.

Third, the merged code is scalable since the separate codes are scalable. Thus, we can conclude that $G M$ is indeed a TSSC. At last, note that fixing $S M$ to $S A × S B$ through a measurement of stabilizers $S∈ S A × S B$ anticommuting with at least one merging generator, the separate codes can be recovered while retaining the eigenstate of $P L A ⊗ P L B$. This gauge fixing has to be accompanied by error correction to ensure full fault tolerance. Q.E.D.

To finally prove Theorem 1, we will now explain the connection between the merged code $G M$ defined in Eq. (4) and the framework discussed in the main text. The merging procedure described in steps (ii)–(iv) can be understood as an initialization of the merged code. Specifically, measuring merging generators as in Eq. (3) (or similarly, Eq. (2)) initializes $G M$ from the prepared codes $G A × G B$. The parity of all random measurement outcomes yields the parity of $P L A ⊗ P L B$ and error correction has to be performed thereafter in order to ensure correctness (see step (iv)). Fault tolerance is guaranteed since merging generators are constant-weight and errors can only propagate to a constant number of physical qubits. Since we have established in Lemma 1 that $G M$ is indeed a TSSC with distance at least dmin, this concludes the proof of Theorem 1.

Altogether, by proving Theorem 1 and Lemma 1, we showed that SLS is fault-tolerant and well-defined through a merging, i.e., a mapping $G A × G B ↦ G M$, followed by a splitting, i.e., a mapping $G M ↦ G A × G B × P L A ⊗ P L B$.

Concluding this Methods section, we return to the discussion of the ancillas added during step (i) of the preparation. As already discussed in the main text, ancillas can be understood as additional stabilizer qubits included into the initial codes. In the merged code these become gauge qubits. The usefulness of ancillas arises when one considers TSCs as it is the case for the example discussed in the Results section. In that case the merged code can be understood as a TSC with stabilizers merged across the boundary. Here, introducing ancillas means that stabilizers of one surface are instead merged with stabilizers of ancillas, allowing for the possibility of reducing the interaction range of the merged code.

### Merged code structure

In this section, we provide a careful analysis of the merged code. In particular, we will discuss the structure of the subgroups $S M$ and $L G M$. Here we claim that $G M$ is a [[nA + nB, kA + kB − 1, gA + gB + Δg, dM]] code with distance dM ≥ dmin. That is, the distance dM merged code has nA + nB physical qubits, kA + kB − 1 logical qubits, and gA + gB + Δg gauge qubits, where Δg is the number of merging generators (see Eq. (3)). To see this, we have to understand the structure of $S M$ and $G G M$ in comparison with the separate codes $G A × G B$.

First, note that we can define Δg new gauge qubits via their respective Pauli operators $G i M , S i i = 1 , . . . , Δ g$ where S i SA × SB i such that $G i M , S j =0$ for i ≠ j. That is, there exist Δg independent stabilizers which are now included as gauge operators together with the same number of merging generators. As we will see, the existence of such stabilizers is guaranteed by the choice of logical operators $P L A$ and $P L B$ as explained in the proof of Lemma 1.

Lemma 2. For the operators $P L A$ and $P L B$ chosen above there exists a stabilizer $S i ∈ S A × S B$ for any merging generator $G i M ∈W$ such that $G i M , S i =0$ and $G j M , S i =0$$∀ G j M ∈W- G i M$.

Proof. Suppose such a stabilizer does not exist. Then, there exists a $G∈M$ that yields the same error syndrome as $G i M$, i.e., $ψ G i M G ψ =0$ for any codeword $ψ ∈ C A × C B$. Since $G i M G∉ G A × G B$, it is a non-trivial logical operator in $L A × L B$. Combining this with the fact that $W⊂ { G j M } j = 1 , . . . , N$, the existence of the logical operator $G i M G$ is not compatible with our construction of $P L I$ as discussed in the proof of Lemma 1. That is, there exist no logical operators $P I ∈ L I$ with $supp P I ⊂supp P L I$ (I = A, B) for our choice of $P L I$. Q.E.D.

We have hence defined Δg new gauge qubits by $W$ and the same number of independent stabilizers. As another consequence of Lemma 2, we can also define an additional stabilizer equivalent to $P L A ⊗ P L B$. That is, the merged code has sA + sB − Δg + 1 independent stabilizers and thus, a necessarily non-empty center (but reduced logical subspace).

To complete our analysis of the merged code, we have to verify that $G M$ still contains gA + gB gauge qubits besides new ones. Therefore, note that there might exist pairs of gauge operators $g, g ̃ ∈ L G A × L G B$ generating a gauge qubit, for which ${ g , G j M } =0$ with $G j M ∈W$ j J where J {1, ..., Δg}. While the associated gauge qubit in $L G A × L G B$ was defined by $g ̃ , g$, in the merged code it is redefined to be generated by $⟨ g ̃ , g ⊗ ∏ j ∈ J S j ⟩$. Here, $S j ∈ L G M$ is associated with one of the Δg new gauge qubits introduced above. W.l.o.g. we have assumed that $[ g ̃ , G j M ] =0$ j = 1, ..., Δg. Otherwise, we would simply have to apply the same argument to $g ̃ ∈ L G A × L G B$ with ${ g ̃ , G j M } =0$ for some j J {1, ..., Δg}.

One can see that this code is indeed generated as indicated in Eq. (4). Hence, the distinction to the separated codes is that some stabilizers now act on gauge qubits which can be reversed by gauge fixing. Interestingly, applying this formalism to two Bacon-Shor codes22 on regular square lattices [1, L]2, yields a merged, asymmetric Bacon-Shor code23 on a [1, 2L] × [1, L] lattice.

### Subsystem surface code lattice surgery

Here, we exemplify SLS by means of the subsystem surface code (SSC)21. Therefore, consider two such codes $G A$ and $G B$ defined on regular square lattices [1, L]2 with qubits located on vertices. In Fig. 4a, we chose the smallest SSC with distance d = L = 3 defining a unit cell where the central vertex is unoccupied. The codes are generated by triangle and boundary operators, labeled $G i I$ and $S i I$, respectively, with i = 1, ..., 4 and I = A, B (Fig. 4a). Triangle operators ${ G i I } i = 1 , . . . , 4$ act on qubits adjacent to a triangular plaquette p as $G i I = ∏ v ∈ N ( p ) X v$ for i = 2, 3 and $G i I = ∏ v ∈ N ( p ) Z v$ for i = 1, 4. Boundary operators ${ S i I } i = 1 , . . . , 4$ are weight-two Pauli operators acting on every other pair of boundary qubits as either X-type or Z-type operators for i = 1, 4 and i = 2, 3, respectively. The stabilizer group is defined as

$S I = S 1 I , . . . , S 4 I , G 1 I G 4 I , G 2 I G 3 I .$
(5)

Henceforth, we write AB whenever we identify a group A with a generating set B up to phases. A single gauge qubit is defined up to irrelevant phases by

$L G I ∝ G 1 I , G 3 I .$
(6)

Logical operators $X L I$ and $Z L I$ are tensor products of single-qubit Pauli X- and Z operators, respectively, connecting two opposite boundaries as shown in Fig. 4a.

Now we initialize a merged code by measuring merging generators ${ G i M } i = 1 , 2 , 3$ as depicted in Fig. 4b. The merged code is left with 5 stabilizer qubits,

$S M = S 1 A , S 4 B , G 2 A G 3 A S 1 B , S 4 A G 2 B G 3 B , Z L A Z L B ,$
(7)

where we only kept stabilizers in $S A × S B$ that commute with the merging generators. Consequently, we can identify 2 additional gauge qubits, i.e., 4 in total,

$L G M ∝ G 1 A , G 3 A S 1 B ; G 1 B , G 3 B ; G 1 M , S 1 B ; G 3 M , S 4 A .$
(8)

Here we included a semicolon between generators of independent gauge qubits and neglected additional phases. Evidently, this code has the structure predicted in the preceding Methods section and is indeed a TSSC with distance 3.

### Beyond 2D topological codes

Finally, let us discuss the applicability of SLS to higher-dimensional topological codes as well as to non-topological codes. As we shall argue, all of the above holds true in these cases. In short, this is because the essential feature of SLS is to project onto a joint eigenstate of two logical operators by measuring generators of a merged code. Such a merged code can always be formally defined, irrespective of whether or not the initial codes are topological.

Let us first consider topological codes in more than two dimensions. For instance, 3D topological codes (as opposed to 2D topological codes) can support membrane-like logical operators on their 2D boundary46,47. Similarly, it can be expected that most topological codes in D dimensions can support logical operators that are associated with (D − 1)-dimensional extended objects on the boundary46. With this assumption, it is straightforward to show that SLS can be applied in any dimension. This leaves us with the question of whether SLS can also be used to switch between dimensions. This is indeed the case, since, interestingly, 3D topological codes also support string-like logical operators33 which can be used to teleport information from a 2D topological code to a higher-dimensional one via SLS. In fact, at the expense of its 2D layout, a 2D code can even be wrapped along the surface of a 3D code to perform SLS between a string- and a membrane-like logical operator while preserving a 3D notion of locality.

Finally, let us consider the effects of relaxing the constraint of demanding topological features for the quantum error correction codes under scrutiny. For such codes there exists no notion of locality or scalability. Therefore, an underlying lattice of physical qubits cannot be defined in a meaningful way. However, when revising the arguments from Lemmas 1 and 2 in the spirit of non-topological codes, it turns out that one does not require any topological features to prove that the distance of the merged code is the minimum distance of the initial codes. Neither is it necessary to require locality or scalability to show that the merged code can be gauge-fixed to the original codes. The merged code as specified in Eq. (4) is always well-defined algebraically even without topological features. That is, at the expense of locality and/or scalability, Lemmas 1 and 2 hold and we can use SLS to switch between topological and non-topological codes. Nevertheless, one can expect that scalability in particular is a feature that is desirable for any code. Therefore, let us note that the merged code is scalable if the separate codes are scalable even if it is not topological otherwise. As an example of codes that are scalable but not topological consider the doubled codes36 which are also amenable for SLS.

### Data availability

Data sharing is not applicable to this article as no data sets were generated or analyzed during the current study.

Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## References

1. 1.

Nielsen, M. A. & Chuang, I. L. Quantum Computation and Quantum Information (Cambridge University Press, Cambridge, 2000).

2. 2.

Preskill, J. Fault-tolerant quantum computation. in: Introduction to Quantum Computation and Information (eds Lo, H.-K., Spiller, T. & Popescu, S.) (World-Scientific, Singapore, 1998).

3. 3.

Campbell, E. T., Terhal, B. M. & Vuillot, C. The steep road towards robust and universal quantum computation. Nature, 549, 172-179 (2017).

4. 4.

Gottesman, D. Stabilizer Codes and Quantum Error Correction (California Insitute of Technology, Pasadena, 1997).

5. 5.

Bravyi, S. & Terhal, B. A no-go theorem for a two-dimensional self-correcting quantum memory based on stabilizer codes. New J. Phys. 11, 043029 (2009).

6. 6.

Bravyi, S. B. & Kitaev, A. Y. Quantum codes on a lattice with boundary. Preprint at https://arxiv.org/abs/quant-ph/9811052 (1998).

7. 7.

Fowler, A. G., Mariantoni, M., Martinis, J. M. & Cleland, A. N. Surface codes: towards practical large-scale quantum computation. Phys. Rev. A 86, 032324 (2012).

8. 8.

Bombín, H. & Martín-Delgado, M. A. Topological quantum distillation. Phys. Rev. Lett. 97, 180501 (2006).

9. 9.

Fujii, K. & Tokunaga, Y. Error and loss tolerances of surface codes with general lattice structures. Phys. Rev. A 86, 020303(R) (2012).

10. 10.

Wang, D. S., Fowler, A. G. & Hollenberg, L. C. L. Surface code quantum computing with error rates over 1%. Phys. Rev. A 83, 020302(R) (2011).

11. 11.

Bombín, H. Gauge color codes: optimal transversal gates and gauge fixing in topological stabilizer codes. New J. Phys. 17, 083002 (2015).

12. 12.

Bombín, H. Dimensional jump in quantum error correction. New J. Phys. 18, 043038 (2016).

13. 13.

Horsman, C., Fowler, A. G., Devitt, S. & Van Meter, R. Surface code quantum computing by lattice surgery. New J. Phys. 14, 123011 (2012).

14. 14.

Landahl A. J. & Ryan-Anderson, C. Quantum computing by color-code lattice surgery. Preprint at https://arxiv.org/abs/1407.5103 (2014).

15. 15.

Poulin, D. Stabilizer formalism for operator quantum error correction. Phys. Rev. Lett. 95, 230504 (2005).

16. 16.

Raussendorf, R. & Briegel, H. J. A one-way quantum computer. Phys. Rev. Lett. 86, 5188 (2001).

17. 17.

Zanardi, P., Lidar, D. & Lloyd, S. Quantum tensor product structures are observable induced. Phys. Rev. Lett. 92, 060402 (2004).

18. 18.

Bombín, H. Structure of 2D topological stabilizer codes. Commun. Math. Phys. 327, 387 (2014).

19. 19.

Bombín, H. Topological subsystem codes. Phys. Rev. A 81, 032301 (2010).

20. 20.

Bombín, H., Duclos-Cianci, G. & Poulin, D. Universal topological phase of two-dimensional stabilizer codes. New J. Phys. 14, 073048 (2012).

21. 21.

Bravyi, S., Duclos-Cianci, G., Poulin, D. & Suchara, M. Subsystem surface codes with three-qubit check operators. Quant. Inf. Comput. 13, 0963 (2013).

22. 22.

Bacon, D. Operator quantum error-correcting subsystems for self-correcting quantum memories. Phys. Rev. A 73, 012340 (2006).

23. 23.

Brooks, P. & Preskill, J. Fault-tolerant quantum computation with asymmetric Bacon-Shor codes. Phys. Rev. A 87, 032310 (2013).

24. 24.

Yoder, T. J. Universal fault-tolerant quantum computation with Bacon-Shor codes. Preprint at https://arxiv.org/abs/1705.01686 (2017).

25. 25.

Bombín, H. & Martín-Delgado, M. A. Quantum measurements and gates by code deformation. J. Phys. A: Math. Theor. 42, 095302 (2009).

26. 26.

Kubica, A., Yoshida, B. & Pastawski, F. Unfolding the color code. New J. Phys. 17, 083026 (2015).

27. 27.

Anderson, J. T., Duclos-Cianci, G. & Poulin, D. Fault-tolerant conversion between the steane and reed-muller quantum codes. Phys. Rev. Lett. 113, 080501 (2014).

28. 28.

Hwang, Y., Choi, B.-S., Ko, Y.-C. & Heo, J. Fault-tolerant conversion between stabilizer codes by Clifford operations. Preprint at https://arxiv.org/abs/1511.02596 (2015).

29. 29.

Nagayama, S. Distributed Quantum Computing Utilizing Multiple Codes on Imperfect Hardware (Graduate School of Media and Governance, Keio University, Fujisawa, 2017).

30. 30.

Bravyi, S. & Kitaev, A. Universal quantum computation with ideal Clifford gates and noisy ancillas. Phys. Rev. A 71, 022316 (2005).

31. 31.

Eastin, B. & Knill, E. Restrictions on transversal encoded quantum gate sets. Phys. Rev. Lett. 102, 110502 (2009).

32. 32.

Bravyi, S. & König, R. Classification of topologically protected gates for local stabilizer codes. Phys. Rev. Lett. 110, 170503 (2013).

33. 33.

Pastawski, F. & Yoshida, B. Fault-tolerant logical gates in quantum error-correcting codes. Phys. Rev. A 91, 012305 (2015).

34. 34.

Paetznick, A. & Reichardt, B. W. Universal fault-tolerant quantum computation with only transversal gates and error correction. Phys. Rev. Lett. 111, 090505 (2013).

35. 35.

Jochym-Oonnor, T. & Bartlett, S. D. Stacked codes: universal fault-tolerant quantum computation in a two-dimensional layout. Phys. Rev. A 93, 022323 (2016).

36. 36.

Bravyi, S. & Cross, A. Doubled color codes. Preprint at https://arxiv.org/abs/1509.03239 (2015).

37. 37.

Jones, C., Brooks, P. & Harrington, J. Gauge color codes in two dimensions. Phys. Rev. A 93, 052332 (2016).

38. 38.

Brown, B. J., Nickerson, N. H. & Browne, D. E. Fault-tolerant error correction with the gauge color code. Nat. Commun. 7, 12302 (2016).

39. 39.

Bombín, H. Single-shot fault-tolerant quantum error correction. Phys. Rev. X 5, 031043 (2015).

40. 40.

Nigg, D. et al. Quantum computations on a topologically encoded qubit. Science 345, 302 (2014).

41. 41.

Bowler, R. et al. Coherent diabatic ion transport and separation in a multizone trap array. Phys. Rev. Lett. 109, 080502 (2012).

42. 42.

Barends, R. et al. Superconducting quantum circuits at the surface code threshold for fault tolerance. Nature 508, 500 (2014).

43. 43.

Yao, N. Y. et al. Scalable architecture for a room temperature solid-state quantum information processor. Nat. Commun. 3, 800 (2012).

44. 44.

Delfosse, N., Iyer, P. & Poulin, D. A linear-time benchmarking tool for generalized surface codes. Preprint at https://arxiv.org/abs/1611.04256 (2016).

45. 45.

Orsucci, D., Tiersch, M. & Briegel, H. J. Estimation of coherent error sources from stabilizer measurements. Phys. Rev. A 93, 042303 (2016).

46. 46.

Bombín, H. & Martín-Delgado, M. A. Exact topological quantum order in D = 3 and beyond: Branyons and brane-net condensates. Phys. Rev. B 75, 075103 (2007).

47. 47.

Bombín, H., Chhajlany, R. W., Horodecki, M. & Martín-Delgado, M. A. Self-correcting quantum computers. New J. Phys. 15, 055023 (2013).

## Acknowledgements

We are grateful to Rainer Blatt, Nicolas Delfosse, Vedran Dunjko, Alexander Erhard, Esteban A. Martinez, and Philipp Schindler for valuable discussions and comments. We acknowledge support from the Austrian Science Fund (FWF) through the DK-ALM: W1259-N27, the SFB FoQuS: F4012, the START project Y879-N27, and the Templeton World Charity Foundation Grant No. TWCF0078/AB46.

## Author information

### Affiliations

1. #### Institute for Theoretical Physics, University of Innsbruck, Technikerstr. 21a, 6020, Innsbruck, Austria

• Hendrik Poulsen Nautrup
• , Nicolai Friis
•  & Hans J. Briegel
2. #### Institute for Quantum Optics and Quantum Information, Austrian Academy of Sciences, Boltzmanngasse 3, 1090, Vienna, Austria

• Nicolai Friis

### Contributions

H.P.N. has devised the code switching protocol, proven Theorem 1 and composed the manuscript. N.F. has contributed to the conceptual development of the project and helped writing the manuscript. H.J.B. has supervised the project. All authors have discussed the results.

### Competing interests

The authors declare no competing financial interests.

### Corresponding author

Correspondence to Hendrik Poulsen Nautrup.