Main

Quantum computing takes advantage of quantum superposition and entanglement to accelerate the computational tasks12,13. However, these quantum properties are sensitive to decoherence errors owing to energy relaxation and dephasing. As the number of qubits increases and/or the computational tasks become more complex, the errors cause exponential reduction of the accuracy of computational results. QEC is a protocol to circumvent this problem by distributing the quantum information across a larger multiqubit entangled state so that the errors can be detected and corrected14. Its basic concept has been demonstrated in various platforms, such as nuclear magnetic resonance9,15, trapped ions10,16, nitrogen vacancy centres17 and superconducting circuits11,18,19, and has served as an important benchmark of the qubit systems. Silicon-based spin qubits have emerged as a qubit platform in the past decade, and there has been rapid progress in long coherence times20,21, high-fidelity universal quantum gates6,7,8, high-temperature operation22,23 and generation of three-qubit entanglement24,25.

Our three-qubit system (Fig. 1a) comprises one data qubit (Q2) to be corrected and two ancilla qubits (Q1 and Q3). The sequence starts from encoding the data qubit state to a three-qubit entangled state. Then the phase-flip errors that occurred in the encoded state are mapped to the ancilla qubit states by the decoding. The original data qubit state can finally be restored by a correcting logic gate based on the ancilla qubit states. Most commonly, this correction can be performed by a projective measurement of ancilla qubits followed by a feedback quantum gate on the data qubit. However, this requires a capability to perform high-fidelity qubit measurement much faster than the coherence time, which is still challenging with spins in silicon. Although this measurement-based operation is a key component for fault tolerance, in the case of three-qubit QEC, it can alternatively be performed by a multiqubit conditional qubit rotation. In this Article, we take this approach by using a three-qubit iToffoli gate, which coherently rotates the data qubit conditioned on the ancilla spin polarization. We synthesize a three-qubit phase-flip code and demonstrate that one-qubit phase-flip error can be corrected and the intrinsic ensemble spin dephasing can be mitigated.

Fig. 1: Three-qubit QEC and silicon-based three-qubit device.
figure 1

a, Outline of the three-qubit phase-flip quantum error correcting code. The two-qubit CNOT gates entangle the three qubits, then the Hadamard (H) gates rotate the qubit basis for phase-flip errors. The decoding is the inverse of the encoding. Finally, the correction is performed by a three-qubit Toffoli gate. b, Scanning electron microscope image of the device. Scale bar, 100 nm. The screening gates (brown) are used to restrict the electric field of the plunger (green) and barrier (purple) gates. The three circles (red, green and blue) indicate the position of the triple-quantum-dot array. A further quantum dot shown as the grey circle is used as a charge sensor. The gates P1, P2, P3, B2 and B3 are connected to an arbitrary waveform generator to apply fast voltage pulses. The microwave control pulse for electric-dipole spin resonance is applied to the lower screening gate. c, Schematic cross section of the device. The line in the silicon quantum well shows the schematic triple-dot confinement potential. J12 (J23) represents the nearest-neighbour exchange coupling between Q1 and Q2 (Q2 and Q3).

Our sample is a gate-defined triple quantum dot in an isotopically natural silicon/silicon-germanium (Si/SiGe) heterostructure. Three layers of overlapping aluminium gates26 are used to control the triple-dot confinement. A micro-magnet is fabricated on top of the aluminium gates to provide a local magnetic field gradient27. As schematically shown in Fig. 1b, we configure the gate voltages so that only one electron is confined under each of the plunger gates (P1, P2 and P3) and the inter-dot tunnel coupling is controlled by the barrier gates (B2 and B3). Measurement of the triple-dot charge configuration is performed by monitoring the conductance of the nearby charge sensor quantum dot using the radio-frequency reflectometry technique28,29. An in-plane external magnetic field of Bext = 0.607 T is applied using a superconducting magnet. We use the Zeeman-split spin-1/2 states of the single electrons as our spin qubits (labelled Q1, Q2 and Q3 in Fig. 1b,c). The Zeeman energy splitting (about 20 GHz) much larger than the thermal excitation energy (about 0.8 GHz or 40 mK) enables initialization and readout of the three-spin state by the combination of energy-selective tunnelling30, shuttling31 and controlled rotation (see Methods and Extended Data Fig. 1 for the full details of the sequence).

The single-qubit rotations are performed by applying resonant microwave pulses (see Methods and Extended Data Fig. 2). The microwave pulse displaces the quantum dot position, effectively creating an oscillating transverse magnetic field that induces electric-dipole spin resonance27. The two-qubit controlled phase (CZ) gate is implemented by adiabatically pulsing the exchange couplings J12 and J23 by the barrier gates B2 and B3, respectively (see Methods and Extended Data Fig. 3). To operate the qubit close to the charge-symmetry point, the effect of capacitive crosstalk between the plunger and barrier gates is suppressed by the virtual gate technique (see Methods). The spin qubits herein have an average T1 relaxation time of 22 ms, inhomogeneous dephasing time \({T}_{2}^{* }\) of 1.8 μs and Hahn echo dephasing time \({T}_{2}^{{\rm{H}}}\) of 43 μs (Extended Data Fig. 4). Because electron spins have orders of magnitude longer T1 times compared with the dephasing times \({T}_{2}^{* }\) and \({T}_{2}^{{\rm{H}}}\), we focus on the implementation of a phase-flip correction code in this work, whereas a bit-flip correction code can easily be assembled by introducing further single-qubit rotations.

First we demonstrate the ability to encode and decode the data qubit state. For simplicity, here we perform encoding of an input state on the equator of the Bloch sphere, \({{\rm{Q}}}_{2}=(| \downarrow \rangle +{{\rm{e}}}^{{\rm{i}}\varphi }| \uparrow \rangle )/\sqrt{2}\) (Fig. 2a, ϕ is an azimuthal angle), which is encoded to a maximally entangled three-qubit Greenberger–Horne–Zeilinger (GHZ) state \(| {{\rm{GHZ}}}_{\varphi }\rangle \,=\) \((| \downarrow \downarrow \downarrow \rangle +{{\rm{e}}}^{{\rm{i}}\varphi }| \uparrow \uparrow \uparrow \rangle )/\sqrt{2}\). The controlled NOT (CNOT) gates used in the encoding are decomposed to native CZ gates combined with the decoupling pulses to mitigate the local quasi-static phase noise. For the QEC implementation, a crucial property is that the encoded state is a genuine three-qubit GHZ-class state. We confirm this by characterizing the generated state using three-qubit quantum state tomography (Methods). In Fig. 2b (2c), the real part of the measured experimental density matrix ρ for ϕ = 0 (π) is plotted. We evaluate the state fidelities \(F=\left\langle {{\rm{GHZ}}}_{\varphi }| \rho | {{\rm{GHZ}}}_{\varphi }\right\rangle \) for various ϕ (Fig. 2d) and confirm that all the states have fidelities above 0.75, the threshold to witness genuine GHZ-class states.

Fig. 2: Encoding of three-qubit GHZ states and resonantly driven iToffoli gate.
figure 2

a, Quantum circuit to generate three-qubit GHZ-class states. X (Y, Z) represents a π rotation about the x (y, z) axis and X/2 (Y/2, Z/2) represents a π/2 rotation about the x (y, z) axis. The two CNOT gates acting on the neighbouring qubits are implemented by the combination of single-qubit and two-qubit gates, as shown in the bottom half. The Y pulses in the middle of the sequence (surrounded by the purple box) are used to suppress the low-frequency single-qubit phase noise. b,c, Real parts of the measured density matrices of the three-qubit GHZ states (ϕ = 0 in b and ϕ = π in c). d, Result of the GHZ state generation for various input states. The solid black line shows the average of GHZ state fidelities, that is 0.866. The range above the threshold value 0.75 (0.5) to distinguish the GHZ-class states from the W-class (biseparable) states40 is shown as the coloured band. e, Schematic energy diagram of the three-spin state. f, Resonance peaks of Q2 for four different control qubit states at the exchange couplings J12 = J23 = 4.5 MHz. Here we define δf = 0 as the resonance condition when \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \downarrow \rangle \). The circles show the measured Q2 spin-up probabilities for the four different control qubit configurations. The solid lines show fitting with Gaussian functions. The traces are offset by 1 from each other for clarity. g, Schematic sequence of the measurement of the iToffoli gate truth table. h, Measurement result of the iToffoli gate truth table.

For correcting the decoded state, we implement a Toffoli-class three-qubit gate. The standard three-qubit Toffoli gate can be synthesized from 12 CNOT and two single-qubit gates32,33 (excluding T gates that can be implemented in software), albeit that decoherence in our device does not allow this implementation with a reasonable fidelity. Alternatively, we use a single-step, resonantly driven iToffoli gate implemented by a resonant π pulse in the presence of simultaneous nearest-neighbour exchange couplings (Fig. 2e). Without the exchange couplings (left side of Fig. 2e), the four transitions associated with the Q2 rotation are degenerate with a resonance frequency of f0. The finite exchange couplings shift downward the energy levels of the antiparallel spin configurations. As a result, the resonance frequency of Q2 is modulated as f0 + s1J12 + s3J23, in which si = ±1/2 is the spin number of Qi. Under the condition of J12 = J23 required for conditional phase synchronization (see Methods), a rotation of Q2 with \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \downarrow \rangle \;{\rm{or}}\,| \uparrow \uparrow \rangle \) corresponds to a controlled-controlled-rotation.

Figure 2f shows the spectra of Q2 with four different ancilla qubit states \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \downarrow \rangle ,| \downarrow \uparrow \rangle ,| \uparrow \downarrow \rangle \;{\rm{and}}\;| \uparrow \uparrow \rangle \) at J12 = J23 = 4.5 MHz, in which we observe the peak positions as expected from the exchange couplings. We use a resonant π pulse at \({f}_{{\rm{MW}}}={f}_{1}({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \downarrow \rangle )\) to implement our iToffoli gate, as this transition yields the highest visibility34. The iToffoli gate is a three-qubit gate equivalent to a Toffoli gate with an extra phase factor of i on the ancilla qubits. To characterize its property, we prepare the eight possible three-spin eigenstates, apply the iToffoli gate and perform three-spin projective measurement (Fig. 2g,h). The readout errors are removed from the data based on the measured readout fidelities (see Methods). The Rabi frequency is chosen so that the off-resonant rotations for the \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \uparrow \rangle /| \uparrow \downarrow \rangle \) subspaces are synchronized (see Methods). In Fig. 2h, as expected, the populations of \(|\downarrow \downarrow \downarrow \rangle \) and \(|\downarrow \uparrow \downarrow \rangle \) states are swapped, whereas the other states are essentially unaffected. From this result, we obtain a population transfer fidelity of our iToffoli gate as Tr(UexptUideal)/8 = 0.96, in which Uexpt (Uideal) represents the experimental (ideal) gate action on the eigenstates (see Methods and Extended Data Fig. 5e–g for the result of the full quantum process tomography). In addition, we perform a calibration of the pulse duration and timing to eliminate unwanted phase accumulation on Q2 (see Methods). Note that the dephasing and phase accumulation on the ancilla qubits do not affect the error correction outcome.

We then turn to the implementation of the phase-flip correcting code. Figure 3a shows the quantum circuit diagram. The three-qubit operation U serves to encode the data qubit state \(|\psi \rangle \) to the three-qubit entangled state. The exact implementation of U is shown in the bottom half of the figure, and it is equivalent to the two CNOT gates shown in Fig. 2a, except for the single-qubit gates that do not affect the function of the QEC. Here the data qubit state \(|\psi \rangle =\alpha |\downarrow \rangle +\beta |\uparrow \rangle \) is encoded to a phase-sensitive three-qubit state \(\alpha |+++\rangle +\beta |---\rangle \), in which \(|\pm \rangle =(|\downarrow \rangle \,\pm \,|\uparrow \rangle )/\sqrt{2}\) are the eigenstates of the Pauli X operator. For a phase-flip error with a flip rate of p on Q2, the decoded state is \(\sqrt{1-p}|\downarrow \rangle (\alpha |\downarrow \rangle +\beta |\uparrow \rangle )|\downarrow \rangle +\sqrt{p}|\uparrow \rangle (\beta |\downarrow \rangle +\alpha |\uparrow \rangle )|\uparrow \rangle \) (see Extended Data Table 1 for the cases with an error on ancilla). The correcting procedure is implemented so that Q2 is flipped only when \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \uparrow \uparrow \rangle \) by applying π pulses on the ancilla qubits followed by the iToffoli gate, resulting in a product state of \({{\rm{Q}}}_{2}=\alpha | \downarrow \rangle +\beta | \uparrow \rangle \) and \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=\sqrt{1-p}| \uparrow \uparrow \rangle \,+\) \({\rm{i}}\sqrt{p}|\downarrow \downarrow \rangle \). Now the data qubit state is the same as the input state regardless of p. This is demonstrated in Fig. 3b, in which we estimate the process fidelity of the data qubit for various intentional one-qubit errors (see Methods for details of the quantum process tomography). We implement the one-qubit error as a phase rotation with a known rotation angle θ, which is equivalent to a phase-flip error with p = sin2(θ/2). Therefore, without the correction, the process fidelity oscillates as a function of θ, shown as the black points. With the correction, the oscillation vanishes, and it confirms the basic function of the phase-flip correcting code (corrected Qi error means that a phase-flip error is applied to only Qi and the correction is performed). When there is no error (θ = 0), the process fidelity slightly decreases after the correction. This can be attributed to the infidelity of the iToffoli gate projected to the data qubit subspace. Furthermore, we show that the state of ancilla qubits reflects the error on the encoded qubit state (error detection). We measure the joint probability of the ancilla qubits Q1 and Q3 for the four possible cases with no error or a full π flip error. We observe that the measured ancilla states correctly reflect the error occurring on the encoded three-qubit state (Fig. 3c).

Fig. 3: One-qubit phase error correction.
figure 3

a, Schematic of the quantum circuit. The operation U used for encoding and decoding is decomposed into the single-qubit and two-qubit gates, as shown in the lower half of the figure. b, Result of one-qubit phase error correction. In the case of uncorrected, we omit the iToffoli gate and the rest of the quantum circuit is the same as the one for the corrected case. For the ideal case without gate infidelities, the uncorrected fidelity oscillates from 0 to 1 and the corrected fidelities are always equal to 1. c, Ancilla qubit measurement results. Note that, owing to the implementation of our correcting procedure, the resulting population of the ancilla qubit state is flipped as compared with the implementation using a standard Toffoli gate11.

Errors in actual quantum computers probably occur on all qubits simultaneously rather than on only one of the qubits. We verify the performance of our error correcting code in such a case in which all errors have the same effective error rate of p as per the common assumption in QEC14 (Fig. 4a). Without the correction, the data qubit process fidelity linearly decreases as p is increased. When the error correction is applied, errors on two and three qubits remain uncorrected, resulting in a process fidelity insensitive to p up to the first order, F(p) = 1 − 3p2 + 2p3 (ref. 14) (see Fig. 4b inset). The quadratic dependence on p is a crucial property of QEC and it ideally results in an improvement of the fidelity for p < 0.5. We confirm this crucial property in Fig. 4b, in which the measured process fidelity with the correction is plotted as the cyan curve. A quadratic function fits well to the data (see Extended Data Fig. 6 for a comparison between different fitting models). If we allow the first-order term in the fit, it is 0.0 ± 0.1 (the error is 1σ), representing a marked reduction of the first-order sensitivity as compared with the uncorrected case. As for the fidelity enhancement, the corrected qubit shows improvements in the range p < 0.429 ± 0.003 (the threshold is obtained by comparing the two fitted curves in Fig. 4b, the error is 1σ). Although the corrected fidelities are always lower than those of the ideal uncorrected qubit in the present experiment (dashed grey line in Fig. 4b), improvement of the coherence times and thereby the fidelity of the iToffoli gate, which primarily limits the performance in the corrected case, would ameliorate the situation. In silicon spin qubits, the intrinsic phase error is more like a quasi-static phase shift rather than a sudden phase flip. In our device, the phase shift is mainly caused by the fluctuating spins of surrounding 29Si nuclei. To demonstrate the effectiveness of our error correcting code to this type of phase error, we measure the dephasing of the encoded three-qubit state (Fig. 4c,d). As predicted from the ability to correct small phase errors in Fig. 4b, the initial slope of the fidelity decay is suppressed as compared with that of an uncorrected encoded qubit. Overall, these results show a successful implementation of three-qubit phase-correcting code in silicon.

Fig. 4: Three-qubit phase error correction.
figure 4

a, Schematic of the quantum circuit for three-qubit phase error correction. The phase error Z(p) is a virtual phase rotation with a rotation angle of \(2{\rm{\arcsin }}\left(\sqrt{p}\right)\), which results in an effective error rate of p. We prepare the data qubit input state \(|\psi \rangle \) by initialization to a spin-down state and a subsequent single-qubit rotation I, X/2, Y/2 or X. b, Measured process fidelities for the corrected and uncorrected cases. Each data point is obtained by averaging 2,000 experiments that are segmented into 1,000 experiments with interleaved qubit frequency calibrations. The error bars are obtained by a Monte Carlo resampling method41 and represent 1σ from the mean. Inset, calculated fidelities for the ideal cases without gate errors. c, Schematic of the quantum circuit for three-qubit dephasing error correction. The waiting time tw is the time interval between the last single-qubit rotation in U and the first single-qubit rotation in U−1. The deviation of the purple curve from the black curve reflects the gate infidelities in the encoding and decoding. d, Comparison of the state fidelities of the corrected and uncorrected qubits. In the case of the physical qubit, we perform a Ramsey measurement with varying waiting time tw between the first π/2 pulse and the pre-rotation for tomographic readout. Each data point is obtained by averaging 3,000 experiments that are segmented into 1,000 experiments with interleaved qubit frequency calibrations. The data acquisition time is the same for all traces in this figure. The solid curves are guides to the eye obtained by fitting to a general exponential decaying function42 F(t) = (1 + αexp(−(t/T2)n)/2, with α = 0.492 ± 0.005, 0.432 ± 0.008 and 0.464 ± 0.007, T2 = 1.44 ± 0.02, 1.36 ± 0.04 and 1.12 ± 0.03 μs, and n = 1.90 ± 0.08, 2.1 ± 0.2 and 1.68 ± 0.08 for the physical qubit, corrected qubit and uncorrected qubit, respectively. The errors are 1σ from the mean.

In conclusion, we have demonstrated the generation of the various three-qubit entangled states, the effective single-step resonantly driven iToffoli gate and the fundamental properties of three-qubit QEC in silicon. Extending the experiment to a larger scale would require a more flexible feedback-based correcting rotation. This would be limited by the slow spin measurement and initialization by energy-selective tunnelling, which also pose a challenge to complete the error correction (or detection) before the phase coherence is completely lost. Substantial improvements should be possible by switching to the singlet-triplet readout, in which high-fidelity spin measurements in a few μs (refs. 35,36), orders of magnitude shorter than the phase coherence time with dynamical decoupling21, are routinely achieved. Along with the recent advances in scalable device design37, electronics38 and gate fidelities6,7,8, we anticipate that it will become possible to demonstrate more sophisticated quantum error correcting codes in a large-scale silicon-based quantum processor.

Methods

Quantum dot device

The triple-quantum-dot device is identical to the one characterized in ref. 24. The device is fabricated using an isotopically natural, undoped Si/SiGe heterostructure. The ohmic contacts are made by phosphorus ion implantation. Standard electron-beam lithography and lift-off techniques are used to fabricate the overlapping aluminium gates and the micro-magnet.

Experimental setup

The GHZ state tomography and the iToffoli gate characterization (Fig. 2) are performed using the experimental setup as described in ref. 24. In what follows, we detail the modified experimental setup used for the QEC experiments in Figs. 3 and 4. The sample is cooled down in a dry dilution refrigerator (Oxford Instruments Triton 300) to a base electron temperature of around 40 mK. The configuration of d.c. lines is the same as in the previous report24. Control pulses are generated by four Keysight M3201A arbitrary waveform generator modules in a Keysight M9019A PXIe chassis (16 channels running at 500 MSa s−1). The plunger (P1, P2 and P3), barrier (B2 and B3) and sensor plunger gates are connected to the outputs of the arbitrary waveform generator, each of which is filtered by a Mini Circuits SBLP-39+ Bessel low-pass filter. The filtering results in a minimum pulse rise/fall time of approximately 15 ns. Microwave signals are generated by three vector microwave signal generators (two Keysight E8267D and a Rohde & Schwarz SGS100A with an SGU100A upconverter). Each microwave signal is single sideband I/Q modulated to prevent unintentional spin rotations owing to microwave carrier leakage. Furthermore, we use pulse modulation to further suppress the bleed-through signal during the initialization and readout stages. The outputs of the three signal generators are combined at room temperature and connected to the lower screening gate. Radio-frequency reflectometry is used for fast measurement of the charge sensor conductance. The right reservoir of the charge sensor quantum dot in Fig. 1b is connected to a tank circuit with an inductance of 1.2 μH and a resonance frequency of 181 MHz. The reflected signal is amplified and demodulated, then digitized using an AlazarTech ATS9440 digitizer card.

Three-spin initialization and measurement

The three-spin initialization and measurement are performed as follows. The numbers (n1n2n3) indicate the respective number of electrons in the left, centre and right quantum dots. We collect 400 to 3,000 single-shot outcomes to obtain the measured probabilities. The labels A–E represent the gate voltage configurations depicted in Extended Data Fig. 1c.

  1. 1.

    Unload electrons in the left and centre quantum dots by biasing gate voltages so that the ground state charge configuration is (001) (A). The duration is 100 μs.

  2. 2.

    Initialize Q1 by means of spin-selective tunnelling by biasing the voltages so that the charge configuration is near the (101)–(001) boundary (B). The duration is 750 μs.

  3. 3.

    Shuttle the electron in the left quantum dot to the centre quantum dot by biasing the voltages so that the ground charge configuration is (011) (C). No intentional gate voltage ramp is used. The typical pulse rise time is 15 ns owing to the low-pass filter. We wait for 1 μs in the (011) configuration.

  4. 4.

    Initialize Q1 by means of spin-selective tunnelling by biasing the voltages so that the charge configuration is near the (011)–(111) boundary (D). The duration is 750 μs.

  5. 5.

    Initialize Q3 by means of spin-selective tunnelling by biasing the voltages so that the charge configuration is near the (110)–(111) boundary (E). The duration is 750 μs.

  6. 6.

    Qubit manipulation in the (111) configuration (F). The typical duration is 5 μs. There is an extra waiting time of 50 μs to reduce the effect of heating by the microwave pulses.

  7. 7.

    Read out Q1 by means of spin-selective tunnelling by biasing the voltages so that the charge configuration is near the (011)–(111) boundary (D). The total duration is 600 μs. The data for readout is collected for the first 200 μs. The extra waiting time of 400-μs duration facilitates the initialization of Q1.

  8. 8.

    Perform controlled rotation between Q1 and Q2 to project the Q2 state to Q1 in (111). Here we pulse the virtual B2 gate to turn on J12 at the charge-symmetry point. Because Q1 is initialized to a spin-down state during the previous readout stage, for a Q2 input state \({\rm{\alpha }}|\uparrow \rangle +\beta |\downarrow \rangle \), the resulting Q1Q2 state is \(\alpha |\uparrow \downarrow \rangle +{{\rm{e}}}^{{\rm{i}}\theta }\beta |\downarrow \uparrow \rangle \), in which \({{\rm{e}}}^{{\rm{i}}\theta }\) is a phase factor that does not affect the readout. The duration is 1 μs. There is an extra waiting time of 50 μs to reduce the effect of heating by the microwave pulse.

  9. 9.

    Read out Q2 by means of spin-selective tunnelling of Q1 by biasing the voltages so that the charge configuration is near the (011)–(111) boundary (D). The duration is 200 μs.

  10. 10.

    Read out Q3 by means of spin-selective tunnelling by biasing the voltages so that the charge configuration is near the (110)–(111) boundary (E). The duration is 500 μs.

Virtual gate

The effect of capacitive couplings between the gates is suppressed by the virtual gate technique. We measure the capacitive couplings between the gates and construct the virtual gate as follows. The crosstalk between the exchange couplings is not taken into account. The virtual gate voltages vB2 and vB3 are used to control the exchange couplings.

$$\left(\begin{array}{c}{\rm{vP}}1\\ {\rm{vB}}2\\ {\rm{vP}}2\\ {\rm{vB}}3\\ {\rm{vP}}3\end{array}\right)=\left(\begin{array}{ccccc}1 & 0.30 & 0.54 & 0.14 & 0.17\\ 0 & 1 & 0 & 0 & 0\\ 0.61 & 0.35 & 1 & 0.25 & 0.31\\ 0 & 0 & 0 & 1 & 0\\ 0.15 & 0.10 & 0.46 & 0.31 & 1\end{array}\right)\left(\begin{array}{c}\Delta {\rm{P}}1\\ \Delta {\rm{B}}2\\ \Delta {\rm{P}}2\\ \Delta {\rm{B}}3\\ \Delta {\rm{P}}3\end{array}\right).$$

Single-qubit and two-qubit gates

The single-qubit rotations about the x and y axes are performed by applying microwave voltage pulses resonant with the Zeeman splitting of each spin qubit. The microwave voltage results in an effectiveout-of-plane a.c. magnetic field by the micro-magnet, which induces electric-dipole spin resonance. The spin qubits have typical resonance frequencies of 19,942.6 MHz (Q1), 20,372.6 MHz (Q2) and 20,923.2 MHz (Q3). We use a shaped raised-cosine pulse with a duration of 124 (62) ns to implement a single-qubit π (π/2) pulse. For the spectroscopy measurements in Fig. 2f, we use a Gaussian pulse (truncated at ±2σ). The phase rotation is virtually implemented by shifting the reference phase of the I/Q modulation waveform. Wherever possible, the single-qubit gates are applied in parallel. The two-qubit CZ gate is implemented by adiabatically pulsing the exchange coupling by the barrier gates. To guarantee the adiabaticity, we use a shaped cosine pulse6 with a duration of 50 ns to implement the CZ/2 gates, which results in a nominal peak exchange coupling of 10 MHz. During the experiments in the main text, the coupling strengths are fine-tuned to account for the conditional phase accumulation owing to the residual couplings of about 0.2 MHz (Extended Data Fig. 3d–f). We set the minimum interval between pulses to 20 ns to avoid the pulse interference owing to reflection.

Three-qubit iToffoli gate

The resonantly driven iToffoli gate consists of the three stages in Extended Data Fig. 5a. In the main text, the population transfer property of the iToffoli gate is shown. For that, we set \({f}_{{\rm{Rabi}}}=J/\sqrt{3}\) (J = J12 = J23) so that the off-resonant rotation in the \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \uparrow \downarrow \rangle /| \downarrow \uparrow \rangle \) subspaces is a 2π rotation. Furthermore, to obtain a correct quantum action, any unwanted phase accumulations on the three-qubit state have to be calibrated out. This can be achieved by setting an appropriate exchange pulse duration of ttot = tdc1 + tMW + tdc2 and pulse timing of δt = tdc1 − tdc2 (ref. 33). In theory, by setting the optimal exchange pulse duration to \({t}_{{\rm{tot}}}=\pi (4+\sqrt{3}-\sqrt{13})/J\), the conditional phases between the \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \uparrow \downarrow \rangle ,| \downarrow \uparrow \rangle \;{\rm{and}}\;| \uparrow \uparrow \rangle \) subspaces can be eliminated32. For an exchange coupling of 4.5 MHz, it is 473 ns. In the experiment, we typically use a 460-ns-long rectangular pulse, which is shorter than the theoretical length owing to the finite pulse bandwidth. The microwave pulse timing δt is then adjusted to eliminate the conditional phase between the \({{\rm{Q}}}_{1}{{\rm{Q}}}_{3}=| \downarrow \downarrow \rangle \) and the other subspaces. For the subspaces in which Q2 spin flip does not occur, shifting δt does not affect the outcome. In the case in which Q2 flips, when δt = 0, (quasi-)static phase accumulation is fully cancelled out by the spin-echo effect. The conditional phase in this case can be adjusted by varying δt because for finite δt, the echo works only partially and there is a phase accumulation of 2π(f1 − f0t. The remaining single-qubit phase offset is removed by a virtual single-qubit phase rotation. The phase offsets on the ancilla qubits are uncalibrated in the QEC experiments, although they can be calibrated out similarly. In Extended Data Fig. 5b, we illustrate the experimental sequence to calibrate the iToffoli gate phase accumulation. Extended Data Fig. 5c shows an example of an uncalibrated iToffoli gate and Extended Data Fig. 5d shows a phase measurement after the calibration. In the QEC experiments, this calibration is performed just before the data acquisition to minimize the influence of the slow drift of the resonance frequencies.

Readout error removal

For each of the experiments in which the readout errors are removed, we perform a reference measurement to obtain the readout fidelities. The spin-down (spin-up) readout fidelity \({F}_{\downarrow i}\) (\({F}_{\uparrow i}\)) is directly obtained by preparing a spin-down (spin-up) state and a projective measurement of Qi. Using the measured readout fidelities, we correct the raw probabilities \({{\bf{P}}}_{{\rm{M}}}=({P}_{\downarrow \downarrow \downarrow },\ldots ,\,{P}_{\uparrow \uparrow \uparrow })\) as \({\bf{P}}{\boldsymbol{=}}{\left({F}_{1}\bigotimes {F}_{2}\bigotimes {F}_{3}\right)}^{-1}{{\bf{P}}}_{{\rm{M}}},\) in which \({F}_{i}=\left(\begin{array}{cc}{F}_{\downarrow i} & 1-{F}_{\uparrow i}\\ 1-{F}_{\downarrow i} & {F}_{\uparrow i}\end{array}\right)\) and P is the corrected probabilities used for maximum likelihood estimation.

Measurement of the iToffoli gate truth table

To constrain all the elements of the truth table to be non-negative, we use a maximum likelihood procedure as follows. The input is a set of 64 measured probabilities Pij, in which the input is the ith eigenstate and the measurement is projected at the jth eigenstate. The readout errors are removed following the procedure above. We then minimize a cost function \(C\left({P}_{11}^{{\rm{MLE}}},\ldots ,{P}_{88}^{{\rm{MLE}}}\right)=\mathop{\sum }\limits_{i,j=1}^{8}{\left({P}_{ij}^{{\rm{MLE}}}-{P}_{ij}\right)}^{2}\) for non-negative parameters \({P}_{{ij}}^{{\rm{MLE}}}\). We constrain \({P}_{{ij}}^{{\rm{MLE}}}\) so that the sum of probabilities in one cycle of data acquisition is unity, that is, \(\mathop{\sum }\limits_{j=1}^{8}{P}_{{ij}}^{{\rm{MLE}}}=1\).

Quantum state tomography

Owing to the noise in the experiment, the density matrix obtained by a linear inversion is not always physical. Therefore, we use a maximum likelihood estimation to restrict the density matrix to be physical. We start from a Cholesky decomposition of a physical density matrix \(\rho ={T}^{\dagger }T/{\rm{Tr}}({T}^{\dagger }T)\), in which T is a complex lower triangular matrix with real diagonal elements. T has 22D (D is the number of qubits; D = 1 in Fig. 4d and D = 3 in Fig. 2d) real parameters \({\bf{t}}=({t}_{1},\ldots ,\,{t}_{{2}^{2D}})\) and we minimize the cost function

$$C\left({\bf{t}}\right)=\mathop{\sum }\limits_{\nu =1}^{{2}^{2D}}\frac{{\left(\left\langle {\psi }_{\nu }| \rho \left({\bf{t}}\right)| {\psi }_{\nu }\right\rangle -{P}_{\nu }\right)}^{2}}{2\left\langle {\psi }_{\nu }| \rho \left({\bf{t}}\right)| {\psi }_{\nu }\right\rangle },$$

in which Pν is the measured probability projected at a basis \(|{\psi }_{\nu }\rangle \). To determine the 22D parameters, the projection outcomes for linearly independent pre-rotations \({({\rm{I}},{\rm{X}}/2,{\rm{Y}}/2,{\rm{X}})}^{\bigotimes D}\) are used. To remove the error that could be introduced by the X pre-rotation, the projection outcomes for the X pre-rotations are calculated from the corresponding I rotation outcomes39.

Quantum process tomography

We perform quantum process tomography to verify the process matrix and fidelity (Figs. 3 and 4 and Extended Data Fig. 5). The input state \(|\psi \rangle \) is prepared by a spin-down initialization followed by a single-qubit rotation \({R}_{i}\in {({\rm{I}},{\rm{X}}/2,{\rm{Y}}/2,{\rm{X}})}^{\bigotimes D}\,\) (D is the number of qubits; D = 1 in Fig. 4b and D = 3 in Extended Data Fig. 5e). After the quantum operations, tomographic readout of the resulting state is performed similarly to the case of quantum state tomography. For a quantum operation E acting on an input density matrix \({\rho }_{{\rm{in}}}^{k}\), the density matrix of the output state can be written as follows,

$$E\left({\rho }_{{\rm{in}}}^{k}\right)=\mathop{\sum }\limits_{m,n=1}^{{2}^{2D}}{B}_{m}{\rho }_{{\rm{in}}}^{k}{B}_{n}^{\dagger }\,{\chi }_{mn},$$
(1)

in which χ is the process matrix defined with respect to the Pauli operators \(B={({\rm{I}},{\sigma }_{{\rm{x}}},{\sigma }_{{\rm{y}}},{\sigma }_{{\rm{z}}})}^{\bigotimes D}\). Linear inversion of equation (1) can be performed to obtain a process matrix. However, the process matrix obtained in this way does not necessarily satisfy the physical conditions owing to the noise in the experiment. As in the state tomography, we can obtain an estimate of the physical process matrix by a maximum likelihood estimation. We start from a Cholesky decomposition \(\chi ={S}^{\dagger }S/{\rm{Tr}}({S}^{\dagger }S)\), in which S is a lower triangular matrix with real diagonal elements. S is parametrized by 24D real parameters \({\bf{s}}=({s}_{1},\cdots ,{s}_{{2}^{4D}})\) and we use a cost function L(s) as follows,

$$L({\bf{s}})=\mathop{\sum }\limits_{k,l=1}^{{2}^{2D}}{[{P}^{kl}-\mathop{\sum }\limits_{m,n=1}^{{2}^{2D}}{\chi }_{mn}{\rm{T}}{\rm{r}}({M}_{l}{B}_{m}{\rho }_{{\rm{i}}{\rm{n}}}^{k}{B}_{n}^{\dagger })]}^{2},$$
(2)

in which Pkl is the measured probability projected at \(|\downarrow \rangle \) (D = 1) or \(|\downarrow \downarrow \downarrow \rangle \) (D = 3) when an input state \({\rho }_{{\rm{in}}}^{k}\) is prepared and an observable Ml is measured. We numerically minimize the cost function to obtain the most probable estimate of physical χ. Then the process fidelity is calculated as Tr(χidealχ), in which χideal is an ideal process matrix.