Introduction

Quantum noise is a major obstacle for devices that take advantage of quantum mechanics, such as quantum computers1, quantum networks2, quantum simulators3, and quantum-enhanced sensors4,5,6. The quest to find viable strategies for mitigating errors is thus an essential prerequisite for the development of quantum technologies and has led to techniques for quantum error correction7,8,9,10,11,12,13,14. Improving quantum sensing protocols in the presence of noise15,16,17,18,19,20,21 by applying quantum error-correcting codes22,23,24,25,26 represents a young research direction and impressive proof-of-concept realizations have already been demonstrated using nitrogen-vacancy centers11,12,13. Here we consider whether high-precision measurements can be improved by a self-correction mechanism induced by engineered dissipation. In particular we regard trapped-ion systems, which have proven to be an excellent platform for high precision measurements27,28, as well as for the realization of quantum error-correcting codes9,10.

Harnessing dissipative processes by engineering the coupling of a system to an environment or reservoir29,30,31,32,33,34,35,36,37 provides a route for processing quantum information alternative to relying on unitary gate operations9,10,11,12,13,14. Such reservoir engineering techniques have for example been successfully applied for state preparation38,39,40,41,42. Dissipative schemes for preparing entangled resource states have been shown to have advantages over standard methods, leading for example to a better use of resources34 and extending entanglement lifetimes by stabilizing the target state38.

Employing dissipation for quantum error correction takes this idea further since it requires the stabilization of an unknown state (i.e., of a manifold of states). The idea of dissipative error correction has attracted considerable interest43,44,45,46,47,48,49,50. The challenge of implementing this strategy by engineering suitable dissipative processes in concrete experimental systems has recently led to theoretical proposals for superconducting circuits51,52,53,54,55, as well as first experimental efforts towards the realization of building blocks required for dissipative quantum error correction56. Despite their central roles in both quantum information processing and quantum metrology, such achievements have not been made with trapped ions.

In this work, we address this challenge by combining the paradigms of dissipative quantum error correction and trapped-ion quantum information processing to a scheme for quantum error-corrected metrology. Standard error-correcting schemes entail classical apparatuses to perform measurements and feedback operations on the quantum system. In contrast to this gate-based approach, our scheme neither relies on time-dependent unitary operations, nor requires macroscopic measurements or feedback operations. Instead, tailored dissipative dynamics continuously corrects for spin-flips or phase-flips at a microscopic level by coupling the internal degrees of freedom of a system of trapped ions to an environment consisting of cooled motional modes (Fig. 1). The resulting dynamical protection of a qubit against noise results in a significant enhancement of its lifetime, and hence in a substantial improvement of quantum measurements. The proposed scheme allows for the realization of a repetition code7, where a logical qubit is encoded in a three-particle entangled state. Dissipative processes are designed such that the code space is a steady-state dark manifold, as shown in Fig. 1. Errors take the quantum state out of this subspace, which causes engineered dissipative processes to become resonant and thereby coherently correct the error by a generalized optical pumping process. Once the error is corrected, the engineered dissipative processes are shifted out of resonance such that they cease to act on the system. As we show below, this allows one to stabilize a qubit against a given type of error: either single-qubit spin-flips or phase-flips, or against correlated noise. Adding to the potential of this approach for quantum information processing we demonstrate that the proposed scheme can be applied for improving the sensitivity of quantum sensing protocols, where a “dissipative” quantum-error correction paradigm has not been explored up to now. Here our scheme provides a blueprint for quantum error correction enhanced metrology in trapped-ion systems based on current experimental means. We analyze the applicability of our scheme in the context of a paradigmatic measurement setting with trapped ions and show that the attainable sensitivity can be significantly enhanced for realistic experimental parameters. Our work provides a stepping stone towards a new paradigm of self-correcting quantum systems that can be realized with current technology and will enable experiments with ions that take dissipative quantum information processing to a new level.

Fig. 1
figure 1

Dissipative realization of a three-qubit code in trapped ions. The unknown state |ψ〉 = c 0|000〉 + c 1|111〉 is encoded in the internal states of three ions and protected against single spin-flips by means of engineered couplings to a quantum reservoir that consists of motional modes. a Spin-flip errors are continuously removed from the system through cooling of the motional modes. b Compromised states \({\left| {\psi ^{(j)}} \right\rangle} = {\sigma _{x}^{(j)}} {\left|\psi \right\rangle} , \, j = 1, \, 2, \, 3\) are driven back to the logical subspace at a rate Γqec, while the code space is a dark manifold of the engineered dissipative processes. c The scheme can be scaled up to several logical qubits using a segmented trap (Supplementary Note 3)

Results

Error-correcting protocol

We consider a three-qubit repetition code, where a logical qubit is encoded in three physical qubits,

$$\left|\psi \right\rangle = c_0\left|0\right\rangle _L + c_1\left|1\right\rangle _L = c_0\left|000\right\rangle + c_1\left|111\right\rangle ,$$
(1)

with logical qubit states |0〉 L  = |000〉 and |1〉 L  = |111〉, forming a codespace {|0〉 L , |1〉 L }. This encoding allows one to protect the quantum state against single spin-flips on the physical qubits, which lead to the single-error states

$$\left|\psi\right. ^{(j)}\left.\right\rangle = \sigma _x^{(j)}\left|\psi \right\rangle ,\quad j = 1,\,2,\,3,$$
(2)

where the Pauli operator \(\sigma _x^{(j)} = \left|0\right\rangle _j\left\langle 1\right| + \left|1\right\rangle _j\left\langle 0\right|\) acts on the jth qubit. As explained below, a majority vote allows for the restoration of the state |ψ〉. Later we will also consider the correction of single-qubit phase-flips and correlated noise. In principle it is also possible to convert this scheme into a protocol simultaneously correcting spin-flip and phase errors by extending it to a nine-qubit error-correcting code7 capable of correcting any type of single-qubit error. However, a full error-correcting code is not compatible with quantum sensing, since it would remove both errors and the signal to be measured from the dynamics.

In the following, we describe the noisy dynamics of a quantum system by a master equation \(\dot \rho = {\cal L}(\rho )\) with a Liouvilllian \({\cal L}\) of Lindblad form,

$${\cal L}_{{\mathrm{noise}}}(\rho ) = \mathop {\sum}\limits_k \,{\cal D}[L_k](\rho ),$$
(3)
$${\cal D}[L_k](\rho ) = L_k\rho L_k^{\mathrm{\dagger }} - \frac{1}{2}\left( {L_k^{\mathrm{\dagger }}L_k\rho + \rho L_k^{\mathrm{\dagger }}L_k} \right),$$

with dissipators \({\cal D}[L_k]\) and jump operators L k . In the special case when L k describe local spin-flip noise affecting each of the constituent qubits independently, the jump operators are given by

$$L_x^{(j)} = \sqrt {\mathrm{\Gamma }} \sigma _x^{(j)},\quad j = 1,\,2,\,3,$$
(4)

where Γ is the rate at which a spin flip occurs.

Single spin-flip errors are corrected by implementing a majority vote: to correct errors on, for example, the second qubit, we interrogate the two-body stabilizer operators \(S^{(12)} = \sigma _z^{(1)}\sigma _z^{(2)}\) and \(S^{(23)} = \sigma _z^{(2)}\sigma _z^{(3)}\), which involve the second qubit and its neighbors, qubit 1 and qubit 3. The code state |ψ〉 is an eigenstate of these operators with eigenvalue +1, while the single error state |ψ (2)〉 is an eigenstate with eigenvalue −1. If a spin-flip has occurred, the resulting state |ψ (2)〉 of the system thus violates both stabilizers, S (12)|ψ (2)〉 = S (23)|ψ (2)〉 = −|ψ (2)〉. Conditioned on this result, a spin-flip \(\sigma _x^{(2)}\) is applied to qubit 2, and the original state |ψ〉 is restored. Errors on the first and third qubits are corrected in an analogous fashion. This recovery protocol can be implemented in a continuous manner by realizing the dissipative dynamics

$${\cal L}_{{\mathrm{qec}}} = {\cal D}[L_{x,{\mathrm{qec}}}^{(1)}] + {\cal D}[L_{x,{\mathrm{qec}}}^{(2)}] + {\cal D}[L_{x,{\mathrm{qec}}}^{(3)}],$$
(5)

with quantum error-correcting jump operators of the form

$$L_{x,{\mathrm{qec}}}^{(2)} = \sqrt {{\mathrm{\Gamma }}_{{\mathrm{qec}}}} \sigma _x^{(2)}\frac{{{\Bbb{1}} - \sigma _z^{(1)}\sigma _z^{(2)}}}{2}\frac{{{\Bbb{1}} - \sigma _z^{(2)}\sigma _z^{(3)}}}{2}.$$
(6)

Here, we have Γqec as the correction rate, \(\sigma _x^{(2)}\) as the correcting spin-flip, and two “interrogation parts” of the form (\({\Bbb{1}}\)S)/2. Each of them interrogates a stabilizer S, yielding 0 if the qubits are of the same value and \({\Bbb{1}}\) if they are different. This realizes the described majority vote: If both stabilizers S (12) and S (23) are violated, an action \({L_{x , {\mathrm{qec}}}^{(2)}} \sim {\sigma _{x}^{(2)}}\) is realized. Correcting operators for qubits 1 and 3 can be written analogously:

$$L_{x,{\mathrm{qec}}}^{(1)} = \sqrt {{\mathrm{\Gamma }}_{{\mathrm{qec}}}} \sigma _x^{(1)}\frac{{{\Bbb{1}} - \sigma _z^{(1)}\sigma _z^{(2)}}}{2}\frac{{{\Bbb{1}} - \sigma _z^{(1)}\sigma _z^{(3)}}}{2},$$
(7)
$$L_{x,{\mathrm{qec}}}^{(3)} = \sqrt {{\mathrm{\Gamma }}_{{\mathrm{qec}}}} \sigma _x^{(3)}\frac{{{\Bbb{1}} - \sigma _z^{(1)}\sigma _z^{(3)}}}{2}\frac{{{\Bbb{1}} - \sigma _z^{(2)}\sigma _z^{(3)}}}{2}.$$
(8)

For the physical implementation, it will be useful to translate the conditional jump operators in Eqs. (6)–(8) into the form

$$L_{x,{\mathrm{qec}}}^{(j)} = \sqrt {{\mathrm{\Gamma }}_{{\mathrm{qec}}}} \left( {\sigma _ - ^{(j)}P_{n_1 = 1} + \sigma _ + ^{(j)}P_{n_0 = 1}} \right),\quad j = 1,\,2,\,3,$$
(9)

where \(\sigma _ + ^{(j)}\) (\(\sigma _ - ^{(j)}\)) are the raising (lowering) operators on qubit j. \(P_{n_k = n}\) are projectors on the states with n qubits in state |k〉, e.g., \(P_{n_1 = 1} = \left|100\right\rangle \left\langle 100\right| + \left|010\right\rangle \left\langle 001\right| + \left|001\right\rangle \left\langle 001\right|\) and \(P_{n_0 = 1} = \left|011\right\rangle \left\langle 011\right| + \left|101\right\rangle \left\langle 101\right| + \left|110\right\rangle \left\langle 110\right|\). Similar conditional jump operators containing an interrogation part (\({\Bbb{1}}\)S)/2 were proposed in ref. 31 and implemented with trapped ions in ref. 39 using a sequence of quantum gates to dissipatively generate Bell pairs. In the following, we show how the conditional jump operator performing a majority vote in Eq. (9) can be implemented in a time-continuous fashion in a system of trapped ions.

The presented scheme can be generalized to correct for correlated spin-flip or phase errors, as explained in the “Methods” section.

Setup

We consider a setup consisting of three ions in a trap with identical levels and couplings as shown in Fig. 2. The logical qubit states |0〉 and |1〉 are encoded in internal electronic levels of the ions, which we shall refer to as ground states. In addition, we consider two levels, |e〉 and |f〉, referred to as excited states. The internal levels are coherently coupled to two collective motional modes of the ion chain, a and b, by applying appropriate laser fields. These modes are used for the interrogation of the system. In addition, for the correction of physical errors we require auxiliary modes c (j), which we discuss further down. The four internal states are assumed to be at least meta-stable and the modes are assumed to be cooled to the ground state. In a suitable rotating frame, the free Hamiltonian of the system is given by

$$H_{{\mathrm{free}},({\mathrm{\Delta }},\,\delta )} = {\mathrm{\Delta }}\mathop {\sum}\limits_{j = 1}^3 \,\left( {{\left|e\right\rangle}_{j}\left\langle e\right| + {\left|f\right\rangle}_{j} \left\langle f\right|} \right) + \delta \left( {a^{\mathrm{\dagger}}a + b^{\mathrm{\dagger}}b} \right).$$
(10)
Fig. 2
figure 2

Setup for the implementation of the error correction scheme. The setup consists of three system ions, which couple collectively to two shared motional modes a and b, used for the interrogation of the system. For the correction, we require auxiliary modes c (j), which can be realized either by additional motional modes or ancilla ions. In the figure this additional degree of freedom is denoted by a level \(\left|1\right\rangle _{c^{(j)}}\). The ions are assumed to have two levels, |0〉 and |1〉, which we shall refer to as ground states, and two levels, |e〉 and |f〉, referred to as excited states. The transitions are excited by a driving (weak carrier) field Ω and strongly coupled to two motional sidebands a and b with coupling constant G. Excitations of the ions (|e〉, |f〉) are coherently transferred to the auxiliary modes/ancillas by coherent couplings g and subsequently removed by cooling/reset with a rate κ

As will be explained below, the selectivity of the correction processes (i.e., spin-flips \(\sigma _x^{(j)}\)) to the single error states |ψ (j)〉 will be achieved by a suitable choice of the detunings Δ and δ. To interrogate the system, we apply weak carrier drives on the transitions |1〉 ↔ |e〉 and |0〉 ↔ |f〉,

$$H_{{\mathrm{drive}},{\mathrm{\Omega}}} = \frac{{\mathrm{\Omega}}}{2}\mathop {\sum}\limits_{j = 1}^N \,\left( {{\left| e \right\rangle}_{j} \left\langle 1\right| + {\left|f \right\rangle}_{j}\left\langle 0 \right|} \right) + {\mathrm{H}}.{\mathrm{c}}.,$$
(11)

and use sideband couplings that couple the transition |e〉 → |1〉 to interrogation mode a and the transition |f〉 → |0〉 to interrogation mode b,

$$H_{{\mathrm{int}},G} = G\mathop {\sum}\limits_{j = 1}^3 \,\left( {a^{\mathrm{\dagger}}{\left|1\right\rangle}_{j}\left\langle e \right| + b^{\mathrm{\dagger }}{\left|0\right\rangle}_{j}\left\langle f\right|} \right) + {\mathrm{H}}.{\mathrm{c}}.$$
(12)

This description is valid within the Lamb–Dicke approximation. The Lamb–Dicke approximation holds for \(\eta ^2(2\bar n + 1) \ll 1\), where \(\bar n\) is the average phonon number and η = 2πx 0/λ is the Lamb–Dicke parameter given by the ratio of the ion’s ground state wave packet size x 0 and the wavelength of the applied light field λ. For the considered type of experiment, we consider the Lamb–Dicke parameter to be small. The coupling strength G is assumed to be strong compared to all other rates in the system. The combination of the couplings H drive,Ω and H int,G , and the detunings in H free,(Δ,δ) will be used to identify ions which, after an error, reside in the state |1〉 (|0〉) and drive them to the state |e〉 (|f〉). While the interrogation modes a and b are needed to determine whether an error has occurred on the system ions, we also require couplings to additional auxiliary modes to remove such errors:

As can be seen from Eq. (9), the recovery process consists of two parts, one of which corrects states with a single qubit in state |1〉, represented by \(P_{n_1 = 1}\), by a lowering operation \(\sigma _ - ^{(j)}\), e.g., |001〉 → |000〉. The second part corrects states with a single qubit in state |0〉, i.e., \(P_{n_0 = 1}\), by a raising operation \(\sigma _ + ^{(j)}\), e.g., |110〉 → |111〉. For implementing the operation in Eq. (9) it is important to maintain the coherence between these two parts of the error correction. Thus, individual uncorrelated dissipation such as decay of |e〉 and |f〉 by spontaneous emission does not suffice. Instead, we use an engineered cooling process which is a combination of a mapping of the errors from the system ions to the auxiliary modes and a subsequent dissipative process to remove the errors as explained below. These auxiliary modes can be either additional ions or additional motional modes. The exact level structure is not important, the only requirement is that the first excited level needs to be strongly damped, thus effectively resulting in a two-level system. In the following, we focus on implementations based on the use of additional motional modes subjected to sympathetic cooling40. However, the analysis that follows can be straightforwardly adopted to the case of ancilla ions by replacing the bosonic operator c (j) in Eq. (13) and Eq. (15) by the Pauli operator \(\sigma _ - ^{(j)}\). In this case, the required dissipative mechanism \(L_ - ^{(j)} = \sqrt \kappa \sigma _ - ^{(j)}\) acting on each ancilla ion can be realized by continuously resetting its state by means of optical pump fields39.

In the following we assume that for the correction of spin-flips acting independently on qubits 1, 2, and 3, the excitations of the system ions are mapped onto auxiliary motional modes c (j), j = 1, 2, 3. This is achieved by sideband couplings

$$H_{{\mathrm{aux}},\,g} = g\mathop {\sum}\limits_{j = 1}^3 \,e^{i\delta _ct}(c^{(j)})^{\mathrm{\dagger}}\left( {{\left| 0 \right\rangle}_{j}\left\langle e \right| + {\left| 1 \right\rangle}_{j}\left\langle f \right|} \right) + {\mathrm{H}}.{\mathrm{c}}.,$$
(13)

with the coupling strength g and the detuning δ c . The Hamiltonian of the overall system is given by

$$H_{{\mathrm{total}}} = H_{{\mathrm{free}},({\mathrm{\Delta }},\delta )} + H_{{\mathrm{drive}},{\mathrm{\Omega }}} + H_{{\mathrm{int}},G} + H_{{\mathrm{aux}},g}.$$
(14)

The resulting excitations in the motional modes are removed by a dissipative process,

$$L_c^{(j)} = \sqrt \kappa c^{(j)},$$
(15)

for which we assume a large cooling rate \(\kappa \gg g,\,\delta _c\) so that we can adiabatically eliminate c (j) from the dynamics57. This yields the engineered cooling operators

$$L_{{\mathrm{eng}}}^{(j)} = \sqrt {\kappa _{{\mathrm{eng}}}} \left({\left| 0 \right\rangle}_{j}\left\langle e \right| + {\left| 1 \right\rangle}_{j}\left\langle f \right| \right),$$
(16)

with an engineered cooling rate κ eng = g 2/κ. The minor shift of the levels by H aux,g can be neglected and the Hamiltonian becomes

$$H_{{\mathrm{total}},{\mathrm{eng}}} = H_{{\mathrm{free}},({\mathrm{\Delta }},\delta )} + H_{{\mathrm{drive}},{\mathrm{\Omega }}} + H_{{\mathrm{int}},G}.$$
(17)

As opposed to typical sources of noise such as spontaneous emission and decay of the vibrational modes, the engineered decay in Eq. (16) preserves the coherence between |e〉 and |f〉 (c 0|e〉 + c 1|f〉 → c 0|0〉 + c 1|1〉), which is a prerequisite for quantum error correction and for using the scheme in a quantum metrology setting as discussed below.

Working mechanism

We use the above couplings to implement the error-correcting dynamics in Eq. (9). To this end, we tailor effective jump processes mediated by engineered resonances involving the couplings to the excited levels and the motional modes in the setup. We carefully adjust the system parameters such that these dissipative mechanisms become resonant if the system is in a single-error state, resulting in a dynamical correction of the error. Detrimental action on the codespace and on the single-error space will be off-resonant and thus largely suppressed. Still, the remaining undesired dynamics introduce additional decay from the codespace and the single-error space towards higher-error spaces. Their rates need to be balanced by the choice of the available parameters, i.e., the strength of the drive and the engineered decay to ensure that these processes are not too detrimental.

Figure 3 illustrates the correction of the encoded qubit after a spin-flip on qubit 1. Spin-flips on qubits 2 and 3 are corrected analogously. Starting from the single-error state after a spin-flip on qubit 1 (Eq. (2)),

$$\left|\psi\right. ^{(1)}\left.\right\rangle = c_0\left|100\right\rangle + c_1\left|011\right\rangle ,$$
(18)

the weak drive H drive,Ω couples |100〉 to |e00〉 and |011〉 to |f11〉. This excitation is a priori off-resonant due to the detunings in H free,(Δ,δ). We now use the coupling H int,G to create resonances in the excited state manifold which are selective to the number of qubits in |0〉 or |1〉 in the initial state: H int,G couples |e00〉 back to |100〉 by exciting the interrogation mode a, resulting in the state |100〉|1〉 a . This coupling between |e00〉 and |100〉|1〉 a leads to the formation of dressed states,

$$\left|\phi _{e, \pm }\right\rangle = c_{e, \pm }\left|e00\right\rangle \pm c_{a, \pm }\left|100\right\rangle \left|1\right\rangle _a,$$
(19)

which are indicated in Fig. 3. For Δ = δ = G, the lower dressed state resides at the detuning Δ1,− = 0 (the upper one at Δ1,+ = 2G), such that it is in resonance with the drive H drive,Ω from |100〉. Hence, |100〉 is excited to |ϕ e,−〉.

Fig. 3
figure 3

Error correction mechanism. The states after a spin-flip on ion 1, |100〉 and |011〉, are off-resonantly excited to the excited states |e00〉 (left) and |f11〉 (right). The strong sideband coupling G results in the formation of the dressed states |ϕ e/f〉. For Δ = δ = G, the lower dressed states |ϕ e/f,−〉 are in resonance with the drives from the single-error states, allowing for their selective excitation. The excitations in |e〉 and |f〉 are transferred from the ion to the auxiliary mode c (1) by a coherent coupling, g, and removed by cooling, κ, maintaining the coherence between the two paths |100〉 → |000〉 and |011〉 → |111〉. Correction of spin-flips on other ions j is performed in the same way, utilizing the auxiliary mode c (j)

Simultaneously, the |011〉-part in Eq. (18) is excited to the state |f11〉. The excitation |f〉 is coupled to interrogation mode b by H int, G , which results in the formation of the dressed states

$$\left|\phi _{f, \pm }\right\rangle = c_{f, \pm }\left|f11\right\rangle \pm c_{b, \pm }\left|011\right\rangle \left|1\right\rangle _b,$$
(20)

with the energies Δ1,±. For the parameter choice Δ = δ = G, |011〉 is resonantly excited to |ϕ f,−〉. Thus the state in Eq. (18) is excited to

$$\left|\phi _1\right\rangle = c_0\left|\phi _{e, - }\right\rangle + c_1\left|\phi\right. _{f, - }\left.\right\rangle .$$
(21)

From here, excitation exchange with the auxiliary mode c (1) by H aux,g transfers the system to \(\left|\psi \right\rangle \left|1\right\rangle _{c^{{\mathrm{(1)}}}}\). Cooling of the auxiliary mode by \(L_c^{(1)}\) recovers the original state |ψ〉. The last two steps can be described as an effective decay process from |ϕ 1〉 to |ψ〉 (cf. Eq. (16)), which, together with the coherent drive from |ϕ 1〉 to |ψ (1)〉, realizes the desired error correction on qubit 1. Errors on other qubits are corrected in an analogous fashion, utilizing the auxiliary mode c (j). We will later verify that this procedure indeed realizes the desired operators (9).

We remark that the correction of several types of errors can also be realized sequentially rather than simultaneously. In this case only a single auxiliary mode c is required. For correcting local spin-flips, individual time slots T 1, T 2, T 3 can be assigned for correcting spin-flip errors on qubit 1, qubit 2, and qubit 3 such that a sequence repeating these dedicated time slots T 1, T 2, T 3, T 1, T 2, T 3, T 1... corrects the errors on the individual qubits one after the other. Such a “Trotterization” would, however, lead to an effective decrease in the correction rate by a factor of three. The error rates would, on the other hand, be unchanged such that the increase in the lifetime of the codeword would be less pronounced than in the continuous case.

Apart from the error-correcting mechanism, the scheme also entails undesired processes where spins are not flipped in accordance with the majority vote. As illustrated in Fig. 4, this includes processes such as |100〉 → |110〉 or |000〉 → |100〉. For example, the undesired excitations from |100〉 to the f-excited state \(\left|\chi _f\right\rangle = (\left|1f0\right\rangle + \left|10f\right\rangle )/\sqrt 2 \) and from |011〉 to the e-excited state \(\left| \chi_e \right\rangle = (\left| 0e1 \right\rangle + \left| 01e \right\rangle )/\sqrt 2\), shown in Fig. 4a), are suppressed by our parameter choice of Δ = δ = G. This can be understood as follows: H int,G couples |χ f 〉 to |100〉|1〉 b . Due to constructive interference between the two terms in |χ f 〉, this coupling has a strength of \(\sqrt 2 G\). The resulting dressed states thus reside at energies \({\mathrm{\Delta }}_{2, \pm } \approx (1 \pm \sqrt 2 )G\) such that neither of the dressed states are in resonance with the drive. As a consequence, these processes taking the system away from the desired state will be much slower than the resonant processes correcting the errors. Excitation from |011〉 to |χ e 〉 is suppressed for the same reason. The same arguments hold for states after single errors on other qubits. The resulting slow process leads to a loss of population from the subspace of single-error states to the subspace of double-error states, which we discuss below.

Fig. 4
figure 4

Intrinsic error processes. a Excitation of erroneous but correctable states, e.g., |100〉 and |011〉 can lead to excited states such as \(\left|\chi _f\right\rangle = (\left|1f0\right\rangle + \left|10f\right\rangle )/\sqrt 2 \) instead of |e00〉 and \(\left|\chi _e\right\rangle = (\left|0e1\right\rangle + \left|01e\right\rangle )/\sqrt 2 \) instead of |f11〉. Their dressed states with the motionally excited states |100〉|1〉 b and |011〉|1〉 a reside at detunings \(|{\mathrm{\Delta }}| = \sqrt 2 G\). For Δ = δ = G, such processes are off-resonant with respect to the drive, resulting in weak excitation. These processes, however, lead to a leakage of population from the subspace of correctable states since they generate double errors, e.g., \(\left|100\right\rangle \to (\left|110\right\rangle + \left|101\right\rangle )/\sqrt 2 \) and \(\left|011\right\rangle \to (\left|010\right\rangle + \left|001\right\rangle )/\sqrt 2 \), which cannot be corrected by our protocol. b Excitation of the logical states |000〉 and |111〉 leads to excited states |ξ f 〉 and |ξ e 〉 that couple to motionally excited states with strength \(\sqrt 3 G\) and thus form dressed states at energies \( \pm \sqrt 3 G\). These states are driven off-resonantly by the weak drive, which has a detuning |Δ| = G. Such off-resonant excitations and subsequent engineered cooling processes transfer code states to the manifold with one error and can thus be recovered by the correction mechanism in the same manner as the physical error

In addition, the operation of the protocol also causes losses from the logical subspace, as shown in Fig. 4b): |000〉 is excited to \(\left|\xi _f\right\rangle = (\left|f00\right\rangle + \left|0f0\right\rangle + \left|00f\right\rangle )/\sqrt 3 \) and |111〉 to \(\left|\xi _e\right\rangle = (\left|e11\right\rangle + \left|1e1\right\rangle + \left|11e\right\rangle )/\sqrt 3 \). These superposition states consist of three terms and couple to |000〉|1〉b and |111〉|1〉a with a coupling strength \(\sqrt 3 G\). The energies of the resulting dressed states are therefore given by \({\mathrm{\Delta }}_{3, \pm } = (1 \pm \sqrt 3 )G\). Hence, this excitation is also off-resonant with respect to the drive, leading only to a weak additional error process, which is, however, intrinsic to the scheme.

To optimize the performance of the error correction in the presence of these undesired dynamics, we invoke a quantitative model of the effective dynamics of the system further down. We find that the lifetime of the codeword is maximized by balancing the intrinsic loss rates through the choice of the engineered decay rate κ eng and the driving strength Ω. Optimizing for long operation times, we find that the optimum occurs when the total decay rates (i) from the codespace to the single-error space and (ii) from the single-error space to the double-error space are small and similar in magnitude. Still, the precise values of the couplings Ω, G, g, and κ are not critical in our scheme. To maintain the coherence of the codeword |ψ〉 = c 0|000〉 + c 1|111〉 under the correction in Eq. (9), we require that the rate Γqec is the same for both parts of the superposition, which is for example fulfilled if Ω, G, and g are identical for both paths illustrated in Fig. 3. To achieve a maximum correction rate, the detunings Δ and δ need to be tuned with an accuracy of at least κ eng.

Effective model

In order to analytically verify that our scheme realizes the desired operators, we use the effective operator formalism57 to adiabatically eliminate the excited degrees of freedom, which are coupled to the stable ground states by perturbative coherent couplings and are only weakly populated. Adiabatic elimination of the internal levels |e〉 and |f〉 (see “Methods”) leads to effective ground state dynamics (involving only the internal levels |0〉 and |1〉 with motional modes in the ground state) that is described by an effective master equation with jump operators

$$L_{{\mathrm{eff}}}^{(j)} = \mathop {\sum}\limits_{n = 1}^3 \sqrt {\kappa _{{\mathrm{eff}},n}} \left( {\sigma _ - ^{(j)}P_{n_1 = n} + \sigma _ + ^{(j)}P_{n_0 = n}} \right).$$
(22)

The above jump operators contain the desired error-correcting terms (n = 1) given by Eq. (9). These result in a decay of the subspace of single-error states to the logical manifold at a large effective rate Γqecκ eff,1 ≈ Ω2/κ eng, where κ eng = g 2/κ is the engineered cooling rate introduced in Eq. (16). In addition to these error-correcting processes, we also obtain weak undesired decay terms (Fig. 4). These include (i) terms with n = 3 that act on the logical manifold introducing single-qubit errors (e.g., |000〉 → |100〉) at a rate κ eff,3 and (ii) terms with n = 2, transferring single-error states to uncorrectable double-error states (e.g., |110〉 → |100〉). As discussed above, these processes are detuned by an amount ~G and are therefore strongly suppressed. We verify this explicitly in Supplementary Note 2.

Performance of the scheme

We analyze the dynamics of our protocol analytically and numerically. For the former, we use the error correction rate Γqec = κ eff,1 and the rates of undesired processes κ eff,2 and κ eff,3 to describe the effective dynamics of the scheme by a system of coupled rate equations (Supplementary Note 2). For the numerical analysis, we simulate the full dynamics of the system without using the effective operator formalism. This is modeled by a master equation \(\dot \rho = {\cal L}_{{\mathrm{total}}}(\rho )\) with the Liouvillian \({\cal L}_{{\mathrm{total}}} = {\cal L}_{{\mathrm{noise}}} + {\cal L}_{{\mathrm{qec}}}\), which accounts for the noise processes we aim to correct for and the physical couplings of the error correction scheme (see “Methods”). The error-correcting code is assumed to operate on three physical qubits that are each subject to spin-flip errors acting at a rate Γ. We calculate the fidelity F(t) = Tr{ρ(t)|ψ(0)〉〈ψ(0)|} with respect to the initial state \(\left|\psi (0)\right\rangle = (\left|000\right\rangle + i\left|111\right\rangle )/\sqrt 2 \) and compare the result with the decay of a single qubit subject to spin-flips (cf. Eq. (4), with a rate Γ), that is initially prepared in the state \(\left|\psi (0)\right\rangle = (\left|0\right\rangle + i\left|1\right\rangle )/\sqrt 2 \). For different sideband coupling strengths, we numerically optimize the parameters κ eng and Ω to achieve maximum fidelity at the time t = 1/Γ. The number of excitations in the simulation is limited to at most one. Given that we mostly operate in a regime of weak driving \({\mathrm{\Omega }}^2 \ll \kappa _{{\mathrm{eng}}}^2,\,G^2\) this constitutes a good approximation. Truncating at higher numbers of excitations is found not to result in a notable difference of the evolution.

The results are shown in Fig. 5, where we plot the dynamical evolution of the system for different values of G/Γ (see Supplementary Figure 1 in Supplementary Note 2 for a wider range of sideband couplings). It can be seen that applying the dissipative three-qubit error correction code yields a significant advantage compared to using a single decaying qubit. For G = 5000Γ the code maintains a fidelity close to 0.9 at \(t \sim 1/{\mathrm{\Gamma }}\), where the single-qubit fidelity has almost dropped to the steady state value of 0.5.

Fig. 5
figure 5

Continuous error correction of a three-qubit code against spin-flip noise compared to single-qubit decay. We simulate the dynamics of a system of three physical qubits subjected to individual spin-flip errors at a rate Γ under the action of the error correction scheme by simulating the full master equation \(\dot \rho (t)\) restricted to at most one excitation. The shown results are obtained from optimizing the fidelity (see main text) at t = 1/Γ by the choice of κ eng and Ω for each considered value of the sideband coupling G. For comparison, the red dotted line displays the decay of a single qubit subject to spin-flips at a rate Γ. We find that the implementation of our scheme in trapped ions leads to a significantly reduced decay: Assuming a sideband coupling of G = 5000Γ (green solid line), a fidelity of F ≈ 0.9 of the dissipatively protected logical qubit (encoded in three decaying physical qubits) is maintained after a time \(t \sim 1/{\mathrm{\Gamma }}\)

The decrease in the fidelity of the codeword generally takes a hockey-stick-shaped form consisting of two parts: a fast initial drop and a slow exponential decay. This shape is a characteristic feature of time-continuous quantum error-correcting schemes (see, e.g., ref. 48). The initial drop is due to the fact that physical decay processes acting on the three physical qubits and laser-induced error processes lead to a loss of population from the codespace. The losses set in immediately, while the error correction-induced transfer back to the codespace sets in with a delay that is determined by the timescale on which population accumulates in the single-error space and Γqec. The subsequent effective decay rate in the presence of error correction is substantially reduced as compared to the single-qubit decay rate. This is clearly visible in Fig. 5.

In Supplementary Note 2, we introduce a rate equation model, which allows us to quantitatively describe the dynamics and to derive the optimal parameters for the scheme. We find that the fidelity of the codeword initially drops to F 0 = 1−E 0 with E 0 ≈ Γerrqec, where Γerr = 3(Γ + κ eff,3) is the loss rate from of the logical subspace. For the slow exponential decay we obtain an effective rate Γeff ≈ ΓerrΓleakqec, where Γleak = 2(Γ + κ eff,2) is the total leakage rate from the subspace of single-error states to the subspace of two-error states (Supplementary Note 2). Assuming perfect error correction (G → ∞), the detrimental rates approach the bare spin-flip rates, thus Γerr → 3Γ, Γleak → 2Γ, and the initial drop and effective decay rate become E 0 ≈ Γ/Γqec and Γeff ≈ 6Γ2qec, as expected for a continuous implementation of the three-qubit code43,48.

For finite sideband coupling G, we maximize the fidelity for long times by minimizing Γ eff (the details of the optimization are given in Supplementary Note 2). This leads to an optimal parameter choice Ω ≈ κ eng ≈ 1.2(ΓG 2)1/3, which allows for a correction rate Γqecκ eng/3 and leads to small and similar error and leakage rates, Γerr ≈ 3.3Γ and Γleak ≈ 2.7Γ. The resulting initial drop and effective decay rate are E 0 ≈ 10(Γ/G)2/3 and Γeff ≈ 27(Γ/G)2/3Γ. Alternatively, the protocol can be optimized for short operation times by minimizing the initial drop E 0.

In “Methods” section, we discuss imperfections that can occur in realistic setups and can lead to a reduction of the fidelity of the logical state. We address the effect of (i) decoherence associated with the decay of the excited degrees of freedom, (ii) imperfect cooling and heating of the motional modes, and (iii) the effect of “complementary” errors that are not corrected by our scheme. More specifically, our scheme is designed to correct for one type of errors (for example spin-flip errors). Errors other than the targeted type cannot be corrected simultaneously in the present version of the protocol. The performance of a scheme that corrects spin-flips (x-errors), will for example be degraded by the presence of “complementary” z-errors.

Application to quantum metrology

Quantum error correction protocols find attractive applications for quantum metrology, as has been proposed for example in refs. 22,23,24. Following these ideas, we explore the application of our error correction scheme for improving high-precision measurements of weak magnetic fields with ions. To this end, we study a prototypical setting, where a Ramsey-type protocol (Fig. 6a) is used to measure a signal originating from a field in the z-direction acting on several probe particles \(H = (\omega /2)\mathop {\sum}\nolimits_{j = 1}^N \,\sigma _z^{(j)}\). We commence by considering three probe particles constituting one logical qubit. The measurement sequence involves four steps. (i) Starting from the initial state |000〉, a first Ramsey pulse (a π/2 rotation on the logical qubit) prepares the superposition state \(\left|\psi (0)\right\rangle = (\left|000\right\rangle + \left|111\right\rangle )/\sqrt 2 \) using standard gate operations in ions9,10. (ii) During a Ramsey waiting time of duration τ R, the superposition state picks up a relative phase ϕ(τ R) = 3ωτ R, such that \(\left|\psi (\tau _{\mathrm{R}})\right\rangle = (\left|000\right\rangle + e^{ - i\phi (\tau _{\mathrm{R}})}\left|111\right\rangle )/\sqrt 2 \). (iii) A second Ramsey pulse (another π/2 rotation on the logical qubit) transforms the evolved state into |ψ′(τ R)〉 = cos(ϕ(τ R)/2)|111〉 + i sin(ϕ(τ R)/2)|000〉. (iv) Finally, a measurement in the σ z -basis is performed on one of the qubits. The probability to detect the first (or any other) qubit in state |1〉 is given by \(P_1 = \mathop {{{\mathrm{cos}}}}\nolimits^2 (\phi (\tau _{\mathrm{R}})/2)\), which allows one to infer the phase ϕ(τ R) and thus the signal strength ω. As explained in “Methods”, the sensitivity of this measurement is given by \(\left|\delta \omega \right| = 1/\left( {N\sqrt {\tau _{\mathrm{R}}} \sqrt T } \right)\), where N is the number of probe particles (N = 3 in our case) and T is the total measurement time (T =  R, where m is the number of runs). Increasing the Ramsey time leads to an improvement of the measurement precision (Fig. 7).

Fig. 6
figure 6

Application of the proposed error correction scheme to quantum metrology. a Ramsey scheme. From an initial state |000〉, a Ramsey pulse prepares \((\left|000\right\rangle + \left|111\right\rangle )/\sqrt 2 \). Under \(H = (\omega /2)\mathop {\sum}\nolimits_{j = 1}^N \,\sigma _z^{(j)}\), the state evolves to \((\left|000\right\rangle + e^{ - i\phi }\left|111\right\rangle )/\sqrt 2 \) during a Ramsey time τ R. Rotation by a second Ramsey pulse and measurement of the population P 1 of one ion in the {|0〉,|1〉} basis allows deducing ω according to \(P_1 = \mathop {{{\mathrm{cos}}}}\nolimits^2 (\phi /2)\) with ϕ = 3ωτ R. b In the absence of errors, the Ramsey measurement has full fringe contrast (dotted blue line). Spin-flips at a rate Γ = ω/2 damp out the oscillations (dashed red line). Applying the presented scheme for error correction protects the evolution and restores the fringe contrast (solid green line, assuming a sideband coupling of G = 5000Γ)

Fig. 7
figure 7

Quantum error correction enhanced sensing. The plot shows the normalized measurement precision \(|\delta \omega |\sqrt T \) vs. the Ramsey time τ R for a Ramsey measurement subject to spin-flips. The action of the error-correcting scheme can be seen to improve the achievable sensitivity by about an order of magnitude: The shown results display the normalized measurement precision assuming errors and (i) no error correction, (ii) error correction using the ideal jump operators given in Eq. (9), and (iii) error correction including undesired processes using the jump operators given in Eq. (22). As reference, the precision in the absence of errors (iv) is also shown. For the numerical simulation, we use G = 5000Γ, where Γ is the spin-flip rate, and the optimized parameters Ω = 4κ eng/5 and κ eng = 1.2(ΓG 2)1/3 discussed in the text, and restrict the full master equation to the subspace of at most one excitation

In the presence of noise, the precision of the measurement changes significantly5,15,17,18,19, given that both the amplitude and period of the fringes (cf. Fig. 6b) are affected by the noise. It has been shown theoretically26 that quantum error correction can be used to restore the optimal measurement precision in the presence of directed noise, as long as it is not parallel to the signal. Noise processes acting along the same direction as the signal (z) cannot be distinguished from the signal and thus cannot be targeted (we consider their effect in Supplementary Fig. 3). In the following, we analyze how well the detrimental effect of noise in the orthogonal direction (x) can be mitigated by the error correction protocol. Generally, if a signal in an arbitrary direction is assumed, correction of noise in x-direction as described below will allow for sensing the z-component of the signal with enhanced precision26.

In the Ramsey-type sensing scheme above, we consider a signal in z-direction and transverse noise in the form of local spin-flips, \(L_x^{(j)} = \sqrt {\mathrm{\Gamma }} \sigma _x^{(j)}\). This degrades the state with a resulting decrease of the fringe contrast (as can be seen in Fig. 6b). As shown in Fig. 7, the normalized sensitivity \(\sqrt T |\delta \omega |\) improves up to Ramsey waiting times \(\tau _R \sim {\mathrm{\Gamma }}^{ - 1}\), which limits the achievable measurement precision. The application of our quantum error correction scheme during step (ii) of the protocol (free evolution for a time τ R) thus reduces the speed at which the state is degraded. This shifts the optimum Ramsey waiting time to higher values, which improves the achievable measurement sensitivity. Figure 7 illustrates this effect for realistic experimental parameters and demonstrates that the presented error correction scheme significantly improves the performance of the Ramsey sequence compared to the situation where transversal errors are not corrected. The achievable sensitivity in the presence of both transversal and parallel noise (σ x and σ z errors) is shown in Supplementary Fig. 3.

So far our discussion has involved one logical qubit. The scheme can be scaled up to involve N log logical qubits using a segmented trap60,61, as shown in Fig. 1c) and explained in Supplementary Note 3. In this case, the potential barriers can be ramped up to divide the trap into segments confining three ions each. For sufficiently high barriers, the motional modes of the ion triples are independent from each other such that each logical qubit can be individually protected. This ramping into individual segments can be performed after the qubits are merged into an entangled state containing all qubits. Thereby the protocol can be used to obtain maximal quantum enhanced sensitivity while simultaneously being protected against spin-flip errors.

Discussion

In summary, we have presented a continuous quantum error correction scheme for trapped ions that dynamically stabilizes an encoded qubit by coupling it to an engineered reservoir. This protocol does not require the use of a classical measurement apparatus or classical feedback loops. The error correction mechanism results from a built-in back-action mechanism induced by engineered dissipative processes. From a practical perspective, avoiding the measurement procedure is a major advantage since measurements typically require scattering thousands of photons, which is a slow process and heats up the motional mode. While our scheme relies on the coupling of internal degrees of freedom to motional modes that underpins the realization of quantum gates in trapped ions9,10, it does not involve a sequence of gates, as in standard approaches to quantum error correction. Instead, our protocol uses the interaction between internal degrees of freedom and motional modes directly and requires only always-on couplings that act simultaneously and continuously on the encoded qubit. In this way, the role of auxiliary modes, to which the error syndromes are mapped, can be naturally played by the motional degrees of freedom, which allows one to continuously remove errors by means of standard sympathetic cooling of the motional modes.

The proposed error correction scheme can for example be used for quantum sensing, as we showed for the case of one logical qubit. By protecting random superposition states of three qubits we significantly increase the lifetime of the coherent oscillations in a Ramsey measurement. As a result, the sensitivity can be improved and the optimal measurement time can be shifted to higher values. For scaling up this approach, segmented ion traps can be used that can accommodate several logical qubits in different trap segments.

Our protocol pushes forward the boundary of dissipation-driven quantum information processing towards universal dissipative quantum computing. Engineered dissipation has already found useful applications for quantum state preparation, where the initial state is destroyed in the process of preparing a desired target state. In contrast, quantum error-correcting schemes need to preserve coherences in the initial state of a quantum system. Since such quantum error correction inherently relies on dissipation to get rid of entropy, it naturally fits into the framework of engineered dissipation. The realization of dissipative protocols that are capable of manipulating non-orthogonal quantum states while maintaining their coherence is an essential step in the endeavor to perform dynamically stabilized quantum information processing tasks. As the couplings assumed for the implementation of our scheme are generic couplings of a register of qubits to motional modes/ancilla qubits, the presented working mechanism can be adopted to other systems such as superconducting architectures and Rydberg atoms.

The principles we have employed to implement a dissipative three-qubit code can be taken further towards more sophisticated quantum error-correcting codes. Here it will be interesting to tailor suitable many-body dissipation to protect larger classes of stabilizers with the aim to realize, for example, topological error correction. Moreover, it will be very interesting to develop codes that do not only correct for noise of Pauli type as discussed in this article, but also for other error types such as loss errors. Hybrid schemes, where the paradigm of dissipative quantum error correction is combined with the technique of monitoring environmental degrees of freedom, have already been proven to be useful for sensing62 and may provide a promising route towards realizing such advanced schemes38.

We remark that the dissipative confinement of a quantum system to a desired subspace could also be useful for quantum simulations of lattice gauge theories, where devising methods for limiting the dynamics of a system to the gauge-invariant part of the Hilbert space is a key challenge for the development of future quantum simulators63,64. From a broader perspective, the design of dissipative maps can find a wide range of applications for quantum information processing including dissipative schemes for entanglement distillation65, generalized quantum measurements and the simulation of exotic quantum channels55.

Methods

Dynamical model

The dynamics of the system is modeled by a master equation \(\dot \rho = {\cal L}_{{\mathrm{total}}}(\rho )\) with the Liouvillian \({\cal L}_{{\mathrm{total}}} = {\cal L}_{{\mathrm{noise}}} + {\cal L}_{{\mathrm{qec}}}\), where \({\cal L}_{{\mathrm{noise}}}\) describes the noise processes we aim to correct for (Eq. (3)), and \({\cal L}_{{\mathrm{qec}}}\) contains the physical couplings required for the error correction scheme,

$${\cal L}_{{\mathrm{qec}}}(\rho ) = - i[H_{{\mathrm{total}},{\mathrm{eng}}},\,\rho ] + \mathop {\sum}\limits_{j = 1}^3 \,{\cal D}[L_{{\mathrm{eng}}}^{(j)}](\rho ).$$
(23)

Here the Hamiltonian H total,eng is given by Eq. (17) and the jump operators \(L_{{\mathrm{eng}}}^{(j)}\) by Eq. (16). Simulation of the master equation allows us to verify the action of the proposed error-correcting scheme numerically.

Effective dynamics of the open quantum system

We reduce the full dynamics of the system to effective dynamics of the ground states by adiabatically eliminating the excited degrees of freedom. To this end, we use the effective operator formalism57. Here we assume that the stable ground states are coupled to the excited states by perturbative coherent couplings V = V + + V , where V + (V ) denotes (de-)excitation. The coherent and dissipative dynamics of the excited states is described by a non-Hermitian Hamiltonian

$$H_{{\mathrm{NH}}} = H_e - \frac{i}{2}\mathop {\sum}\limits_k \,L_k^{\mathrm{\dagger }}L_k,$$
(24)

where H e contains the coherent couplings between the excited states and L k are decay processes taking them to the ground states. Applying the formalism57, we then obtain the effective operators

$$H_{{\mathrm{eff}}} = - \frac{1}{2}V_ - H_{{\mathrm{NH}}}^{ - 1}V_ + + {\mathrm{H}}{\mathrm{.c}}.$$
(25)
$$L_{k,{\mathrm{eff}}} = L_kH_{{\mathrm{NH}}}^{ - 1}V_ + .$$
(26)

Here, H eff is the effective Hamiltonian and L k,eff are the effective jump operators. The resulting effective dynamics is described by an effective master equation

$$\dot \rho = - i[H_{{\mathrm{eff}}},\rho ] + \mathop {\sum}\limits_k \,{\cal D}[L_{k,{\mathrm{eff}}}](\rho ).$$
(27)

From this reduced model we derive the rates for the error correction and leakage processes. Considering a simplified rate equation model allows us to assess the performance of the scheme and to derive and optimize the available parameters of the scheme analytically. The detailed calculations and a numerical comparison to the full dynamics of Eq. (23) can be found in Supplementary Note 2.

Sensitivity of the measurement

The sensitivity of a Ramsey spectroscopy scheme with entangled particles5,66,67,68 is determined as follows. Using the Ramsey sequence described in the main text, a first Ramsey pulse prepares a system of N qubits in the state \(\left|\psi (0)\right\rangle ^{ \otimes N} = (\left|0\right\rangle ^{ \otimes N} + \left|1\right\rangle ^{ \otimes N})/\sqrt 2 \), which evolves under the Hamiltonian \(H = (\omega /2)\mathop {\sum}\nolimits_{j = 1}^N \,\sigma _z^{(j)}\) for a time τ R, resulting in the state \(\left|\psi (\tau _{\mathrm{R}})\right\rangle = (\left|0\right\rangle ^{ \otimes N} + e^{ - iN\omega \tau _{\mathrm{R}}}\left|1\right\rangle ^{ \otimes N})/\sqrt 2 \). After the second Ramsey pulse one of the qubits is measured. The probability to find this qubit in state |1〉 is given by \(P_1 = \mathop {{{\mathrm{cos}}}}\nolimits^2 (N\omega \tau _{\mathrm{R}}/2)\). The uncertainty in estimating P 1 due to the statistical fluctuations associated with a finite sample \({\mathrm{\Delta }}P_1 = \sqrt {P_1(1 - P_1)/n_{{\mathrm{data}}}} \), depends on the number of experimental data n data. In the considered case this equals the number of runs n runs = n data = T/τ R, where T is the total measurement time. The uncertainty in the measurement of ω is therefore given by

$$|\delta \omega | = \frac{{{\mathrm{\Delta }}P_1}}{{|{\mathrm{d}}P_1/{\mathrm{d}}\omega |}}.$$

In the ideal case, this yields \(|\delta \omega | = 1/\left( {N\sqrt {T\tau _{\mathrm{R}}} } \right)\). The numerical results in Figs. 6 and 7 have been obtained by calculating the time evolution of the density matrix of a three-ion system ρ(t) in the presence of the signal Hamiltonian, individual spin-flips and the error-correcting scheme. Supplementary Figure 3 in Supplementary Note 3 shows the dynamics that is obtained if collective dephasing is added to the problem.

Correction of other types of errors

Our scheme can be generalized to correct for correlated spin-flip or phase errors, as detailed in Supplementary Note 1.

The action of correlated spin-flips, \(L_x = L_x^{(1)} + L_x^{(2)} + L_x^{(3)} = \sqrt {{\mathrm{\Gamma }}_X} \left( {\sigma _x^{(1)} + \sigma _x^{(2)} + \sigma _x^{(3)}} \right)\) leaves the system in a superposition state of all single-qubit spin-flip errors, \(\left|\psi _X\right\rangle = \left( {\left|\psi ^{(1)}\right\rangle + \left|\psi ^{(2)}\right\rangle + \left|\psi ^{(3)}\right\rangle } \right)/\sqrt 3 \). To correct for such an error, we replace the coupling of the ions to the three auxiliary modes c (j) in Eq. (13) by a coherent coupling to a single auxiliary mode c,

$$H_{{\mathrm{aux}},g} = gc^{\mathrm{\dagger }}\mathop {\sum}\limits_{j = 1}^3 \,e^{i\delta _ct}\left( {{\left| 0 \right\rangle}_{j}\left\langle e\right| + {\left|1\right\rangle}_{j} \left\langle f\right|} \right) + {\mathrm{H}}.{\mathrm{c}}.$$
(28)

The drive in Eq. (11) also coherently acts on the three ions. Correlated errors of all qubits are thereby coherently mapped onto c. Dissipating the excitations of c by \(L_c = \sqrt \kappa c\) (cf. Eq. (15)) then realizes the single collective jump operator \(L_{X,{\mathrm{qec}}} = L_{x,{\mathrm{qec}}}^{(1)} + L_{x,{\mathrm{qec}}}^{(2)} + L_{x,{\mathrm{qec}}}^{(3)}\), with \(L_{x{\mathrm{,qec}}}^{(j)}\) as in Eqs. (6)–(8).

To generalize the scheme to phase-flips, we perform the mapping |0〉 → |+〉 and |1〉 → | − 〉, where \(\left| \pm \right\rangle = (\left|0\right\rangle \pm \left|1\right\rangle )/\sqrt 2 \). The resulting codeword is given by |ψ〉 = c +|+ ++〉 + c |− −−〉. Phase-flips on the second qubit are corrected by the action of the jump operator

$$L_{z,{\mathrm{qec}}}^{(2)} = \sqrt {{\mathrm{\Gamma }}_{{\mathrm{qec}}}} \sigma _z^{(2)}\frac{{{\Bbb{1}} - \sigma _x^{(1)}\sigma _x^{(2)}}}{2}\frac{{{\Bbb{1}} - \sigma _x^{(2)}\sigma _x^{(3)}}}{2}.$$
(29)

Errors on the first and third qubit are corrected analogously.

To correct for correlated phase-flips, we proceed as in the case of spin-flips above and adapt the scheme for individual errors to collective errors. We replace the couplings of the ions to individual auxiliary modes c (j) by a coherent coupling of all three ions to a single auxiliary mode c,

$$H_{{\mathrm{aux}},g} = gc^{\mathrm{\dagger }}\mathop {\sum}\limits_{j = 1}^3 \,e^{i\delta _ct}\left( {{\left| + \right\rangle}_{j}\left\langle e\right| + {\left| - \right\rangle}_{j}\left\langle f\right|} \right) + {\mathrm{H}}.{\mathrm{c}}.,$$
(30)

Phase errors of the qubits are thus coherently mapped on the auxiliary mode c. Subsequent cooling of c (Eq. (15)) then yields the jump operator \(L_{Z,{\mathrm{qec}}} = L_{z,{\mathrm{qec}}}^{(1)} + L_{z,{\mathrm{qec}}}^{(2)} + L_{z,{\mathrm{qec}}}^{(3)}\) which combines the individual operators \(L_{z,{\mathrm{qec}}}^{(j)}\) for j = 1, 2, 3 (cf. Eq. (29) for j = 2) and thus corrects for correlated phase errors.

External imperfections

In the following, we discuss imperfections that can occur in realistic setups and may lead to a reduction of the fidelity of the logical state.

Our scheme is designed to correct for one type of individual or collective errors (for example for correcting either spin-flip or phase errors). Errors other than the targeted type cannot be corrected simultaneously in the present version of the scheme. The performance of a scheme that corrects spin-flips (σ x -errors), will for example be degraded by the presence of “complementary” σ z -errors,

$$L_z^{(j)} = \sqrt {{\mathrm{\Gamma }}_z} \sigma _z^{(j)},$$
(31)
$$L_Z = \sqrt {{\mathrm{\Gamma }}_Z} \mathop {\sum}\limits_{j = 1}^N \,\sigma _z^{(j)}.$$
(32)

These errors contribute to the effective error-correcting dynamics and cause a decaying envelope for the population of the codeword |ψ〉, resulting in an additional decay of the fidelity \(F_{{\mathrm{comp}}}(t) = F(t)e^{ - (3{\mathrm{\Gamma }}_z + {\mathrm{\Gamma }}_Z)t}\). To limit the additional error to the few-percent level at \(t \sim 1/{\mathrm{\Gamma }}\), it is thus required that \({\mathrm{\Gamma }}_k \, \lesssim \,{\mathrm{\Gamma }}/50 - {\mathrm{\Gamma }}/100\) depending on the kind of error process. In Fig. 8, we plot the evolution for G/Γ = 5000 and individual phase-flips with Γ z /Γ = 0, 1/50, 1/25, finding that Γ z /Γ = 1/50 leads to a decrease in fidelity of about ~0.05 at \(t \sim 1/{\mathrm{\Gamma }}\). The decrease is less pronounced for smaller G/Γ. In the absence of correction, even without dephasing (Γ z /Γ = 0), one observes much stronger decay of the fidelity.

Fig. 8
figure 8

Dissipative correction of spin-flips in the presence of dephasing. The plot shows the decrease in fidelity (compare Fig. 5) for three different values of the ratio Γ z /Γ, where Γ z (Γ) is the rate at which an individual phase-flip (individual spin-flip) occurs, assuming a sideband coupling G = 5000Γ: Γ z  = 0 (light green solid), Γ z  = 1/25Γ (long green dash), and Γ z  = 1/50Γ (short dark green dash). As reference, the plot also includes the decay of a single uncorrected ion under spin-flips at a rate Γ with Γ z  = 0 (red dashed line), for which one observes much stronger decay of the fidelity

Next, we address the effect of decoherence associated with the decay of the excited degrees of freedom. More specifically, we include the decay of the excited states |e〉 and |f〉 by spontaneous emission described by the jump operators \(L_{mn}^{(j)} = \sqrt {\gamma _{m,n}} {\left|m\right\rangle}_{j}\left\langle n\right|\), where m{e, f} and n{0,1}, in the master equation. Also the motional modes are assumed to undergo decay \(L_r = \sqrt {\kappa _r} r\), where r {a, b}. For simplicity we assume γ m0 = γ m1 = γ m /2 (for m{e, f}), γ e  = γ f  = γ and κ a  = κ b . These imperfections do not change the effective couplings significantly. Analytically, they can easily be taken into account as imaginary parts in the detunings57: Δ → Δ − m /2 and δδ r /2. For \(\kappa _{{\mathrm{eng}}} \gg \gamma _m,\kappa _r\) we can safely assume that the rates κ eff,1 − 3 are not affected. Numerical simulations show that for the parameters used in Fig. 5, \(\{ G/\gamma _m,\,G/\kappa _r\} \sim 10^3\) or \(\{ \gamma _m,\,\kappa _r\} \sim {\mathrm{\Gamma }}\), respectively, can be tolerated, as they only lead to minor errors at the percent level. Note that in the quantum jump formalism, dephasing of states |e〉 and |f〉 enter into the effective non-Hermitian Hamiltonian in a similar manner as the decay. Decay and dephasing thus only differ in their dynamics after a decay causing an error; we therefore obtain similar results for dephasing.

So far, the motional modes have been assumed to be in the ground state. Initial excitations due to imperfect cooling to mean phonon numbers \(\bar n_r\) (r {a, b, c (j)}, and heating processes with rates \(\kappa _r^ + \) constitute another source of imperfections. We study their effect in detail in Supplementary Note 3. For the auxiliary modes c (j), we find that neither heating nor initial excitations have a significant effect, provided that the modes are subject to a strong and continuous cooling process, such as sympathetic cooling or ancilla reset. For realistic experimental parameters \(\kappa _r^ + \sim 10^{ - 3} G\) 58,59 one obtains errors ~0.01 per mode. For the interrogation modes a and b, initial excitations lead to an additional error \(\varepsilon \approx \bar n_a + \bar n_b\). Heating of the interrogation modes has a more pronounced effect since motional excitations can couple to excitations of the system ions by the strong sideband coupling H int,G . While such imperfections of the interrogation modes can also be countered by cooling with a rate \(\kappa _r \gg \kappa _r^ + \), the cooling rates need to be moderate, \(\kappa _r \ll G\), to avoid decoherence during the error correction process. As detailed in Supplementary Note 3, for realistic parameters59 the resulting errors can be at the few-percent level, comparable to the initial drop E 0. Still, with these parameters the presented scheme yields a significant improvement over the uncorrected case, allowing for its application in quantum metrology.

Data availability

The data that support the findings of this study are available from the authors upon request.