Introduction

Quantum metrology exploits non-classical effects to extend the sensitivity of sensing and parameter estimation methods beyond classical limits. The achievable precision in quantum metrology depends on the interplay of quantum correlations of the probe states, the unavoidable quantum noise present in the scheme, the geometry of the parameters to be estimated, and the information that is gained by possibly intricate measurements1,2. Carefully designing suitable quantum probes and measurements is therefore a frontier of quantum metrology3,4 and can lead to significantly improved sensitivity as has been demonstrated in numerous works5,6,7,8,9. Such methods have recently been generalized to a multi-parameter setting where a set of spatially distributed sensors is used to simultaneously estimate a number of distinct parameters or a function thereof10,11,12,13,14, a setting that is relevant for a broad range of applications, including nanoscale NMR15, multi-dimensional field and gradient estimation16,17, and quantum networks for atomic clocks18 or astronomical imaging19.

Designing close to optimal quantum protocols for a specific metrological task is, however, highly challenging. Identifying suitable probes and measurement schemes can be a classically intractable task even in the absence of errors. It requires optimizing over quantum states of high dimension, which soon becomes infeasible in practice due to the exponential growth of dimension with the system size. To add insult to injury, the solution of this task is even less obvious when realistic constraints such as experimental imperfections and decoherence are taken into account: Such decoherence processes, however, are at the heart of the matter when designing realistic quantum metrological protocols in the first place. This observation gives rise to the insight that in many relevant and meaningful scenarios, one cannot help but resort to quantum tools to find such protocols.

The increasing body of tools originating from the study of near-term noisy intermediate-scale quantum (NISQ) computers20 may come to the rescue here: variational quantum algorithms21 have been proposed to solve one part of the metrology puzzle—namely to optimize quantum probes for single-parameter metrology in qubit-based systems22,23,24.

In this work, we provide a toolbox that allows quantum-aided design of the entire metrology process as a whole. Our unified framework allows us to optimize quantum probes and measurements for the more general multi-parameter-sensing problems while taking into account limited experimental capabilities. The method can account for post-processing of the data, recognizing that the physical variables measured are usually only surrogates for the actual quantities of interest. The approach is sufficiently general to be executed on both discrete- and continuous-variable systems. We detail how our algorithm can be implemented on the target platform or on NISQ computers, bringing forth a promising application of these devices.

We consider the generic task of estimating a multi-variate function of the sensing parameters and use the multi-parameter Cramér-Rao bound to quantify the quality of probe state and measurement as it provides for a saturable lower bound on the quality of any unbiased estimator. Importantly, we describe how this is extracted experimentally based on an insight regarding the parameter-shift rule25 in a noisy setting, an idea that has arisen in the context of quantum optimal control26 and learning applications of quantum circuits27 and which we develop further, expected to be interesting in its own right. Due to the variational nature of our quantum algorithm—involving a quantum circuit in its core instead of a possibly inefficient classical prescription—we can tailor estimation strategies to the specific experimental capabilities and dominating noise sources. Our techniques are very general and can be applied to both discrete variable architectures based on atomic systems28,29, superconducting qubits30 or optical systems31 and continuous-variable architectures based on Gaussian light sources32,33. As such, we add quantum metrology to the possible applications of NISQ devices while at the same time providing a solution to the challenging problem of optimizing quantum metrological prescriptions.

Results

The structure of the algorithm

A high-level description of our algorithm is sketched in Fig. 1. In each step of the algorithm, a probe quantum state ρ0(θ) is generated by a quantum circuit parametrized by θ. It undergoes a quantum channel \({\mathcal{E}}({\mathbf{\phi }})\) that encodes the parameters, which are the arguments of f, the multi-variate function representing the post-processing. In this work, we will consider multiple ways to parametrize the encoding channel. The state of the system before the measurement is

$${\mathcal{E}}({\mathbf{\phi }})[{\rho }_{0}({\mathbf{\theta }})]=\rho ({\mathbf{\theta }},{\mathbf{\phi }}).$$
(1)
Fig. 1: Illustration of the Algorithm.
figure 1

Illustration of the hybrid approach presented in this work to variationally optimize the probe state and measurement for a noisy multi-parameter estimation problem. The various parameters are defined in the main text.

The subsequent measurement is most generally described by a parametrized positive-operator valued measure (POVM) \({\mathcal{M}}=\{{{{\Pi }}}_{l}({\mathbf{\mu }})\}\) resulting in measurement output probabilities

$${p}_{l}={\mathrm{Tr}}\,\{{{{\Pi }}}_{l}({\mathbf{\mu }})\rho ({\mathbf{\theta }},{\mathbf{\phi }})\},$$
(2)

with μ being the POVM parametrization. This concludes the part of the protocol that runs on the quantum device. This step is repeated a number of times to get accurate estimates of the outcome probabilities. These are then used to classically compute a cost function quantifying the estimation quality achieved by the protocol. From this, both the state preparation circuit and the measurement procedure are updated to further increase the estimation quality based on gradient-descent techniques34. The entire procedure is iterated until a minimum is reached, yielding a close to optimal sensing protocol within the variational manifold of probe state preparation and measurement procedure.

Cost function

The central challenge when constructing a variational quantum algorithm is to identify a cost function that captures the nature of the problem and that can be effectively evaluated and differentiated on actual quantum hardware. We want to quantify the performance of an estimator for a general multi-variate function f(ϕ) of the parameters ϕ. We therefore consider the classical Fisher information matrix (CFIM)35f = JTIϕJ, where J is the Jacobian of f with entries Jj,k = ∂ϕj/∂fk and

$${[{I}_{{\mathbf{\phi }}}]}_{j,k}:= \mathop{\sum}\limits_{l}\frac{({\partial }_{j}{p}_{l})({\partial }_{k}{p}_{l})}{{p}_{l}},$$
(3)

where we have used ∂j as a shorthand notation for ∂/∂ϕj. The CFIM gives a fundamental lower bound to the covariance matrix of any unbiased estimator \(\hat{{\bf{f}}}\) of f(ϕ) according to the Cramér-Rao bound

$${\mathrm{Cov}}\,[\hat{{\bf{f}}}]\ge \frac{1}{n}{I}_{{\bf{f}}}^{-1},$$
(4)

where n is the number of samples. The Cramér-Rao bound is the definite measure of estimation precision because it can always be saturated in the limit n →  by maximum-likelihood estimation36. Previous variational approaches to quantum metrology relied on surrogate quantities for the quantum Fisher information (QFI) as their cost function. The QFI provides a bound on the achievable classical Fisher information when optimizing over all possible measurement schemes and as such does not quantify the performance of the current incarnation of the sensing protocol. As experimental capabilities are usually limited and not every intricate measurement can be performed, it is actually a misleading quantifier—there is no guarantee that a state with maximum QFI also achieves the maximum CFI over the set of possible measurements.

For single-parameter estimation, the CFIM reduces to a scalar quantity and the Cramér-Rao bound can directly be used as a cost function. For the multi-variate setting, we will follow the approach of ref. 10 and apply a positive semi-definite weighting matrix W to both sides of the Cramér-Rao bound (4) and perform a trace to obtain the scalar inequality

$${\mathrm{Tr}}\,\{W{\mathrm{Cov}}\,[\hat{{\bf{f}}}]\}\ge \frac{1}{n}{\mathrm{Tr}}\,\{W{I}_{{\bf{f}}}^{-1}\}.$$
(5)

The right-hand side is the natural choice for the cost function

$${C}_{W}({\mathbf{\theta }},{\mathbf{\phi }},{\mathbf{\mu }}):= {\mathrm{Tr}}\,\{W{I}_{{\bf{f}}}^{-1}\}.$$
(6)

While the outcome probabilities {pl} can be readily estimated through repeated measurements, the CFIM also contains their derivatives with respect to the encoded parameters. These derivatives are at the heart of our algorithm and we will detail how to obtain them for multiple variants of quantum encoding processes.

We note that as the most common elementary operations considered both in the discrete variable and the Gaussian continuous-variable case admit a parameter-shift rule, we will assume that the circuits parametrizing the state preparation and the POVM in our scheme can be trained using the parameter-shift rule.

On the sensing platform

The difficulty of running the variational algorithm naturally depends on the capabilities of the quantum device available. If we have the opportunity to perform the parametrized state preparation and measurement on the sensing platform, we can use it directly to run the algorithm. This is of course desirable since it circumvents the need to simulate the encoding and noise channel on another device. To be able to execute the algorithm we have to assume some structure about the encoding evolution \({\mathcal{E}}\). We will consider the case where a unitary encoding is followed by a parameter-independent quantum channel as

$${\mathcal{E}}({\mathbf{\phi }})[{\rho }_{0}]={\mathcal{N}}[U({\mathbf{\phi }}){\rho }_{0}{U}^{\dagger }({\mathbf{\phi }})].$$
(7)

We stress that this model does not only capture noise processes happening after the parameter encoding. It is valid for all processes where the noise commutes with the encoding unitary, which covers many practically relevant scenarios such as lossy optical phase estimation, depolarizing noise in discrete variable systems, and dephasing and amplitude-damping noise in Ramsay spectroscopy23.

While initially derived for unitary quantum circuits, we prove in the Supplementary Methods that the parameter-shift rule extends to unitaries interleaved with noise channels. Consequently, all necessary derivatives of expectation values can be computed analytically on quantum hardware from the expectation values evaluated at different points in parameter space25,37 even in the presence of realistic noise as detailed above.

To apply the parameter-shift rule it will, however, be necessary to be able to re-run the same evolution with the parameter in question shifted by a fixed amount. On the sensing platform, direct control over the physical parameters is usually not possible, but we can exploit the composition of unitary evolutions to synthesize a shift of the parameter in question as shown in Fig. 2a. We give a detailed explanation of how the parameter-shift rule should be applied in the Supplementary Methods.

Fig. 2: Realizing the algorithm.
figure 2

Realization of the approach proposed in Fig. 1 for the encoding of Eq. (7). a On a sensing platform or during its emulation, the output probabilities are directly computed from the POVM measurements. The derivatives are computed using the parameter-shift rule. b When simulating on a quantum computer, the action of the noise channel is simulated by altering the POVM. The derivatives are computed by measuring the expectation values of a set of operators, used in training the network.

Emulating the sensing platform

If the necessary level of control is not achievable on the sensing platform directly, another quantum system with more control can be used to run the algorithm and optimize a sensing strategy. In particular, NISQ devices with high levels of control could be employed. We stress, however, that the inherent errors of the NISQ device need to be sufficiently low to provide for a faithful emulation of the sensing platform. The noise of the sensing platform can be recreated either through the use of ancillary qubits or repeated sampling of unitaries, an approach that we explain in detail in the Supplementary Methods.

If a noise process of the form of Eq. (7) is hard to emulate on the NISQ device, or if the parameter-shift rule cannot be implemented for the encoding process, part of the algorithm can be moved from the quantum device to the classical hardware. This can alleviate the requirements for the NISQ device for a, in many realistic cases, modest overhead on the classical computation. In the Supplementary Methods, we provide observables \({{\Pi }}^{\prime}\) and \({{{\Delta }}}_{l}^{j}\) whose expectation values model the noisy output probabilities pl and their derivatives ∂jpl. The procedure in this situation is shown in Fig. 2b.

Emulating the sensing platform also opens up the possibility to analyze more intricate encoding evolutions. The Stinespring dilation theorem38 guarantees that any quantum channel can be modeled via a unitary evolution on the system along with an environment in some state σ:

$${\mathcal{E}}({\mathbf{\phi }})[{\rho }_{0}]={{\mathrm{Tr}}\,}_{\text{E}}\{{U}_{\text{SE}}({\mathbf{\phi }})({\rho }_{0}\otimes \upsigma ){U}_{\,\text{SE}\,}^{\dagger }({\mathbf{\phi }})\}.$$
(8)

If the unitary has the particular form

$${U}_{\text{SE}}({\mathbf{\phi }})=\exp \left(-{\rm{i}}t\left[{H}_{\text{SE}}+\mathop{\sum}\limits_{j}{\upalpha }_{j}{H}_{j}\right]\right),$$
(9)

where the encoded parameters are given by ϕj = tαj, we can apply a generalized parameter-shift rule to calculate the derivative \(\frac{\partial }{\partial {\alpha }_{j}}{\mathcal{E}}({\mathbf{\phi }})\) and hence the derivative with respect to ϕj37. Finally, the Suzuki-Trotter formalism can be used to decompose the evolution into elementary quantum gates that depend on ϕ and use the parameter-shift rule for these gates to calculate the derivative.

Numerical experiments

To showcase possible applications of our variational approach, we numerically investigate two exemplary noisy estimation problems. The experiments have been implemented using the PennyLane library for quantum machine learning39 and the QuEST mixed state simulator40.

We first employ the setting of Ramsay spectroscopy, a widely used technique for quantum metrology with atoms and ions. The metrological parameters are phase shifts ϕ arising from the interaction of probe ions modeled as two-level systems with an external driving force. We follow ref. 41 and model the noise in the parameter encoding as local dephasing with dephasing probability p. We consider a pure probe state and a projective measurement, where the computational basis is parametrized by local unitaries.

We optimize a sensing strategy for a system of three ions and instead of estimating the phases independently, we analyze the task of estimating their average \(\frac{1}{N}{\sum }_{j}{\upphi }_{j}\). We first reproduce known results to validate the performance of our approach. Reference 10 has shown that generalized GHZ states are optimal when the encoding is noise-free. We have emulated the sensing task with \({\upphi }_{j}=\frac{\pi }{6}\), the sweet spot for GHZ sensing and performed co-optimization of state preparation and measurement. The parametrization was chosen so that it can produce any three qubit quantum state and any local measurement. Figure 3 shows that we recover the optimality of the GHZ-sensing procedure with a measurement in the Hadamard basis for p = 0. At increasing noise levels, the advantage of GHZ sensing disappears as expected41 and we find sensing procedures that outperform both GHZ and standard Ramsay spectroscopy. In the Supplementary Methods, we analyze the optimized sensing schemes and find that the optimal probe states continue to have non-classical correlations even for a high dephasing probabilities of up to 40%.

Fig. 3: Average phase sensing results.
figure 3

Semi-logarithmic plot of the Cramér-Rao bound for average phase sensing over the dephasing probability of (blue) the standard Ramsey probe and (orange) a GHZ probe. Each green dot marks the bound for a probe optimized for the particular dephasing probability. The phase shifts were fixed at the optimal spot for GHZ sensing at \({\upphi }_{j}=\frac{\pi }{6}\). We recover the optimality of the GHZ probe in the noiseless case and find improved sensing protocols in the noisy case.

As a second task, we will apply our algorithm to the setting of spin imaging. This is at the heart of nanoscale NMR, which has a wide range of applications within chemistry and biological imaging. In particular, nanoscale sensors based on nitrogen-vacancy (NV) centers have shown great potential15,42,43,44,45 and we will consider the task of determining the position of a spin by triangulation with three NV center probes. In short, the dipole–dipole interaction between the NV centers and the spin shifts the energy levels of the NV centers resulting in a position dependent phase shift. From measurements of this phase, the position of the spin can be determined. We neglect the dipole–dipole interaction between the three NV centers assuming that they can be decoupled by appropriate pulse sequences46. Furthermore, we perform a secular approximation, simplifying the interaction to a Pauli rotation about the symmetry axis of the NV centers47. We model the encoding noise as local dephasing with a fixed probability of pe = 0.1. We refer to the Supplementary Methods for a more detailed derivation of our model.

We use our algorithm to study the influence of noise that is incurred by performing additional quantum gates in the state preparation on the quality of the sensing protocol. We model the noise as depolarizing noise with depolarization probability pg. Specifically, we study the trade-off between additional noise induced by performing entangling operations and the sensitivity enhancement from the generated entanglement by comparing a purely local probe with a probe that has two additional entangling operations. The measurement is always kept local. The “shallow entangled” probe constitutes the minimal example of a circuit that can generate generic three-particle entanglement between the NV probes. The exact structure of the sensing protocols is detailed in the Supplementary Methods. Figure 4 shows that the shallow entangled probe yields an advantage in the absence of gate noise. But even at very small gate noise levels, the additional noise from the entangling operations will make the entangled probe inferior to the local probe. Although we only consider one specific ansatz for an entangled probe, this sheds light on the importance of gate noise in realistic probe preparations. In the Supplementary Methods, we further analyze the optimized sensing schemes and show that entanglement causes the advantage in the noiseless case and is still present in the optimized probes at small noise levels (1%). However, the probes quickly become separable as the gate noise is increased.

Fig. 4: NV trilateration results.
figure 4

Semi-logarithmic plot of the weighted Cramér-Rao bound for NV trilateration over the gate depolarization probability of (blue) local probes and (orange) shallow entangled probes. Each dot marks the bound for a probe optimized for the particular gate depolarization probability. The measurement is always local. The inset shows the positions of the NV centers and the target spin used in the experiment. The entangling operations only yield an advantage for vanishing gate noise.

Discussion

In this work, we have introduced a variational approach that can be applied to a wide variety of metrological problems to optimize multi-parameter estimation schemes both on sensing platforms and on quantum devices. These approaches can be tailored to specifically match the available hardware and the sensing problem in question. Instead of addressing the challenges of noisy quantum metrology by classically computing optimal probes and measurements, we have shown how to learn variational parameters of a quantum circuit for this purpose. The proposed machinery can also be used to improve upon an already good guess. The variational nature of our approach naturally causes a dependence of the quality of the optimized protocol on the choice of parametrization and optimization method. It is therefore complementary to analytic approaches that broaden our understanding of optimal sensing schemes in realistic scenarios which in turn can inform good choices for the parametrization of probes and measurements.

While the approach outlined in the main text is widely applicable, covering arbitrary noise models and post-processing functions, it still does not cover all possible metrological tasks. In the Supplementary Methods, we therefore present extensions of our algorithm that take into account prior knowledge about the underlying parameters, handle mutual time dependence of unitary evolution and noise, and outline how we can benchmark our results against the ultimately attainable precision given by the quantum Cramér-Rao bound. The results about parameter-shift rules for quantum channels furthermore allow the extension of our method to the metrology of error channel parameters. We hope that the present work contributes to a shift in mindset—somewhat reminiscent of the idea of quantum computer-aided design of physical platforms48—so that not all sensing protocols have to be designed classically, but that one can make use of quantum technologies themselves to actually learn improved quantum protocols.