Fault-Tolerant Code Switching Protocols for Near-Term Quantum Processors

Topological color codes are widely acknowledged as promising candidates for fault-tolerant quantum computing. Neither a two-dimensional nor a three-dimensional topology, however, can provide a universal gate set $\{$H, T, CNOT$\}$, with the T-gate missing in the two-dimensional and the H-gate in the three-dimensional case. These complementary shortcomings of the isolated topologies may be overcome in a combined approach, by switching between a two- and a three-dimensional code while maintaining the logical state. In this work, we construct resource-optimized deterministic and non-deterministic code switching protocols for two- and three-dimensional distance-three color codes using fault-tolerant quantum circuits based on flag-qubits. Deterministic protocols allow for the fault-tolerant implementation of logical gates on an encoded quantum state, while non-deterministic protocols may be used for the fault-tolerant preparation of magic states. Taking the error rates of state-of-the-art trapped-ion quantum processors as a reference, we find a logical failure probability of $3\%$ for deterministic logical gates, which cannot be realized transversally in the respective code. By replacing the three-dimensional distance-three color code in the protocol for magic state preparation with the morphed code introduced in [1], we reduce the logical failure rates by two orders of magnitude, thus rendering it a viable method for magic state preparation on near-term quantum processors. Our results demonstrate that code switching enables the fault-tolerant and deterministic implementation of a universal gate set under realistic conditions, and thereby provide a practical avenue to advance universal, fault-tolerant quantum computing and enable quantum algorithms on first, error-corrected logical qubits.


I. INTRODUCTION
Universal quantum computation holds the promise to perform certain computational tasks exponentially faster than any known classical algorithm [2,3].In the current noisy intermediate-scale quantum (NISQ) era, however, the accuracy of quantum algorithms is limited by noise [4].A prospective means of increasing their robustness against the noise is to encode quantum information on logical qubits, with each logical qubit consisting of multiple physical qubits.On these logical qubits, quantum error correction (QEC) [5,6] can be performed to correct for errors on physical qubits and, thereby, to recover the initially encoded information [7,8].For physical error rates below a certain threshold, QEC enables practical quantum computing for arbitrarily long times given suitable, i.e. fault-tolerant (FT), circuit constructions [9][10][11][12].FT circuits can be designed by using transversal gate operations, which are composed of single-qubit unitaries acting on individual qubits in each encoded block, such that potential errors in any of these operations are prevented from proliferating uncontrollably [6,13].In order to approximate arbitrary computations on encoded qubits, a discrete set of operations that forms a universal gate set can be used, which requires at least one non-Clifford gate [9,14].However, the Eastin-Knill theorem states that no QEC code exists that has a universal, transversally encoded and, therefore, FT gate set [15].This complicates the imple- * friederike.butt@rwth-aachen.dementation of a universal FT gate set and poses a key challenge towards error-corrected universal quantum computing.
Recent quantum computing experiments are focused on the practical encoding of qubits on a logical level and investigate the implementation of a quantum memory.For example, on trapped-ion systems, the preparation of logical states [16], error detecting codes [17], FT stabilizer readouts [18] in a shuttling based architecture [19], as well as repeated cycles of QEC [20] have been implemented.In superconducting qubits, logical qubits have successfully been initialized [21,22], while repeated QEC has been realized [23][24][25], as well as error detection codes [26,27].Recently, a distance-five surface code logical qubit outperformed a distance-three logical qubit, demonstrating an improvement of performance of QEC codes with an increasing number of qubits [28].Rydberg atoms are a promising candidate for building quantum processors due to their strong long-range interactions and scalability [29,30] and have shown rapid progress in single-and multi-qubit control [31][32][33] as well as first elements of quantum error correction [34].Advancements in other qubit architectures have been reported, as for example a threequbit phase-correcting code in a silicon-based architecture [35] and fault-tolerant operations on a logical qubit using spin qubits in diamond [36], among others.
These advancements in practical and scalable implementations of logical qubits enable FT operations on these encoded states and motivate the search for ways to achieve FT, universal quantum computing on near-term devices.The FT control of an errorcorrected single logical qubit [37] has been demon-FIG.1: Transversal gate set of three-dimensional tetrahedral and two-dimensional triangular color codes.A two-dimensional triangular color code, as depicted on the right, has a transversal implementation of the CNOT-and the Hadamard-gate.On the left side, a three-dimensional tetrahedral code is illustrated, which has a transversal implementation of the CNOT-gate and the non-Clifford T-gate.By switching between these two code classes, it is possible to access all gates of a universal gate set {CNOT, H, T} with transversal implementations.strated on a trapped ion processor, as well as logical operations in a distance-two error-detecting surface code on a superconducting architecture [38] and entangling gates between logical qubits [39].A universal set of gates was recently implemented for the first time on a seven-qubit Steane code, which is the smallest error-correcting color code, using FT circuit constructions with flag qubits [40].Here, the universal gate set is completed by using magic state injection to realize a logical non-Clifford operation.The non-Clifford T-gate can be implemented by preparing a magic state fault-tolerantly on an ancillary system [41,42] and then injecting this magic state onto the target qubits using a logical CNOT-gate [43].
An alternative to magic state injection is to complete a FT universal gate set using code switching between codes with complementary transversal gate sets [44][45][46].Code switching allows one to transfer encoded information between specific codes.To do so, stabilizers are measured to project the state onto the desired codespace.Based on the measurement outcomes, local Pauli operations are applied to change the state into the correct +1-eigenstate of the stabilizers of the target code.One candidate for implementing a universal gate set with code switching are two-dimensional color codes, because all Clifford gates can be implemented transversally [47][48][49][50].For a universal set of gates, at least one non-Clifford gate such as the T-gate is required, which can only be implemented transversally in three-dimensional codes, as for example tetrahedral color codes as illustrated in Fig. 1 [51].By switching between these two-and three-dimensional color codes in a FT manner, it is possible to access all gates of a universal gate set with a transversal implementation.
To achieve fault tolerance for code switching protocols, it is not sufficient to simply use FT stabilizer measurements for error correction.The objec-tive for syndrome measurements for error correction is to detect errors on data qubits and correct for them.The objective of stabilizer measurements during code switching is to project the state onto a desired codespace and apply a corresponding switching operation.In this case, single errors on data qubits invert the measurement outcomes and can directly introduce logical errors on the target code.Furthermore, the initial code can have different error correcting properties than the target code, which has to be carefully taken into account, as we discuss in detail in Sec.V.
In this work, we present strategies that allow for FT switching between two-and three-dimensional color codes.We explicitly consider the distancethree instances of these codes.These instances consist of a number of physical qubits that is available on near-term quantum processors while a single arbitrary computational error is correctable.We make use of ancillary flag qubits that herald the presence of errors resulting from faults in the circuits [41,42,52].The concept of flag qubits has been extended to codes with arbitrary distance [48,53,54] and has been used for the FT initialization of logical qubits [40][41][42] and the FT encoding of magic states [55].We develop FT protocols considering circuit-level noise, i.e. noise models where all components of the underlying circuits, such as initialization, gate operations and measurements are modeled as noisy.We construct new flag-qubit based circuits for the encoding of logical states and for sequences of stabilizer measurements, which are resource-optimized in terms of qubit and gate count.Furthermore, we introduce new non-deterministic code switching protocols that make use of a transformed morphed code, which was introduced in [ makes it a candidate for completing a universal gate set.We construct a scheme for the FT preparation of a magic state using this new code.In doing so, the success rate can be increased significantly compared to the preparation of a magic state via the initial three-dimensional color code.Using the morphed code for magic state preparation, we find similar success rates as state-of-the-art implementations [40].
We construct an entire toolbox of modular FT building blocks, which are illustrated in Fig. 2. Each block is FT by itself and different blocks can be composed to FT protocols.Tab.I summarizes the resources for the constructed building blocks and composite protocols, illustrated in Fig. 2, in terms of the two-qubit-gate count and the number of qubits.
This manuscript is structured as follows.In Sec.II and Sec.III we briefly review basic properties of two-and three-dimensional color codes and, specifically, the smallest instances of these code classes.In Sec.IV, we summarize the underlying theory for code switching.In Sec.V, we discuss the different Pauli errors that have to be considered in detail and present strategies for a FT implementation of code switching.We introduce FT switching with the morphed code in Sec.VI and present results of numerical simulations of noisy circuits implementing logical operations in Sec.VIII for a single-parameter noise model.In Sec.IX, we consider a multi-parameter noise model and estimate the projected performance on near-term devices, specifically focusing on stateof-the-art trapped-ion quantum processors.Lastly, we provide conclusions and an outlook in Sec.X.

II. 2D COLOR CODES
Two-dimensional topological color codes were originally proposed by Bombin et al. [47].They fall into the important class of so-called CSS (Calderbank-Shor-Steane) stabilizer codes [56,57].They can be specified by the code parameters where n is number of physical qubits, k is the number of encoded logical qubits and d is the code distance.The simultaneous +1-eigenspace of all stabilizer generators corresponds to the codespace spanned by the valid logical states [44].A two-dimensional color code can be constructed by placing qubits on the vertices of a three-valent and three-colorable lattice [47].Different vertices are connected by links.Plaquettes are formed by a closed set of links.Three colors, say red, blue and green {R, B, G} are commonly assigned to the plaquettes.Colors are assigned to links according to the color of the plaquettes they connect, so that, for example, blue plaquettes are connected by blue links.Colors are assigned in such a way that three links of different color meet at each site.By closing the boundaries periodically to form a torus, one can identify the logical operators of the two-dimensional color codes as the non-contractible loops on the torus.
A closely related class of two-dimensional color codes with open boundary conditions are triangular color codes, as exemplarily illustrated in Fig. 1.They can be constructed by placing the described lattice on the surface of a sphere and removing one site and all its neighboring links and plaquettes.This lattice contains an odd number of physical qubits and can be deformed into a triangular shape.Xand Z-stabilizers are defined on the plaquettes of the code, which ensures that all stabilizers overlap at an even number of sites and, therefore, commute.Logical operators can be implemented by applying Xand Z-operations to all qubits.By applying stabilizers, one finds equivalent string-type logical operators   [47].With the set of gates {H, S, CNOT}, the whole Clifford group of gates can be generated transversally [58].
The smallest triangular color code with this set of transversal gates is a code that is equivalent to the Steane code [59].
The [ [7,1,3]] Steane code consists of n = 7 physical qubit, encodes k = 1 logical qubit and has distance d = 3 [59].Six stabilizer generators are defined as with the color labels red (R), green (G) and blue (B) and for the indexing given in Fig. 3(a).The two logical operators can be implemented by applying Pauli X-and Z-operators to all seven qubit and are stabilizer-equivalent to operators of minimum weight 3.For example, the logical Pauli-operators can be implemented on the edges of the triangle with X = X 4 X 5 X 6 and Z = Z 4 Z 5 Z 6 . (2)

III. 3D COLOR CODES
To construct a three-dimensional color code, qubits are arranged on a three-dimensional, fourvalent and four-colorable lattice structure.Four colors red, green, blue and yellow {R, G, B, Y } are assigned to the smaller three-dimensional units, which are called cells.Cells of the same color never touch but are connected by links of that same color, for example blue cells are connected by blue links [51].So, a link has color κ ∈ {R, B, G, Y } if the three cells, of which the link is part of, have colors different from κ.The two-dimensional boundaries of the cells are called faces and have the color-labels κ 1 κ 2 according to the colors of the two cells of which they are part of [60].This construction can be generalized also to n-dimensional codes [44,45].
One class of three-dimensional color codes are tetrahedral codes, as exemplarily illustrated in Fig. 1.Analogously to the two-dimensional case, a tetrahedral code can be constructed by arranging a The [ [7,1,3]] Steane code consists of seven qubits (black dots) forming a green, red and blue plaquette (colored faces).The X-and Z-type stabilizers S σ col of color {R, G, B} are defined as σ = X, Z Pauli operators applied to the qubits that form the given plaquette.For example, the red X-stabilizer corresponds to S X R = X 0 X 1 X 2 X 3 .The logical operators can be implemented by applying X and Z to one edge of the triangle, for example to qubits 4, 5 and 6.(b) The 15-qubit tetrahedral code [ [15,1,3]] has distance three, encodes one logical qubit and consists of 15 qubits (black dots), which form threedimensional units.These units are called cells and are labeled with the colors red, blue, green and yellow.Each cell is formed by eight qubits and shares two-dimensional boundaries (faces) with three adjacent cells.Four X-stabilizers B X c are defined on the cells c ∈ {R, B, G, Y } of the code, as for example the red X-stabilizer B X R = X 0 X 1 X 2 X 3 X 4 X 5 X 6 X 7 .Ten independent Z-stabilizers B Z f are defined on the faces f ∈ {R, B, G, Y, RB, RG, RY, BG, BY, GY } of the code, as for example the red-yellow Z-stabilizer The faces contain four qubits and can lie within the tetrahedron, or on the boundary of the tetrahedron.The logical X-operator has minimum weight 7 and can be implemented by applying Pauli X-operators to one side of the tetrahedron, as for example the red-blue-green seven-qubit side on the right.The logical Z-operator has minimum weight 3 and can be implemented by applying Pauli Z-operators to one edge of the tetrahedron, as for example to qubits 10, 13 and 14. three-dimensional lattice within the volume of a 3sphere, in the above described manner.By removing one site and its neighboring cells, faces and links, the lattice contains an odd number of physical qubits and can be deformed into a tetrahedron, encoding a single logical qubit [51].One associates faces F with Z-stabilizers and cells C with X-stabilizers, ensuring commutativity since each cell and face contains an even number of qubits by construction.A codestate |ψ⟩ of this system is characterized by the conditions An operator basis is defined for the qubit encoded in the tetrahedral code by X = X ⊗n and Z = Z ⊗n (5) with the total number of qubits n.This definition ensures that all stabilizers commute with the logical Pauli-operators, since the tetrahedral code contains an odd number of physical qubits and each stabilizer has support on an even number of sites.The T-gate can be implemented transversally on specific tetrahedral codes if the following two conditions are fulfilled.
Let M be subset of the set of all physical qubits Q.
Then let T-gates be applied to the subset M and T †gates applied to the subset M C = Q \ M .Then for the support of the X-stabilizer G, the transversal Tgate can be implemented in this manner if [44,60,61] 1. |M ∩ G| − |M C ∩ G| = 0 mod 8.In words, an equal number of T-and T † -gates has to be applied in each cell (mod8).

|M | − |M
In words, T has to be applied to one more qubit than T † in total (mod8).
It has been shown that the tetrahedral [ [15,1,3]] code is the smallest distance-three QEC code with a transversal non-Clifford gate [62].
The 15-qubit tetrahedral code [ [15,1,3]] The 15-qubit tetrahedral code [ [15,1,3]], as illustrated in Fig. 3(b), consists of 15 physical qubits, one encoded logical qubit and can correct for one arbitrary error [44].Four X-type stabilizers B X c are defined on the cells of the code, as depicted in Fig. 3(b).Ten independent Z-type stabilizers B Z f are defined on the faces of the code.The logical operators are defined as These are stabilizer-equivalent to logical X-operators with minimum weight 7 and logical Z-operators with minimum weight 3. Accordingly, the tetrahedral [ [15,1,3]] code has distance d x = 7 for X-errors and distance d z = 3 for Z-errors, so it is possible to correct X-errors of weight less or equal to 3 and any single Z-error, as well as error configurations that are stabilizer-equivalent to these.The CNOT-gate can be realized in a transversal manner by coupling two code blocks pairwise with physical CNOT gates.The H-gate cannot be implemented transversally (note that the stabilizer group is in particular not preserved under the operation H ⊗n ).In Fig. 4, we show a bipartition that implements a transversal T-gate according to the above stated conditions.
In the next section, we review how to switch between general two-and three-dimensional color codes and, specifically between the [ [7,1,3]] Steane code and the tetrahedral [ [15,1,3]] code.

IV. CODE SWITCHING
Encoded information can be transferred between specific stabilizer codes, if they correspond to two variants of the same subsystem code (subsystem codes also known as gauge codes).A subsystem code is defined by its gauge group G, describing a general subgroup of the n-qubit Pauli group on a set of physical qubits [63,64].The stabilizer group S ⊆ G is the center of G, which is generated by those Pauli operators in G that commute with all elements in G.A stabilizer code can be viewed as a special case of a subsystem code where S = G.The subspace of codestates can be split into a tensor product of the logical qubits and so-called gauge qubits [44] Here, |ψ⟩ represents the logical state and |g⟩ G represents the gauge state.The gauge state corresponds to extra degrees of freedom which are not uniquely fixed by the stabilizers.An element U of G \ S has the effect on this state |ψ⟩ Given a stabilizer code S A , for which S ⊂ S A , any +1-eigenstate of S A is consequentially also a codestate in the subsystem S. Therefore, any codestate |ψ⟩ A ∈ S A is also a subsystem codestate, i.e. it can be written as a tensor product of a logical state and a gauge state as in Eq. ( 10) Analogously, a second stabilizer code S B can be defined, for which S ⊂ S B , so we can write The stabilizer groups of the three codes considered are illustrated in Fig. 5.If the logical operators L, L A and L B of the three codes can be represented in the same way, and |ψ⟩ A and |ψ⟩ B correspond to the same logical state in their stabilizer code, they must be logically equivalent in the subsystem code.This means that |ψ⟩ and |ψ ′ ⟩ are the same logical state for both  A. Code switching between the [ [7,1,3]] and [ [15,1,3]] Switching between the Steane code and the 15qubit tetrahedral code has been discussed and analyzed in [45,61] and [65], among others.In the following, we briefly review Non-FT switching between these codes before presenting a FT scheme in Sec.V.
One can define a subsystem code whose gauge group G is generated by all independent X-and Zfaces that can be defined on the tetrahedral structure.The stabilizer group of this subsystem code S subsystem is generated by those elements that commute with all other elements of G and is therefore generated by the X-and Z-cells of the tetrahedron.In contrast to the stabilizers of the stabilizer code [ [15,1,3]], the Z-stabilizers of the subsystem code are not defined on the ten independent faces of the code, but only on the four weight-8 cells.The stabilizer group of the subsystem is part of both the stabilizer group of the Steane code, together with the bulk, and of the stabilizer group of the [ [15,1,3]] tetrahedral code, meaning Here, the bulk is formed by those data qubits of the tetrahedron that are not part of the Steane code (yellow cell).Note that, if the state fulfills two opposing faces individually, then it is also a +1-eigenstate of its products, which corresponds to the composed cell.Consequentially, every codestate of the tetrahedral stabilizer code, which is a +1eigenstate of all elements of S tetra , is always also a codestate of the subsystem code.Analogously, every codestate of the Steane code together with the bulk is also always a codestate of the subsystem.So, one can write codestates of the [ [15,1,3]] code and the [ [7,1,3]] Steane code in the subsystem as a tensor product of the corresponding logical state and a specific gauge state, as given in Eq. (15).
If the logical operators of the three codes have a common representation, so that |ψ⟩ is the same logical state for both codes, they must be logically equivalent in the subsystem code.One common representation for the logical operators of the Steane code and the [ [15,1,3]] tetrahedral code corresponds to one side of the tetrahedron, such as for the indexing given in Fig. 3(b).To switch between the two codes [ [7,1,3]] and [ [15,1,3]], first, stabilizers of the target code have to be measured.This projects the encoded state into a +1-or −1eigenstate of the measured stabilizers.For a negative measurement outcome, a combination of gaugeoperators has to be applied that forces the state into a +1-eigenstate of all stabilizers of the target code.
Concretely, to switch from the [ [15,1,3]] code to the Steane code, first, one has to measure the three X-plaquettes of the Steane code, which are and S X G = X 6 X 7 X 13 X 14 for the indexing given in Fig. 3

(b).
Based on these measurement outcomes, a combination of Z-faces connecting the Steane code with the bulk is applied in order to force the state into the codespace of the Steane code.For example, let us consider the case where the measurement outcome of the X-plaquettes of the Steane code is (S X R , S X B , S X G ) = (1, 0, 0).This means that the measurement projected the state onto a +1-eigenstate of the blue and green plaquettes and a −1-eigenstate of the red plaquette.In order to force the state into the desired codespace, we apply the gauge operator B Z BG = Z 5 Z 6 Z 13 Z 14 , as illustrated in Fig. 7(a).This operator overlaps at an even number of sites with the blue and green plaquette, so the state stays a +1-eigenstate of these stabilizers.It overlaps at a single site with the red plaquette and, therefore, forces the state into a +1-eigenstate of this plaquette.Note that this is in contrast to using single Paulioperations as one would do for correcting errors on a set of qubits.This would affect both the gauge state |g⟩ G and the logical state |ψ⟩, as given in Eq. 10 and, therefore, change the encoded information.
This protocol is inverted for the other direction.To switch from the Steane code to the [ [15,1,3]] code, first, one has to measure the three Z-faces that connect the Steane code and the bulk, which are Based on these measurement outcomes, a combination of the Steane X-plaquettes is applied in order to change the state into the codespace of the [ [15,1,3]] code.

V. DETERMINISTIC FT CODE SWITCHING
For the physical implementation of code switching protocols on quantum processors, the underlying operations have to be constructed in a way that is resilient against noise.In this section, we aim at finding schemes that tolerate any single error on an arbitrary component of the circuit.Then, the probability that two components of the circuit fail at the same time and thus cause a logical failure is order p 2 , where p is the failure probability for a single component [6].For deterministic schemes, we should be able to correct for any single error reliably.In order to construct these FT code switching protocols, a set of criteria has to be fulfilled.
The first criterion is that the error configuration on the initial code also has to be correctable on the target code.For the color codes considered, it is possible to correct weight-three X-errors on the threedimensional code, while it is only possible to correct a single X-error on the two-dimensional code.Starting in a codestate of the three-dimensional code that contains a weight-three error configuration, this would initially be correctable.Assuming perfect switching, which does not introduce any additional errors, this error configuration would be transferred onto the two-dimensional code, where a weight-three error configuration can directly correspond to a logical operator.Therefore, we perform one round of Xerror correction with flag qubits before switching to the two-dimensional code.This corrects any previously present configuration with up to three X-errors and corrects for any single error that occurs during the EC procedure.
The second condition is that we have to be able to identify errors on data qubits.Specific errors on data qubits invert the outcome of the stabilizer measurements.If we cannot distinguish this inverted measurement outcome from the original information, we do not notice that an error has occurred and a logical error can be introduced, as illustrated in Fig. 7. Therefore, one does not directly achieve fault tolerance for code switching by simply using the concept of FT stabilizer measurements with flag qubits.Considering realistic circuitry with noisy components, it is necessary to consider these errors on data qubits as well.
In general, we can obtain the expectation value of an operator O, that has a transversal implementation on a given code, by coupling an ancilla qubit to the data qubits that participate in the measurement [66].Using this kind of circuit to extract the syndrome is, however, not FT because single faults can directly cause a logical failure.A single fault on FIG.6: Circuits for stabilizer measurements using flag qubits [52].(a) Circuit for measuring a weight-4 Pauli X-operator containing an ancilla qubit which is coupled to the data qubits that participate in the corresponding measurement.An additional flag qubit is coupled with CNOT-gates to the first ancilla.An X-error in the middle of the circuit, as depicted in red, propagates onto two data qubits and the flag qubit.Measuring the flag qubit in the end indicates that a potentially dangerous error has occurred.By performing an additional Z-face stabilizer measurement without flags afterwards, one can detect these errors and correct for them.Since an error before the second or after the next to last CNOT-gate only results in an error which is equivalent to a weight-1 error on the data qubits, this scheme is FT with respect to errors on the ancilla qubits.A Z-error during this X-plaquette measurement, as depicted in green, propagates onto the ancilla qubit, which changes the measured syndrome as illustrated in Fig. 7.In order to avoid applying a logical error, these errors on the data qubits have to be detected and corrected.(c) Circuit for measuring a weight-4 Pauli Z operator using an additional flag qubit.Analogously, Z-errors on the ancilla qubits are detected by the flag qubit and can be corrected by performing an additional stabilizer measurement.X-errors on the data qubits during the Z-face measurement can propagate and cause a logical failure.
(A) ancilla qubits during a stabilizer measurement, (B) data qubits before or during a stabilizer measurement, (C) a measurement of the ancilla qubit at the end of a stabilizer readout can induce a logical error, which we discuss in detail in the remainder of this section.

A. Errors on ancilla qubits
Single errors on the ancilla qubit can propagate onto data qubits.An X-error after the second CNOT-gate in the circuit shown in Fig. 6(a) propagates onto two data qubits.On the target Steane code, this results in a logical failure, since in the Steane code, only a single X-error is correctable.Analogously, Z-errors on the ancilla qubit during the measurement of a Z-stabilizer can lead to a logical error Z on the target code, since only a single Z-error is correctable in the [ [15,1,3]] tetrahedral stabilizer code.We can implement stabilizer measurements, which are FT with respect to these errors on ancillary qubits, using a flag-based measurement scheme, as depicted in Fig. 6.The concept of flag qubits was introduced in [52] and has, for example, been used for FT error correction in color codes in two and three dimensions [48,53,54] and the initialization of logical qubits [40][41][42].Again, an ancilla qubit is coupled to the data qubits via CNOT-gates and a flag qubit is coupled to the ancilla, as depicted in Fig. 6.If a dangerous fault occurs on the ancilla qubit during this measurement, it still propagates onto one or more of the data qubits, but it also propagates onto the flag qubit.In that case, the flag qubit will be measured in the −1-state in the end and indicates that a potentially dangerous error has occurred.
If a circuit flags, meaning that a flag qubit was measured in the corresponding −1-eigenstate, we still have to identify which error has occurred.The circuit could have flagged owing to a measurement error in the end, or to an error before the second to last CNOT-gate.Specifically, we have to check if the flag error leads to a logical failure.Here, these dangerous flag errors correspond to propagated weight-2 errors on the data qubits resulting from a single error on the ancilla qubit, as depicted in Fig. 6.In order to localize these errors, one additional Z-(X-) stabilizer has to be measured.After this additional measurement of a single stabilizer, the complete syndrome is measured again without flag qubits.Together with the information which circuit flagged before, the dangerous weight-2 errors can be identified and corrected.

B. Errors on data qubits
Errors on the data qubits can propagate onto the ancilla qubit and invert the measurement outcome, as illustrated in Fig. 6.Taking this inverted measurement outcome would cause us to apply the incorrect switching operation and can lead to a logical failure on the target code.
For example, a single Z-error on the top qubit 0 would invert the measurement outcome of the red plaquette, when switching from the tetrahedral code to the Steane code.We would then apply the according switching operation, as illustrated in Fig. 7(a).But owing to the inverted measurement outcome, we now introduce additional errors on the data qubits of the Steane code that overlap with the applied gauge operator.Together with the initial error, this can directly correspond to a logical operator on the Steane code.For FT code switching, these errors on data qubits have to be corrected.
To identify and correct for these errors on data qubits, one can exploit that the state should always be a +1-eigenstate of the complete cells.This means that, for switching from the [ [15,1,3]] code to the [ [7,1,3]] Steane code, the X-faces opposite of the measured Steane plaquettes have to agree with the measured Steane X-plaquette to also fulfill the cells.For example, considering the red cell, as illustrated in Fig. 3, the state is either in a +1-eigenstate of both S X R = X 0 X 3 X 6 X 7 and B X RY = X 1 X 2 X 4 X 5 or in a −1-eigenstate of both these operators so that the state is a +1-eigenstate of the corresponding cell, which is formed by these two opposing faces [61].If all three pairs of opposing faces agree, we know that either no data error or an error on the corner qubit of the yellow cell (qubit 8) has occurred and we can proceed.If we find some disagreement, we know that an error has happened on a specific pair of qubits.To localize the error, we measure the yellow X-cell.If we measure −1, we know that an the error has occurred on the corresponding qubit of the yellow cell and can correct for it and continue.If we find +1, we know that the error has occurred on the Steane code and update the syndrome accordingly.In practice, the bulk, which is formed by those data qubits of the tetrahedron that are not part of the Steane code (yellow cell), can be measured destructively to localize all potentially dangerous errors on the data qubits.
For switching back to the tetrahedral code afterwards, the bulk has to be in a specific state that corresponds to the +1-eigenstate of its cells and faces.To this end, the bulk has to be re-initialized into the correct state using the circuit given in Fig. 20.For switching from the Steane code to the [ [15,1,3]] code, we identify only three qubit positions on which a single X-error can lead to a logical failure indicated in Fig. 7(b), by numerically checking all possible error positions.We can distinguish these X-errors by measuring the complete Z-syndrome of the Steane code.To avoid further error propagation, we use the flag qubit scheme for this syndrome measurement.If a circuit flags, we measure one of the weight-eight Xcells using a single ancilla qubit to localize dangerous flag errors.After identifying the dangerous flag error, we remeasure the syndrome once without flags, to ensure that the syndrome contains the detected error.We can then update the syndrome according to the detected error correctly and continue.

C. Measurement errors
A single error on the measurement of the first ancilla qubit in the circuits in Fig. 6 would invert the measurement outcome and can lead to a logical failure after applying the corresponding switching operation.To achieve fault tolerance, we repeat the syndrome measurement and take a majority vote.If we obtain the same syndrome twice, we assume that no single measurement error has occurred and continue.If the syndromes are different, we repeat the syndrome measurement a third time, without a flag qubit, and proceed with the result of this last measurement.The probability that the measurement is incorrect two times is order p 2 , where p is the failure probability for a single measurement [6].

VI. NON-DETERMINISTIC FT CODE SWITCHING
The above deterministic schemes for code switching require a large number of gates, as summarized in Tab.I, and a large circuit depth due the additional checks that have to be performed.We propose nondeterministic schemes as more feasible alternatives on near-term devices.These schemes achieve lower failure rates than the deterministic protocols, due to effectively postselecting for errors and reducing the required number of CNOT-gates and, therefore, the circuit depth.However, postselecting results in a finite success rate, since a fraction of runs is discarded.These non-deterministic schemes allow, for example, the preparation of a magic state on a twodimensional color code with fewer resources than for the deterministic scheme while achieving lower logical failure rates.The methods we describe in the following are postselection and code morphing to an effective error detecting code.

A. Code switching with postselection
For FT switching between the Steane and the [ [15,1,3]] code, we check for potentially dangerous errors on data and ancilla qubits.As discussed in Sec.V, this is done by measuring extra stabilizers in addition to the gauge operators and using flag qubits.We now adjust the scheme to postselect for any detected error: whenever an error is detected, we now stop the protocol and discard the results.This includes flag qubits measured in the |1⟩or |−⟩-state and any disagreement in opposing faces for the data error check.By postselecting [67,68] for any detected error, a fraction of weight-2 or higher weight errors is sorted out, resulting in lower logical failure rates.The number of required qubits and two-qubit gates remains the same as for the fault-free deterministic protocols, since the exact same circuits are executed.

B. Code switching with morphed codes
Code morphing was introduced in [1] and is a method for generating new codes from existing ones by effectively turning the logical qubits of a sub-code, called the child code, into bare physical qubits.This new code inherits the logical gates of the parent code.By morphing a suitable code, it is possible to find a code that still has a fault-tolerant T-gate, but requires fewer qubits and has lower stabilizer weights, while the code distance is reduced.Therefore, the number of required CNOT-gates for the additional stabilizer measurements for error-checks can be reduced.This offers a more feasible alternative for code switching on current experimental setups.
One can invert the encoding circuit of the [ [8,3,2]] code, by reverting the order of gates and the direction of all CNOT-gates, and apply it to the tetrahedral code.Thereby, the three encoded qubits of the [ [8,3,2]] are replaced by bare, physical qubits, leaving the new morphed [ [10,1,2]] code, as illustrated in Fig. 8 and discussed in App. A. The new stabilizers of the morphed code can be derived by replacing the logical operators of the child code with the corresponding operators acting on the bare physical qubit.The previous weight-8 X-stabilizers of the parent code are turned into weight-5 cells on the morphed [[10, 1, 2]] code.We illustrate the weight-5 operators by placing one extra qubit in the center of the plaquettes of the Steane code, as depicted in Fig. 8 on the right.These are B ′X G = X 1 X 2 X 4 X 5 X 8 Three Z-stabilizers are defined on the plaquettes of the code, and three Z-stabilizers are defined on the extended plaquette intersections as The Z-stabilizers of the morphed code are defined on the three weight-4 plaquettes Z 0 Z 1 Z 2 Z 3 , Z 1 Z 2 Z 4 Z 5 and Z 2 Z 3 Z 5 Z 6 , as well as the three weight-3 operators Z 2 Z 5 Z 7 and Z 1 Z 2 Z 9 as well as By morphing a code, we can effectively trade off different code properties.In this case, we traded off the reduced stabilizer weights against code distance, since the morphed code is only an error detecting code with distance d ′ = 2.Note that code morphing is not physically executed but is a strategy to generate a new code that can be then used for code switching protocols.
The logical T-gate can be implemented on the [[10, 1, 2]] code using the circuit shown in Fig. 9(a).This implementation is not transversal anymore but fault-tolerant in the sense that all possible errors resulting from a single Z-error can be detected.All possible X-errors on qubits 7, 8 and 9, as for example X 7 X 8 X 9 , are correctable because the corresponding Z-syndromes do not coincide with any single-error configuration.Therefore, we can assign the syndromes to these higher weight X-errors and correct for them.This implementation of T can be under- In order to switch between the two stabilizer codes, first, the two codes must have a common representation of the logical operators and, secondly, a subsystem code with stabilizer group S has to be defined that suffices S ⊂ S [ [10,1,2]] and S ⊂ (S Steane , S bulk ).
The [[10, 1, 2]] code inherits the logical operators from its parent code, the 15-qubit tetrahedral code.Since the 15-qubit tetrahedral code and the Steane code have a common representation of their logical operators, this condition is consequentially also fulfilled for the [[10, 1, 2]] code.Furthermore, a suitable subsystem can be defined whose gauge group G is generated by the stabilizers of the [[10, 1, 2]] code, which includes the Z-plaquettes of the Steane code, and the single-qubit Pauli operators X 7 , X 8 and X 9 for the indexing given in Fig. 8.The stabilizer group S of the subsystem is then generated by the weight-5 X-and Z-cells of the [ [10,1,2]] code structure.
We can switch from the [ [10,1,2]] code to the Steane code by measuring the stabilizers of the Steane code, which are not fulfilled by the initial codestate in the [ [10,1,2]] code.These stabilizers are the X-plaquettes of the Steane code, since the [ [10,1,2]] code only fulfills the weight-5 X-cells and not the weight-4 X-plaquettes.After measuring the stabilizers of the target code, we apply combinations of the gauge operators , in order to fix the gauge state accordingly.
The FT switching scheme from the 15-qubit tetrahedral code to the Steane code, discussed in the previous section, can directly be adapted for the morphed code.The X-plaquettes of the Steane code are measured using flag qubits and errors on data qubits can, again, be detected by measuring opposing pairs of stabilizers in the subsystem.We only need to replace the bulk measurement with single-qubit measurements of qubits 7, 8 and 9 in the X-basis.If some disagreement between opposing pairs of stabilizers, as for example between X 7 and B ′X R = X 0 X 1 X 2 X 3 , is found, we have to discard the corresponding run because Z-errors on the data qubits cannot be uniquely identified in the subsystem which makes the protocol non-deterministic.
For switching from the Steane code to the [ [10,1,2]] code, we have to measure those stabilizers of the [[10, 1, 2]] code, which are not fulfilled in the Steane code.These are the weight-3 Zstabilizers on the extended intersections of plaquettes (B ′Z RB , B ′Z GB , B ′Z RG ).Based on the measurement outcome, we apply combinations of the Steane Xplaquettes.Since the stabilizers are of weight-3, any error on the ancilla qubit during these measurements may indeed propagate but is only equivalent to a single error on the data qubits.So, for a FT measurement of the weight-3 stabilizers, we do not need additional flag qubits.To check for errors on the data qubits that can lead to a logical failure, we measure the green and blue Z-plaquettes.If some error is discovered in this check, we discard this run.If no error is found, we take the measured Z-syndrome and continue.These measurements can also be performed without additional flag qubits, since every dangerous flag error is detectable on the target code.

VII. ERROR MODEL AND SIMULATION METHODS
In the following simulations, we investigate the logical failure rates p L for different protocols by performing Monte Carlo (MC) simulations.We consider circuit-level noise with a single error parameter p, which describes the error rates on each component.This includes single-and two-qubit gates, as well as measurements and initializations of physical qubits.Each circuit element is modeled as an ideal operation U ideal followed by an error E with the given probability Furthermore, faulty operators for measurements are placed before the ideal measurement location.We consider depolarizing noise channels on all singleand two-qubit gates, which are described by the noise operators [40,71,72] with the Pauli matrices σ k = {I, X, Y, Z} with k = 0, 1, 2, 3.The depolarizing channels are then determined by This means that, one of the 3(15) possible combinations of single(two)-qubit Pauli-errors is applied with a given probability p/3 (p/15).Qubits are prepared in |0⟩ and measured in the Z-basis.We model faults on these state preparations and measurements by applying X-errors after state preparations and before measurements each with a probability p.
The logical failure rate is determined as follows.At the end of each MC shot, we perform one round of ideal QEC on the noisy output states, which maps the state back into the codespace.Finally, we extract the expectation value of the corresponding logical operator ⟨O⟩ classically in software.This indicates that a logical error has occurred if we find an expectation value of −1.We realize n runs MC shots for each protocol and obtain the logical failure rate p L by averaging over all shots.
The uncertainties on the logical failure rates are calculated by taking the uncertainty of the mean value for a binomial distribution where n runs is the total number of simulation runs and p L is the estimated logical failure probability.We repeat each simulation 10 5 to 10 6 times, until the relative uncertainty on a given data point is smaller than 5%.Up to 10 6 shots are required for small physical error rates, where error events are rare.We use the package Pecos, which is a Python framework for studying, developing, and evaluating quantum error-correction protocols through numerically performing stabilizer or statevector simulations of noisy quantum circuits [73].

VIII. BUILDING BLOCKS USING FT CODE SWITCHING
We determine the logical failure rates for each block given in Fig. 2 by means of the above described simulation methods.This includes the initialization of the logical states |0⟩ and |+⟩ on the tetrahedral [ [15,1,3]] and the morphed [ [10,1,2]] code, FT switching in both directions to and from the [ [7,1,3]] Steane code, as well as the composite protocols specified in Fig. 2(c).These protocols implement the Hadamard-gate on the tetrahedral code, the T-gate on the Steane code and the preparation of a magic state on the Steane code via the morphed code.
For the initialization of logical states on the tetrahedral code [ [15,1,3]], we construct the FT circuits shown in Figs.18 and 19.For the FT initialization of a logical state on the morphed [ [10,1,2]] code, we design the circuits shown in Fig. 21.The logical failure rates for these protocols are shown in Fig. 10.In the regime of low physical error rates p → 0, we identify a quadratic scaling in the logical failure rate p L ∼ p 2 for the FT protocols and a linear scaling p L ∼ p for the Non-FT protocol.This indicates that for the Non-FT protocol, single errors result in a logical failure, whereas for the FT protocols only weight-2 error configurations contribute to p L .The logical failure rates for the initialization of the morphed [[10, 1, 2]] code is smaller than for the tetrahedral code.Since the circuit depth and the number of required gates for the [[10, 1, 2]] code is smaller, as summarized in Tab.I, there are fewer weight-2 error configurations that can contribute to the logical failure rate.Thus, the logical failure rates are lower than for the tetrahedral code, as can be seen in Fig. 10.
The figures 11a and b show the logical failure rates for FT switching with the tetrahedral code.Furthermore, we determine the logical failure rates for Non-FT code switching, where the corresponding three stabilizers are measured once without flags.A third simulation considers switching with the tetrahedral code while postselecting for any detected error.Whenever a flag is triggered, or an error on a data qubit is detected, the corresponding run is discarded and the protocol is restarted as discussed in Sec.VI A. For the morphed code, we determine the logical failure rates for FT switching, as well as for the Non-FT switching scheme.These protocols are non-deterministic, since the [ [10,1,2]] code is an error detecting code.For Non-FT switching, the stabilizers are measured once without flags.
The logical failure rates for FT switching from the tetrahedral [ [15,1,3]] code to the [ [7,1,3]] Steane code intersects with the logical failure rate for Non-FT switching for values at approximately p = 5 • 10 −3 .This crossing point is higher for the inverse direction at approximately p = 10 −2 .The X-error correction block for switching to the Steane code, which is necessary to achieve fault tolerance, requires many CNOT gates, as summarized in Tab.I.This increases the number of possible error configurations and, therefore, leads to an asymmetry between the two switching directions.Considering switching with the tetrahedral [ [15,1,3]] code, we observe that the Non-FT schemes achieve similar values for p L for both switching directions, while for the FT protocols, these rates differ.The Non-FT protocol is symmetric in the switching directions.In both cases, the three weight-4 stabilizers have to be measured and each Pauli error is equally likely in this error model.For the FT switching protocols, the directions are not symmetric.For Non-FT switching with the morphed [ [10,1,2]] code, the logical failure rates also differ.Non-FT switching from the [ [10,1,2]] code to the Steane code achieves higher logical failure rates than the inverse direction, since the stabilizer weights for the two directions differ.For switching to the Steane code, the weight-4 plaquettes are measured, where for example a single error on an ancilla qubit can cause a logical failure.For switching from the Steane code to the [ [10,1,2]] code, only the weight-3 stabilizers have to be measured.
The figures 11(c) and (d) show the acceptance rates for the non-deterministic protocols, which include switching with the tetrahedral code with postselection and FT switching with the morphed code.The acceptance rate indicates the number of runs that are not discarded due to an error-detection event divided by the total number of runs.For switching from the [ [7,1,3]] Steane code to the morphed [ [10,1,2]] code, a larger fraction of runs is accepted than for the corresponding protocol with the tetrahedral [ [15,1,3]] code.This is inverted for the reverse direction, while the relative difference between the acceptance rates decreases.
Figures 12(a) and (b) show the logical failure and acceptance rates for the gates that cannot be realized transversally in the corresponding codes but are necessary in order to complete the universal gate set.
] using a FT scheme that includes a verification step (green) and a Non-FT (NFT) scheme without this verification (blue), as well as on the morphed [ [10,1,2]] code (dark red).The logical failure rates for the Non-FT protocol scale linearly in the error parameter p, since single physical errors can result in a logical failure.For the FT initializations, we can identify a quadratic scaling in p, verifying that only two physical failures introduce a logical error.For the [[10, 1, 2]] code, lower failure rates are reached than for the initialization of the same state on the tetrahedral code.
For the Hadamard-gate on the tetrahedral [ [15,1,3]] code, first, switching to the [[7, 1, 3]] Steane code is applied, followed by a transversal Hadamard operation on the Steane code and switching back to the tetrahedral code.Analogously, the T-gate on the Steane code is implemented by switching to the tetrahedral code, applying the transversal T-gate and switching back to the initial code.Again, we consider FT protocols, as discussed in the previous sections, as well as Non-FT switching and a nondeterministic version of the corresponding protocol, which includes postselection for any detected error.
The FT protocols only outperform the Non-FT schemes for p ≤ 5 • 10 −3 , due to the large overhead that is required to achieve fault tolerance.Again, we observe that the failure rates for the Non-FT scheme on the tetrahedral code are similar for both operations.In this case, the switching cycles are symmetric, meaning that after the first switching step in one protocol, the probability for a given number of errors is the same as after the first switching step for the other protocol.For the FT protocols, these may differ, since the two switching directions include different operations and a different number of stabilizer measurements.Non-FT switching from the Steane code to the morphed [ [10,1,2]] code achieves lower logical failure rates than for the inverse direction.For switching from the Steane code, we only need to measure the weight-3 Z-stabilizers.Any error on the ancilla qubits may propagate but is always equivalent to a weight-1 error.For switching in the inverse direction, the weight-4 plaquettes have to be mea-sured requiring more two-qubit gates and giving rise to logical failures due to propagated errors on the ancilla qubits.
Figure 12(c) and (d) show the logical failure rates and acceptance rates for the preparation of a magic state on the Steane code using the morphed [ [10,1,2]] code.The logical failure rates scale quadratically, indicating that no single error results in a logical failure.The logical failure rate of the FT scheme surpasses the corresponding physical error rate at approximately p = 10 −2 , while keeping more than 50% of the runs below this point.
To summarize, we observe the characteristic quadratic scaling at low physical error rates for the constructed FT code switching protocols.In addition, we find that the Non-FT code switching protocol for switching from the [ [7,1,3]] Steane code to the morphed [ [10,1,2]] code achieves lower physical error rates than FT switching with the tetrahedral [ [15,1,3]] code for p ≤ 10 −3 .Furthermore, we estimate a breakeven point at a physical error rate of approximately 1 • 10 −2 with an acceptance rate of 50% for the preparation of a magic state on the Steane code using the morphed [ [10,1,2]] code.

IX. PROJECTED PERFORMANCE FOR TRAPPED-ION QUANTUM PROCESSORS
Noise on real devices cannot be described by a single-parameter noise model.Error rates can vary for different circuit components, for example the two-FIG.11: Logical failure rates and acceptance rates R for building blocks introduced in Fig. 2(b).(a) Logical failure rates for switching from the Steane code to the tetrahedral code using a fault-tolerant (FT, green) scheme, a Non-FT (NFT, blue) scheme and postselection (PS, purple), as well as for switching from the Steane code to the morphed code using a FT (dark red) and NFT (orange) scheme.The FT nondeterministic protocols achieve lower logical failure rates than the deterministic ones, while the FT scheme with the [ [10,1,2]] code performs best.The circuit depth of the required round of X-error correction on the tetrahedral code before switching to the Steane code is large, as summarized in Tab.I.For switching from the [ [10,1,2]] code, the circuit depth of one round of X-error correction is a factor of 3 smaller, which reduces the number of potential error locations and, therefore, lowers the logical failure rate.(b) Logical failure rates for switching from the tetrahedral code to the Steane code using a FT (green) scheme, a Non-FT (blue) scheme and postselection (purple), as well as for switching from the morphed code to the Steane code using a FT (dark red) and Non-FT (orange) scheme.Switching from the [ [10,1,2]] code achieves lower failure rates for p > 10 −3 , even for the Non-FT scheme.(c) Acceptance rates R for switching from the Steane code to the [ [15,1,3]] code and the [[10, 1, 2]] code using non-deterministic protocols.The acceptance rates for the [[10, 1, 2]] code are slightly smaller than for the [ [15,1,3]] code in the considered range of the physical error rate p.(d) Acceptance rates R for the inverse switching direction.The acceptance rates for the [[10, 1, 2]] code are higher than for the [ [15,1,3]] code in the considered range of the physical error rate p. qubit gate error rates are typically higher than those of other error sources.In order to estimate the projected performance on near-term trapped-ion quantum processors, we consider a multi-parameter noise model with different errors rates for each type of circuit component [26,40,74,75].
We simulate a Hadamard-gate for the tetrahedral code, a T-gate for the Steane code and the prepa-ration of a magic state on the Steane code using a modified noise model inspired by current ion trap processors.Instead of using a single error parameter p, we use multiple parameters to describe noise on different components of the circuit.We specify the depolarizing channel on single-qubit gates with a parameter p 1 and on two-qubit gates with p 2 .Faulty measurements and initializations are modeled with FIG.12: Logical failure rates for logical operations illustrated in Fig. 2(c).The logical failure rates are averaged over different initial states for the Non-FT (blue), FT (green) and postselected (PS, purple) implementation of (a) the Hadamard-gate on the tetrahedral [ [15,1,3]] code and (b) the T-gate on the Steane code.The Non-FT implementations of both gates achieve similar logical failure rates, while the FT versions perform worse for the T-gate than for the Hadamard-gate.Note that for a specific input state, these failure rates may look different.Different states are sensitive to different kinds of errors and the amount of dangerous error positions throughout the protocols varies for each type of error.(c) Logical failure rates for the preparation of the magic state T |+⟩ on the [ [7,1,3]] Steane code using the morphed [ [10,1,2]] code for the Non-FT (orange) and FT (red) scheme.The grey dotted line corresponds to the physical error rate p.For p < 10 −2 , the FT scheme the logical failure rate is smaller than p.(d) Acceptance rates R for magic state preparation via the morphed [ [10,1,2]] code.For p < 10 −2 , more than half of the runs is accepted.faults with a probability p m and p i , respectively, with which the state of the qubit is inverted.In the following simulations, we choose parameter values based on recent benchmarks on ion trap processors [20] as p 1 = 1 • 10 −4 , p 2 = 3 • 10 −3 , p i = 1 • 10 −3 and p m = 1•10 −3 .A detailed discussion on the modeling of noise in ion traps [20,71,72] is beyond the scope of this work.x Fig. 13(a) shows the averaged logical failure rates for deterministic gates using code switching protocols.We find a logical failure rate of 2.62 • 10 −2 ± 0.05 • 10 −2 for the deterministic Hadamard-gate on the tetrahedral [ [15,1,3]] code and a failure rate of 3.01•10 −2 ±0.06•10 −2 for the deterministic T-gate on the Steane code for this noise model.Both these values are much larger than the estimated corresponding physical error rate, but are comparable to recent benchmarks on trapped-ion setups [20,40,42].The projected performance for deterministic Hadamard-(left) and T-gate (right) is estimated for current ion trap setups [26].These protocols correspond to the two left composite column in Fig. 2(c).The shown logical failure rates are calculated for an ideal input state.The left bar corresponds to the averaged logical failure rate of p L = 2.62 • 10 −2 ± 0.05 • 10 −2 for a Hadamard-gate on the [ [15,1,3]] tetrahedral code via the Steane code.For the T-gate on the Steane code, we obtain slightly higher failure rates of p L = 3.01•10 −2 ±0.06•10 −2 .The black dashed line corresponds to the failure rate of the according sequence for a single physical qubit.For both logical gates, the determined logical failure rate on near-term ion trap processors is still more than one order of magnitude larger than the expected rate for a single physical qubit.(b) Logical failure rates for the preparation of the magic state T |+⟩ on the Steane code on a logarithmic scale.These protocols correspond to the composite column in Fig. 2 In order to compare our results to existing methods, we simulate the preparation of a magic state on the Steane code using a state-of-the-art method [40][41][42].Here, the magic state is prepared non-faulttolerantly on the Steane code, followed by a measurement of a logical operator and one round of error detection on the Steane code.For this implementation, we find p L = 1.0 • 10 −2 • 10 −2 ± 3 • 10 −3 • 10 −2 .We observe that the logical failure rates using the morphed [ [10,1,2]] code are of similar order of magnitude as this state-of-the-art magic state preparation on the Steane code [40,65].
The logical failure rates shown in Fig. 13 are averaged over different initial input states.However, the number of Pauli X-and Z-error configurations that cause a logical failure may vary, depending on the direction of switching and the given input state.on the tetrahedral code is inherently less sensitive to these errors on data qubits than on the initial state |+⟩.Furthermore, |0⟩ is an eigenstate of the T-gate, so it is expected that logical failure rates are lower than for other states, in agreement with recent experimental observations [40].To estimate the impact of an imperfect initialization, we determine the logical failure rates for the same protocols including a noisy initialization as shown in Fig. 14(b).The initializations are implemented using the circuits shown in Fig. 18, 19, 20, 21 and 22.Including a noisy initialization increases p L by a factor of approximately 1.1.This indicates that the logical failure rate is dominated by the noisy switching procedure, rather than by the noisy initialization of logical input states.
We identify the parameters p 2 as a limiting factor for the above code switching schemes.It is the largest value in our noise model and the number of two-qubit gates is much higher than for any other component.In order to estimate the sensitivity of the considered protocols to changes in p 2 , we choose p 1 = p i = p m = 0 and only vary the two-qubit gate parameter p 2 .Fig. 15 shows the averaged logical failure rates for the composite protocols as specified in Fig. 2(c) for this noise model.The logical failure rate for the initial value of p 2 = 3 • 10 −3 for the Hadamard-gate is p L = 2.4 • 10 −2 and for the T-gate p L = 2.5 • 10 −2 .This is close to the logical failure rates for the above noise model, where we included errors on single-qubit operations.This is in alignment with the expectation that faulty single-qubit operations have a minor impact on the logical failure rate and the probability for errors on two-qubit gates p 2 is the limiting parameter.Furthermore, we observe that an improvement of a factor of 5 should suffice to reach the regime of the corresponding phys-ical error rate for a FT non-deterministic magic state preparation, as shown in Fig. 15(b) on the left.
Overall, we report that the morphed [[10, 1, 2]] code can reduce the logical failure rates by up to two orders of magnitude compared to the tetrahedral [ [15,1,3]] code, as for example for magic state preparation shown in Fig. 13.Furthermore, the FT deterministic logical gates are within reach of recently proposed implementations [40,42,65].

X. CONCLUSIONS AND OUTLOOK
In this work, we have constructed fault-tolerant (FT) code switching protocols that enable the implementation of a FT universal gate set on the logical level.We provide specific instructions for the implementation of code switching protocols based on FT building blocks offering multiple methods as summarized in Fig. 2. Composite code switching protocols can be constructed from this suite by composing building blocks in ways that are most suitable and optimized for given experimental setups.Based on current ion trap quantum processors, we estimate the performance of code switching protocols on near-term devices using a multi-parameter noise model and find that the logical failure rates reach values on par with state-of-the-art magic state injection [26,40].
A study comparing the overhead and thresholds for preparing magic states on the Steane code us- ing magic state distillation (MSD) and deterministic code switching does not find an advantage in using code switching over MSD for this task [65].We complement this study by considering morphed codes.As demonstrated in our work, stabilizer weights and, therefore, the circuit depth of a given protocol can be reduced by replacing the distance-three tetrahedral color code with the respective morphed code.This can be generalized by morphing tetrahedral color codes with higher distances [1] and might offer a more feasible alternative for magic state preparation on larger codes.
Our numerical results provide a basis for the experimental realization of code switching protocols on existing or near-term quantum processors.Our protocols are readily implementable in architectures offering all-to-all qubit connectivity, such as e.g. in ion trap quantum processors [76,77].It would be interesting to adapt the protocols and also consider connectivity of other platforms, in particular nearest neighbor connectivity of superconducting qubits [78] or dynamically reconfigurable quantum registers of neutral atom processors [33,79] or shuttling-based trapped-ion architectures [76,80].We emphasize that the proposed protocols and quantum circuit constructions are not limited to low-distance codes, but can be readily leveraged to scalable larger-distance two-and three-dimensional color codes.Furthermore, tailoring FT code switching to setups with biased noise [81][82][83] offers the potential of reaching even lower logical failure rates for suitable experimental systems with such noise characteristics.ing (ML4Q) EXC 2004/1" 390534769.This research is also part of the Munich Quantum Valley (K-8), which is supported by the Bavarian state government with funds from the Hightech Agenda Bayern Plus.This research is also supported by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via the U.S. Army Research Office through Grant No. W911NF-16-1-0070.The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily repre-senting the official policies or endorsements, either expressed or implied, of the ODNI, IARPA, or the U.S. Government.The U.S. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright annotation thereon.Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the view of the U.S. Army Research Office.The numerical simulations were performed with the aid of computing resources at Forschungszentrum Jülich.
FIG. 16: Encoding of a logical state |ψ 1 ψ 2 ψ 3 ⟩ on the [ [8,3,2]] code.We construct this circuit by initializing a +1-eigenstate of all stabilizers, as given in Eq.A2 and coupling qubits 0, 1 and 2, which are in state |ψ 1 ⟩, |ψ 2 ⟩ and |ψ 3 ⟩, to the qubits to the corresponding logical operator.[15,1,3]] code into the [ [10,1,2]].We find this circuit by inverting the encoding circuit of the child [ [8,3,2]] code and applying it to the yellow cell of the tetrahedral code for the indexing specified in Fig. 3(b).The marked qubits are effectively decoupled from the remaining 10 qubits.[15,1,3]].We obtain this circuit using the Latin rectangle method [84].A verification step is added in order to achieve fault tolerance.This verification corresponds to the measurement of a logical Z = Z 2 Z 5 Z 14 and detects all incorrectable weight-four X-errors that result from a single propagated error.In total, 25 CNOT-gates and 16 qubits are required to fault-tolerantly initialize |0⟩.[15,1,3]].We construct this circuit using the Latin rectangle method [84].In this case, the verification step corresponds to the measurement of a logical X = X 1 X 3 X 5 X 7 X 9 X 12 X 13 and it detects all incorrectable weight-two Zerrors that result from a single propagated error.In total, 32 CNOT-gates and 16 qubits are required to fault-tolerantly initialize |+⟩.[15,1,3]] code.Since the bulk has to be prepared in a specific state but does not encode any information, there is no logical operator that can be used in a verification step.Therefore, two stabilizers have to be measured in order to verify the resulting state.We choose the stabilizers X 1 X 4 X 8 X 12 and X 1 X 2 X 4 X 5 in order to detect weight-two Z-errors on the data qubits, which would result in a logical failure on the target [ [15,1,3]] code.(b) Indexing of the bulk qubits used for the encoding circuit in alignment with the previous sections.[40,41].The logical operator Z = Z 0 Z 2 Z 5 is measured in order to detect all single errors that propagate and would cause a logical failure.

FIG. 2 :
FIG. 2: Codes and FT building blocks used to compose FT code switching protocols.(a) The tetrahedral [[15, 1, 3]] code (top) contains 15 physical qubit, encodes one logical qubit and has distance three.The two-dimensional [[7, 1, 3]] Steane code (center) consists of 7 physical qubits and has the same distance and number of logical qubits.The morphed [[10, 1, 2]] code (bottom) is made up of 10 physical qubits, encodes a single logical qubit, but is a distance-two code, so arbitrary single errors are detectable, yet not correctable.When constructing code switching schemes, we distinguish between deterministic and non-deterministic protocols.Deterministic protocols are implemented using the tetrahedral code, correcting for any single error in each block.Non-deterministic protocols include postselecting during switching and replacing the tetrahedral code with the error detecting morphed [[10, 1, 2]] code.(b) FT building blocks for the considered codes.These include the unitary initialization of logical states on the considered codes (left).The unitary encoding circuits are given in Fig. 18, 19, 20 and 21.The central blocks represent FT switching to and from the [[7, 1, 3]] Steane code.The X-EC block represents one round of X-error correction, which is required when switching to the two-dimensional code.In the illustrated blocks, each tetrahedron can be replaced by the morphed [[10, 1, 2]] code to obtain the corresponding block for the morphed code.(c) The FT building blocks illustrated in (b) can be combined into FT protocols.The logical FT Hadamard-gate for the tetrahedral [[15, 1, 3]] code (left) can be implemented by, first, switching to the Steane code, then, applying the transversal Hadamard-gate and, lastly, switching back to the tetrahedral code.Similarly, the T-gate for the [[7, 1, 3]] Steane code (center) can be realized by switching to the three-dimensional code, applying the transversal T-gate and switching back to the Steane code afterwards.These two protocols correspond to deterministic FT logical operations, which are not restricted to specific input states.The right column represents the preparation of a magic state on the [[7, 1, 3]] Steane code with the morphed [[10, 1, 2]] code.After initializing the logical |+⟩-state on the morphed code, a reduced round of X-error detection is applied.Then, a FT T-gate is applied to the morphed code, followed by FT switching to the [[7, 1, 3]] Steane code.

FIG. 3 :
FIG.3: Illustration of the two-and threedimensional distance-three color codes.(a)The [[7,1,3]] Steane code consists of seven qubits (black dots) forming a green, red and blue plaquette (colored faces).The X-and Z-type stabilizers S σ col of color {R, G, B} are defined as σ = X, Z Pauli operators applied to the qubits that form the given plaquette.For example, the red X-stabilizer corresponds to S X R = X 0 X 1 X 2 X 3 .The logical operators can be implemented by applying X and Z to one edge of the triangle, for example to qubits 4, 5 and 6.(b) The 15-qubit tetrahedral code [[15,1,3]] has distance three, encodes one logical qubit and consists of 15 qubits (black dots), which form threedimensional units.These units are called cells and are labeled with the colors red, blue, green and yellow.Each cell is formed by eight qubits and shares two-dimensional boundaries (faces) with three adjacent cells.Four X-stabilizers B X c are defined on the cells c ∈ {R, B, G, Y } of the code, as for example the red X-stabilizer B X R = X 0 X 1 X 2 X 3 X 4 X 5 X 6 X 7 .Ten independent Z-stabilizers B Z f are defined on the faces f ∈ {R, B, G, Y, RB, RG, RY, BG, BY, GY } of the code, as for example the red-yellow Z-stabilizerB Z RY = Z 1 Z 2 Z 4 Z 5 .The faces contain four qubits and can lie within the tetrahedron, or on the boundary of the tetrahedron.The logical X-operator has minimum weight 7 and can be implemented by applying Pauli X-operators to one side of the tetrahedron, as for example the red-blue-green seven-qubit side on the right.The logical Z-operator has minimum weight 3 and can be implemented by applying Pauli Z-operators to one edge of the tetrahedron, as for example to qubits 10, 13 and 14.

FIG. 4 :
FIG. 4: Bipartition for the implementation of a transversal T-gate on the tetrahedral [[15, 1, 3]] code.The vertices in the [[15,1,3]] code can be partitioned into two sets, so that vertices connected by an edge belong to different sets[60].Given this kind of bipartition, a T-gate can be implemented transversally by applying single T-gates to the qubits on the pink positions and T † to qubits on the brown positions.
leaving the logical state |ψ⟩ unchanged and only affecting the gauge state |g⟩ G .Thereby, equivalent codestates can be generated by applying elements of G \ S without changing the encoded information.A logical gate L can affect both the logical state and the gauge state, while preserving the codespace[44]

FIG. 5 :
FIG. 5: Illustration of the stabilizer groups of two stabilizer codes A and B within the same subsystem code.The stabilizer groups of a stabilizer code S A and S B are part of the gauge group of the corresponding subsystem code G with its center S. Both codes S A and S B contain S. Therefore, codestates in A and B can be written as tensor products in the subsystem |ψ⟩ A = |ψ⟩ ⊗ |g A ⟩ G and |ψ⟩ B = |ψ ′ ⟩ ⊗ |g B ⟩ G .

FIG. 7 :
FIG. 7: Error configurations on data qubits that can lead to a logical failure.(a) Consider switching from the 15-qubits tetrahedral code to the target Steane code, which lives on the seven qubits forming the right three-plaquette triangle of the tetrahedron.To transfer the encoded information to the Steane code, we measure the three X-plaquettes of the Steane code.If for example a Z-error has occurred on the top qubit of the red cell (large green position on the left) before the measurement, this inverts the measurement outcome of the corresponding plaquette.If we originally had measured the syndrome (S X R , S X B , S X G ) = (0, 0, 0), we would now find (S X R , S X B , S X G ) = (1, 0, 0).Based on this measurement outcome, we would apply B Z BG to switch to the Steane code (center).If we then consider the Steane code (right), we effectively applied Pauli Z-operations to the three qubits on the large green positions.This directly corresponds to a logical Z on the Steane code and results in a logical failure.(b) The three positions where a single X-error leads to a logical failure when switching from the Steane code to the tetrahedral code are depicted in red.

FIG. 8 :
FIG. 8: Morphing the tetrahedral [[15, 1, 3]] into the [[10, 1, 2]] error detecting code.One can morph the tetrahedral [[15, 1, 3]] code with the yellow cell [[8, 3, 2]], contained in the initial parent code.By taking the encoding circuit of the [[8, 3, 2]] child code and applying its inverse to a codestate of the [[15, 1, 3]] parent code, 5 qubits are decoupled while keeping the encoded information in the remaining qubits.The encoding circuit and the inverted operation are discussed in App. A. This morphing effectively reduces the number of qubits and the stabilizer weights while reducing the distance.Three physical qubits of the yellow cell remain in the final morphed code, which are depicted in the center of the plaquettes as qubits 7, 8 and 9.We obtain the [[10, 1, 2]] code, which has new stabilizers of lower weight than the tetrahedral parent code.Instead of the weight-8 cells of the parent code, the cells of the morphed [[10, 1, 2]] code now have weight 5 withB ′X R = X 0 X 1 X 2 X 3 X 7 , B ′X B = X 2 X 3 X 5 X 6 X 9 and B ′X G = X 1 X 2 X 4 X 5 X 8 .The Z-stabilizers of the morphed code are defined on the three weight-4 plaquettes Z 0 Z 1 Z 2 Z 3 , Z 1 Z 2 Z 4 Z 5 and Z 2 Z 3 Z 5 Z 6 , as well as the three weight-3 operators Z 2 Z 5 Z 7 and Z 1 Z 2 Z 9 as well as Z 2 Z 3 Z 8 .

FIG. 9 :
FIG.9: Implementation of the FT logical Tgate for the[[10, 1, 2]] code[1] .Single T-and T †gates are applied to qubits 0−6 and a CCZ operation is applied to the three qubits in the center of the plaquettes.The CCZ-gate on qubits 7, 8 and 9 can be decomposed into single-qubit and CNOT-gates[70] using the implementation given on the right.This implementation of T with a three-qubit gate is still fault-tolerant even though errors on qubits 7, 8 or 9 can propagate onto other data qubits.Any Z-error on these qubits is detectable and all possible X-errors on these qubits are correctable.

FIG. 10 :
FIG. 10: Logical failure rates for the initialization of logical states illustrated in Fig. 2(b).The logical failure rates are shown for the initialization of (a) |0⟩ and (b) |+⟩ on the tetrahedral code [[15,1,3]] using a FT scheme that includes a verification step (green) and a Non-FT (NFT) scheme without this verification (blue), as well as on the morphed [[10,1,2]] code (dark red).The logical failure rates for the Non-FT protocol scale linearly in the error parameter p, since single physical errors can result in a logical failure.For the FT initializations, we can identify a quadratic scaling in p, verifying that only two physical failures introduce a logical error.For the[[10, 1, 2]] code, lower failure rates are reached than for the initialization of the same state on the tetrahedral code.

Fig. 13 ( 2 FIG. 13 :
FIG.13: Projected performance of logical operations on trapped ion quantum processors.(a) The projected performance for deterministic Hadamard-(left) and T-gate (right) is estimated for current ion trap setups[26].These protocols correspond to the two left composite column in Fig.2(c).The shown logical failure rates are calculated for an ideal input state.The left bar corresponds to the averaged logical failure rate of p L = 2.62 • 10 −2 ± 0.05 • 10 −2 for a Hadamard-gate on the [[15,1,3]] tetrahedral code via the Steane code.For the T-gate on the Steane code, we obtain slightly higher failure rates of p L = 3.01•10 −2 ±0.06•10 −2 .The black dashed line corresponds to the failure rate of the according sequence for a single physical qubit.For both logical gates, the determined logical failure rate on near-term ion trap processors is still more than one order of magnitude larger than the expected rate for a single physical qubit.(b) Logical failure rates for the preparation of the magic state T |+⟩ on the Steane code on a logarithmic scale.These protocols correspond to the composite column in Fig.2(c) on the right, including a noisy initialization, a noisy application of the T-gate and noisy switching to the Steane code.For the tetrahedral [[15,1,3]] code (left) with postselection, we obtain p L = 1.13 • 10 −2 ± 0.02 • 10 −2 at an acceptance rate of R = 76%.Using the morphed [[10,1,2]] code (center) yields p L = 1.6 • 10 −4 ± 2 • 10 −5 with an acceptance rate of R = 82%.HMS corresponds to the preparation of a heralded magic state on the Steane code using a state-of-the-art FT implementation[40].For this scheme, we obtain p L = 1.0 • 10 −4 ± 3 • 10 −5 with an acceptance rate of R = 85%.
FIG.13: Projected performance of logical operations on trapped ion quantum processors.(a) The projected performance for deterministic Hadamard-(left) and T-gate (right) is estimated for current ion trap setups[26].These protocols correspond to the two left composite column in Fig.2(c).The shown logical failure rates are calculated for an ideal input state.The left bar corresponds to the averaged logical failure rate of p L = 2.62 • 10 −2 ± 0.05 • 10 −2 for a Hadamard-gate on the [[15,1,3]] tetrahedral code via the Steane code.For the T-gate on the Steane code, we obtain slightly higher failure rates of p L = 3.01•10 −2 ±0.06•10 −2 .The black dashed line corresponds to the failure rate of the according sequence for a single physical qubit.For both logical gates, the determined logical failure rate on near-term ion trap processors is still more than one order of magnitude larger than the expected rate for a single physical qubit.(b) Logical failure rates for the preparation of the magic state T |+⟩ on the Steane code on a logarithmic scale.These protocols correspond to the composite column in Fig.2(c) on the right, including a noisy initialization, a noisy application of the T-gate and noisy switching to the Steane code.For the tetrahedral [[15,1,3]] code (left) with postselection, we obtain p L = 1.13 • 10 −2 ± 0.02 • 10 −2 at an acceptance rate of R = 76%.Using the morphed [[10,1,2]] code (center) yields p L = 1.6 • 10 −4 ± 2 • 10 −5 with an acceptance rate of R = 82%.HMS corresponds to the preparation of a heralded magic state on the Steane code using a state-of-the-art FT implementation[40].For this scheme, we obtain p L = 1.0 • 10 −4 ± 3 • 10 −5 with an acceptance rate of R = 85%.

Fig. 14 (
Fig. 14(a) shows the failure rates for the deterministic Hadamard-and T-gate for ideal logical input states |0⟩ and |+⟩.We observe that the failure rates for the logical input state |+⟩ are higher than for the input state |0⟩.Considering the Hadamard-gate, this can be explained by looking at the dangerous Pauli error positions on data qubits.As discussed in Sec.V, Pauli Z-errors on data qubits can induce a logical failure when switching from the tetrahedral [[15, 1, code to the [[7, 1, 3]] Steane code.Analogously, Pauli X-errors on data qubits can cause a logical failure when switching from the Steane code to the tetrahedral code.For the initial state |0⟩, Pauli Z-errors do not affect the encoded state, since Z|0⟩ = |0⟩.After switching to the Steane code, the state is changed to |+⟩ by applying the Hadamardgate on the Steane code.The dangerous Pauli Xerrors during the second switching step do not affect this encoded state.So, the Hadamard-gate on |0⟩on the tetrahedral code is inherently less sensitive to these errors on data qubits than on the initial state |+⟩.Furthermore, |0⟩ is an eigenstate of the T-gate, so it is expected that logical failure rates are lower than for other states, in agreement with recent experimental observations[40].

FIG. 15 :
FIG. 15:Scaling of logical failure rates with the two-qubit gate noise parameter p 2 for different protocols.(a) Averaged logical failure rates for the deterministic Hadamard-gate on the [[15,1,3]] tetrahedral code and the deterministic T-gate on the Steane code according to the protocol specified in Fig.2(c) given an ideal logical input state.The parameters p 1 , p i and p m are set to 0 and p 2 is reduced by a factor n for n = 1, 2, 5, 10.At the initial value of p 2 , we find a logical failure rate of p L = 2.41 • 10 −2 ± 0.05 • 10 −2 for the Hadamard-gate and p L = 2.79 • 10 −2 ± 0.07 • 10 −2 for the T-gate.The black dots correspond to the physical error rate of p2 n .The logical failure rates are larger than this physical error rate for the considered variation in p 2 .(b) Averaged logical failure rates for the preparation of a magic state on the Steane code on a logarithmic scale as specified in Fig.2(c).The preparation of the magic state includes the noisy initialization of the [[15,1,3]] (left) and[[10, 1, 2]] (right) code, the application of the FT T-gate and switching to the [[7,1,3]] Steane code.We consider the same variation in the parameter p 2 for p 1 = p i = p m = 0.At the initial value of p 2 , we find a logical failure rate of p L = 9.34 • 10 −3 ± 0.20 • 10 −3 for the [[15,1,3]] code and p L = 1.34 • 10 −4 ± 0.17 • 10 −4 for the[[10, 1, 2]] code.For magic state preparation using the tetrahedral [[15,1,3]] code and postselection, the logical failure rates succeeds the corresponding physical failure rate at p2 5 , while for the morphed [[10,1,2]] code, p L is already below this rate for the initial value of p 2 .

FIG. 17 :
FIG. 17: Circuit for morphing the [[15,1,3]] code into the [[10,1,2]].We find this circuit by inverting the encoding circuit of the child [[8,3,2]] code and applying it to the yellow cell of the tetrahedral code for the indexing specified in Fig.3(b).The marked qubits are effectively decoupled from the remaining 10 qubits.

FIG. 18 :
FIG.18: Circuit for the initialization of |0⟩ on the 15-qubit tetrahedral code [[15,1,3]].We obtain this circuit using the Latin rectangle method[84].A verification step is added in order to achieve fault tolerance.This verification corresponds to the measurement of a logical Z = Z 2 Z 5 Z 14 and detects all incorrectable weight-four X-errors that result from a single propagated error.In total, 25 CNOT-gates and 16 qubits are required to fault-tolerantly initialize |0⟩.

FIG. 19 :
FIG.19: Circuit for the of |+⟩ on the 15-qubit tetrahedral code [[15,1,3]].We construct this circuit using the Latin rectangle method[84].In this case, the verification step corresponds to the measurement of a logical X = X 1 X 3 X 5 X 7 X 9 X 12 X 13 and it detects all incorrectable weight-two Zerrors that result from a single propagated error.In total, 32 CNOT-gates and 16 qubits are required to fault-tolerantly initialize |+⟩.

FIG. 20 :
FIG.20: Circuit for preparing the bulk for code switching.(a) Encoding circuit of the initialization of the bulk (yellow cell) for switching from the Steane code to the tetrahedral [[15,1,3]] code.Since the bulk has to be prepared in a specific state but does not encode any information, there is no logical operator that can be used in a verification step.Therefore, two stabilizers have to be measured in order to verify the resulting state.We choose the stabilizers X 1 X 4 X 8 X 12 and X 1 X 2 X 4 X 5 in order to detect weight-two Z-errors on the data qubits, which would result in a logical failure on the target [[15,1,3]] code.(b) Indexing of the bulk qubits used for the encoding circuit in alignment with the previous sections.

TABLE I :
Required resources for FT building blocks used for composing FT code switching protocols as illustrated in Fig.2.The center column indicates the number of qubits which are required for a given block.The right So, in the subsystem code, |ψ⟩ A and |ψ⟩ B only differ in their gauge state |g A ⟩, |g B ⟩. Elements of G \ S only affect the gauge state and leave the logical state unchanged.These elements can be used to fix the gauge state from |g A ⟩ to |g B ⟩ or vice versa, while leaving the logical state unchanged.Now, let us consider switching from code A to code B. First, those stabilizers of the target code B, which are not fulfilled initially, have to be measured.This measurement projects the state randomly into a ±1-eigenstate of the measured stabilizer.Secondly, elements of G \ S are applied, which only affect the gauge state, to force the gauge state into the corresponding state |ψ⟩ B = |ψ⟩ ⊗ |g B ⟩ G .