Hybrid quantum-classical approach to enhanced quantum metrology

Quantum metrology plays a fundamental role in many scientific areas. However, the complexity of engineering entangled probes and the external noise raise technological barriers for realizing the expected precision of the to-be-estimated parameter with given resources. Here, we address this problem by introducing adjustable controls into the encoding process and then utilizing a hybrid quantum-classical approach to automatically optimize the controls online. Our scheme does not require any complex or intractable off-line design, and it can inherently correct certain unitary errors during the learning procedure. We also report the first experimental demonstration of this promising scheme for the task of finding optimal probes for frequency estimation on a nuclear magnetic resonance (NMR) processor. The proposed scheme paves the way to experimentally auto-search optimal protocol for improving the metrology precision.

Hybrid quantum-classical approach to enhanced quantum metrology Xiaodong Yang 1,9 , Xi Chen 1,2,9 , Jun Li 3,4* , Xinhua Peng 1,5,6* & Raymond Laflamme 2,7,8 Quantum metrology plays a fundamental role in many scientific areas. However, the complexity of engineering entangled probes and the external noise raise technological barriers for realizing the expected precision of the to-be-estimated parameter with given resources. Here, we address this problem by introducing adjustable controls into the encoding process and then utilizing a hybrid quantum-classical approach to automatically optimize the controls online. Our scheme does not require any complex or intractable off-line design, and it can inherently correct certain unitary errors during the learning procedure. We also report the first experimental demonstration of this promising scheme for the task of finding optimal probes for frequency estimation on a nuclear magnetic resonance (NMR) processor. The proposed scheme paves the way to experimentally auto-search optimal protocol for improving the metrology precision.
Measuring physical parameters of interest with highest precision remains the everlasting pursuit in science and technology 1 . The general measurement procedure reads: prepare a probe, interact it with the system, and measure the probe. During this process, errors will result in a statistical uncertainty on the interested parameter φ . These errors mainly come from intrinsic fluctuations, insufficient controls and external perturbations [2][3][4] . The central limit theorem tells us that repeated applications of this process N times can improve the estimation precision, inducing a bound of �φ ∼ 1/ √ N , which is called Standard Quantum Limit. Quantum metrology 1,5-7 exploits available quantum resources to beat this limit and can approach a scaling called Heisenberg Limit, namely �φ ∼ 1/N . However, in practical applications, realizing the expected precision under many cases, including inevitable external noise [8][9][10] , complex probe states [11][12][13][14][15][16] and complicated encoding dynamics [17][18][19][20] , are often very challenging.
Fortunately, additional controls were found to be useful and necessary for quantum metrology to address these issues 21 . Dynamical decoupling methods [22][23][24] and quantum error corrections 25,26 were used specifically to defend against certain external noise for maintaining the precision. For extended types of encoding dynamics, including time-dependent 21 , noncommuting 27 , or general form 28 , carefully designed controls were applied to alter the dynamics and enhance the estimation precision. The above mentioned control methods are for specific purposes and are often very complex to design. Recently, Yuan and Liu 29 proposed a systematic controlled sequential scheme to search the required controls in noisy system for enhancing the quantum metrology abilities. It is based on an optimal control algorithm called Gradient Ascent Pulse Engineering (GRAPE), where the added controls could be iteratively refreshed until the performance function (e.g., quantum Fisher information 1,7 ) reaches the optimum. This algorithm is very efficient and easily-implemented for small-scale systems. However, in actual applications, it often happens that an exact model of the noise is lacking so that it is difficult to evaluate the gradient of the performance function to a good precision, even for the single-qubit case. These problems are further harmed by the exponentially increased complexity of the system dynamics.
To tackle these issues, we utilize a hybrid quantum-classical approach 30,31 assisted GRAPE (hqc-GRAPE for short) to practically learn the optimal controls experimentally. Under a completely different motivation, the previous works concern how to speedup quantum optimal control problems, while here we seek for its extension www.nature.com/scientificreports/ to quantum metrology area. Hybrid quantum-classical (HQC) algorithms, which combine the present-day accessible quantum resources with sophisticated classical computation routines, have witnessed tremendous successful applications, ranging from simulating quantum chemistry [32][33][34][35] to solving optimization problems 30,31,36,37 . By applying this approach, we do not require any prior-knowledge of how the optimal controls are related to the encoding dynamics, as they are automatically learned in the experiments without any design. These searched controls and the encoding dynamics are then coupled together to deliver an optimal metrology procedure. The computationally resource-consuming and experimentally intractable parts of the GRAPE algorithm, namely the gradient of the performance function, are efficiently and conveniently measured by applying some single-qubit rotations to the system. Furthermore, as this HQC approach is combined with GRAPE to deliver a closed-loop learning 38 procedure, it has inherent features of defending against certain kinds of unitary noise for improving the metrology precision. We also presented a demonstrative experiment of finding optimal probes for estimating the frequency by hqc-GRAPE on a two-qubit NMR processor. The experimental results verify the success of hqc-GRAPE in learning optimal controls for improving the metrology precision. The outline of this study is described as follows. Firstly, we introduce the details of hqc-GRAPE for quantum metrology in "Framework" section. The experimental procedure is presented in "Experiment" section. Finally, we provide some conclusions and discussions in "Discussion" section.

Results
Framework. Consider a typical quantum metrology task of estimating an interested parameter which is encoded in a general form of Hamiltonian H 0 (�) (with couplings between system qubits). Conventional quantum metrology schemes then proceed to design optimal probe state and the corresponding optimal measurements to gain the best metrology precision. In particular, the metrology can be thought of as two distinct tasks: (1) Find a classical procedure that enables us to engineer the probe state whose quantum Fisher information is sufficiently optimal. (2) Application of the encoding process to an optimal probe (synthesized using the above procedure), then estimate the interested parameter with suitable measurements. Here, we mainly focus on the first task. In practice, inevitable noise and the complexity of synthesizing the probes will prevent us from realizing the best precision. As stated in the introduction part, additional controls can be applied to address these problems and improve the precision that can be reached.
Here, we implement adjustable controls to alter the encoding dynamics, thus the total Hamiltonian can be expressed as where u k (t)(t ∈ (0, T)) represents the amplitude of the k-th control field. Note that H 0 (�) contains the interactions between qubits, thus the above total Hamiltonian captures a general form for the metrology application. Without loss of generality, we assume the k-th control Hamiltonian can be formulated as H k = σ k α with σ k α (α = x, y, z) being the Pauli matrix, i.e., the controls are at most three directions for each qubit, which is a standard form in many quantum systems [39][40][41] . To optimize these controls by hqc-GRAPE, we divide the total evolution time T into M equal segments, and the controls in each segment of duration �t = T/M are approximately treated as constants. Thus, in the m-th segment, the sliced evolution operator can be depicted by this will lead to the total evolution operator ε � (T) = M m=1 ε m � . The metrology process using hqc-GRAPE begins with some easily prepared pure probe state ρ 0 , which does not need to be optimal. This avoids the complex design and synthesis of the optimal probes, thus greatly easing the analytical efforts. The probe ρ 0 is then engineered by the system evolution with some trial control fields u = (u k [m]), k = 1, 2, ..., K; m = 1, 2, ..., M , leading to the final system state ρ � (T) = ε � (T)ρ 0 ε � (T) † . Performing the corresponding optimal measurements will induce the best metrology precision that can be reached in this situation. Here, to quantify the performance of estimating the interested parameter x, we can use the quantum Fisher information ( F Q for short) as a performance function 42,43 , namely In order to achieve the possibly best precision with the given resources, we need to iteratively refresh the control fields to maximize the performance function F Q . In hqc-GRAPE, the control fields are updated by moving towards the gradient direction of the performance function with some appropriate distance. The explicit form of the gradient of F Q , i.e., , can be easily calculated as follows The key idea of hqc-GRAPE is that we can compute this commutator by some local rotations 30 . It is achieved by using the relation which holds for any operator ρ where R k α (±π/2) represents the ±π/2 rotations along α axis. Thus, we can get In this way, by inserting local rotations, we can obtain the m-th gradient information similarly as presented in Eq. 3, i.e., directly measuring the F Q of the final system state involving the inserted local rotations. Note that this transformation does not depend on how we measure the F Q . Thus, 2KM operations are needed to compute the gradient g in each iteration.
Overall, one needs 2KM + 1 measurements of the performance function in each iteration. In general, K scales polynomially with the increasing of qubits, as the control Hamiltonians H k are single Pauli matrixes along at most three directions for each qubit. Typically, M increases polynomially with the growing of system size. Indeed, for most randomly selected Hamiltonian H , the minimal number of the controls required to synthesize it will scale exponentially. However, near-term quantum metrology applications are likely concerned with what can be done with a polynomial number of gate operations. This corresponds to optimizing over the best possible probes that can be synthesized with a polynomial number of control slices -which is precisely the problem our protocol is ideally suited for. Thus, for the practicality of our protocol, the key issue becomes how to efficiently measure the performance function, i.e., F Q . Fortunately, there have emerged several scalable methods to estimate F Q in experiment, where they have replaced F Q with some easily accessible quantities, such as (1) purity loss 44,45 . F Q is bounded by purity loss, which captures how fragile the purity of the resultant state with respect to stochastic noise on the encoding parameter and can be obtained by simulating a finite stochastic noise regardless of the system size.
(2) multiple-quantum coherence (MQC) 46 . By appending reversion of the system dynamics, MQC can be efficiently accessed and used to calculate F Q in an experiment. This procedure takes finite runs of experiments for Fourier transformation of the measured signal, thus does not need exponential resource. (3) Loschmidt echo 47 . This method is similar as method (2) but needs added controlled operations and an ancillary qubit. However, it carries a great advantage of readout from a single ancillary qubit. In real experiment, it is advisable to choose the suitable method in consideration of the experimental resource needed.
We proceed by briefly summarizing the algorithmic procedure of hqc-GRAPE (see schematic diagram in Fig. 1) for solving this metrology task: Step 1: Randomly generate initial control field u 0 , then apply it to some easily prepared probe state ρ 0 . The system state will evolve under this control together with the encoding dynamics governed by H 0 . Measure the performance function F 0 Q (u 0 ) and the corresponding gradient g 0 = ∇F 0 Q (u 0 ) = (g 0 k [m]), k = 1, 2, ..., K; m = 1, 2, ..., M.
Step 2: Set the iteration number as l = l + 1 , calculate the updated controls by u l+1 = u l + l g l ,where l is some appropriate stepsize along the gradient direction and g l = ∇F l Q (u l ) = (g l k [m]) . Measure the performance function F l+1 Q and the gradient g l+1 again.
Step 3: Check whether the measured performance function satisfies the stopping criterion, if not, go to Step 2.

Classical Computer
Find a suitable stepsize l Compute new controls yes no Figure 1. Schematic diagram of hybrid quantum-classical approach assisted GRAPE (hqc-GRAPE) for quantum metrology. From easily prepared state ρ 0 , initial controls u 0 is imported into the encoding process, resulting in ε � (T) over an encoding time T. The resultant state ρ � (T) is then measured to obtain the quantum Fisher information F l Q (u l ) and its gradient ∇F l Q (u l ) in l-th iteration. Afterwards, a suitable stepsize l is determined to generate new controls by u l+1 = u l + l ∇F l Q (u l ) , which are imported into the encoding process for the next iteration l + 1 . This procedure is looped until the stopping criterion is met. Here, the quantum sensor is combined with the classical computer to deliver a practical hybrid approach for quantum metrology. www.nature.com/scientificreports/ In this closed-loop learning procedure, the resource-consuming parts, i.e., the computing of F Q and its gradient ∇F Q , are efficiently accomplished by the quantum system. The classical computer is used to determine the suitable stepsize for updating controls fields, to generate the pulses for single-qubit rotations, and to store the data in each iteration. The resources needed for the classical computer are then very moderate, even for very large quantum systems. Therefore, the cooperated scheme of quantum sensor and classical computer is very applicable for the near-term quantum metrology tasks with accessible resources.

Experiment. Setup and techniques.
The proof-of-principle experiments were conducted using the 13 C-labeled sample Chloroform on a Bruker Avance III 400 MHz spectrometer at room temperature. We mark the spins 13 C , 1 H as 1 and 2, respectively. The internal Hamiltonian can be described as H int = 2 i=1 � i σ i z /2 + πJσ 1 z σ 2 z /2 , where i represents the offset of the i-th spin in the rotating frame and J = 214.5 Hz is the scalar coupling strength between the two spins.
For brevity, we set 1 = 2 = and consider estimating the single parameter encoded in the following Hamiltonian H 0 (�) = �(σ 1 z + σ 2 z )/2 + πJσ 1 z σ 2 z /2 . Additional control fields are introduced along x and y directions of each spin, thus leading to H = H 0 (�) + 2 k=1 u k,x [m]σ k x + u k,y [m]σ k y . For an encoding time T, the to-be-optimized control fields are sliced into M segments with u = (u k,x [m], u k,y [m]) , where k = 1, 2; m = 1, 2, ..., M . In this simple case, we do not need to seek for advanced methods as mentioned above to estimate F Q . Specifically, the quantum Fisher information of the resultant state ρ � (T) corresponding to the controls u can be explicitly written as Note that the trace operations only concern the diagonal elements, and the Pauli matrix σ k z is diagonal, thus only the diagonal elements of ρ � (T) matter. Direct derivation indicates that only two diagonal elements of ρ � (T) are needed to compute F Q (u) , which greatly reduces the experimental cost. Similarly, the gradient of F Q (u) reduces to and α = x, y , where ρ ′ (T) is obtained by applying local rotations on the k-th spin during the m-th sliced controls.
Experimental procedures and results. The detailed experimental procedure of hqc-GRAPE can be divided into the following five steps: (i) Preparation of initial state ρ 0 . We initialized the system at pseudo-pure (PPS) state by line-selective method 48 , i.e., ρ pps = 1−ε 4 I 4 + ε|00��00| , where I 4 represents the 4 × 4 identity matrix and ε ≈ 10 −5 is the thermal polarization of the two-qubit system. Notice that the identity matrix doesn't produce observable effects, thus the initial PPS state effectively behaves like ρ th 0 = |00��00| . Full tomography 49 verified that the prepared initial state ρ 0 has a fidelity of 0.9986 compared with ρ th 0 by defining (iii) Measurement of F l Q (u l ) and g l . In the l-th iteration, we first measured the performance of the resultant state ρ � (T) corresponding to u l , namely F l Q (u l ) . As stated above, only two diagonal elements of ρ � (T) are needed to compute its quantum Fisher information. In our NMR simulator, this was accomplished by applying two local π/2 rotations along y axis on spin 1 and 2, respectively, and observing the corresponding spectra 49 . To obtain g l = (g l k,x [m], g l k,y [m]) , after the m-th sliced evolution operator, we inserted two groups of local rotations R k x (±π/2) and R k y (±π/2) sequentially and measured the resultant state ρ ′ (T) = ∂ρ � (T)/∂u k,α [m], α = x, y according to Eq. 4 and Eq. 6. Similarly, only diagonal elements of ρ ′ (T) are necessary to compute g l . (iv) Generation of new controls u l+1 . The measured F l Q (u l ) and g l were then fed back to the classical computer. A suitable stepsize l was decided to generate new controls by u l+1 = u l + l g l . Here, l was initially set as 5000 and gradually decreased by 50% if F l Q (u l+1 ) was worse than F l Q (u l ). (v) Loop of the optimization procedure. The iteration number was set as l = l + 1 and the refreshed controls u l+1 were applied to the NMR simulator again. We then jumped to step (iii) to loop the rest steps. This iterative procedure was stopped until the settled maximum iteration number 10 was hit.
Furthermore, in order to demonstrate the advantages of hqc-GRAPE in searching optimal protocol for quantum metrology in realistic experiments, we compared it with the conventional open-loop designs entirely running on classical computer, which we marked as GRAPE. This pure classical simulation iteratively calculates F l Q (u l ) and g l according to the ideal Hamiltonian, which does not include the effects of the inevitable noises in real situation, thus deserves the above mentioned closed-loop optimization. We also directly applied the classically searched controls by GRAPE to the NMR quantum simulator to measure the corresponding F Q in each iteration, which was denoted as GRAPE-exp. Specifically, we first prepare the system at its initial state ρ 0 as described in the step (i). Next for each iteration l, we directly import the corresponding optimal controls searched by the open-loop GRAPE into the quantum simulator. Finally we measure its performance function as introduced in the step (iii).
The experimental results are shown in Fig. 2. Green dashed line in Fig. 2a shows the optimization process entirely running on classical computer by the GRAPE method. The searched optimal controls induce a final F Q of 4.00, which saturates the theoretical bound 7  www.nature.com/scientificreports/ directly applying the controls searched by the open-loop GRAPE to the NMR simulator. The final optimal controls are tested 5 times to estimate the statistical error resulting in F Q = 3.8798 ± 0.0006 for GRAPE-exp. The deviation from the theoretical optimum attributes to various noise and errors existing in the control process. Red solid line then presents the optimization process of hqc-GRAPE, the final F Q corresponding to the learned optimal controls is 3.9102 ± 0.0007 over 5 tests. This indicates that in the metrology process, hqc-GRAPE method automatically corrected some forms of errors, thus reaching a higher F Q than that of the open-loop designs. We also reconstructed the final optimal resultant state ρ � (T) , as shown in Fig. 2b for GRAPE-exp, and Fig. 2c for hqc-GRAPE. Compared them with the theoretical optimal NOON state ρ t = |ψ t ��ψ t | , |ψ t � = (|00� + e iφ |11�)/ √ 2 7 , we obtained a fidelity of 0.9954 ± 0.0002 for GRAPE-exp and 0.9962 ± 0.0001 for hqc-GRAPE by defining F(ρ t , ρ � (T)) = Tr(ρ t ρ � (T))/ Tr[(ρ t ) 2 ]Tr[(ρ � (T) 2 ] . This reveals that hqc-GRAPE can reach a state closer to the theoretical optimum than GRAPE-exp does. Moreover, we plot the initial controls (0-th iteration) and the final optimal controls (10-th iteration) searched by GRAPE and hqc-GRAPE in Fig. 2d,e, respectively. These two approaches started from the same initial controls, but terminated with slightly different control amplitudes, which leads to their distinct performances.

Analysis of the benefits of hqc-GRAPE.
As demonstrated above, the final optimal controls searched by hqc-GRAPE induce a higher quantum Fisher information F Q than GRAEP-exp did. The benefits come from the inherent features of closed-loop learning, which can automatically correct some specific unitary errors 38 . To explicitly understand how hqc-GRAPE improve the estimation precision, we now proceed to carefully analyze the existing errors in our experiments. In general, they can be divided into the following four types: Initial state imperfection. It refers to the deviation of experimentally prepared initial state and the desired one. From the experimentally reconstructed initial state ρ 0 , we applied optimal controls searched by GRAPE, leading to the resultant state shown in Fig. 3b (the ideal resultant state is depicted in Fig. 3a). We then performed ideal measurements and got F Q = 3.9573 . This indicates that initial state imperfection yields an error of 0.0427 from the theoretical optimal value. Actually, as the prepared ρ 0 is not a perfect pure state, the non-unitary parts under the controls and the encoding process will finally induce the errors on estimating F Q . In addition, the spectrum of the prepared initial state is directly treated as the reference signal for characterizing F Q . Thus, this kind of error will eventually cause non-unitary effects that can not be corrected in the closed-loop learning process.
Decoherence. Normally, the effects of decoherence in NMR simulator can be described by phase damping channel ε PD and generalized amplitude damping channel ε GAD 50 . In each sliced evolution process, phase damping error www.nature.com/scientificreports/ with η i = 1 − e −�t/T i 1 , p ≈ 1/2 and T 1 1 = 18.5 s, T 2 1 = 9.9 s . With perfect initial state, optimal pulses searched by GRAPE and ideal measurements, the decoherence then induces an error of 0.0370, as shown in Fig. 3c. It's worth noting that the coherent controls may partially ease the decoherence 24 . However, the analysis above has taken the effects of the coherent controls into consideration, thus the remaining error can not be corrected.
Pulse error. To estimate the influence of pulse errors on F Q , we assume that the amplitude of the controls undergoes uniformly distributed stochastic fluctuation with at most 5% distortions. With perfect initial state and ideal measurements, we repeated the optimal controls with fluctuations 1000 times and got an error around 0.0038.
Measurement error. Measurement errors can be estimated from the stochastic fluctuations of NMR spectra. In our experiments, measurements are accomplished by observing the NMR spectra and fitting them with Lorentzian functions. A direct estimation of the measurement error of resultant state was at the level of 10 −4 , which becomes 10 −6 when considering its F Q using error propagation. Reasonably, this type of error can be ignored.
To conclude, initial state imperfection, decoherence and pulse error are three major errors in our experiments. However, as analyzed above, the initial state imperfection here will cause non-unitary effects and the error of decoherence here is the part that controls can not handle. That is to say, the employed coherent controls are not able to further deal with these two errors. Thus when we compensate the loss of these two errors on F Q , the performance of hqc-GRAPE is remarkably improved to 3.9899, which is near the optimal value, as shown in Fig. 3d. For the results of GRAPE-exp after error compensation, there is still a visible gap with respect to the optimal value, see Fig. 3d. These results indicate that hqc-GRAPE can intelligently correct pulse error and some other unknown unitary errors to improve the metrology precision.

Conclusion
For quantum metrology, additional controls are helpful for dealing with the challenges of external noise, complicated designs and manipulation of probes and encoding dynamics. Though this area has attracted much attention recently, practical schemes are still urgently in demand 45 . In this study, we proposed a hybrid quantum-classical approach assisted GRAPE to automatically engineer the encoding dynamics for searching optimal probes to improve the metrology precision. The quantum simulator, which can efficiently simulate the time-consuming www.nature.com/scientificreports/ part of the GRAPE algorithm, is combined with the classical computer to iteratively optimize the controls. In our scheme, there is no need to start from optimal probes, the controls can transform arbitrary pure initial probe to the best resultant state during the learning process without any prior designs. Furthermore, many specific unitary errors can be inherently corrected by this closed-loop learning procedure, which indeed improve the metrology precision. The accompanied experiments successfully verified the effectiveness and advantages of hqc-GRAPE.
The demonstrative experiments were implemented on a small-scale NMR quantum simulator, however, the proposed scheme is scalable and feasible for current NISQ 51 systems. Cooperated with many efficient methods of estimating quantum Fisher information in experiments 44,46,47 , the proposed scheme is promising in realizing optimal quantum metrology with auto-design techniques for more complicated and large-sized applications.

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