## Abstract

Quantum computers will eventually reach a size at which quantum error correction becomes imperative. Quantum information can be protected from qubit imperfections and flawed control operations by encoding a single logical qubit in multiple physical qubits. This redundancy allows the extraction of error syndromes and the subsequent detection or correction of errors without destroying the logical state itself through direct measurement. We show the encoding and syndrome measurement of a fault-tolerantly prepared logical qubit via an error detection protocol on four physical qubits, represented by trapped atomic ions. This demonstrates the robustness of a logical qubit to imperfections in the very operations used to encode it. The advantage persists in the face of large added error rates and experimental calibration errors.

## INTRODUCTION

The discovery of quantum error correction codes gave credibility to the idea of scaling up physical quantum systems to arbitrary sizes (*1*–*3*). Showing that all elements of error correction can be realized in a fault-tolerant way is therefore of fundamental interest. Fault tolerance removes the assumption of perfect encoding and decoding of logical qubits (*4*), because the logical error probability scales as a convex function of the physical error probability for small errors (*5*). Although several experiments have shown a reduction of high intrinsic or artificially introduced errors in logical qubits (*6*–*14*), fault-tolerant encoding of a logical qubit has never been demonstrated. We note that there are subtle issues with respect to the definition of fault tolerance that are beyond the scope of this paper.

Here, we implement a four-qubit error detection code with two stabilizers (see Fig. 1). This leaves two possible encoded qubits, *L*_{a} and *L*_{b}, for which errors can be detected: a [[4, 2, 2]] code (*15*, *16*). The preparation and error detection procedures considered here are fault-tolerant on only a single encoded qubit. From a fault tolerance perspective, this is a [[4, 1, 2]] subsystem code where the logical qubit *L*_{a} is protected and the gauge qubit *L*_{b} is not. As such, the code was used in experiments with photonic qubits (*17*, *18*). By instead considering errors on both encoded qubits, we highlight the importance of fault tolerance for reducing intrinsic errors and managing error propagation. The non–fault-tolerant procedures that generate *L*_{b} still succeed in reducing added errors.

The code implements *L*_{a} and *L*_{b} on only four physical qubits and hence violates the quantum Hamming bound (*5*), which means that detected errors cannot be uniquely identified and corrected. We must therefore rely on postselection to find and discard cases where an error occurred. The code does have the advantage of requiring only five physical qubits for the fault-tolerant encoding of *L*_{a}: four data qubits and one ancilla qubit.

The logical codewords |*L*_{a}*L*_{b}〉_{L} in the computational or *Z*-basis are(1*A*)(1*B*)(1*C*)(1*D*)and with , we can write them down along *X* as follows(2*A*)(2*B*)(2*C*)(2*D*)

The encoding of different initial states is shown in Fig. 2 (A to D). The fault tolerance arises because the circuits for encoding and syndrome extraction are carefully constructed such that a single physical qubit error occurring anywhere cannot lead to an undetectable error on logical qubit *L*_{a}. It comes at the cost of the logical gauge qubit *L*_{b}, for which there is such an undetectable error channel. An example of this is shown in Fig. 2G.

With the Pauli operators *X*, *Y*, and *Z* and the identity *I*, the logical operators are(3*A*)(3*B*)(3*C*)(3*D*)

With these operators and the circuits given in Fig. 2 (A to D), any state |*L*_{a}*L*_{b}〉_{L} can be generated maintaining the fault tolerance of *L*_{a}.

The [[4, 2, 2]] code has the additional advantage that, in contrast to other codes (*19*), fault-tolerant syndrome extraction for the logical qubit *L*_{a} can be achieved using a bare ancilla, that is, an ancilla qubit that is not itself a logical qubit. The stabilizers to extract logical phase-flip (*Z*) and bit-flip (*X*) errors are *S*_{x} and *S*_{z}, respectively(4*A*)(4*B*)

As in a Bacon-Shor code block (*20*, *21*), the code space together with the logical operators and stabilizers form a subsystem that allows local syndrome extraction similar to that of Napp and Preskill (*22*), as depicted in Fig. 1. The difference is that the stabilizers have weight 4 because we simultaneously extract information about the gauge qubit *L*_{b}. Applying these stabilizers conditional on the state of an ancilla qubit extracts the parity of the data qubits along *X* or *Z* (see Fig. 2, E and F). Measuring the ancilla yields either |0〉, indicating no error, or |1〉, meaning an error has occurred and the run is to be discarded. With only one ancilla qubit available, we measure the two stabilizers in separate experiments. Because we prepare eigenstates of logical Pauli operators, only logical Pauli operations that change the ideal state result in errors. Both stabilizer measurements serve to determine the overall yield, that is, the fraction of runs for which no error was indicated. In addition to the error checks provided by stabilizer measurements, only even-parity outcomes are accepted when the data qubits are measured at the end of the circuit. Note that similar weight 4 stabilizers have recently been implemented in superconducting qubits (*23*).

We implement the [[4, 2, 2]] code on a fully connected quantum computer comprising a chain of five single ^{171}Yb^{+} ions confined in a Paul trap (see Materials and Methods). The state-detection fidelity for a single qubit is 99.7(1)% for state |0〉 and 99.1(1)% for state |1〉. A general five-qubit state is detected with 95.7(1)% fidelity. Single- and two-qubit gate fidelities are typically 99.1(5) and 97(1)%, respectively. Typical gate times are 20 and 250 μs for single- and two-qubit gates, respectively. The computational gates H and CNOT are generated by combining several physical-level single- and two-qubit gates in a modular fashion (*24*).

## RESULTS

We start by preparing state |00〉_{L} using the circuit shown in Fig. 2A. The results of measuring this state directly after preparation are shown in Fig. 3A. The target states 0 (|00000〉) and 30 (|11110〉) show that we succeed in preparing and measuring this state with ≃90% probability. The data yield 91.1(4)% even-parity outcomes from the four data qubits. Breaking these results down by logical state gives 98.0(2)% population in the target state |00〉_{L}. The error falls almost entirely on |01〉_{L}, which corresponds to a 1.7(2)% error on the non–fault-tolerantly prepared gauge qubit *L*_{b}. The 0.11(6)% error exclusively on *L*_{a} is an order of magnitude lower than this, and at a similar level to the 0.18(7)% logical two-qubit error resulting in |11〉_{L}. For the logical state preparation step, both of these small erroneous state populations are dominated by physical readout errors.

With |00〉_{L} thus prepared, we apply in turn the two stabilizers *S*_{z} and *S*_{x}, shown in Fig. 2 (E and F), for nondemolition syndrome extraction. The results are shown in Fig. 3B. Populations in the odd-numbered states reflect events where an error is detected by a stabilizer. The results of the logical states are similar, with |00〉_{L} populations of 97.8(2) and 97.1(3)%, respectively, and the errors occur predominantly in the non–fault-tolerantly prepared gauge qubit *L*_{b}. The errors on *L*_{a} are 0.2(1)%, similar to the error floor given by the |11〉_{L} population, which is slightly higher than after mere state preparation due to the additional gates introduced by the stabilizers. *S*_{x} introduces *X*-type errors in the system, which can be seen from a higher *L*_{b} error. *S*_{z} introduces *Z*-type errors, which do not affect |00〉_{L}. The opposite is true when applying the stabilizers to |++〉 instead. Table 1 (see Materials and Methods) summarizes results for different logical states prepared with the circuits shown in Fig. 2 (A to D). The circuit elements that dominate the intrinsic errors in our system are the two-qubit gates. Note that after a circuit with seven CNOT gates, each of which introduces 3 to 4% infidelity, we obtain the correct answer |00〉_{L} with 97 to 98% probability. The gauge qubit *L*_{b} circuit failures occur at approximately the error rate of one two-qubit gate, whereas *L*_{a} errors are suppressed substantially below that level to <1%. These results show the power of fault-tolerant preparation and stabilizer measurement. The circuits succeed in discarding nearly all errors, but we pay a price because the yield is in the 65 to 75% range. We must expect to discard around half of the runs when measuring both stabilizers. The yield is higher for preparation of logical states without syndrome measurements because there are fewer gates to introduce error and there is only a single selection step.

The [[4, 2, 2]] code allows transversal operations, that is, single-qubit logical gates that are generated by applying single-qubit physical gates. To show an example of this, we prepare |00〉_{L} followed by the logical *X*_{a}*X*_{b} operation consisting of *X*-gates on physical qubits 2 and 3. This gives |11〉_{L}, on which we apply the *S*_{x} stabilizer followed by readout. The yield is 77.3(6)%, and the logical state populations are as follows: |00〉_{L}, 0.4(1)%; |01〉_{L}, 0.3(1)%; |10〉_{L}, 2.8(3)%; and |11〉_{L}, 96.5(3)%. Apart from surpassing *L*_{b} as before, the *L*_{a} error of 0.7% also outperforms the physical qubit. We find that after an *X*-gate, the correct state of a physical qubit is measured with 98.8(2)% fidelity, nearly a factor of 2 worse than *L*_{a}. The infidelity in this case is dominated by the single-qubit detection error of 0.9(1)% for |1〉, which the code successfully suppresses in *L*_{a}.

To further investigate the robustness of the code, we add two kinds of error to the system. First, we deliberately introduce single- and two-qubit Pauli errors and study how errors on *L*_{a} and *L*_{b} scale with increasing physical qubit errors. Instead of trying to reproduce a stochastic error channel, which can be tedious for low error rates (*25*), we sample the various error configurations and then multiply them by their respective statistical importance to obtain a logical error probability (see Materials and Methods). We further compare our experimental results to an exact simulation with optimized error parameters (see Materials and Methods). The results are shown in Fig. 4A. The clear separation between the two logical qubits is persistent until they converge above 20% introduced error and approach the curve for the theoretical case without intrinsic errors. In this example, a physical qubit prepared in state |0〉 is outperformed by logical qubit *L*_{a} over the entire range, although our measurement uncertainty limits the significance of this to above *p* ~ 0.07%. *L*_{b} outperforms the physical qubit above 4% added error (solid black line in Fig. 4A). For state preparations |−〉 and |1〉, *L*_{a} also outperforms the physical error based on circuits of preparation and measurement, whereas for |+〉, the errors are consistent within statistical uncertainty (see Table 1).

Second, we run the |00〉_{L} data with purposefully miscalibrated two-qubit gates. The results for the logical errors are shown in Fig. 4C. The error gap of nearly an order of magnitude between *L*_{a} and *L*_{b} persists over a wide range of calibration errors, which are absorbed into a reduced yield as shown in Fig. 4B. This proves that the code succeeds in protecting qubit *L*_{a} against intrinsic systematic errors.

## DISCUSSION

Note that the [[4, 2, 2]] code is relevant beyond its limited immediate application as an error detection code. It forms the base encoding layer of the high-threshold Knill C4/C6 code (*26*) and of a recent proposal for a topological code (*27*), and it is equivalent to one face of the distance 3 color code (*28*) or the Steane code (*2*). The code is robust to the high levels of intrinsic errors present in current realizations of quantum computers. We find no evidence of unexpected two-qubit correlated errors, which are always assumed absent when constructing error correction procedures. Therefore, our results both serve as a demonstration that this underlying model is correct and pave the way toward error-corrected quantum computations on a larger scale.

## MATERIALS AND METHODS

### Experimental system

The experiment was performed on a quantum computer consisting of a chain of five single ^{171}Yb^{+} ions confined in a Paul trap and laser-cooled near the motional ground state. Each ion provided one physical qubit in the form of a pair of states in the hyperfine-split ^{2}*S*_{1/2} ground level with an energy difference of 12.642821 GHz, which is magnetic field–independent to first order. This so-called “atomic clock” qubit has a typical coherence time of 0.5 s, which could be straightforwardly extended by suppressing magnetic field noise. All qubits were collectively initialized by optical pumping and measured via state-dependent fluorescence detection (*29*). Each ion was mapped to a distinct channel of a photomultiplier tube array. Its state could be detected with 99.4(1)% average fidelity, although a five-qubit state was read out with 95.7(1)% average fidelity, limited by channel-to-channel cross-talk. Qubit manipulation was achieved by applying two Raman beams from a single 355-nm mode-locked laser, which formed beat notes near the qubit frequency. The first Raman beam was a global beam applied to the entire chain, whereas the second was split into individual addressing beams, each of which could be switched independently to target any single qubit (*24*). Single qubit gates were generated by driving resonant Rabi rotations of defined phase, amplitude, and duration. Two-qubit gates (so-called *XX*-gates) were realized by illuminating two ions with beat-note frequencies near the motional sidebands and creating an effective spin-spin (Ising) interaction via transient entanglement between the state of two ions and all modes of motion (*30*–*32*). To ensure that the motion was left disentangled from the qubit states at the end of the interaction, we used a pulse shaping scheme by modulating the amplitude of the global beam (*33*, *34*).

### Artificial stochastic errors

To analyze how the code copes with artificially introduced stochastic errors, we prepared logical state |00〉_{L} and added a specific Pauli error, for example, *I* ⊗ *X* ⊗ *Y* ⊗ *I*. We then applied the *S*_{z} stabilizer and measured the state. We repeated this for different error configurations ε. The error probability *p* on a physical qubit corresponds to an *X*, *Y*, or *Z* error, each occurring with probability *p*/3. The number of errors that appear in a particular error configuration is given by its weight *w*, and its probability of occurrence or statistical importance is *p*_{o} = (*p*/3)^{w}(1 − *p*)^{4−w}. The probability of a logical error is given by(5)

The sum runs over all error configurations. *p*_{a} is the yield, that is, the probability that a run is accepted, and *p*_{f} is the probability of failure after postselection, that is, the probability that an accepted run suffers a logical error. The dividend is the number of accepted runs with a logical error, whereas the divisor is the number of accepted runs (both divided by the total number of runs). The parameters *p*_{a} and *p*_{f} were found from either experiment or simulation (see Fig. 4A). Out of the total number of error configurations, . We covered the error configurations of weight 0 and 1 exhaustively. For the *w* = 2 subset, we only sampled 27 representative configurations out of the total 54 and doubled their weight. The weight 3 and weight 4 subsets were not sampled, and their logical error rates were set to zero, because their statistical importance is significant only at very high added error rates. In the limit of no intrinsic errors, that is, perfect gates, preparation, and measurement, both logical qubits had the same error rate under this model (dash-dotted line in Fig. 4A). We found this error rate from Eq. 5 by counting accepted error configurations with *w* ≤ 2 (denominator) and checking which of those caused an error (numerator).(6)

The dashed curves in Fig. 4A were obtained by performing a full density matrix simulation of the five-qubit circuits. We used a simplified error model to emulate experimental errors. The model had three independent parameters corresponding to errors associated with over- or underrotations after (i) single-qubit and (ii) two-qubit gates and (iii) phase errors caused by Stark shifts. An experimentally found state-transfer matrix was used to take state preparation and detection errors, including cross-talk, into account. We then optimized the model over the parameter space to minimize the difference between the final state populations of the experimental and simulated circuits. The resulting values for the error rates were 0.50, 1.0, and 1.4%, respectively.

The physical error curve in Fig. 4A is the straight line *p*_{p} = *r* + (2/3 *F*_{x})*p*, where *r* = 0.003 is the readout error for a physical qubit in state |0〉. The slope is 2/3 *F*_{x} because one in three added errors is a *Z*-type error, which does not affect |0〉, and *F*_{x} = 0.997 is the success probability of a physical spin flip operation.

This is an open-access article distributed under the terms of the Creative Commons Attribution-NonCommercial license, which permits use, distribution, and reproduction in any medium, so long as the resultant use is **not** for commercial advantage and provided the original work is properly cited.

## REFERENCES AND NOTES

**Acknowledgments:**We thank J. Kim and D. Maslov for helpful discussions and D. Gottesman for useful comments.

**Funding:**This work was supported by the Army Research Office with funds from the Intelligence Advanced Research Projects Activity LogiQ program (grant 3130638), the Air Force Office of Scientific Research Multidisciplinary University Research Initiative program on Quantum Measurement and Verification (grant 5710003628), and the NSF Physics Frontier Center at the Joint Quantum Institute (grant PHY0822671).

**Author contributions:**N.M.L., M.G., K.A.L., C.F., S.D., K.R.B., and C.M. all contributed to the experimental design, construction, data collection, and analysis of this experiment. All authors contributed to this manuscript.

**Competing interests:**C.M. is a founding scientist of IonQ Inc. All other authors declare that they have no competing interests.

**Data and materials availability:**All data needed to evaluate the conclusions in the paper are present in the paper. Additional data related to this paper may be requested from the authors.

- Copyright © 2017 The Authors, some rights reserved; exclusive licensee American Association for the Advancement of Science. No claim to original U.S. Government Works. Distributed under a Creative Commons Attribution NonCommercial License 4.0 (CC BY-NC).