One of the main obstacles for building a quantum computer is environmentally induced decoherence, which destroys the quantum information stored in the qubits. The errors caused by decoherence can be corrected by repetitive application of a quantum error correction (QEC) procedure, whereby the logical qubit is encoded in a high-dimensional Hilbert space, such that different errors project the system into different orthogonal subspaces and thus can be unambiguously identified and corrected without disturbing the stored quantum information. In conventional QEC schemes^{1,9}, the code words of a logical qubit are formed by two highly symmetric entangled states of several physical qubits encoded with some discrete variables. The past two decades have witnessed remarkable advances in experimental demonstrations of this kind of QEC code in different systems, including nuclear spins^{5,6}, nitrogen-vacancy centres in diamond^{10,20}, trapped ions^{7,11,21,22,23}, photonic qubits^{24}, silicon spin qubits^{25} and superconducting circuits^{12,13,14,15,16,26,27}. However, in these experiments, the lifetime of the logical qubit still needs to be greatly extended to reach that of the best available physical component, which is regarded as the break-even point for judging whether or not a QEC code can benefit quantum information storage and processing.

An alternative QEC encoding scheme is to use the large space of an oscillator, which can be used to encode either a continuous-variable or a discrete-variable qubit^{28,29,30,31,32}. Both types of code can tolerate errors due to loss and gain of energy quanta, enabling QEC to be performed in a hardware-efficient way. Circuit quantum electrodynamics (QED) systems^{18} represent an ideal platform for realizing such encoding schemes: the break-even point has been exceeded in two breakthrough experiments^{33,34} by distributing the quantum information over an infinite-dimensional Hilbert space of a continuous-variable-encoded photonic qubit, but the code words of this photonic qubit are not strictly orthogonal. This inherent restriction can be overcome with discrete-variable encoding schemes, whereby the code words of a logical qubit are encoded with mutually orthogonal Fock states of an oscillator. This feature, together with their intrinsic compatibility with error-correctable gates^{35,36} and their usefulness in logically connecting modules in a quantum network^{37}, makes such discrete-variable qubits promising in fault-tolerant quantum computation. These advantages can be turned into practical benefits in real quantum information processing only when the lifetime of the encoded logical qubits is extended beyond the break-even point, which, however, remains an elusive result, although enduring efforts have been made towards this goal^{17,32}.

Here, we demonstrate the exceeding of the QEC break-even point by real-time feedback correction for a discrete-variable photonic qubit in a microwave cavity, whose code words remain mutually orthogonal and can be unambiguously discriminated. The dominant error, single photon loss, of the logical qubit is mapped to the state of a Josephson junction-based nonlinear oscillator that is dispersively coupled to the cavity and serves as an auxiliary qubit, realized with a continuous pulse involving an ingeniously tailored comb of frequency components. As the driving frequencies aim at the error space where a photon loss event occurs, perturbations on the logical qubit are highly suppressed when it remains in the encoded logical space. Another intrinsic advantage of this error syndrome detection is that the continuous driving protects the system from the auxiliary qubit’s dephasing noise. We demonstrate this procedure with the lowest-order binomial code and extend the stored quantum information lifetime 16% longer than the best physical qubit, encoded in the two lowest Fock states and referred to as the Fock qubit. A more important characteristic associated with this error-detecting procedure is that neither the logical nor the error space needs to have a definite parity, which allows the implementation of QEC codes that can tolerate losses of more than one photon.

The key stages of a QEC procedure are encoding the quantum information to the logical qubit from the auxiliary qubit, the error syndrome measurement, the real-time error correction of the system depending on the measurement output and the decoding process to read out the quantum information stored in the logical qubit. Our logical qubit is realized in a three-dimensional microwave cavity, and the dominant decoherence to combat is the excitation loss error. The logical qubit is encoded with a binomial code^{8}, with the code words:

$$\begin{array}{r}| {0}_{{\rm{L}}}\rangle =(| 0\rangle +| 4\rangle )/\sqrt{2},\\ | {1}_{{\rm{L}}}\rangle =| 2\rangle ,\end{array}$$

where the number in each ket denotes the photon number in the cavity. The binomial code is a typical stabilizer QEC code: when the single-photon-loss error occurs, the quantum information is projected into the error space spanned by \(\{\left|{0}_{{\rm{E}}}\right\rangle =\left|3\right\rangle ,\left|{1}_{{\rm{E}}}\right\rangle =\left|1\right\rangle \}\), with the photon number parity acting as the error syndrome to distinguish these two spaces. A general QEC protection of quantum information stored in the bosonic system is illustrated in Fig. 1. After correctly measuring the photon number parity and applying the corresponding correction operations in real time, quantum information stored in the cavity can be recovered.

The experiments are performed with a circuit QED architecture^{18}, where a superconducting transmon qubit^{38} as an auxiliary qubit is dispersively coupled to a three-dimensional microwave cavity^{39,40,41}. The auxiliary qubit has an energy relaxation time of about 98 μs and a pure dephasing time of 968 μs, whereas the storage cavity has a single-photon lifetime of 578 μs (corresponding to a decay rate *κ*_{s}/2π = 0.28 kHz) and a pure dephasing time of 4.4 ms. The universal control of the multiple photon states of the cavity can be realized by using the anharmonicity of the auxiliary qubit, and thus the key stages of the QEC procedure, as illustrated in Fig. 1, can be achieved by encoding the logical qubit in the high-dimensional Fock spaces of the bosonic mode.

Our route towards the break-even points in the QEC is twofold: improving both the operation fidelity to the logical qubit and the error syndrome measurement fidelity. The first goal is achieved by using a tantalum transmon qubit with high coherence^{42,43} and an optimal quantum control technique^{44} with carefully calibrated system parameters (Methods). We attempt the second goal by an ingenious scheme of projection measurement of a selected collection of Fock states. The principle of the scheme is illustrated in Fig. 2a, where a classical microwave pulse containing 2*M* frequency components is applied on the auxiliary qubit to read out the Fock states. Because the frequency of the auxiliary qubit depends on the photon number *n* (see Methods for more details), error syndrome detection is achieved by mapping the even parity to the auxiliary qubit ground state \(\left|g\right\rangle \) (and the odd parity to the excited state \(\left|e\right\rangle \)) in a quantum non-demolition manner. This approach holds potential advantages of more flexible choices of error spaces and less sensitivity to auxiliary qubit damping and dephasing errors because the auxiliary qubit excitation is pronounced only when loss error occurs.

To characterize our syndrome measurement, the cavity is encoded to the six cardinal point states in the Bloch spheres of both the code and error spaces on the basis of the lowest-order binomial code words. The measured results of the cavity photon number parities are presented in Fig. 2b and show an average detection error of 1.1% and 2.5% for the cavity states in the code and error spaces, respectively. The encoding of the cavity, one of the most elementary processes of QEC, is further verified by the Wigner function with a high fidelity of 0.95, as shown in Fig. 2c.

On the basis of the above techniques, the QEC process of the binomial code can be implemented following the procedure in Fig. 1. However, practical imperfections limit the QEC performance: (1) during a waiting time of *t*_{w}, that is, an idle process, there is a probability of about \(2{({\kappa }_{{\rm{s}}}{t}_{{\rm{w}}})}^{2}\exp (-2{\kappa }_{{\rm{s}}}{t}_{{\rm{w}}})\) of a two-photon-loss error, which is undetectable for this lowest-order binomial code. (2) Owing to the non-commutativity of the single-photon-loss error and the self-Kerr interaction of the cavity, there is a large dephasing effect of the logical qubit induced by the unpredictable photon loss event, thus destroying the stored quantum information. (3) Quantum recovery operations are imperfect. It is worth noting that there is a logical state distortion even if no photon loss is detected^{8}. Strategies to mitigate the above imperfections are introduced, taking into account the whole system: choose an optimal waiting time, use a two-layer QEC procedure^{17} to avoid unnecessary operation errors introduced by the error corrections and adopt the photon-number-resolved a.c. Stark shift (PASS) method^{35} during idle operations to suppress photon-jump-error-induced decoherence in the code space (see Supplementary Information for more details). The measured Wigner functions of the cavity states after a single QEC cycle (about 90 μs of waiting) without and with performing the error correction operation are shown in Fig. 2d,e, with state fidelities of 0.81 and 0.88, respectively.

The performance of the QEC is benchmarked by the process fidelity \({F}_{\chi }\), which is defined as the trace of *χ*_{exp}*χ*_{ideal}, where *χ*_{exp} denotes the experimentally measured process matrix for the QEC process and *χ*_{ideal} is the ideal process matrix for an identity operation. In Fig. 3a, we present the measured process matrix for the encoding and decoding process only, which indicates a reference fidelity of 0.96. In the absence of a QEC operation after a waiting time of 105 μs, the process fidelity is reduced to a value of 0.73 because of the inability to protect the quantum information stored in the cavity from the single-photon-loss error, with the corresponding measured process matrix shown in Fig. 3b. When using the QEC operation, the process fidelity is improved because of the protection from the single-photon-loss error, with the process matrices for the one-layer and two-layer QECs shown in Fig. 3c,d, respectively.

The most important benchmark to characterize the performance of a QEC procedure is the gain in the lifetime of the protected logical qubit against that of the constituent element with the longest lifetime. For the three-dimensional circuit QED device, the best physical qubit is encoded with the two lowest photon-number states \(\{\left|0\right\rangle ,\left|1\right\rangle \}\), which is more robust against decoherence effects than any other encoded photonic qubit without QEC protection. To quantitatively show the advantage of our QEC scheme, in Fig. 3e we present the measured process fidelities of the corrected binomial code as a function of the storage time with the repetitive one-layer (red triangles) and two-layer (blue circles) QECs, as well as those for the unprotected binomial code (yellow stars), the transmon qubit (green diamonds) and the Fock qubit (black squares) for comparison.

All curves are fitted according to the function *F*_{χ} = *A**e*^{−t/τ} + 0.25, with *τ* corresponding to the lifetime of the specific encoding and *A* being a fitting parameter. The offset in the fitting function is fixed to 0.25, implying a complete loss of information at the final time. As a result, the lifetime *τ* for the corrected binomial code with one-layer QEC is improved by about 8.3 times compared with the uncorrected transmon qubit and 2.8 times compared with the uncorrected binomial code. In particular, *τ* is improved to about 1.1 times that of the uncorrected Fock qubit encoding, that is, exceeding the break-even point of QEC in this system. Using the two-layer QEC scheme, the corresponding lifetime *τ* of the logical qubit is improved to about 8.8 times that of the uncorrected transmon qubit, 2.9 times that of the uncorrected binomial code and 1.2 times that of the break-even point. These results demonstrate that the quantum information stored in the cavity with multiphoton binomial encoding can indeed be preserved and protected from photon loss errors by means of repetitive QEC operations.

Table 1 shows an overall error analysis for the one-layer and two-layer QEC experiments. The error sources are divided into four parts: the intrinsic errors for the lowest-order binomial code, the error detection errors, the recovery operation errors and the auxiliary qubit thermal excitation errors during the QEC cycle. These errors can be estimated from either the numerical simulations or the measurement results of individual calibration experiments (Supplementary Information). The predicted lifetimes *τ* for the QEC experiments, calculated by \(\tau =-{T}_{{\rm{w}}}/ln(1-{\epsilon })\)^{17}, with *T*_{w} and *ϵ* being the total duration and the weighted total error per QEC cycle, are consistent with those in our QEC experiments.

In conclusion, we experimentally demonstrate the prolonged coherence time of quantum information encoded with discrete variables in a bosonic mode by repetitive QEC. The break-even point has been reached by carefully designing the QEC procedure to balance the fidelity losses due to undetectable errors during the idle process, and error detection and correction operations. At present, the main infidelity is contributed by the two-photon-loss error that is beyond the ability of our current QEC code, but can be corrected by higher-order binomial codes^{8}. Our frequency comb method could be used to measure the generalized photon number parity of such codes, enabling detection and correction of both single-photon-loss and two-photon-loss errors. Our work thus represents a key step towards scalable quantum computing and provides a practical guide for system optimization of quantum control and the design of the QEC procedure for future applications of logical qubits.