Introduction

Quantum sensors exploit the strong sensitivity of quantum systems to external disturbances. They typically measure an external quantity—a DC signal in the most common scenario—whose value is manifested as a parameter in the sensor’s Hamiltonian. This parameter can then be estimated by preparing the sensor in a superposition of two energy eigenstates and letting them acquire a relative phase that depends on the unknown quantity, which is then read out.1

This strong sensitivity of quantum systems to their environment is a double-edged sword, however, as it also brings about decoherence. For quantum sensors, decoherence means that not only the relative phase—but also the phase uncertainty—between energy eigenstates grows with time. The competing contributions of phase (signal) and phase uncertainty (noise) both stemming from a sensor’s environment fundamentally limit the precision with which it can measure external quantities. A central way to improve the sensitivity of a quantum sensor is therefore to operate it in a way that filters out environmental disturbances which constitute noise, leaving those which constitute signal.

Dynamical decoupling (DD) sequences provide a family of such filters, which are ubiquitous in quantum sensing experiments.1,2,3 They comprise a series of control pulses (or continuous controls) applied to a sensor, which modify its response to perturbations of different frequencies. This allows them to filter noise from signal in a quantum sensor on the basis of frequency; typically, by forming an effective narrow-band filter around an AC signal, thus letting the signal imprint on the sensor while suppressing much of the noise outside the main passband. Since DD sequences act as filters in the frequency domain, their main limitations for quantum sensing have to do with the spectra of signal and noise: First, DD-based sensors can only measure a narrow frequency band of the signal at a time. Moreover, they cannot directly measure DC signals, as DD suppresses both noise and signal at low frequencies. Second, they remain vulnerable to high-frequency noise components, which limit the sensitivity they can achieve.4 A complementary family of filters based instead on quantum error correction has recently emerged, which do not suppress noise on the basis of frequency, and therefore do not share these same limitations.5,6,7,8

The canonical scheme for error-corrected quantum sensing (ECQS), illustrated here with a Lindblad description, is: (i) to prepare a superposition of logical energy eigenstates, (ii) to let the sensor evolve for a time Δt under the Liouvillian \({\mathcal{L}} = - i{\mathcal{H}} + {\mathcal{D}}\), where the Hamiltonian superoperator \({\cal H}\left( \rho \right) = \left[ {H,\rho } \right]\) is proportional to the parameter one wants to estimate (that is, the signal9), and (iii) to apply a recovery operation \({\cal R}\) which seeks to correct the effects of the noise from

$${\cal D}\left( \rho \right) = \mathop {\sum}\limits_i L_i\rho L_i^\dagger - \frac{1}{2}\left\{ {L_i^\dagger L_i,\rho } \right\},$$
(1)

where {Li} are the Lindblad error operators describing decoherence, which can be interpreted as quantum jumps.10 (The recovery is approximated as being instantaneous.) Steps (ii) and (iii) are repeated until (iv) the final state is read out after a total time t. In the limit where (ii)–(iii) are fast and repeated many times (Δt → 0 with t finite), the sensor evolves stroboscopically as

$${\cal L}_{{\mathrm{eff}}} = - i{\cal R}{\cal H} + {\cal R}{\cal D} + O\left( {\left\Vert {\cal L} \right\Vert\Delta t} \right)$$
(2)

according to Chernoff’s theorem (ref. 11 p. 241, see also ref. 12). If \({\cal R}{\cal D} = 0\) but \({\cal R}{\cal H} \ne 0\) on logical states then ECQS can approach a noiseless sensing limit by making Δt sufficiently short compared to the noise strength.

For ECQS to provide such a noiseless Δt → 0 limit \(\left( {\left. {{\cal R}{\cal D}} \right|_{{\mathrm{code}}} = 0} \right)\), the error operators for the sensor must satisfy the usual Knill-Laflamme condition:13,14

$$PL_i^\dagger L_jP \propto P$$
(3)

for all i, j ≥ 0, where \(P = P^\dagger\) projects onto the codespace and L0:= I. For the signal to survive in this limit \(\left( {\left. {{\cal R}{\cal H}} \right|_{{\mathrm{code}}} \ne 0} \right)\), however, H must not be fully correctable:

$$PHP\not \propto P.$$
(4)

Naturally then, H must not be a linear combination of \(L_i^\dagger L_j\) terms. Indeed, it was recently proven that there exists a code with projector P satisfying these ECQS conditions, Eqs. (3) and (4), if and only if \(H\,\notin\,{\cal S}\) where \({\cal S} = {\mathrm{span}}\left\{ {I,L_i,L_i^\dagger ,L_i^\dagger L_j} \right\}\) is the so-called Lindblad span.15,16

An archetypal example of ECQS to measure a DC signal ω was proposed in refs. 7,8,17: it involves a three-qubit sensor with \(H = \mathop {\sum}\nolimits_{i = 1}^3 \frac{\omega }{2}{\kern 1pt} Z_i\) subject to independent bit-flip errors on each qubit (Li = Xi). Initializing the sensor in \(\left| { + _L} \right\rangle = \frac{1}{{\sqrt 2 }}\left( {\left| {0_L} \right\rangle + \left| {1_L} \right\rangle } \right)\), where |0L〉 = |000〉 and |1L〉 = |111〉, the errors can be detected and corrected by the bit-flip code recovery \({\cal R}\) (ref. 18), while the signal ω imprints through H as a relative phase in the encoded state. The signal is unimpeded by the frequent applications of \({\cal R}\) as it couples to the qubits through a different operator than the noise, giving \(H\,\notin\,{\cal S}\), and hence \({\cal R}{\cal D} = 0\) but \({\cal R}{\cal H} \ne 0\) on logical states. Therefore, the scheme enables near-noiseless sensing of ω for short Δt. To our knowledge, all explicit ECQS schemes to date for multi-qudit sensors operate similarly, correcting only for noise which couples to the sensor via different operators than the signal.5,6,7,8,17,19,20,21,22,23,24,25,26 If instead the jump operators were Li = Zi (that is, if the noise coupled to each qubit in the same way as the signal), Eqs. (3) and (4) could not be satisfied, as no code could filter noise from signal since \(H \in {\cal S}\).

This example illustrates a deficiency in ECQS schemes to date, of both practical and fundamental importance. In many quantum sensors, noise which couples through the same operators as the signal is the dominant source of decoherence (often by several orders of magnitude27,28,29,30,31,32), and thus imposes the main limit on achievable sensitivity. Schemes which do not protect against such a central noise source can offer only a limited advantage in practice. More fundamentally, the outsized importance of such noise derives from a tension at the core of quantum sensing: A good sensor must couple strongly to the quantity it is to measure. Such strong coupling, in turn, renders the device highly sensitive to fluctuations in this quantity, thus bounding the duration of coherent sensing. While DD can suppress certain frequency components of this noise, explicit ECQS schemes to date cannot address it at all, to our knowledge. Moreover, refs. 15,16 make no pronouncements as to whether, or when, it is possible to correct for noise that couples to a sensor through the same operator in its Hamiltonian as the signal. This potential Achilles’ heel would seem to largely determine the practical value of error correction in many quantum sensors.

We propose a general error-correction scheme to filter out noise which couples to each qubit in a quantum sensor identically to the signal. Our scheme is not frequency-selective, and therefore does not share the same limitations of dynamical decoupling. The key insight is that Eqs. (3) and (4) can be viewed not only as a condition on how signal and noise couple to the sensor, as with existing codes, but also as a condition on the spatial profiles of each in the sensor. Indeed, we show that quantum error correction can filter noise from signal on the basis of their respective spatial correlations, much like DD filters based on temporal correlations (i.e., frequency profiles).

Results

We first consider the task of measuring a DC signal ω0, inaccessible through DD, in the presence of background noise δω. We assume a generic sensor comprising N qubits, each coupled locally to the external field \(\omega \left( {\vec x,t} \right) = \omega _0 + \delta \omega \left( {\vec x,t} \right)\) as

$$H\left( t \right) = \frac{1}{2}\mathop {\sum}\limits_{i = 1}^N \omega \left( {\vec x_i,t} \right){\kern 1pt} Z_i$$
(5)

in a suitable reference frame, where \(\vec x_j\) is the position of qubit j and δω describes zero-mean stationary fluctuations. We take δω to be Gaussian white noise with strength ~1/T2, for both mathematical convenience and to highlight the ability of error correction to filter high-frequency background noise beyond the reach of DD. We allow, however, for general spatial correlations between the fluctuations at positions \(\vec x_i\) and \(\vec x_j\):

$$\left\langle {\delta \omega \left( {\vec x_i,t} \right){\kern 1pt} \delta \omega \left( {\vec x_j,0} \right)} \right\rangle = \frac{{2\delta \left( t \right)}}{{T_2}}{\kern 1pt} c_{ij}.$$
(6)

Thus, any qubit prepared in the state |+〉 will precess about its z-axis at a rate ω0 and lose phase coherence as \(\left| {\left\langle {\sigma _ + ^{\left( j \right)}} \right\rangle } \right| = {\mathrm{exp}}\left( { - t/T_2} \right)\) (ref. 33). The coefficients cij [−1, 1] describe the noise correlations between positions \(\vec x_i\) and \(\vec x_j\): The extreme values of cij = ±1, for instance, describe identical (+1) or opposite (−1) fluctuations in ω at either position, whereas cij = 0 means no correlation. Naturally cii = 1. Note that while this noise is external to the sensing degrees of freedom, it may still arise from within the experimental device, e.g., from the surrounding nuclear bath in the case of spin qubits.

It is convenient to express the sensor’s dynamics as a master equation \(\dot \rho = {\cal L}\left( \rho \right)\), where

$${\cal L}\left( \rho \right) = - i\left[ {H_0,\rho } \right] + \frac{1}{{2T_2}}\mathop {\sum}\limits_{i,j = 1}^N c_{ij}\left( {Z_i\rho Z_j - \frac{1}{2}\left\{ {Z_iZ_j,\rho } \right\}} \right)$$
(7)

and \(H_0 = \frac{{\omega _0}}{2}\mathop {\sum}\nolimits_{i = 1}^N Z_i\) (refs. 34,35). Equation (7) can be cast in the form of (1), thus removing dissipative cross terms, by diagonalizing the correlation matrix C = (cij)i,j≥1 to yield operators \(L_i = \sqrt {\lambda _i} \vec v_i \cdot \vec Z\). Here, \(C\vec v_i = \lambda _i\vec v_i\) and \(\vec Z = \left( {Z_1, \ldots ,Z_N} \right)\). These Li ’s can be interpreted as the sensor’s quantum jumps, while the Zi ’s in Eq. (7) cannot.10 Crucially, the ECQS conditions, (3) and (4), deal with the quantum jump operators Li ’s, not the bare Zi ’s. This distinction is critical because it opens the possibility of engineering a sensor such that C has a vanishing eigenvalue λk = 0, thus suppressing Lk. Generically, the Lindblad span \({\cal S}\) will then fail to contain H0 due to this “missing” jump operator, opening the door for ECQS.

The requirement that \(H_0\,\notin\,{\cal S}\) for conditions (3) and (4) can be restated for signal and noise which couple identically to the sensor (in the sense of Eq. (5)) as

$$\vec h\,\notin\,{\mathrm{col}}\left( C \right),$$
(8)

where \(\vec h = \left( {1, \ldots ,1} \right) \in {\Bbb R}^N\) so that \(H_0 = \frac{{\omega _0}}{2}{\kern 1pt} \vec h \cdot \vec Z\), and col(C) is the column space of C. A full proof is given in the 'Methods' section; we note here simply that Eq. (8) enforces two things: (i) that det(C) = 0 and thus Lk = 0 for some k, and (ii) that H0 is not composed only of non-vanishing Li ’s. It ensures that the signal and noise can be fully distinguished by the recovery operation on the basis of their respective spatial profiles (a requirement we will later relax).

Consider for example N = 3 sensing qubits positioned so that the fluctuations satisfy cij = −γ/2 for each pair i ≠ j, where γ [0, 1] describes the noise correlation strength. (Specifically, γ = 0 produces vanishing correlations whereas γ = 1 gives the strongest correlations possible.) Notice that for γ = 1, \(C\vec h = \vec 0\), and so \(\vec h\,\notin\,{\mathrm{col}}(C)\). The jump operators in the ECQS conditions are not Z1, Z2 and Z3, but rather

$$L_1 = \frac{{\sqrt {2 + \gamma } }}{2}\left( {Z_1 - Z_3} \right),\quad L_2 = \sqrt {\frac{{2 + \gamma }}{{12}}} \left( {Z_1 - 2Z_2 + Z_3} \right),\quad L_3 = \sqrt {\frac{{1 - \gamma }}{3}} \left( {Z_1 + Z_2 + Z_3} \right),$$
(9)

found by diagonalizing C. Observe that the global noise mode, L3, becomes subdominant for larger values of γ, until it vanishes completely when γ = 1, at which point \(H_0\,\notin\,{\cal S}\) as expected. Notice also that \(P = |0_L\rangle \langle 0_L| + |1_L\rangle \langle 1_L|\) with logical states

$$\left| {0_L} \right\rangle = \frac{1}{{\sqrt 3 }}\left( {\left| {100} \right\rangle + \left| {010} \right\rangle + \left| {001} \right\rangle } \right)\quad \left| {1_L} \right\rangle = \frac{1}{{\sqrt 3 }}\left( {\left| {011} \right\rangle + \left| {101} \right\rangle + \left| {110} \right\rangle } \right)$$
(10)

satisfies the conditions (3) and (4) when γ → 1, despite the signal and noise both coupling to each sensing qubit identically. Contrast this with the usual phase-flip code, which corrects for Z1, Z2, Z3 and all linear combinations thereof, including H0 (ref.10). Eq. (10) instead defines a weakened version of the phase-flip code, which corrects for linear combinations of L1 and L2, but not for \(\vec v_3 \cdot \vec Z \propto Z_1 + Z_2 + Z_3\). Accordingly, as γ → 1 it can fully correct the noise \(\left( {\left. {{\cal R}{\cal D}} \right|_{{\mathrm{code}}} = 0} \right)\) while allowing the signal to still imprint on the logical states \(\left( {\left. {{\cal R}{\cal H}} \right|_{{\mathrm{code}}} \ne 0} \right)\). In particular, the dynamics at logical level for Δt → 0 are generated by the effective Hamiltonian \(H_{{\mathrm{eff}}} = \frac{{\omega _0}}{2}Z_L\) and the effective Lindblad error operator

$$L_{{\mathrm{eff}}} = \sqrt {\frac{{1 - \gamma }}{{6T_2}}} Z_L,$$
(11)

where ZL is the logical σz (ref. 16). Notice that Leff → 0 for γ → 1, so the logical dynamics is less noisy for stronger correlations. A detailed calculation of the effective Liouvillian for this example—as well as for an example with positive noise correlations—is provided in the Supplementary Information.

Another possible code for this C uses

$$\left| {0_L^\prime } \right\rangle = \left| {000} \right\rangle \quad \quad \quad \left| {1_L^\prime } \right\rangle = \left| {111} \right\rangle .$$
(12)

When γ → 1 it also satisfies the ECQS conditions, although its recovery procedure is trivial because span \(\left\{ {\left| {0_L^\prime } \right\rangle ,\left| {1_L^\prime } \right\rangle } \right\}\) is a decoherence-free subspace (DFS) within which H0 acts non-trivially.36 ECQS with this code is therefore a Greenberger-Horne-Zeilinger (GHZ) sensing scheme.37 The performance of a quantum sensor can be quantified by the sensitivity it achieves; that is, the smallest signal it can detect per unit time.1 Sensitivity therefore also provides a way to benchmark ECQS schemes: a more effective scheme allows one to resolve a smaller signal per unit time, thus giving lower (i.e., better) sensitivity. The sensitivity offered by the codes in Eqs. (10) and (12) is plotted in Fig. 1 as a function of γ. Both approach noiseless sensing when γ → 1.

Fig. 1
figure 1

The achievable sensitivity with different schemes for a 3-qubit sensor under noise correlations cij = −γ/2, for all i ≠ j. Note that sensitivity is a measure of the smallest resolvable signal per unit time, so a smaller sensitivity indicates better performance. The active recovery and GHZ schemes use codewords (10) and (12) respectively, whereas the parallel scheme operates the qubits individually, without entanglement. The active and GHZ schemes give identical performance (in the regime of Δt → 0 for the former), and both outperform parallel sensing by a factor that grows with the correlation strength γ. The details of this calculation are provided in the Supplementary Information.

In general, a DFS is a code for which |0L〉 and |1L〉 are degenerate eigenvectors of all Li. This means that EP = μEP for all \(E \in {\cal S}\), immediately satisfying condition (3). For states within the DFS to be sensitive to ω0 we also need |0L〉 and |1L〉 to be non-degenerate energy eigenstates, so that \(HP\not \propto P\), satisfying condition (4). Such a DFS satisfies the ECQS conditions—accordingly, our discussion of general ECQS encompasses DFS-enhanced sensing as a special case.

DFS-enhanced sensing is only possible for a small family of correlation matrices C which we discuss below. A code designed for some general C, in contrast, will usually necessitate an active recovery \({\cal R}\). Given a projector P onto the code satisfying the ECQS conditions, an appropriate choice of \({\cal R}\) is the usual so-called transpose channel.16,38 We summarize a standard way of implementing it in the 'Methods' section. For a logical state ρ = PρP this recovery gives \({\cal R}{\cal D}\left( \rho \right) = 0\) and \({\cal R}{\cal H}\left( \rho \right) = \left[ {H_{{\mathrm{eff}}},\rho } \right] \ne 0\) as desired, where Heff = PH0P (ref. 16). In other words, the sensor approaches noiseless evolution by Heff in the limit of frequent error detection/correction (i.e., Δt → 0).

Conditions (3) and (4) seem to impose a stringent requirement on the C's amenable to ECQS under signal and noise which are “parallel”, in that they couple to the sensor through the same operators (along the z direction, i.e., the qubits’ energy gaps, here). This need not be the case, however, since error correction can enhance quantum sensing even if it does not give a strictly noiseless limit. Notice in Fig. 1, for instance, that ECQS enhances sensitivity for all γ > 0, even though conditions (3) and (4) are only satisfied exactly when γ = 1. (Another example is analyzed in the Supplementary Information, as is the robustness of our scheme.) More generally, if instead of satisfying (3) exactly, \(PL_i^\dagger L_jP = m_{ij}P + O\left( \varepsilon \right)\), then \({\cal R}{\cal D}\left( \rho \right) = O\left( \varepsilon \right)\) for a logical ρ instead of vanishing exactly.16 If the time between successive recoveries is nonzero (Δt > 0) as in most experiments, then decoherence will appear in the logical dynamics at order Ot/T2) in \({\cal L}_{{\mathrm{eff}}}\). (We write O(t/T2) rather than \(O\left( {\left\Vert {\cal L} \right\Vert{\mathrm{\Delta }}t} \right)\) to simplify notation, assuming ω0 to be a small compared to 1/T2. If ω0 is not small, Ot/T2) should be taken to mean \(O\left({\left\Vert {\cal L} \right\Vert{\mathrm{\Delta }}t} \right)\)). Provided \(\varepsilon \ll {\mathrm{\Delta }}t/T_2\), then, small violations of condition (3) will not appreciably change the degree to which quantum error correction suppresses noise in a sensor. This is true for generic ECQS schemes. When correcting noise which couples like the signal, in particular, allowing ε ≠ 0 enables codes which—by design—do not correct for errors Lk with ||Lk|| ≈ 0, corresponding to an eigenvalue λk of C which is small but not exactly zero. Therefore in the present setting, relaxing condition (3) reduces the need for fine-tuned noise correlations.

For quantum error correction to filter noise from signal when Δt/T2 is finite, \({\cal R}\) must suppress the former more than the latter. Choosing |0L〉 and |1L〉 to be eigenstates of Heff with E0 > E1, the effective Hamiltonian takes the form \(H_{{\mathrm{eff}}} = \alpha P + \frac{{\omega _L}}{2}Z_L\), where \(Z_L = \left| {0_L} \right\rangle \left\langle {0_L} \right| - \left| {1_L} \right\rangle \left\langle {1_L} \right|\) and P acts as I on the code. Just as ε and Δt/T2 describe the extent to which noise is suppressed through frequent error correction, the ratio \(A_\omega = \frac{{\omega _L}}{{\omega _0}}\) describes the signal gain; that is, the fraction of the physical signal that survives at the logical level. Together with previous arguments about (3), we arrive at sufficient conditions in terms of this signal gain for error correction to enhance quantum sensing: \(PL_i^\dagger L_jP = m_{ij}P + O\left( \varepsilon \right)\), and \(A_\omega \gg \varepsilon\). There is an analogy with dynamical decoupling to be drawn here: both quantum error correction and DD can significantly enhance sensing by partially filtering noise from the signal—they need not remove the noise entirely to be useful.

This analogy goes further: Just as DD sequences must be tailored to sense in a particular frequency band of interest, error-correcting codes must be tailored to C and \(\vec h\) for a sensor to measure only in a particular spatial “mode”, in order to correct for noise which couples locally in the same way as the signal. That is, a particular δω and arrangement of sensing qubits (likely determined at the time of fabrication) will require a unique P. This is because the scheme depends on a code not correcting for \(\vec v_k \cdot \vec Z\) with \(\lambda _k\sim 0\), thus allowing the component of H0 along \(\vec v_k \cdot \vec Z\) to affect the logical states. Therefore, we expect that in experiment, codes will need to be tailored for individual devices, much like control sequences must be. We present here a robust method of doing so.

When \(\vec h\,\notin\,{\mathrm{col}}(C)\), refs. 15,16 provide recipes for codes which exactly satisfy the ECQS conditions, although these may require the sensor to contain up to N noiseless ancilla qubits which do not couple to ω, in addition to the N sensing qubits. Here we take a different approach which naturally tolerates small violations of the ECQS conditions, such as those discussed above. That is, it allows one to find codes which enhance sensitivity, irrespective of whether they provide a noiseless limit in theory. In contrast with several previous works,15,16 our approach does not require the overhead of additional ancillas as part of the code. Specifically, for a given C, we map the task of finding a P for (3) and (4) to an optimization problem, whose solutions are codes satisfying \(PL_i^\dagger L_jP = m_{ij}P + O(\varepsilon )\) for some \(M = M^\dagger\), and giving a minimum signal gain of Aω,min that is freely adjustable:

$${\mathrm{Minimize}}\,F_{{\mathrm{tot}}} = \mathop {\sum}\limits_{E\, \in \,{\cal S}} F_E\,{\mathrm{subject}}\,{\mathrm{to}}\,F_G > A_{\omega ,{\mathrm{min}}}^2\,{\mathrm{and}}\,\left\langle {x|y} \right\rangle = \delta _{xy},$$
(13)

where \(G: = \frac{1}{2}\vec h \cdot \vec Z = H_0/\omega _0\) and

$$F_E\left( {\left| x \right\rangle ,\left| y \right\rangle } \right) = \left| {\left\langle {x|E|x} \right\rangle - \left\langle {y|E|y} \right\rangle } \right|^2 + 4\left| {\left\langle {x|E|y} \right\rangle } \right|^2.$$
(14)

Notice that Ftot is non-negative with zeros where \(P = |x\rangle \langle x| + |y\rangle \langle y|\) satisfies condition (3). In fact, solutions to Ftot = 0 with Aω,min = 0 exactly satisfy the ECQS conditions and vice versa. Relaxing these conditions slightly, one can find codes approximately satisfying (3) and (4) by using Ftot ≤ ε2 as a convergence criterion and \(A_{\omega ,{\kern 1pt} {\mathrm{min}}} \gg \varepsilon\). Note that the resulting codes can be quite general; for instance, they need not be stabilizer codes. Further details are provided in the 'Methods' section.

For a two-qubit sensor, C has a zero eigenvalue only when c12 = ±1. The c12 = 1 case has \(\vec h \in {\mathrm{col}}(C)\) and is therefore not amenable to ECQS. The c12 = −1 case, on the other hand, has \(\vec h\,\notin\,{\mathrm{col}}(C)\). Therefore, N = 2 sensing qubits under strongly anti-correlated noise (c12 ≈−1) can benefit from ECQS—in fact, they can be used for DFS-enhanced sensing. (Both c12 ≈ +1 and −1, however, could be useful for gradiometry, i.e., to measure a mean difference between the energy gap of each qubit.) For a three-qubit sensor a much broader family of C's can satisfy the ECQS conditions. Using the mapping described above, the C's for which Eq. (13) yielded codes approximately satisfying conditions (3) and (4) with no ancillas are shown in Fig. 2. Notice that DFS-enhanced sensing with N = 3 qubits is only possible for a small family C's. Therefore, while such schemes may be powerful,39,40,41,42 it could be exceedingly difficult to engineer the spatial noise correlations they require in many devices. Codes with active recoveries, in contrast, are much more broadly applicable. A scheme to measure C in experiments is given in the 'Methods' section.

Fig. 2
figure 2

Values of c12, c23, and c13 for which there exists a three-qubit code satisfying the ECQS conditions to a tolerance of ε = 10−5 and Aω,min = 10−1, and not requiring noiseless ancillas. The points (c12, c23, c13) approximately satisfying conditions (3) and (4) form a tetrahedron-like surface. The portions of the surface in blue denote C's for which ECQS is possible with an active (i.e., non-trivial) recovery. The red regions (enlarged for visibility) denote C's for which DFS-enhanced sensing is possible, and the white regions denote C's for which the optimization in Eq. (13) failed to converge to within the specified tolerance, either because the achievable signal gain is too small, or because of poor local minima in Ftot. The continuous red band comprises C's for which noise on a pair of qubits is perfectly anti-correlated (cij = −1). Notice that ECQS is generically possible for both positive and negative noise correlations; it fails here only when cij ≈ 1 for some pair of qubits (i ≠ j), since this gives a missing/subdominant jump operator orthogonal to H0

We have assumed for simplicity so far that the coupling strength of each qubit to the external field ω, parameterized by hi = 1, is the same for all qubits i. This assumption is of course not necessary; the results presented here hold (with trivial adjustments) for arbitrary values \(h_i^\prime \ne 0\) which may vary across qubits. Moreover, whether or not ECQS conditions can be satisfied depends only on the spatial profile of δω and on the locations of the qubits, not on the coupling strengths \(\vec h^\prime\). We reserve the proof for the 'Methods' section.

Discussion

We have shown how ECQS can filter noise from a signal when both couple to a sensor locally through the same operators. This stands in contrast with earlier explicit ECQS schemes, which have been limited to correcting noise separate from the quantity to be measured, in that it couples differently to the sensor. In many quantum sensors such noise is sub-dominant, while the type of noise considered here is the limiting source of decoherence, and can only be partially filtered through DD. Our scheme relies on the observation that Eqs. (3) and (4) can be viewed as a condition on the spatial correlations of the signal and noise. This view raises a close parallel between ECQS and DD: for signal and noise which couple identically to a sensor (in the sense of Eq. (5)), ECQS and DD can enhance sensitivity by acting as filters in the spatial and frequency domains, respectively. However, since these two schemes separate noise from signal on totally separate grounds, they are complementary, in that the limitations of one are not shared by the other. Finally, we proposed a numerical method of tailoring ECQS codes to the noise observed in specific devices. It yields not just codes that correct noise perfectly in the Δt → 0 limit, but also codes which can more generally improve sensitivity. We applied this method to sensors comprising two and three qubits—with no extra ancillas in the code—and showed how our error correction scheme could provide an advantage even in relatively small devices.

Both ECQS and DD filter noise which couples locally like the signal by exploiting correlations in it: spatial correlations in the case of ECQS, and temporal correlations for DD. Accordingly, the effectiveness of both schemes depends on the degree to which noise in a sensor can made to have suitable correlations. (Note that different spatial noise correlations may lend themselves best to different sensing tasks. For instance, uniform positive correlations yield a dominant noise mode proportional to H0. This makes them them ill-suited for measuring small field values through ECQS, but well-suited for gradiometry.) Engineering appropriate spatial noise correlations is likely to be highly implementation-dependent, as it is with temporal correlations.43 This is because the main sources of noise can be entirely different in different types of quantum sensors. While an analysis of achievable noise correlations in various types of sensors is beyond the scope of the present work, we note here simply that strong spatial correlations have been reported already in several experiments, e.g., refs. 39,40,44,45,46,47

The scheme presented here exploits spatial correlations to extract signal from a noisy background, which generically causes dephasing. (Of course, the signal and noise in question need not couple to the sensor via σz; in general, the qubits could be damped along any axis.) A similar approach may be possible with generalized amplitude-damping (T1-type) errors, which are second only to phase errors as the dominant decoherence mode in many quantum sensors. That is, a sensor with qubits made to thermalize collectively, rather than individually, could be amenable to quantum error correction. The approach presented here could be combined with such a scheme—or with previous ECQS schemes—raising the intriguing prospect of a quantum sensor that is error-corrected against noise in all three spatial directions. While correlated errors can often be detrimental to error-corrected quantum computation (see, e.g., ref. 48), they may prove a valuable resource for ECQS.

Methods

Proof: Equivalence of Eq. (8) and ECQS conditions

We show here that Eq. (8) is equivalent to \(H_0\,\notin\,{\cal S}\) for the background noise described in Eq. (7), where \({\cal S}\) is the Lindblad span. Let \(\{ \vec v_i\} \subset {\Bbb R}^N\) be an orthonormal eigenbasis of C such that \(C\vec v_i = \lambda _i\vec v_i\), and define \(\tilde L_i: = \vec v_i \cdot \vec Z = \tilde L_i^\dagger\) and \(L_i: = \sqrt {\lambda _i} \tilde L_i = L_i^\dagger\). Notice that \(\left\langle {\tilde L_i,I} \right\rangle = \left\langle {\tilde L_i,\tilde L_j\tilde L_\ell } \right\rangle = 0\) under \(\left\langle {A,B} \right\rangle = tr\left( {A^\dagger B} \right)\), so \({\cal S}\) can be decomposed into orthogonal subspaces as \({\cal S} = {\cal S}_1 \oplus {\cal S}_2\) where \({\cal S}_1: = {\mathrm{span}}\{ L_i\} _{i \ge 1}\) and \({\cal S}_2: = {\mathrm{span}}\left\{ {I,L_iL_j} \right\}_{i,j \ge 1}\). Having diagonalized C, we can express H0 in terms of \(\tilde L_i\) ’s (rather than \(Z_i\) ’s) as \(H_0 = \mathop {\sum}\nolimits_{i = 1}^N \alpha _i\tilde L_i\) for unique coefficients \(\alpha _i = 2^{ - N}tr\left( {\tilde L_iH_0} \right) = \frac{{\omega _0}}{2}{\kern 1pt} \vec v_i \cdot \vec h\), implying that \(H_0 \bot {\cal S}_2\). Therefore, \(H_0\,\notin\,{\cal S}\) if and only if (iff) \(H_0\,\notin\,{\cal S}_1\). This happens iff there is a k such that \(\lambda _k = L_k = 0\) and \(\alpha _k \ne 0\), or equivalently, iff \(\vec v_k \cdot \vec h \ne 0\) for some \(\vec v_k \in {\mathrm{ker}}\left( C \right)\). Finally, since \(C = C^{\rm T}\) we have \({\mathrm{col}}(C) \oplus {\mathrm{ker}}(C) = {\Bbb R}^N\), and so \(H_0\,\notin\,{\cal S}\) iff \(\vec h\,\notin\,{\mathrm{col}}(C)\).

Recovery channel

We describe here a standard way of implementing the so-called transpose recovery channel, following refs. 16,38 Given a known P such that \(PL_i^\dagger L_jP = m_{ij}P\), we have \(P\left( {L_i - m_{0i}I} \right)^\dagger \left( {L_j - m_{0j}I} \right)P = \tilde m_{ij}P\) for some Hermitian \(\tilde M = \left( {\tilde m_{ij}} \right)_{i,j \ge 1}\). Let \(W\) be a unitary matrix such that \(W^\dagger \tilde MW = {\mathrm{diag}}\left( {d_1,d_2, \ldots } \right)\), and \(E_i: = \mathop {\sum}\nolimits_j w_{ji}\left( {L_j - m_{j0}I} \right)\). For \(d_i \ne 0\) one can find a unique unitary \(U_i\) such that \(E_iP = \sqrt {d_i} U_iP\) via polar decomposition. The channel \({\cal R}\) can then be implemented by performing a projective measurement in \(\{ P_0,P_1,P_2, \ldots \}\), where \(P_i: = U_iPU_i^\dagger\) and \(P_0: = P\), then applying \(U_i^\dagger\) for outcome i, where \(U_0: = I\). (N.b., if \({\mathrm{rank}}(\tilde M) = 1\) this procedure is trivial, so the code forms a DFS.)

Numerical code search

The objective function Ftot may have several distinct zeros satisfying the constraints with Aω,min = 0; for instance, the logical states in Eqs. (10) and (12). (In other words, there can be more than one P exactly satisfying Eqs. (3) and (4).) On the other hand, it will have no such zeros when \(\vec h \in {\mathrm{col}}(C)\). More generally, for given ε, Aω,min ≥ 0 there may exist multiple regions where Ftot ≤ ε2 subject to the constraints, or there may exist none for C not amenable to ECQS with N sensing qubits.

A similar approach to finding codes was recently used in ref., 49 although to our knowledge it has not previously been used for ECQS. The factor of 4 in Eq. (14) was included specifically for the purpose of finding codes for sensing: While this factor is irrelevant for enforcing that \(E \in {\cal S}\) be corrected, a simple calculation shows that FG for a code gives exactly its signal gain squared. Therefore, requiring that \(F_G > A_{\omega ,{\mathrm{min}}}^2\) and Ftot ≤ ε2 for some \(A_{\omega ,{\kern 1pt} {\mathrm{min}}} \gg \varepsilon\) is a transparent way of demanding that quantum error correction suppress noise much more strongly than the signal.

Measuring C

In an experiment, finding an appropriate code for ECQS first requires knowledge of the noise correlations encoded in C. For qubits i and j, the coefficient cij can be inferred by preparing the GHZ state \(\frac{1}{{\sqrt 2 }}\left( {\left| {0_i} \right\rangle \left| {0_j} \right\rangle + \left| {1_i} \right\rangle \left| {1_j} \right\rangle } \right)\) and measuring its pure dephasing rate Γij, which is related to cij through \({\mathrm{\Gamma }}_{ij} = \frac{2}{{T_2}}\left( {1 + c_{ij}} \right)\), after subtracting the dephasing due to any relaxation that might also be present in practice. Note that while we arrived at Eq. (7) by considering a signal with a noisy background, the physical source of dephasing is largely immaterial; all that matters is its spatial correlation profile C.

Proof: Independence from coupling strengths

We show here that whether Eq. (8), and therefore also the ECQS conditions, is satisfied does not depend on the coupling strength of each qubit to the external field. Defining \(D = {\mathrm{diag}}(\vec h^\prime )\), the Lindblad equation for general coupling strengths \(\vec h^\prime\) has \(H_0^\prime = \frac{{\omega _0}}{2}\vec h^\prime \cdot \vec Z\) and \(C^{\prime} = DCD\). Observe that \(\vec h^\prime = D\vec h\) and \({\mathrm{ker}}\left( {C^\prime } \right) = \left\{ {D^{ - 1}\vec x{\kern 1pt} |{\kern 1pt} \vec x \in {\mathrm{ker}}\left( C \right)} \right\}\), so \(h^\prime\,\notin\,{\mathrm{col}}\left( {C^\prime } \right)\) if and only if \(\vec h\,\notin\,{\mathrm{col}}(C)\).

Code availability

The optimization in Eq. (13) was performed using the SciPy Python library (v0.17). We employed a basin-hopping global optimization algorithm, which ran a sequential least squares programming (SLSQP) local optimization at each step. The full computer code used to generate these results is available from the corresponding author upon request.

Data availability

The numerical datasets generated during and/or analysed during the current study are available from the corresponding author on reasonable request.