Experimental fault-tolerant universal quantum gates with solid-state spins under ambient conditions

Quantum computation provides great speedup over its classical counterpart for certain problems. One of the key challenges for quantum computation is to realize precise control of the quantum system in the presence of noise. Control of the spin-qubits in solids with the accuracy required by fault-tolerant quantum computation under ambient conditions remains elusive. Here, we quantitatively characterize the source of noise during quantum gate operation and demonstrate strategies to suppress the effect of these. A universal set of logic gates in a nitrogen-vacancy centre in diamond are reported with an average single-qubit gate fidelity of 0.999952 and two-qubit gate fidelity of 0.992. These high control fidelities have been achieved at room temperature in naturally abundant 13C diamond via composite pulses and an optimized control method.

(c) Calculated average gate fidelity of a BB1inC π/2 gate with sampled waveforms without (left penal) and with (right penal) the correction. The region of fidelity larger than 0.9999 is labeled.  Here ρ i denotes the initialized state with laser, ρ f denotes the final state after applying control sequence to ρ i . π RF (π RF1 ) is a radio-frequency π pulse driving the nuclear spin transition between states |m S = 0, m I = 1 and |m S = 0, m I = 0 (transition between states |m S = 0, m I = 0 and |m S = 0, m I = −1 ). The measured photoluminescence intensity after each sequence is denoted by S 1 , S 2 , R 1 , or R 2 .    The NV center includes a substitutional nitrogen atom and a vacancy in the nearest-neighbor lattice position. In our experiment, a static magnetic field, B 0 = 513 G, is applied along the NV symmetry axis ([1 1 1] crystal axis). The Hamiltonian of the NV center can be written as where The strength of the hyperfine interaction is about 2 MHz. Because of the strong zero field splitting and Zeeman splitting terms of the electron spin, the effect of the interaction term S x I x + S y I y is strongly suppressed and can be neglected. A = −2.16 MHz is determined via CW ESR experiment. In the secular approximation, the Hamiltonian is The electron (nuclear) spin states |m S = 0 and |m S = −1 (|m I = 0 and |m I = +1 ) are encoded as the electron (nuclear) spin qubit.
Microwave (MW) and radio-frequency (RF) pulses are used to manipulate the two-qubit system. The frequency of MW and RF pulses are f MW and f RF , respectively. When MW pulses are applied, the total Hamiltonian becomes with where φ is the phase of the MW pulse, ω 1 is the amplitude of the MW pulse.
The Hamiltonian can be transformed into the rotating frame as with With rotating-wave approximation, the Hamiltonian in the rotating frame can be simplified as where with , δΩ = D − ω S − A − f MW , f RF = −P + ω I , and I representing 3 × 3 identity matrix.

Supplementary Note 2: Calculation of average gate fidelity
The average gate fidelity between a quantum operation ξ and a target unitary quantum gate U is defined as where the integral is over the uniform measure dψ on state space, normalized so dψ = 1 1 .
In the single-qubit case, the average gate fidelity can be derived to be 2 where σ x , σ y , and σ z are Pauli matrices.
Quantum optimal control method 3 is used to design the pulse sequence of CNOT gate. To calculate the average gate fidelity of this CNOT gate, Eqn. 12 is generalized so that the integral is on the two-qubit space 4 . The nuclear spin is much less sensitive to the external magnetic noise than the electron spin and the GRAPE pulse sequence contains only microwave pulses, so the decoherence during the operation mainly comes from the static distributions of δ 0 and δ 1 for the electron spin qubit. Then the operation can be expressed as where U seq (δ 0 , δ 1 ) is the calculated two-qubit evolution according to the pulse sequence, with the errors δ 0 and δ 1 considered in Hamiltonian. Substituting Eqn. 14 into Eqn. 12 yields the average gate fidelity between the operation ξ and the target CNOT gate U CNOT , with d = 4 and It can be easily obtained from Eqn. 15 that the fidelity of operation ξ without the effect of the noise (δ 0 and δ 1 ) can be written as where the values of δ 0 and δ 1 are zero.

Supplementary Note 3: High fidelity single-qubit quantum gates
Considering a single-qubit gate corresponding to a rotation of angle θ around the x axis on the Bloch sphere, such a gate can be realized by evolution under the effective Hamiltonian H ideal = 2πω 1 n · S, where S = (S x , S y , S z ) is the spin vector operator of the qubit, n is a three-dimensional vector, and the strength ω 1 is a real parameter. The average gate fidelity is limited by interaction of the qubit with environment and fluctuation of the control field. We consider the model where the Hamiltonian for rotation about the x axis under practical conditions is described as The error δ 0 in the Hamiltonian is due to the interaction of the qubit with environment, the error δ 1 is due to fluctuation of the control field strength and phase error δφ is caused by the imperfect microwave pulse generation. Phase error can be efficiently eliminated by pulse fixing technique (detailed in Section ) and we take it as of zero value in this section. We consider the case where both δ 0 and δ 1 vary in a timescale much longer than that of quantum gates. In this case δ 0 and δ 1 are taken as quasi-static random constants.
Supplementary Figure 1a shows the performance of the gate by simply applying a naive rectangular pulse. Here the gate (π/2) 0 (we denote the rotation of an angle θ around the axis in the equatorial plane with azimuth φ as (θ) φ ) is taken as an example. The average gate fidelity of (π/2) 0 is calculated with respect to different values of δ 0 and δ 1 . The naive pulse is vary sensitive to the errors δ 0 and δ 1 , with leading orders of both errors preserved in the evolution operator Supplementary Figure 1b shows a type of dynamically corrected gate, five-piece SUPCODE 5 .
The pulse sequence is depicted as Here τ 1 = csc θ(1 − 2 cos θ 2 + cos θ + 4 − 8 cos θ 2 + 4 cos θ + θ sin θ) and τ 3 = −2(τ 1 cos θ 2 + sin θ 2 ) are durations when control field is off. Under the five-piece SUPCODE pulse, up to second order of δ 0 can be canceled (corresponding to sixth order preserved in the average gate fidelity). In the lower panel of Supplementary Figure 1b, the average gate fidelity of (2.5π) 0 (equivalent to (π/2) 0 in the single-qubit case) is shown as an example. The region of high average gate fidelity is largely extended in the axis of δ 0 , compared with that by the naive pulae.
In Supplementary Figure 1c a type of composite pulse, BB1 6 , is shown. The pulse sequence Under the BB1 pulse, up to second order of δ 1 is canceled in the evolution operator (corresponding to sixth order preserved in the average gate fidelity). The average gate fidelity of (π/2) 0 with the BB1 pulse is shown in the lower panel of Supplementary Figure 1c. It exhibits a larger region of high fidelity in the axis of δ 1 .
Thus suppressing the δ 1 error by applying the BB1 pulse, in combination with a proper selection of control field strength ω 1 to suppress the δ 0 error, can contribute to realization of a high fidelity (e.g. 0.9999).
Supplementary Figure 1d shows a pulse sequence suppressing both the δ 0 and δ 1 errors simultaneously. The sequence is designed by incorporating the BB1 pulse within the CORPSE pulse, and is named BB1inC here for short. There are similar pulse sequences to suppress the δ 0 and δ 1 error simultaneously 7  Recently the robustness of composite pulse sequences against time-dependent noise is analyzed 8 .
It is shown that composite pulses may also be successfully employed in the presence of timedependent noise. The robustness against static as well as time-dependent noise enables composite pulse an effective method to improve single-qubit gate fidelity.
Supplementary Note 4: Quantum optimal control method for designing the CNOT gate GRAPE is a type of quantum optimal control method. It can be utilized to design control sequence to realize a target gate with high fidelity. The control sequence contains N piece of pulses, with the amplitude and phase of each piece being different. The total Hamiltonian of the kth pulse in the rotating frame is (see Eqn. 8 and Eqn. 9) with where φ k is the phase of the kth pulse, ω 1,k is the amplitude of the kth microwave pulse and δΩ = 0.
The evolution operator under the kth pulse is written as where t k is the duration of the kth pulse. The total evolution under the entire sequence is The time duration of each pulse, t k , is set to be equal value τ . The two-qubit evolution operator can be described as where P is the projection operator on the two-qubit subspace.
The target gate is the CNOT gate, The performance function of the GRAPE algorithm is the fidelity F seq , which is a function of The values of {ω 1,k , φ k } are initialized with random numbers within the experimental conditions. The performance function are maximized by iteration. Within each iteration, the value of F seq ({ω 1,k , φ k }) as well as its derivative to ω 1,k and φ k is calculated, then the value of ω 1,k (φ k ) is replaced by the result of its previous value plus the derivative multiplied by a proper coefficient.
This method works well for designing a sequence with high fidelity, if errors due to qubitenvironment interaction and control field fluctuation are not taken into account. However, our aim is to realize quantum gates, which are not only of high fidelity, but also being robust to the errors.
A method has been presented 3 to design pulse sequence which is robust against the inhomogeneity of ω 1 . Herein, we generalize this method to design pulse sequence, which is not only robust against the inhomogeneity δ 1 , but also is insensitive to the dephasing noise δ 0 . The performance function of the modified GRAPE is defined as F a (ε, U CNOT ) (see Eqn. 15). The new performance function is maximized by iteration of the GRAPE algorithm. In practical implementation of the modified algorithm, the integral in Eqn. 15 is replaced by sum of discrete points. We find that three points of δ 0 (δ 1 ) are enough.
Supplementary Figure 2a shows the amplitude and phase of the designed pulse sequence.
The sequence consists of twelve pieces of pulse. The duration of each pulse is 58 ns. Without considering the errors δ 0 and δ 1 , the sequence produces a two-qubit operation U cal , The fidelity of U cal is 0.9995. Supplementary Figure 2b shows the robustness of the sequence against the errors δ 0 and δ 1 . When the experimental distributions P 0 (δ 0 ) and P 1 (δ 1 ) (which are determined from the experiments) are considered, the sequence provides an average gate fidelity of 0.9927.
Supplementary Note 5: Alignment of the magnetic field, Creation of a solid immersion lens,

Ultra-broadband coplanar waveguide
We used the fluorescence dependence on the misalignment angle to align the magnetic field. According to the literature 9 , the fluorescence of NV center is sensitive to misalignment angle of the NV axis from a magnetic field B 0 when the magnitude is approximately 513 G. The difference in fluorescence counts is still noticeable even when the misalignment angle is only 0.5 • . In our experiment, the fluorescence count was the same (within counting errors) for B 0 ≈ 0 G and B 0 ≈ 513 G.
So we estimate the misalignment angle to be within 0.5 • .
All measurements in our experiment are based on detection of the NV photoluminescence.
Much of the photoluminescence is lost at the diamond surface due to internal reflection. The problem can be overcome by creating a solid immersion lens (SIL) 10 . We created a SIL in the diamond around an NV center (Supplementary Figure 3). The SIL increases the PL rate to about 400 kcounts s −1 .
In the experiment, manipulation of qubits is achieved by microwave (MW) and radio-frequency (RF) pulses, which are applied through a coplanar waveguide (CPW). The ultra-broadband CPW is designed and fabricated. Supplementary Figure 4 shows scattering parameters of the CPW. Up to 15 GHz, the S21 parameter is larger than -3 dB, and the S11 parameter is about or less than -10 dB. Such wide bandwith ensures that there is almost no extra distortion of microwave / RF pulses with this CPW.

Supplementary Note 6: Correction of microwave pulse distortions
The imperfect devices generate microwave pulses with non-ideal amplitudes and phases. The imperfection of microwave pulses sent to the NV centers are carefully corrected with pulse fixing

Supplementary Note 7: Normalization of the experimental data
In the single-qubit experiment, the normalization is carried out by performing a nutation experiment 12 .
The normalized data corresponds to the population of |0 for the final state.
In the two-qubit experiment, the population of |m S = 0, m I = 1 (P |01 ) for the final state is where |k denotes the nine energy levels of the NV center (|m S , m I with m S = 0, ±1 and m I = 0, ±1), P ρ,|k is the population of |k for the state ρ, β k is the photoluminescence intensity if the state is |k .
In Supplementary Figure 8, ρ i denotes the initialized state after initializing laser pulse, ρ f denotes the final state after applying control sequence to ρ i . The RF (RF1) π pulse exchanges the population of |m S = 0, m I = 1 and |m S = 0, m I = 0 (|m S = 0, m I = 0 and |m S = 0, m I = −1 ). The measured I PL after the four sequences (S 1 , S 2 , R 1 , and R 2 , respectively) satisfy where P |k (P ρ i ,|k ,) is the population of |k for ρ f (ρ i ). After the initializing laser pulse, the electron spin is polarized with coefficient α, and the nuclear spin is almost completely polarized. Thus we have P ρ i ,|0,1 = α and P ρ i ,|0,−1 = 0. The state |m S = 0, m I = −1 remains idle during the control sequence, thus P |0,−1 = 0. The population of |m S = 0, m I = 1 for the final state can be derived as

Supplementary Note 8: Measuring the polarization of the NV electron spin
The measurement of the polarization described here is similar to that described before 13 . Supplementary Figure 9 shows the results and pulse sequences used in the measurement. We first recorded the nuclear Rabi oscillation by driving the |m S = 0, m I = 1 and |m S = 0, m I = 0 transition. The nuclear spin is almost completely polarized. The amplitude of this nuclear Rabi oscillation is proportional to the polarization α of the electron spin, with Secondly, another nuclear Rabi oscillation is recorded after a MW2 π pulse. The MW2 π pulse exchanges the population of |m S = 0, m I = 1 and |m S = −1, m I = 1 . The amplitude of this nuclear Rabi oscillation is proportional to the population of |m S = −1, m I = 1 for the initialized state.
Then the polarization α can be obtained with With the results shown in Supplementary Figure 9, we estimated the polarization of the NV electron spin to be α = 0.83(2).

Supplementary Note 9: Measurement of the average gate fidelity
We first describe the method for measuring the average gate fidelity of single-qubit gates. The average gate fidelity of single-qubit gates are measured with randomized benchmarking (RB) method 14 .
Unlike that with quantum process tomography, the measured fidelity with RB method is not limited by errors in state preparation and measurement. The qubit is initialized to |0 , then a predetermined sequence of randomized computational gates is applied. Each computational gate consists of a Pauli gate followed by a (non-Pauli) Clifford gate. Pauli gates are randomly chosen to rotate the qubit about the ±x, ±y, or ±z axes for an angle π on the Bloch sphere, or to be a ±I identity gate; Clifford gates are randomly chosen to rotate about the ±x or ±y axes for an angle π/2. The gate sequence is followed by a final Clifford gate chosen to ensure that the final qubit state is |0 if all the gates are ideal. The fidelity of the final state ρ f , F = 0|ρ f |0 , is measured. The measured final state fidelity is averaged over different random sequences. The averaged fidelity, F , is fitted with Eqn. 32 where l is the number of computational gates, ε g is the average error per gate, and d if describes errors in state preparation and measurement. The average gate fidelity is In the experiment, ±x, ±y rotations are realized by proper microwave settings, and ±z rotations are implemented by a rotation of the logical frame of the qubit for the subsequent pulses [15][16][17] .
For the naive pulse, each Clifford gate is performed by a rectangular π/2 pulse and each Pauli gate by a rectangular π pulse; For the five-piece SUPCODE pulse, each Clifford gate is performed by a five-piece SUPCODE 2.5π pulse (equivalent to π/2 in the single-qubit case, see Section ) and each Pauli gate by a pair of five-piece SUPCODE 2.5π pulses; For the BB1 (BB1inC) pulse, each Clifford gate is performed by a BB1 (BB1inC) π/2 pulse and each Pauli gate by a BB1 (BB1inC) π pulse (see Section ).
The RB results for naive, five-piece SUPCODE, BB1 and BB1inC pulses are shown in Fig.   2 However, in the hybrid system composed of electron and nuclear spins, single-qubit gates on the nuclear spin cost longer time than the electron coherence time. The error of gates on the nuclear spin will dominate the fidelity decay in randomized benchmarking, and the gate fidelity of CNOT can not be precisely determined this way.
Herein, we present a method to estimate the average fidelity of CNOT gate. We determine the fidelity by repeated application of the CNOT gates on the system. A wealth of information can be obtained by studying the state dynamics under repeated application of quantum gates 18 . In Ref.
19, CNOT gates were repeatedly applied on the input state generated by X −π/2 ⊗ I, and the fidelity F s of final states were measured. The fidelity F s decays as the number of the CNOT gate, N , is increased. The maximum value of N was 12 in that work. By assuming that the decay obeys an exponential model, the gate fidelity F g can be extracted.
The pulse sequence used in our experiment is shown in the inset of Fig. 4e in the main text. The initial state of the two-qubit system is prepared by applying a RF π/2 pulse after the initial laser pulse. Then N , which is even, times of repeated CNOT gates are applied. Finally, the population of state |01 (P |01 ) after another RF π/2 is measured. Up to 192 CNOT gates are applied, the dynamics of P |01 , however, does not obey a simple exponential decay. As shown in Supplementary Figure 10, the measured P |01 oscillates while decaying with N . In our experiment, the nuclear spin qubit is extremely 'clean' due to being insensitive to the external noises. The CNOT gate designed by quantum optimal control method consists of microwave pulses only. Thus the decay is due to the static fluctuation of δ 0 and δ 1 , while the oscillation is mainly due to the deviation of the experimental operation from the ideal CNOT gate.
We simulated the dynamics of P |01 based on the Hamiltonian H rot , the pulse sequence Supplementary Note 10: Robust and precise optimal control method on NV-NV system We have demonstrated a high fidelity CNOT gate at fault-tolerant threshold, taking the NV electron spin and 14 N nuclear spin as qubits. The CNOT gate is designed with modified optimal control method. This method can also be used to design robust and precise quantum gates on NV-NV coupled system, a key ingredient for scalable quantum computation using diamond.
The static Hamiltonian of two coupled NV centers can be described as with where S 1 and S 2 are the spin operators of individual NV centers, NV 1 and NV 2, respectively.
The zero filed splitting is D =2870 MHz. The coupling tensor between NV 1 and NV 2 is denoted as C. The static magnetic field applied on NV 1 (NV 2) is B 0,1 (B 0,2 ).
The system can be controlled by oscillating magnetic fields. The corresponding control Hamiltonian is where f m are the carrier frequencies of the control fields, B 1,m contain the amplitudes B 1,m = |B 1,m | and the polarization u m = B 1,m /B 1,m . The amplitudes B 1,m and the phases φ m can be changed in time to steer the system.
We turn to a rotating frame, in which the Hamiltonian is The evolution operator with a time duration T is where T is the time-ordering operator.
Similar to that described in Section , the pulse sequence for a target two-qubit unitary gate U can be designed by maximizing the performance function with d =4 and where P is projection operator on the two-qubit subspace.
Then the performance function is defined by integrating F seq, err over distributions of δ 0,1 , δ 0,2 , and δ 1,m, rel . By maximizing the performance function, pulse sequence for target U can be designed to be robust against the noises.
We take the optimization of pulse sequence for a robust and precise CNOT gate as an example. The static magnetic field applied on each NV center is aligned along the NV symmetry axis, and the NV centers can be individually addressable by application of gradient magnetic field. The coupling strength is taken to be 100 kHz, corresponding to a distance of about 8 nm between two NV centers 20 . According to Ref. 21, a magnetic-field gradient of 12 G nm −1 is available, corresponding to a difference of more than 200 MHz between the NV centers' resonant frequencies.
Considering the distributions, a pulse sequence for the CNOT gate can be optimized to achieve an average gate fidelity F a = 0.9926 by our method. The pulse sequence is shown in Supplementary   Figure 11. Thus our method can be applied to realize robust and high fidelity two-qubit gate on spatially separated NV centers.