Rewiring Stabilizer Codes

We present an algorithm for manipulating quantum information via a sequence of projective measurements. We frame this manipulation in the language of stabilizer codes: a quantum computation approach in which errors are prevented and corrected in part by repeatedly measuring redundant degrees of freedom. We show how to construct a set of projective measurements which will map between two arbitrary stabilizer codes. We show that this process preserves all quantum information. It can be used to implement Clifford gates, braid extrinsic defects, or move between codes in which different operations are natural.


Introduction
Although there is broad agreement that quantum mechanics can provide an important resource for computation, the community continues to search for the best way to exploit that resource. Here we describe a tool which can be incorporated into a number of quantum information processing architectures, and we show how it can be applied to solve important problems such as giving access to a universal set of transversal gates and braiding non-abelian anyons.
Our approach is framed in the language of quantum stabilizer codes. These are approaches to quantum error correction in which k logical qubits are stored in n physical qubits (quantum spins or other two level systems): the remaining degrees of freedom are restricted by requiring that the allowed wavefunctions (those in the codespace) are eigenstates of n−k given stabilizer operators. These stabilizer operators define the code.
Given two arbitrary stablilizer codes, we show how to construct a sequence of measurements which map the codespace of one code into the codespace of the other while preserving the quantum information. Under appropriate circumstances this mapping is fault-tolerant. The utility of such rewiring has been recognized by the community, and our arguments build on ideas of "code deformation" [1,2] (which involves small rewirings of topological codes) and "code conversion" [3,4]. This latter strategy has also been termed "code switching" [5,6], and typically is based on a sequence of unitary gates. Our contribution is the construction of a general algorithm for finding a sequence of projective measurements which allow arbitrarily large deformations. As with the previously studied cases, rewiring can be used to implement quantum gates: a cyclic rewiring generically acts as a rotation in the codespace. We explicitly construct the unitary matrix that corresponds to the gate.
One motivator for mapping between codes is the realization that the amount of resources needed to perform different gates depends on the code. Recently, Paetznick and Reichardt [7] noted that this disparity can be taken advantage of by mapping between codes. Specifically, a mapping can thereby produce a universal set of gates which have a particularly simple structure, described as "transversal". Transversal operations are naturally fault-tolerant, but there is no single code that admits a universal set of transversal gates [8]. To overcome this, Anderson, et. al. [9] proposed a quantum circuit which maps between the 7-qubit Steane code and the 15-qubit Reed-Muller code. The former admits transversal Cifford gates, while the latter admits transversal T and control-control-Z gates. Subsequently, several authors proposed other circuits for this mapping [10,11]. Our algorithm provides a systematic approach to this, and related, problems. We illustrate its utility by producing a mapping between the Steane and Reed-Muller codes. The resulting circuit is particularly simple, involving only measuring stabilizer generators of the other code, and is fault-tolerant.
Our algorithm fits in with a long tradition of using measurement to manipulate quantum information. Measurement is a key piece of any quantum circuit, and there are well known computing architectures which consist primarily of repeated measurements [12][13][14][15][16][17][18][19][20][21]. These algorithms are often discussed within the stabilizer formalism [21] and can be interpreted as rewiring stabilizer codes. In this context, we emphasize that our innovation is not the basic idea that one can use projective measurements to map between codes, but rather the explicit construction of the sequence of measurements.
Beyond its application to quantum computing, our algorithm can be used to enable the study of novel collective effects of interest to condensed matter physics. A physical realization of a quantum stabilizer code can be considered a Hamiltonian system where the Hamiltonian is simply the projector onto the codespace. Kitaev has argued that this mapping allows the observation of anyons (excitations which behave as particles with statistics that are neither fermionic nor bosonic [22]). Using our code rewiring algorithm, we show how to braid non-abelian twist defects, allowing the first direct observation of non-abelian quasiparticle statistics. Such "quantum emulation" experiments would be highly impactful.

Stabilizer Codes
A stabilizer code stores k logical qubits in n physical qubits by specifying that a physical state is an eigenstate of n − k given stabilizer operators (generators) with eigenvalue 1. The space of physical states is denoted the codespace. The stabilizer generators (g 0 , g 1 , . . . g n−k−1 ∈ G) are typically taken to belong to the Pauli groupmeaning that they are products of Pauli operators (I, X, Y, Z) acting on the physical qubits. They therefore all have eigenvalues ±1. The generators should be independent, and the space generated by their products is denoted S. For the codespace to be nontrivial, the stabilizers (and hence the generators) must commute with one-another. The generators for a stabilizer code are not unique: the same set S is generated if g i g j replaces g i , for any j.
In addition to the stabilizers, one can define logical operators, which map the codespace onto itself. The space of logical operators is generated by 2k members of the Pauli group, which can be labeledX 1 , · · ·X k ,Z 1 , · · ·Z k , withX j anticommuting withZ j , but commuting with all other logical generators. The labeling of the logical operators is not unique. Any member of the Pauli group that commutes with the stabilizers, but is not itself a stabilizer, is a logical operator.

Moving in the space of stabilizer codes
Consider two stabilizer codes S, S ′ that differ by only one anti-commuting generator: S is generated by G = {g 0 , g 1 , · · · g n−k−1 }, while S ′ is generated by G ′ = {g ′ 0 , g 1 , g 2 , · · · g n−k−1 }, with anticommutator {g 0 , g ′ 0 } = 0. As is readily verified by its action on the generators, the unitary operator U = (1 + g ′ 0 g 0 )/ √ 2 maps the codespace of S to the codespace of S ′ . One can further see that when acting on a state |ψ in the codespace of S, where P ±1 = (1 ± g ′ 0 )/2 are projectors into the space spanned by the ±1 eigenstates of g ′ 0 . This relationship suggests an algorithm. Starting from a state |ψ , one measures g ′ 0 . If the result of the measurement is −1, one applies g 0 to the new state, otherwise one leaves it alone. Due to Eq. (1), this procedure is completely equivalent to the unitary transform, but is often simpler to implement. One can chain these operations together -one-by-one changing the stabilizer generators. In the next section we show how to construct a sequence of measurements that map between any two given stabilizer codes. If the final code is the same as the initial code, then we thereby apply a gate (given by the product of the U 's in Eq. (1)). This feature is used in a number of algorithms, such as topological [1,2], and teleportation [12] based computing schemes.
The operator U in Eq. (1) maps the Pauli group onto itself, and is therefore described as a Clifford operator. Clifford operators are insufficient for universal quantum computation, and a quantum circuit only involving Clifford operators can be efficiently simulated on a classical computer [23]. Relaxing the constraint that the generators belong to the Pauli group opens up the ability to generate arbitrary gates.
Although the arguments have largely appeared elsewhere, in Appendix A we give the proofs that U has all of these properties. Note, if one has a non-measurement way to apply U , such gates could also be used as part of the rewiring.

Constructing a sequence of stabilizer codes
Given two stabilizer codes S, S ′ , we wish to construct a sequence of stabilizer codes S 0 , S 1 , · · · , S N , such that S 0 = S, S N = S ′ , and S j differs from S j−1 by only one anticommuting generator. By the arguments in Sec. 2.2 one then can map between S and S ′ by performing N measurements.
To facilitate constructing this sequence of stabilizer codes, we first make use of the fact that the generators are not unique, and find a set of generators of S and S ′ such that each of the generators fall into one of three blocks, denoted G A , G B , G C and The first blocks are identical: The second blocks, G B and G ′ B contain the same number of elements, and have the property that the generators in G B commute with members of S ′ , but are not in S ′ . Conversely, those in G ′ B commute with the members of S, but are not in S. Thus the elements of G B are logical operators for the code defined by S ′ , and vice versa. The elements in the third block are in one-to-one correspondence, and for each g j ∈ G C , there exists a single element g ′ j ∈ G ′ C , such that g j and g ′ j anticommute. The element g j however, commutes with all other elements of G ′ (and likewise for g ′ j ). We claim that one can always find generators satisfying these conditions, and in Sec. 2.4 we provide a constructive algorithm for finding these generators.
For each element g j ∈ G B our construction also gives a complementary operator g (c) j with the property that g (c) j anticommutes with g j , but commutes with all other elements of G. Furthermore g (c) j commutes will all elements of G ′ . Similarly, for each g ′ j ∈ G ′ B we find a complementary operator g ′(c) j with analogous properties. Given this construction, we can then generate the sequence of stabilizer codes S 0 , S 1 , S 2 , · · · S N . If the number of generators in blocks G A , G B , G C are a, b, c, then we require N = 2b + c steps. It will require one step to replace an element of G C with one of G ′ C , and two steps to replace an element of G B with one of G ′ B . The required operation for replacing elements of G C is simple: one just measures the elements of G ′ C . In order to replace g j ∈ G B with g ′ j ∈ G ′ B , one first measures the product g Each of these steps is of the form detailed in Sec. 2.2. Note if G B is empty, then the two codes S and S ′ are different gauge fixings of a single subsystem code. In that case, our algorithm reduces to a standard gauge fixing approach. See Sec. 2.5.1.
In Appendix C we give some simple examples to illustrate the mechanics of this procedure. Section 3 further explores the utility of these mappings.

Construction of the generators and complementary operators
In this section we explicitly construct generators of the form described in Sec. 2.3. Given an arbitrary set of generators, G and G ′ of S and S ′ , we first construct a connectivity matrix M , whose (i, j)'th element is 1 if the i'th member of G anticommutes with the j'th member of G ′ . Otherwise that element is zero. For codes with n physical qubits and k logical qubits, M will be a (n − k) × (n − k) matrix. As already emphasized, the generators are not unique, and the same set of stabilizers are formed if one replaces any one generator by its product with another. Such a replacement in G corresponds to adding the j-th row of M to the i-th row mod (2). A similar replacement in G ′ corresponds to adding columns mod (2). By using the same techniques used for row reduction, one can thereby find a set of generators for which M is diagonal (with zeros and ones along the diagonal). The generators g i and g ′ i with M ii = 1 correspond to block C, as defined in Sec. 2.2.
Consider any g j / ∈ G C . Because of the structure of M , it commutes with all of the generators of the stabilizer group of S ′ . Thus it is either a member of S ′ or logical operator of S ′ . If it belongs to S ′ , then it equals a product of the members of G ′and one can always construct a set of generators for S ′ such that g j ∈ G ′ , giving us blocks G A and G ′ A . This rearrangement of G ′ does not require replacing any of the elements of block C. Finally, all of the remaining generators are logical operators for the other code, and hence are in blocks G B and G ′ B . We further transform the generators, based upon the operators in blocks G B and G ′ B . Each g j ∈ G B is a logical operator for S ′ , and hence there is a complementary logical operator g (c) j , that anticommutes with g j . By construction, g j g k . After this manipulation, one can further transform the generators so that g j , we take g k → g k g j . This transformation does not change any of the other commutation relations. Note, as illustrated in Sec. 3, one can map between codes with different numbers of qubits by simply appending auxillary qubits to the shorter code with trivial local stabilizers.

Distance Bounds
In commonly-studied noise models, noise acts independently on physical qubits. Consequently, one measure of the robustness of the code is its distance -the lowest weight operator that performs a logical X-or Z-operation. Here weight is the number of qubits which are acted on by the operator. A code of distance d can correct errors of weight t or less, where d = 2t + 1.
Our basic algorithm can produce intermediate codes whose distance is smaller than that of S and S ′ . Appendix D gives an explicit example. In Secs. 2.5.1 and 2.5.2 we quantify this issue by deriving lower bounds on the distances of the intervening codes generated by our algorithm when mapping between S and S ′ . As recently shown by Huang et al. [24], these lower bounds are worst case scenarios, and after adding appropriate ancilla qubits, there always exists a path in which the intermediate codes have distance no smaller than S or S ′ . Moreover, Huang et al. find the remarkable result that a random path yields high distance codes with high probability (and this probability can be made arbitrarily large by adding more ancillas).

Subsystem Codes.
We first consider the case where G B is empty, and one only needs to measure stabilizers belonging to the code to which we wish to map. In this case our algorithm may be interpreted as a gauge fixing procedure on a subsystem code [25][26][27][28]. Below we describe subsystem codes and outline this procedure. In particular we show that if G B is empty, then all codes in the path between S and S ′ are gauge fixings of a single subsystem code. One consequence is that the distances of each of these codes are bounded below by the distance of that subsystem code.
A subsystem code stores k logical qubits in n physical qubits. States in the codespace are eigenstates of s independent stabilizer operators (forming a group S and having generators G), where s < n − k. This leaves r = n − k − s degrees of freedom which are not used to encode any information. These r degrees of freedom are called gauge qubits, and they can be freely manipulated. The gauge group T is composed of Pauli operators that commute with both the logical operators and the stabilizers of the subsystem code. This is the set of operators which cannot disturb the encoded information. The gauge group of a subsystem code is generated by s + 2r elements -the generators of the stabilizer group and the generators of the "logical operators" that act on the gauge qubits. Gauge fixing amounts to creating a stabilizer code whose generators consist of r independent commuting elements of T /S along with the elements of G. Choosing those r elements in different ways can produce distinct stabilizer codes. Given a state stored in a subsystem code, its gauge-fixed variant is produced by simply measuring the relevant gauge operators.
Consider two stabilizer codes with stabilizer generators G and G ′ , decomposed into blocks A, B, and C, as in Sec. 2.3. Recall that the elements of the two A blocks are identical: G A = G ′ A , and the elements of the two C blocks are in one-to-one correspondence with g j ∈ G C anticommuting with one g ′ j ∈ G ′ C and commuting with all other elements of G ′ C . If the B block is empty, we can construct a subsystem code by taking its stabilizer group to be generated by G A = G ′ A . We use G C and G ′ C as the generators of the gauge group (along with G A ). The two stabilizer codes are created from this subsystem code via gauge fixing. Our algorithm then reduces to the standard gauge-fixing process, and each code along the path represents a different gauge fixing. A consequence is that if the subsystem code has distance d, then we are guaranteed that each code visited during the conversion will have at least distance d. This distance, for example, can be calculated using the approach in [29]. When G B and G ′ B contain b > 0 elements, the most naive generalization of this procedure fails. Namely, consider a subsystem code with stabilizer group G A and gauge group containing the union of G B , G ′ B , G C , and G ′ C . If b is the number of elements in G B and c is the number of elements in G C , this gauge group contains at least 2b + c linearly independent commuting elements -namely the set Thus it encodes at most n − (a + 2b + c) logical qbits, which is smaller than the n − (a + b + c) qbits encoded by the two original stabilizer codes.

Generic Case.
Here we generalize the argument of Sec. 2.5.1 to produce a general bound on the distances of our codes. In particular, if the B-blocks of S and S ′ contain b elements each, then we construct 2 b subsystem codes. We argue that any stabilizer code generated by our procedure must be a gauge fixing of one of these. In the special case where b = 0, this procedure generates the subsystem code in Sec. 2.5.1. The distance of any code generated by our procedure is then bounded below by the smaller of the distances of all these subsystem codes. For modest b the task of enumerating these subsystem codes and finding their distances is reasonable.
For this construction we take the B-blocks to contain and Z j are logical operators for S and S ′ . Note, this notation does not imply that these necessarily correspond to logical Z. The complementary logical operators are {X ′ 1 , ..., X ′ b } and {X 1 , ..., X b }. We further define the set Here s labels which of these choices are made. We then construct the subsystem code with stabilizer group G A , and gauge group generated by G A , G s B , G B , G C , G ′ C . Any code traversed in our procedure will have its stabilizer generators in the gauge group of one of these codes, and hence is a gauge fixing of that code.

Fault Tolerance
Intuitively, a measurement of the form of those in Sec. 2.2, is fault-tolerant if errors that occur during the measurement do not degrade the error-protective properties of the code. For a code of distance 3 or higher (ie. one in which at least a single qubit error can be corrected), this intuitive requirement can be satisfied by the property that no single error during the measurement can propagate to more than one qubit on the data [23]. The cat state method, as introduced by Shor [30] and nicely discussed by Aliferis, Gottesman, and Preskill [31], provides one approach to meeting this requirement. The measurement is described in detail in Appendix B.

Implementing Constraints
In practical applications, the physical apparatus may introduce constraints on the operators measured. For example, one may only be able to carry out single qubit measurements, or measurements on sets of qubits that are connected by hard-coded wires. In the presence of such constraints, it is no longer possible to map between any two arbitrary stabilizer codes. The mapping may also be asymmetric: the constraints may be satisfied in mapping from A to B, but not in mapping from B to A. This latter setting is the domain of "one-way" quantum computing [12].
One defines the constraints through the set W of all measurable operators. Given stabilizers codes S and S ′ generated by G and G ′ , a necessary, but not sufficient, condition for the existence of a rewiring path is that G ′ is a subset of the group generated by W ∪ G. For small systems, constrained paths can be found via an exhaustive search.
Note in many cases, measuring high-weight stabilizers is problematic. If one constrains the weights of the generators to be measured along the path from one code to another, such a path is not guaranteed to be generated by the algorithm.

Applications
In this section we illustrate the utility of our algorithm by using it in physically relevant cases: code conversion for universal transversal computing and braiding defects and twists in topological codes. Table 1. Generators for Steane code (g 0 − g 5 ) and Reed-Muller codes (g ′ 0 − g ′ 13 ). Additional qubits with arbitrarily chosen stabilizer generators (g 6 − g 13 ) are appended to the Steane code for the conversion.

Universal transversal computing
The [[7,1,1]] Steane code is a 7-qubit code that supports transversal Clifford gates, and the 15-qubit [ [15,1,3]] quantum Reed-Muller code supports several transversal non-Clifford gates which complement those of the Steane code. Thus [9][10][11] suggested sequentially mapping between these codes to produce a universal set of transversal gates. The generators for these codes are given in Table 1, where we have appended extra bits to the Steane code. Without any reference to the structure of the codes, our algorithm gives a mapping between them (see Appendix E for details). For example, we find that 7 operators need to be measured to map from the Steane to the Reed-Muller code: Remarkably, these are all stabilizer generators of the Reed-Muller code, and hence no additional hardware is required, beyond what one already needs for implementing error correction. These operators can be measured in any order desired, or even simultaneously. Similarly one can map back to the Steane code by only measuring stabilizers: g 0 , g 1 , g 2 , g 6 , g 8 , g 9 , g 10 . The resulting round-trip acts as the identity operator. The distance of the code never falls below 3 so, as discussed in Sec. 2.6, the process is fault-tolerant.
Due to its importance, the literature contains several other approaches to map between the Steane and Reed-Muller codes. Hwang et al. produced a circuit based on the particular structure of these codes and the fact that they can both be transformed into a common canonical form [10]. Anderson, Duclos-Cianci, and Poulin made the insightful observation that these two codes could be considered to be identical subsystem codes -with additional stabilizers added to fix the gauge [9]. They were able to use this structure to generate a map between the codes. Bombin also made similar observations [32]. Quan et al. later extended this idea [11]. Our approach is in the same category as these gauge-fixing methods, but has the added benefit that it automatically finds the minimal set of operators which need to be measured. It is purely algorithmic and does not require any insight.
As a related example, Huang and Newman used our algorithm to create a mapping  Figure 1. Transporting an e type defect in the surface code. Qubits sit at the vertices of the square lattice, yellow (light) and red (dark) plaquettes denote stabilizers corresponding to the product of Z or X operators on the four qubits at the corners. The white squares represent the absence of a stabilizer. To convert from the code on the left to the one on the right, one first measures the X operator highlighted in the middle panel, then the highlighted stabilizer in the right panel.
between the 5-qubit code and the Steane code [24].

Moving defects in topological codes
Topological codes are stabilizer codes where the spins are arranged on a lattice, the stabilizer generators are local (meaning they only involve spins which are near oneanother), but the logical operators are non-local. These codes are particularly robust against local noise sources. They are also of great intellectual interest, as they have connections to gauge theories, spin liquids, and topological order. These codes are typically translationally invariant, but it can be advantageous to introduce "extrinsic defects," which locally disrupt the wiring. One can implement gates by deforming the code so that these defects move around one-another [33]. Here we apply our algorithm to the problem of moving these defects -reproducing known protocols for moving "e" and "m" type defects in surface codes, and finding new protocols for converting between these defects, and moving "twist defects". The latter is valuable beyond quantum information processing, as moving twist defects around one-another is equivalent to braiding Majorana fermions, which would allow the direct observation of excitations with non-Abelian statistics.
We will explicitly consider the toric/surface code. There are several conventions for defining this code. We follow [34], and place the qubits on the vertices of a checkerboard lattice with alternate plaquettes colored yellow and red (Fig. 1). For each yellow plaquette there is a stabilizer corresponding to the product of Z's on the four qubits at the vertices. For each red plaquette there is another stabilizer corresponding to the product of X's. The number of logical qubits stored by the code depends on the boundary conditions and the topology of the surface tiled by the qubits.
The simplest defect involves "removing" one of the stabilizers -meaning that one removes that generator from G, reducing the constraints on the codespace. In the presence of appropriate boundaries, this extrinsic defect yields one additional logical qubit. This defect is referred to as an Z or X defect (or equivalently e and m) depending if the removed stabilizer is a product of Z's or X's. Bombin [1,2] uses the phrase "code deformation" to describes the operations required to move these defects, and the algorithm is explained in detail by Fowler [33]. Our general code rewiring algorithm can be used to find these operations. Consider for instance the setup in Fig. 1 where one wishes to move a Z defect (shown as a white square in the leftmost panel) to a diagonally adjascent site (rightmost panel). The two codes differ by only one generator: where Z 4 acts on the shared qubit. These are logical operators for the other code (ie. lie in the B blocks). The complementary logical operators involves a product of X operators extending from the each of the defects to the boundary. The product of these logical operators is simply X 4 . Thus, following the prescription in Sec. 2.2, one rewires the code by first measuring X 4 then measuring g ′ 0 . This protocol coincides with the one in [33].
As a second example, consider Fig. 2 where one wishes to convert a Z defect into an X defect on a neighboring plaquette. Again the codes differ in only one generator, and the generators are logical operators for the other code. The complementary operators this time are a string of X ′ s and a string of Z's extending to a boundary. Their product is a string of Y 's. Thus rewiring this code requires measuring a non-local quantity. In many topological quantum computer architectures this is impractical, as one wishes to avoid measuring non-local operators. In such a case, one could first move the defect near a boundary, where the string becomes short, at the cost of reducing the distance of the code.
Finally we consider a "twist" defect, illustrated in Fig. 3. Two of the square plaquettes are replaced by pentagons, and the plaquettes between them become rhombuses. As illustrated in the figure, the stabilizer associated with a pentagon involves measuring a product of three X operators, a Y and a Z or the product of three Z operators, a Y and a X. The stabilizer associated with a rhombus involves the product of two Z's and two X's. Twist defects are important for several reasons. For example, an X defect can be converted into a Z defect by moving it through the rhombus cells -a procedure that only requires local measurements. Given appropriate boundary conditions, adding a twist defect yields one additional logical qubit.
We wish to consider how to deform the code in order to move one of the pentagons. For example, in Fig. 3 we illustrate a move in which the defect is made shorter. In this case, the code changes by two generators: On the left, g 0 = Z 1 Z 2 X 4 X 5 and g 1 = X 2 X 3 Z 5 Y 6 X 7 . On the right, g ′ 0 = Z 1 Z 2 X 4 Y 5 Z 6 and g ′ 1 = X 2 X 3 X 6 X 7 . Following the algorithm in Sec. 2, we find a new set of generators G = {g 0 , g 1 g 0 }, G ′ = {g ′ 0 , g ′ 1 g ′ 0 }, where g 0 g 1 = g ′ 0 g ′ 1 , and g 0 anticommutes with g ′ 0 . Thus to convert between the codes one need only measure g ′ 0 . These manipulations allow for operations which can be interpreted as braiding quasiparticles with unusual quantum statistics. As discussed by Kitaev [22], the  Figure 3. Shortening a twist. Twist defects, as illustrated in this figure, contain stabilizers corresponding to products of four or five operators. The ends of these defects have properties analogous to Majorana fermions. One converts the code on the left to the one on the right by measuring the operator X 2 X 3 X 6 X 7 . Our algorithm similarly gives the procedure for other moves.
codespace can be identified with the ground-space manifold of a Hamiltonian which is the sum of the stabilizer generators. Turning off one of the generators, say Z 0 , enlarges the space. States that are eigenstates of Z 0 with eigenvalue −1 are identified with excited states of the Hamiltonian and are said to contain a quasiparticle at that location. Moving a Z defect around a X defect produces a control-not gate [33], which in this context can be interpreted as a phase that is contingent on the presence of the quasiparticles. Hence, there is a phase generated by moving one quasiparticle around another, which is the defining property of an anyon. The twist defects are even more interesting, as in this mapping the pentagons play the role of particles with non-Abelian statistics (described either as Ising anyons or Majorana fermions) [34].

Summary and Outlook
Quantum codes, first introduced for error correction, become more powerful with operations that map between them. The way information is encoded influences what operations are most accessible; moreover, gates can be applied through the act of mapping between codes. This code-conversion paradigm is at the heart of one-way quantum computing and topological quantum computing. In this paper, we introduce a general-purpose algorithm for mapping between two arbitrary stabilizer codes, often in a fault-tolerant manner. We illustrate two applications of the algorithm: mapping between the Steane and Reed-Muller codes and moving defects in topological codes.
Our algorithm provides a means for creating a mapping between arbitrary stabilizer codes. Such mappings are not unique, and depending on which path is taken, a different logical gate can be produced. It would be exciting to extend our approach and gain the ability to choose which logical operation is performed: i.e. given a desired logical operator, how does one construct a sequence of measurements that performs the desired gate? Similarly, it would be useful to develop approaches that allow the incorporation of constraints, such as locality or code distance [24].
Here we establish that U = (1 + g ′ 0 g 0 )/ √ 2 in Eq. (1) is a unitary Clifford rotation, and we verify its relationship to the projectors P ±1 = (1 ± g ′ 0 )/2. We rely on the fact that g ′ 0 and g 0 are Pauli operators that anti-commute, {g ′ 0 , g 0 } = 0. The fact that U is unitary follows from writing where we have neglected the subscript. We then note that for any Pauli operator, g 2 = (g ′ ) 2 = 1, and hence U U † = 1. Similar arithmetic gives U gU † = g ′ . The relationships with the projectors come from noting that for any state |ψ in the S-codespace, g|ψ = |ψ . Thus To show that U is a Clifford rotation, we first recall that a Clifford rotation is defined by the property that for any σ in the Pauli group on n qubits, P n , U σU † = σ ′ ∈ P n . We take an arbitrary σ ∈ P n , and separately consider the two cases where σ commutes or anticommutes with gg ′ . (One of these conditions is always satisfied by any two arbitrary Pauli operators.) If [σ, gg ′ ] = 0, then U σU † = σ ∈ P n . If {σ, gg ′ } = 0, then U σU † = (σ + 2σgg ′ − σ)/2 = σgg ′ . Products of Pauli operators are Pauli operators (P n is closed under multiplication), so σgg ′ ∈ P n .

Appendix B. Fault-tolerant measurement of Pauli operators
A stabilizer measurement requires measuring operators of the form g = σ 1 σ 2 · · · σ m , which is a product of m Pauli matrices, each acting on a different qubit, labeled by j = 1, · · · , m. Here we reproduce the argument from Shor [30] (see also, [31]), showing that this measurement can be done in a fault-tolerant manner.
One first prepares m ancilla qubits in a m-qubit cat-state, which is an equal superposition of all ancilla qubits in the |0 state and all ancilla qubits in the |1 state. As shown in Fig. B1, one then entangles the j'th ancilla qubit with the system by applying a control-σ j operator. A Hadamard gate is applied to each ancilla qubit, then the ancillas are measured in the standard basis. A measurement having even parity will have projected the encoded state into the +1 eigenbasis of g. A measurement having odd parity will have projected the encoded state into the −1 eigenbasis of g. Neglecting normalization, the quantum state of the composite system evolves as (|0 ⊗m + |1 ⊗m ) ⊗ |ψ → |0 ⊗m ⊗ |ψ + |1 ⊗m ⊗ g|ψ → |e ⊗ (1 + g)|ψ + |o (1 − g)|ψ , where |e and |o are equal weight superpositions of all of the ancilla states with even and odd parity. Each ancilla qubit interacts with a single, unique physical qubit.  Figure B1. Circuit illustrating the cat-state method [30,31] for the fault-tolerant projection measurement of a stabilizer generator.
While this scheme prevents errors from propagating, an error on one of the ancilla qubits could be mistaken for an error on one of the system qubits (or could mask such an error). The standard procedure for addressing this problem is to repeatedly measure the stabilizer. By comparing subsequent measurements, one can bound the probability of an undetected or misdiagnosed error, yielding a fault-tolerant algorithm.

Appendix C. Trivial Examples
To illustrate the mechanics of our algorithm, we carefully apply it to two simple examples. These are not physically relevant, but they provide a platform for understanding the arithmetic.
First consider the case where we have n = 2 physical qubits, storing k = 1 logical qubits. Suppose S is generated by g 0 = Z 1 and S ′ is generated by g ′ 0 = Z 2 . Following our algorithm, we construct the 1 × 1 connectivity matrix M , which in this case is equal to zero. This tells us that our generators are either equal to one-another (which would put them in blocks G A and G ′ A ), or they are logical operators of the other code (which puts them in blocks G B and G ′ B ). Clearly the latter is the case. The complementary operators are g (c) 0 = X 1 and (g ′ 0 ) (c) = X 2 . The sequence of stabilizer codes is then generated by Each subsequent set of generators differs by exactly one non-commuting element, allowing us to map between them via the the procedure in Sec. 2.2.
A somewhat more sophisticated, but equally artificial, example involves n = 3 physical qubits and k = 1 logical qubits. Suppose S is generated by g 0 = Z 1 Z 2 , g 1 = Z 3 while S ′ is generated by g ′ 0 = Z 1 , g ′ 1 = X 2 X 3 , The connectivity matrix is then This is made diagonal via the transformation g 0 →ḡ 0 = g 0 g 1 = Z 1 Z 2 Z 3 . By construction, S is generated byḡ 0 and g 1 . The operatorsḡ 0 and g ′ 0 are logical operators for the other code (so are in block G B and G ′ B ), and the complementary operators can be taken to beḡ (c) 0 = X 3 and g ′ 0 (c) = X 1 X 2 . Following Sec. 2.4, we then check the anticommutator of these complementary operators with the elements of S and S ′ . We find thatḡ (c) 0 anticommutes with g 1 , necessitating the replacement g 1 →ḡ 1 = g 1ḡ0 . The sequence of stabilizer generators is then:

Appendix D. Code distance during rewiring
The distance of a code d is the minimum number of single qubit errors required to give a non-zero overlap between two basis states in the code-space. Equivalently, d is the minimum number of single qubit Pauli operators which are needed to construct a logical operator. In a distance d code one can correct t = (d−1)/2 errors. As described in Sec. 2.5, an important question is how the distance of the code evolves along the path in Sec. 2.3. In that section we established a lower bound on the distance of these codes. Nonetheless, in many practical examples (Secs. 3.1, 3.2) the distance of the code is maintained throughout the path. Here we explicitly construct a mapping between two distance 3 codes for which our algorithm yields an intermediate code of lower distance.
In particular, consider the case where S 0 = S is the Steane code defined by the first six stabilizers in the left-hand column of Table 1, and S 2 = S ′ is a modified version of the same code where the third and fourth qubit are exchanged -that is in each stabilizer one makes the substitution Both of these are distance 3 codes.
Our algorithm gives an intermediate code S 1 which is generated by This code is only distance 1 as the operator Z 7 commutes with all of the generators, but is not itself a stabilizer -and is therefore a logical operator. Thus if a "phase" error occurs on qubit 7 in this intermediate state, the error could neither be detected, nor corrected.
One approach to avoiding this issue is given in [24].

Appendix E. Connectivity matrices for mapping between Steane and Reed-Muller Codes
Here we explicitly show how our algorithm is applied to finding a mapping between the Steane and Reed-Muller codes. As described in Sec. 3.1, we first append arbitrary stabilizers to the Steane code so that there are an equal number of stabilizers in both codes (see Table 1). Then, we form the connectivity matrix and find its diagonal form by mod(2) row reduction. The row reduction procedure yields a new set of generators that are used to construct the sequence of measurements described in Sec. 3.1. We additionally use column reduction in order to produce the simplest sequence of measurements for mapping in the opposite direction. We start by creating the connectivity matrix, Table E1, corresponding to the operators in Table 1. We show ones where the stabilizers anticommute, and zeros are implied at all other locations. We place explicit zeros in the locations where the stabilizers are identical.
We first note that the first six rows and the last six columns decouple from the Table E1. Connectivity matrix for the Steane and Reed-Muller codes. A one in the row indicates an anticommutation relation, and zeros are inserted where the stabilizer generators are identical.
Thus we have four new elements for block C: {g 13 g 12 , g ′ 0 } = {g 11 g 13 , g ′ 1 } = {g 9 g 13 , g ′ 2 } = {g 6 , g ′ 3 } = 0. The remaining generators either belong to block A (meaning they are equal to stabilizers of the other code) or block B (in which case they are logical operators for the other code). Given that the two codes share a logical operator Z = j Z j , block B must be empty, and the rest of the generators are in block A.
To find the most convenient sequence to convert backwards from the Reed-Muller code to the Steane code, we follow the same procedure but use column reduction. We reorder the rows as shown in Table E3, and add columns together (mod 2) in order to reduce the lower four rows to diagonal form. To simplify the expressions we also reorder the rows. Finally, we use row reduction to eliminate all ones in the upper four rows. This establishes a simple mapping backwards. To map a state from the codespace of the Reed-Muller code to that of the Steane code, we measure: g 0 , g 1 , g 2 , g 6 , g 8 , g 9 , g 10 . Table E3. Connection matrices for intermediate steps of the column reduction used to find the generators needed to map from the Reed-Muller code to the Steane code.