Fault-tolerant quantum computation with few qubits

Reliable qubits are difficult to engineer, but standard fault-tolerance schemes use seven or more physical qubits to encode each logical qubit, with still more qubits required for error correction. The large overhead makes it hard to experiment with fault-tolerance schemes with multiple encoded qubits. Here, we study the 15-qubit Hamming code, which protects seven encoded qubits to distance three. We give fault-tolerant procedures for applying arbitrary Clifford operations on these encoded qubits, using only two extra qubits, 17 in total. In particular, individual encoded qubits within the code block can be targeted. Fault-tolerant universal computation is possible with four extra qubits, 19 in total. The procedures could enable testing more sophisticated protected circuits in small-scale quantum devices. Our main technique is to use gadgets to protect gates against correlated faults. We also take advantage of special code symmetries, and use pieceable fault tolerance. A new approach provides a way to realise fault-tolerant quantum operations with smaller qubit overhead as opposed to existing protocols. In order to protect quantum computers from errors, quantum information is stored in logical qubits—ensembles of physical qubits where eventual errors can be detected and corrected. However, performing quantum operations on logical qubits in a fault-tolerant way is difficult, and normally requires large qubit overheads. Rui Chao and Ben W. Reichardt from the University of Southern California have now demonstrated that carefully designed circuits where gates are replaced with “gadgets”—gates involving extra qubits to catch error propagation—ensure useful fault-tolerant operations on logical qubits. This protocol may make it possible to run fault-tolerant operations on near-term, small quantum computers.


I. INTRODUCTION
Quantum computers are faulty, but schemes to tolerate errors incur a large space overhead. For example, one qubit encodes into seven physical qubits using the Steane code [1], or into nine physical qubits using the Bacon-Shor and smallest surface codes [2][3][4]. Error correction uses additional qubits. When more than one level of encoding is required for better protection, the overhead multiplies, so that thousands of physical qubits can be required for each logical qubit [5]. This overhead will compound the challenge of building large quantum computers. In the near term, it also makes it more difficult to run fault-tolerance experiments, which are important to test different schemes' performance, validate models and learn better approaches.
Codes storing multiple qubits have higher rates [6], but too large codes tend to tolerate less noise since initializing codewords gets difficult [7]. A key obstacle for using any code with multiple qubits per code block is that it is complicated and inefficient to address the individual encoded qubits to compute on them [8,9]. For example, to apply a CNOT gate between two logical qubits in a code block, the optimized method in [9] requires a full ancillary code block, with no stored data, into which the target logical qubit is transferred temporarily.
We introduce lower-overhead methods for computing fault tolerantly on multiple data qubits in codes of distance two or three.
1. For even n, the [[n, n − 2, 2]] code encodes n − 2 logical qubits into n physical qubits, protected to distance two. We show that with two more qubits, encoded CNOT and Hadamard gates can be applied fault tolerantly. For n ≥ 6, four extra qubits suffice to fault-tolerantly apply an encoded CCZ gate, for universality.
2. For better, distance-three protection, we encode seven qubits into 15, and give fault-tolerant circuits for the encoded Clifford group using two more qubits, and for a universal gate set with four extra qubits (19 total).
Combined with the two-qubit fault-tolerant errordetection and error-correction methods in [10], this means that substantial quantum calculations can be implemented fault tolerantly in a quantum device with fewer than 20 physical qubits. Figure 1 summarizes our results. In order to compute on data encoded within a single code block, we need to apply two-or three-qubit gates. The particular circuits use symmetries of the codes or a more general round-robin construction from [11]. This is not fault tolerant, because a single gate failure can cause a correlated error of weight two or worse, which a distance-three code cannot correct. To fix this, we replace each gate with a gadget involving two to four more qubits. With no gate faults, the gadgets are equivalent to the ideal gates they replace. The gadgets' purpose is to detect correlated errors, so that they can be corrected for later. The gadgets cannot prevent the gates from spreading single-qubit faults into problematic multi-qubit errors. To avoid this problem, we design the circuits carefully, and in some cases intersperse partial error correction procedures between gadgets, an idea from [12] recently applied and extended by [11,13]. Sometimes error correction even needs to overlap the gadgets. For the basics of stabilizer algebra, quantum errorcorrecting codes and fault-tolerant quantum computation, we refer the reader to [14].

II. TRICK: FLAGGING A GATE FOR CORRELATED FAULTS
A main trick we use is to replace CZ and CCZ gates with small gadgets that can catch correlated faults. The gadgets are reminiscent of one-ancilla-qubit fault-tolerant SWAP gate gadgets [15].

A. CZ gadget
The controlled-phase gate is a two-qubit diagonal gate CZ = 1 − 2|11 11|, represented in circuits as Observe that CZ gates commute with Z errors, but copy X (or Y ) errors on one wire into Z errors on the other: For fault tolerance, it suffices to study gates that fail with Pauli faults after the gate. That is, when a noisy CZ gate fails, it applies the ideal CZ gate followed by one of the 15 nontrivial two-qubit Pauli operators.
Consider the circuit of Fig. 2(a), using one extra qubit that at the end is measured in the |0 , |1 basis (Z eigenbasis). If the gates are perfect, then the measurement returns 0 and this circuit has the effect of a single CZ gate. If the CZ gate fails with an X or Y fault on the second qubit, however, then the measurement will return 1. Thus certain kinds of faults can be detected. If at most one location fails and the measurement returns 0, then the output cannot have an XX, XY , Y X or Y Y error.
A similar circuit can catch Z faults. If all gates in Fig. 2(b) are perfect, then the X basis (|+ , |− ) measurement will return + and the effect will be of a single CZ. If there is at most one fault and the measurement returns +, then the output cannot have a Y X or ZZ error. (This fact can be verified by, for example, propagating ZZI and ZZX backward through the circuit, and observing that no single gate failure can create either.) The gadgets to catch X and Z faults can be combined:  IX, IY, IZ, XI, Y I, ZI and XZ, Y Z, ZX, ZY ). No CZ gadget can catch more errors than this.
The order of the gates matters. Although the last two gates in Fig. 2(b) formally commute, switching them changes the faulty circuit so that an undetected ZZ error can occur due to a single gate fault. Similarly, in Fig. 2(c) it is important that the gadget for catching Z faults go inside that for X faults. With the other order, a single fault can lead to an undetected XX error. See Fig. 3.
In practice, not every CZ gate need always be replaced with the full CZ gate gadget of Fig. 2(c). Multiple gates can sometimes be combined under single flags. We will see examples below.

B. CCZ gadget
The three-qubit gate CCZ = 1 − 2|111 111| is denoted Again, it commutes with Z errors. It copies an X error on the input into a CZ = 1 2 (II + IZ + ZI − ZZ) error on the output, i.e., into a linear combination of II, IZ, ZI and ZZ errors: The following gadget, using four ancilla qubits, implements a CCZ on the black data qubits. Furthermore, it satisfies that provided there is at most one failed gate and the measurement results are trivial, 0 and +, then the error on the output is a linear combination of Paulis that could result from a onequbit fault before or after a perfect CCZ gate, i.e., III, ZII, XII, Y II, XZI, Y ZI, XZZ, Y ZZ and qubit permutations thereof.
That without faults the black and blue gates realize a CCZ is a special case of the following claim [11], with r = 3, Claim 2. Consider an n-qubit CSS code with k encoded qubits given by . Let U be the product of C (r−1) Z = 1 − 2|1 r 1 r | gates applied to every tuple of qubits in S Z 1 × S Z 2 × · · · × S Z r . (If the S Z j sets are not disjoint, then some of the applied gates will be C (s−1) Z for some s < r.) Then U is a valid logical operation. It implements logical C (r−1) Z on the first r encoded qubits.
Proof. For the case that the sets S Z j are disjoint, the claim is immediate in the case of singleton sets and follows in general by induction on the set size using the identity G = G G for any gate G, on one or more qubits, with G 2 = 1. (Figure 2(b) provides one example.) More generally, the claim follows by writing out computational basis codewords as superpositions of computational basis states, and computing the effect of U . For (x, y) ∈ {0, 1} r ×{0, 1} k−r , the codeword |xy is a uniform superposition of computational basis states: The relationships X i Z j = (−1) δij Z j X i imply that |S X i ∩ S Z j | is odd for i = j and even otherwise; and for any stabilizer X S , [X S , Z j ] = 0 so |S ∩ S Z j | is even. If x = 1 r , say x j = 0, then for every term |z in the above sum, z has an even number of 1s in S Z j , implying that U |z = |z . Hence U |xy = |xy . If x = 1 r , then for any term |z in |xy , z has an odd number of 1s in each S Z j and therefore U |z = −|z . Hence U |xy = −|xy .
For even n, the [[n, n − 2, 2]] error-detecting code has stabilizers X ⊗n and Z ⊗n , and logical operators X j = X 1 X j+1 , Z j = Z j+1 Z n for j = 1, . . . , n−2. This code, its symmetries, and methods of computing fault tolerantly on the encoded qubits were studied by Gottesman [8]. However, his techniques require at least 2n extra qubits. For example, to apply a CNOT gate between two logical qubits in the same code block, he teleports them each into separate code blocks, applies transversal CNOT gates between the blocks, and then teleports them back.
We will give a fault-tolerant implementation of encoded CNOT and Hadamard gates on arbitrary logical qubits, using only two extra qubits. Two-qubit fault-tolerant procedures for state preparation, error detection and projective measurement were given in [10]. For n ≥ 6 (so there are at least three encoded qubits), we will give a four-qubit fault-tolerant implementation of the encoded CCZ gate, thereby completing a universal gate set.

A. Permutation symmetries and transversal operations
Fault tolerance for a distance-two code means that any single fault within an operation should either have no effect or lead to a detectable error. For example, of course the 4 n−2 logical Pauli operators can all be applied fault tolerantly, since the operations do not couple any qubits.
All qubit permutations preserve the two stabilizers and therefore preserve the code space. They are also fault tolerant if implemented either by relabeling the qubits or by moving them past each other (and not by using two-qubit SWAP gates [15]). For i, j ∈ [n − 2], i = j, the qubit swap (i + 1, j + 1) swaps the logical qubits i and j. The qubit swap (1, 2) implements logical CNOTs from qubits 2 through n − 2 into 1, and the qubit swap (2, n) implements logical CNOTs in the opposite direction: . . . and . . .
The operations given so far generate a group much smaller than the full (n − 2)-qubit Clifford group. The qubit permutations generate n! different logical operations (except for n = 4, just 6 operations). With the transversal application of the six one-qubit Clifford gates, up to Paulis, this gives 6(n!) different logical operations (or 36 for n = 4). Table I gives the sizes of various interesting subgroups of the Clifford group, for comparison.
We next give fault-tolerant implementations for a logical Hadamard gate on a single encoded qubit, and for a logical CZ gate between two encoded qubits. These generate a large subgroup of the Clifford group, the CNOT, H column in Table I. B. CZ gate By Claim 2, a logical CZ 1,2 gate can be implemented by Z n CZ 2,3 CZ 2,n CZ 3,n : However, this implementation is not fault tolerant. Some failures are detectable; for example, if the CZ 2,3 gate fails as XI, then the final, detectable error is X 2 Z n . Others are not, e.g., if the CZ 2,3 gate fails as XX, then the final X 2 X 3 = X 1 X 2 error is undetectable.
The bad faults that can cause undetectable logical errors are as follows: In particular, all these bad faults are caught by the CZ gadget of Theorem 1. Therefore replacing each physical CZ gate in (3) with that gadget gives a fault-tolerant implementation of a logical CZ 1,2 gate. The circuit uses at most two ancilla qubits at a time.
In fact, one can simplify the resulting circuit by using the same |0 ancilla to catch X faults on multiple CZ gates. The following circuit is also fault tolerant: The gadgets to catch Z faults can be merged, too. The following circuit is fault tolerant, and still requires at most two ancilla qubits at a time: Perhaps further simplifications are possible.
The circuit's fault tolerance can be verified by enumerating all the ways in which single gates can fail.

D. Four-ancilla CCZ gate
For n ≥ 6, a CCZ gate on encoded qubits 1, 2, 3 can be implemented by round-robin CCZ gates on {2, n} × {3, n} × {4, n}, by Claim 2: This circuit uses one Z, three CZ and four CCZ gates. To make it fault tolerant, use the gadget from Fig. 2(c) for each CZ gate, and replace each CCZ with the gadget of Eq. (2). Overall, this requires four ancilla qubits.
Single gate faults are either caught by the gadgets or lead to an error that could also arise from a one-qubit fault between the gates in (6). A one-qubit X or Y fault will be detectable at the end because it is copied only to linear combinations of Zs-the X component of the final error will still have weight one-and a one-qubit Z fault will be detectable because it commutes through the CZ and CCZ gates. Therefore the procedure is fault tolerant. We first give a presentation of the code and its symmetries following [16]. Then we give a two-ancilla-qubit method for fault tolerantly implementing the full Clifford group on the encoded qubits, and, to complete a universal gate set, a four-qubit fault-tolerant encoded CCZ gate.
Two-qubit fault-tolerant procedures for state preparation and error correction were given in [10].
Index the qubits left to right from 1 to 15. Observe that the columns are these numbers in binary.
As in [16], we define logical operators based on the following seven weight-five strings: From the first string, X 1 = XXIXIIIXIIIIIIX and Z 1 = ZZIZIIIZIIIIIIZ. The remaining strings specify the logical operators X 2 , Z 2 through X 7 , Z 7 .

B. Transversal operations
Transversal operations are automatically fault tolerant. Transversal Pauli operators implement logical transversal Pauli operators. Indeed, transversal X, i.e., X ⊗15 , preserves the code and implements transversal logical X, i.e., X ⊗7 , on the code space, and similarly for Y and Z.
In fact, any one-qubit Clifford operator applied transversally preserves the code space and implements the same operator transversally on the encoded qubits. For example, since the logical operators are each self-dual, applying the Hadamard gates H ⊗15 implements logical H ⊗7 .
Of course, since the code is CSS, transversal CNOT gates between two code blocks implements transversal logical CNOT gates on the code spaces. Furthermore, [17] shows that on three code blocks transversal CCZ can be used to obtain a universal gate set. Here, however, we will consider only single code blocks and Clifford operations.

C. Permutation symmetries
Permutations of the qubits are also fault tolerant, either by physically moving the qubits or by relabeling them.
The code's permutation automorphism group has order 20,160, and is isomorphic to A 8 and GL(4, 2) [16,18]. It is generated by the following three 15-qubit permutations: These permutations fix the code space, but act nontrivially within it. The permutations σ 1 and σ 2 apply the respective permutations (1, 2, 3) and (3,4,5,6,7) to the seven logical qubits. Together, these generate the alternating group A 7 of even permutations.
The logical effect of σ 3 is not a permutation. It is equivalent to the following circuit of 24 CNOT gates, in which gates with the same control wire are condensed: (10) Thus the first logical qubit is fixed, while for j ∈ {2, . . . , 7} and P ∈ {X, Y, Z}, P j is mapped to ( 7 j=2 P j )P j+1 , wrapping the indices cyclically. This is a six-qubit generalization of a four-qubit operator studied in [8,Sec. 6]. (Like permutations, this operation has the property of being a valid transversal operation on any stabilizer code.) . 4. (a) If σ is a permutation automorphism for a self-dual CSS code, then applying CZ gates along its cycles fixes the code space (Claim 3). (b) The logical effect for CZ gates following the permutation σ3.

D. CZ circuits based on permutation symmetries
Any permutation symmetry of the code can be turned into a CZ automorphism (Fig. 4(a)): Claim 3. For a self-dual CSS code, if σ is a qubit permutation that fixes the code space, then the circuit with a CZ gate from i to σ(i), for all i = σ(i), fixes the code space up to Pauli Z corrections.
Notice that the logical effect necessarily consists of encoded CZ gates, because logical Z operators are unchanged and logical X operators pick up Z components. Also, the map from Claim 3 is not a homomorphism from permutations into unitary circuits. The permutation (6, 7)(8, 10, 9, 11)(12, 14, 13, 15) fixes the code, and under Claim 3 corresponds to the eight CZ gates of Fig. 5(a). Figure 5(b) gives their logical effect.
Using Magma [19], we compute that the group generated by this operation, the permutations σ 1 , σ 2 , σ 3 , and transversal H has the same size as the CNOT, H group on six qubits (about 1.001 · 10 20 ). (Adding transversal G only triples the group size.) This hints that by working in a logical basis in which one qubit has X = X ⊗15 and Z = Z ⊗15 (operators fixed by the permutations and by Fig. 5(a)), perhaps arbitrary combinations of CNOT and H can be applied to the other six qubits. But no, only half the CNOT, H group can be reached. Error correction The circuit of Fig. 5(a) is clearly not fault tolerant. (For example, an XX fault after the CZ 9,11 gate gives the error X 9 X 11 , which is indistinguishable from X 2 .) We can use the gadgets from Sec. II A for each CZ gate to obtain the circuit of Fig. 5(c), shown with the trailing error correction. Two ancilla qubits are needed.
We claim that this compiled circuit is fault tolerant. This means that if the input lies in the code space, the compiled circuit has at most one fault (a two-qubit Pauli fault after a gate, or a one-qubit fault on a resting qubit), and the subsequent error correction is perfect; then the final outputs lie in the code space with no logical errors. To verify fault tolerance, there are two cases to check.
First, consider the case that, with at most one fault, all the gadget measurements give the trivial output (0 for a Z measurement, + for X). Since the gadgets catch two-qubit gate faults, we need only check possible one-qubit faults between gates. Inequivalent fault locations are marked with stars in Fig. 5(c). (Faults at other locations either cause the same errors, or will be caught.) In particular, entering error correction the possible error can be 1, X 1 , Z 1 , Y 1 , . . . , X 15 , Z 15 , Y 15from the locations. Or, from locations, it can be XIZZ, Y IZZ, IXZZ, IY ZZ, ZZXI, ZZY I, ZZIX, ZZIY , and IZXI, IZY I, IZIX, IZIY from locations, on qubits 8, 9, 10, 11-and similarly for qubits 12 to 15. This give 70 different errors total. All 70 have distinct syndromes, and therefore can be corrected. (This fact can be verified either by computing all the syndromes, or by observing from Eq. (7) that Z 8 Z 9 Z 10 Z 11 , Z 12 Z 13 Z 14 Z 15 , Z 1 Z 6 Z 7 , Z 1 Z 8 Z 9 , Z 1 Z 12 Z 13 and Z 1 Z 14 Z 15 are logical operators. Thus, for example, if you observe the Z syndrome 1000, for error X 8 , and the X syndrome 0001, for error Z 1 , you can safely correct X 8 Z 10 Z 11 . Z 1 X 8 cannot occur.) Note that the error-correction procedure needs to take into account the X and Z stabilizer syndromes together to decide what correction to apply. This can work because the [ [15,7,3]] code is not a perfect stabilizer code: there are 2 8 possible syndromes but only 1+15·3 possible trivial or weight-one errors. (It is only perfect as a CSS code, i.e., the 2 4 Z stabilizer syndromes are exactly enough to correct the 1 + 15 possible trivial or weight-one X errors, and similarly for Z errors.) This leaves room to correct some errors of weight more than one.
Next, consider the case that, with at most one fault in Fig. 5(c), one or more of the gadget measurements gives a nontrivial output. This case is much simpler, because the measurement results localize the fault, leaving only a few possibilities for the error entering error correction. One must verify that in all cases, these possibilities are distinguished by their syndromes.
For example, if the first Z measurement returns 1 and all other measurements are trivial, the errors from single faults that can occur are, on qubits 8, 9, 10, 11: The above operations do not generate the full sevenqubit logical Clifford group, and we have not been able to find a permutation for which applying Claim 3 enlarges any further the generated logical group. Instead, we turn to the round-robin construction of Claim 2.
Together with permutations and transversal operations, this circuit completes the seven-qubit Clifford group, without needing the operation from Sec. IV D. To make the operation fault tolerant, we will transform it in three steps.
First, consider the circuit below, in which we have wrapped the CZ gates leaving qubits 4, 8 and 12 with overlapping gadgets to catch X faults. If at most one fault occurs and one or more of the Z measurements gives 1, then the errors that can occur are distinguished by their syndromes.
For example, if the orange, first Z measurement off qubit 4 gives 1 and all others 0, then the possible errors entering error correction are, on qubits 4, 5, 6, 7: The circuit in Eq. (12) is not fault tolerant, however, because with at most one fault if all the Z measurements give 0, some inequivalent errors will have the same syndrome. We can list the problematic errors. For each of the following sets, the errors within the set are all possible, but have the same syndrome: Next replace each of the blue CZ gates in Eq. (12) with the ZZ fault gadget from Fig. 2(b). This gadget has the property that, with at most one failure, a ZZ fault can only occur if the X measurement returns −. These measurements thus distinguish the errors in the first three sets above.
Yet the new circuit is still not fault tolerant. The gadget measurements cannot distinguish the errors in each of the last six sets in (13). For example, consider an X 4 error before the circuit. It propagates to X 4 Z 5 Z 6 Z 7 . Since Z 4 Z 5 Z 6 Z 7 is a logical error, X 4 Z 5 Z 6 Z 7 is indistinguishable from a Y 4 error after the circuit, and no error-correction rules can correct for the possible logical error.
Gadgets cannot protect against single-qubit faults that occur just before or after the circuit. This circuit is qualitatively different from the one we considered in Sec. IV D, and a new trick is needed to make it fault tolerant.
Consider the following circuit from [10], ignoring for now the orange portion at top right.
This circuit fault-tolerantly extracts the syndrome of the Z {4,5,6,7,12,13,14,15} stabilizer, in the sense that: • With no gate faults, the Z measurement gives the syndrome, and the X measurement gives +.
• With at most one fault, if the X measurement gives +, then the data error has weight ≤ 1. In [10], this circuit was used in a two-ancilla-qubit faulttolerant error-correction procedure. The circuit in (14) is useful for us now to detect an X 4 or Y 4 error on the input to (12). However, it is not enough to measure the Z syndrome, or even to run full error correction, before applying the circuit (12), because an X 4 or Y 4 fault could happen after the syndrome measurement completes and before (12). This problem is solved by the orange portion of (14), which is meant to continue into (12), replacing the first |0 preparation and CNOT. It gives qubit 4 temporary protection, so that an X 4 or Y 4 fault is caught by either the syndrome measurement or the orange Z measurement, or both.
While the above arguments give intuition for the construction, they leave out the details. Let us now present the full fault-tolerant construction.
3. If the measurements so far were trivial, then apply a circuit analogous to (14) to extract the Z {8, 9,10,11,12,13,14,15} syndrome. (Note that this is still a stabilizer, even though the CZ gates 4 to {5, 6, 7} have changed the code.) If the Z syndrome or X measurement is nontrivial, then apply error correction-a simple errorcorrection procedure is to apply CZ gates 4 to {5, 6, 7} to move back to the [ [15,7,3]] code and correct therebefore finishing with CZ gates 8 to {9, 10, 11} and 12 to {13, 14, 15}. If the Z and X measurements were trivial, then apply the middle portion of (12), where the orange qubit wire extends from qubit 8, to implement protected CZ gates 8 to {9, 10, 11}. If any measurements are nontrivial, then finish by applying unprotected CZ gates from 12 to {13, 14, 15}, then error correction.
4. If the measurements so far were trivial, then extract the Z {8,9,10,11,12,13,14,15} syndrome using (14) except with the data qubits in order 12,13,14,15,8,9,10,11 top to bottom (so that the orange flag attaches to qubit 12). If the Z or X measurement is nontrivial, then with at most one fault whatever error there is on the data can be corrected. (The easiest way is to move forward to the [ [15,7,3]] code using CZ gates 12 to {13, 14, 15} and correct there. Note that these CZ gates turn the weight-one errors X 12 , X 13 , X 14 , X 15 into X 12 Z {13,14,15} , Z 12 X 13 , Z 12 X 14 , Z 12 X 15 , respectively, but these can still be corrected; e.g., if in X error correction you detect X 12 , apply the correction X 12 Z {13,14,15} .) If the Z and X measurements were trivial, then apply the bottom portion of (12) to implement protected CZ gates from 12 to {13, 14, 15}, and correct errors based on the measurement results.
Observe that this procedure requires two ancilla qubits.
F. Four-qubit fault-tolerant CCZ for universality In order to realize a universal set of operations on the seven encoded qubits, we give a four-ancilla-qubit fault-tolerant implementation for an encoded CCZ gate. The idea is to start with a circuit of round-robin CCZ gates to implement the encoded CCZ non-fault-tolerantly (Claim 2), then replace each CCZ with the gadget of Eq. (2) to catch correlated errors. Finally, we intersperse X error correction procedures to catch X faults before they can spread, much like the pieceable fault-tolerance constructions of [11]  To make this circuit fault tolerant, first replace each CZ gate with the gadget from Fig. 2(c), and replace each CCZ gate with the gadget from Eq. (2). After each gadget, apply X error correction, and at the end apply both X and Z error correction. (As in [11], it might be possible to put multiple CCZ gadgets before each X error correction, but we have not tried to optimize this.) Observe that X error correction can be implemented even partially through the round-robin circuit because the code's Z stabilizers are preserved by CCZ gates.
There are two cases to consider to demonstrate fault tolerance: either a gadget is "triggered" with a nontrivial, 1 or −, measurement outcome, or no gadgets are triggered.
1. A gadget is triggered. If a gadget is triggered, then any Pauli errors can be present on its output data qubits. It is straightforward to check mechanically that for each CZ gate in (15), all four possible X errors, II, IX, XI and XX, have distinct Z syndromes, and so can be corrected immediately in the subsequent X error correction, before the errors can spread. By symmetry, the four possible Z errors have distinct syndromes. These errors commute through (15) and are fixed by the final Z error correction.
Similar considerations hold for each CCZ gate: the possible X and Z error components have distinct syndromes, so an error's X component can be corrected immediately and the Z component corrected at the end.
2. No gadgets are triggered. If there is a single failure in a CZ or CCZ gadget, but the gadget is not triggered, then the error leaving the gadget is a linear combination of the same Paulis that could result from a one-qubit X, Y or Z fault before or after the gadget.
If the error has no X component, then as a weight-one Z error it commutes to the end of (15), at which point Z error correction fixes it.
If the error has X component of weight one, then the Z component can be a permutation of any of III, IIZ, IZZ, ZZZ on the three involved qubits (or of II, IZ, ZZ for a CZ gadget). As we have already argued, these Z errors have distinct X syndromes. The X error correction immediately following the gadget will catch and correct the error's X component, keeping it from spreading. The final Z error correction, alerted to the X failure, will correct the error's Z component.

V. CONCLUSION
Space-saving techniques for fault-tolerant quantum computation should be useful both for large-scale quantum computers and for nearer-term fault-tolerance experiments. Our techniques can likely be optimized further, and adapted to experimental model systems-but it might also be useful to relax the space optimization and allow a few more qubits. The techniques can also likely be applied to other codes, especially distance-three CSS codes. The round-robin CZ and CCZ constructions apply to some non-CSS codes, such as the [ [8,3,3]] code, but then are more difficult to make fault tolerant.