Variational-State Quantum Metrology

Quantum technologies exploit entanglement to enhance various tasks beyond their classical limits including computation, communication and measurements. Quantum metrology aims to increase the precision of a measured quantity that is estimated in the presence of statistical errors using entangled quantum states. We present a novel approach for finding (near) optimal states for metrology in the prescence of noise, using variational techniques as a tool for efficiently searching the classically intractable high-dimensional space of quantum states. We comprehensively explore systems consisting of up to 8 qubits and find new highly entangled states that are not symmetric under permutations and non-trivially outperform previously known states up to a constant factor 2. We consider a range of environmental noise models; while passive quantum states cannot achieve a fundamentally superior scaling (as established by prior asymptotic results) we do observe a significant absolute quantum advantage. We finally outline a possible experimental setup for variational quantum metrology which can be implemented in near-term hardware.


I. INTRODUCTION
Variational quantum algorithms (VQAs) are potentially powerful for solving various problems using nearterm quantum computers [1][2][3][4][5][6]. These techniques can be implemented on shallow-depth quantum circuits that depend on external parameters and these parameters are typically optimised externally by a classical computer. Variational quantum algorithms are expected to be the first applications of the quantum computers that could potentially outperform the best classical computers in some useful tasks.
The Hilbert-space dimension of the underlying quantum state increases exponentially in the number of qubits, while variational quantum circuits by construction depend only on a linear or polynomial number of parameters. This advantageous scaling allows one to tackle classically intractable problems. The general concept of the VQAs is to prepare a parametrised quantum state using a quantum processor and to vary its parameters externally until a suitable cost function is optimised. This cost function can be tailored to the particular problem. For example, one can search for the ground state of a molecule by setting the cost function to be the expectation value of the corresponding molecular Hamiltonian. This technique is usually referred to as the variational quantum eigensolver (VQE) [1][2][3][4]. Quantum machine learning is another area where variational techniques may be valuable. One is then interested in optimising a cost function that quantifies how similar the output of the quantum circuit is to a fixed dataset [7]. Moreover, it is also possible to recompile a quantum circuit into another by optimising a metric on related quantum states [8,9].
On the other hand, the aim of quantum metrology is to enhance the precision of a measurement process in the presence of statistical errors using quantum states [10][11][12][13]. Sensing magnetic fields with high precision is crucial in many applications, such as determining chemical structure [14] or imaging living cells [15]. Various different types of high-performance magnetic field sensors have been developed, including hall-effect sensors [16], superconducting quantum interference devices (SQUID) [17] and force sensors [18]. In a qubit-based magnetic field sensor, the qubit system interacts with the magnetic field and the information about the magnetic field is encoded as a relative phase of the quantum state. This information can then be extracted via a Ramsey-type measurement [19][20][21] that relies on projective measurements. These experiments need to be iterated a number of times in order to decrease the effect of statistical errors.
In particular, if the probe state used in a metrology experiment is an unentangled qubit state, the estimation error of the external magnetic field (after a given number ν of fixed-duration field sampling experiments) is proportional to ν −1/2 , the so-called standard quantum limit (SQL) [10][11][12][13]. This scaling can potentially be enhanced by using certain entangled states such as GHZ states, symmetric Dicke states or squeezed states. Although these entangled states offer a scaling of the estimation error beyond the standard quantum limit ν −c with 1/2 ≤ c ≤ 1, they are also sensitive to noise, refer to Fig. 1. In particular, it is well known that in the presence of uncorrelated Markovian dephasing, the scaling achieved with a GHZ state is only the standard quantum limit [22]. It is our aim in the current work to derive quantum states that are robust to environmental noise but also sensitive to the external field of interest. It is known from prior studies that quantum states subject to noise do not offer an improved fundamental scaling [11,[23][24][25] unless they are actively corrected during the environmental interaction [26][27][28][29][30][31]. Nevertheless optimisations of particular probe states show that a significant arXiv:1908.08904v1 [quant-ph] 23  to an external magnetic field, but their coherences rapidly deteriorate due to fluctuations of the external field (as can be inferred from the rapidly fading coherences in their Winger functions). Our aim in the current work is to finding states (lower) that are optimally sensitive to the external field while being robust against noise using variational techniques. These optimal states are not necessarily permutation symmetric (refer to Sec. V B). Red and green colours show positive and negative values of the function while brightness represents the absolute value of the function relative to its global maximum η.
improvement as a constant absolute factor [11,22,32] can be gained, even without active error correction. We use variational qauntum algorithms to optimise parametrised probe states via a cost function that quantifies the usefulness of a quantum state for metrology, i.e., precision of estimating the external field (refer to Sec. III). In particular, a trial wave function is generated with a variational quantum circuit, and subsequently its interaction with the target magnetic field is simulated along with the simultaneous effect of decoherence via environmental noise. Finally the output state is measured to estimate the relevant cost function and this procedure is repeated until the the optimal quantum state is found that reaches the highest sensitivity under a given noise model.
We comprehensively explore systems consisting of up to 8 qubits and numerically simulate experiments under various different error models in Sec IV. We find families of quantum states that non-trivially outperform previously known states. To our best knowledge, states reported so far in the context of quantum metrology are permutation symmetric, e.g., GHZ, squeezed or symmetric Dicke states [11,13]. We find that relaxing permutation symmetry offers an improved sensitivity beyond symmetric states.
This manuscript is organised in the follwing way. We begin by briefly reviewing the key notions for quantum metrology in Sec. II. We then introduce the main idea of using variational algorithms for quantum metrology in Sec. III and numerical simulations of these algorithms are outlined in Sec. IV. Our main results on finding errorrobust quantum states are contained in Sec. V. We finally outline an experimental realisation of our algorithm that could potentially be implemented on near-term hardware.

II. PRECISION IN QAUNTUM METROLOGY
We briefly recall basic notions used in quantum metrology in this section. We refer to reviews as, e.g., [11,12], for more details.
Assume that the task is, e.g., to measure an external magnetic field by using an initially prepared probe state |ψ of N qubits. In this case the Hamiltonian in units of = 1 is proportional to the collective angular momentum component J z as is the Pauli Z operator acting on qubit k, and ω is the field strength to be probed. If there are no imperfections, the time evolution of an initially prepared probe state is described by the unitary operator U (ωt) = exp(−itωJ z ) that generates a global rotation of all qubits. One can subsequently preform projective measurements on identically prepared copies of |ψ(ωt) := U (ωt)|ψ and results of these measurements can be used to estimate the parameter ω. Note that if we take into account the effect of noise on the system during the evolution period, the state to be measured is described by a density matrix ρ ω .
Let us assume that the measurement is described simply by an observable O which decomposes into the projectors with d = 2 N and the result of several repeated measurements performed on identical copies of the probes state are the probabilities p(n|ω) := Tr[ρ ω |n n|] [33]. These probabilities can be used to estimate the value of ω using, e.g., a maximum likelihood estimator [11][12][13]. The likelihood function tends to a Gaussian distribution [11][12][13] for an increasing number of independent measurements ν that is centred at the true value ω and its inverse variance σ −2 is given by the classical Fisher information νF c (O), which we will refer to as the precision. In general, the estimation error ∆ω of the parameter ω is bounded by the so-called Cramér-Rao bound where F c (O) is the classical Fisher information of the probability distribution p(n|ω) that corresponds to eigenstates of the observable O from Eq. (1) and ν is the number of independent measurements. The explicit form of the classical Fisher information can be specified in terms of the measurement probabilities as The best possible estimation error using a fixed probe state can be obtained by maximising Eq. 2 over all possible generalised measurements [11-13, 34, 35] which leads to the so-called quantum Cramér-Rao bound where F Q (ρ ω )] is the so-called quantum Fisher information of the state ρ ω [11-13, 34, 35]. This quantum Fisher information is defined for an arbitrary state ρ ω via the expectation value F Q (ρ ω ) := Tr[ρ ω L 2 ] of the Hermitian symmetric logarithmic derivative L that satisfies This symmetric logarithmic derivative can be obtained for a density matrix by first decomposing it into ρ ω = k p k |ψ k ψ k | projectors onto its eigenstates |ψ k with p k > 0. Matrix elements of the symmetric logarithmic derivative can then be obtained explicitly [36] L ij := ψ i |L|ψ j = 2 This formula simplifies for a unitary evolution as the derivative ∂ρ ω /(∂ω) reduces to the commutator i[ρ ω , H] Its calculation is more involved in case if the evolution is not unitary [36]. Besides calculating the quantum Fisher information, the symmetric logarithmic derivative is also useful for determining the optimal measurement basis. In particular, preforming measurements in the eigenbasis of L saturates the quantum Cramér-Rao bound [11,34]. The statistical fidelity between two density matrices [37] is also related to the quantum Fisher information and offers a more convenient way to numerically calculating it. Assume two density matrices ρ(ω) and ρ(ω + δ ω ) undergo the same noise process but one is exposed to an external field ω while the other is exposed to ω + δ ω . The quantum Fisher information in this case [11] is recovered in the limit δ ω → 0. Although the error term is linear O(δ ω ), it is a very good approximation in practice, i.e, its prefactor is negligible. We will use this formula in later sections for calculating the precision limit of a fixed probe state.

III. VARIATIONAL STATE PREPARATION FOR METROLOGY
We consider a hypothetical device that is depicted in Fig. 2 and can initialise a system of N qubits in the computational 0 state. Then its parametrised encoder circuit creates a probe state that is exposed to the external field whose parameter ω is estimated. The resulting state is finally analysed to obtain an estimate of ω. We are interested in reaching the best sensitivity with respect to the external field when variationally exploring states via the encoder circuit. In particular, the encoder circuit needs to be able to initialise N qubits in a probe state |ψ(θ) that is (near) optimal for sensing the external field under noise and experimental imperfections.
We assume that the encoder circuit is unitary, i.e., contains negligable noise, and acts as |ψ(θ) := U E (θ)|ψ 0 on the computational 0 state |ψ 0 := |0 . . . 00 . The resulting state is then exposed to the environment. This process is characterised by a mapping Φ ωt (·) of density matrices that models the evolution under both the external field and under a non-unitary noise process, and depends on both time t and the parameter ω. We assume that this process is continuous in time. Adapting results on infinitely divisible channels [38,39], we define the explicit action of this process on any density matrix ρ as Encoder

UE(θ)
Sensing with noise Circuit that potentially finds the quantum state ψ(θ) that gives the best precision when estimating the parameter the external field strength ω.
where ωJ z is the superoperator representation of the external field Hamiltonian ωJ z := ω N k=1 σ (k) z /2 which generates unitary dynamics J z ρ := [J z , ρ] and the parameter ω is to be estimated. The superopertor L generates non-unitary dynamics via a completely positive trace preserving map between density operators and γ is the decay rate of the error model. Note that this form is very general and independent of the particular choice of the noise model (as long as the process is continuous), and goes beyond previous investigations on quantum metrology [32,40,41] using noise models that commute with the external field evolution.
After exposing |ψ(θ) to the field, we denote its mixed state by the density matrix ρ(ωt, θ). This state contains information about the external field, whose information is deteriorated by noise during the evolution time t. The information about the evolution can be read out during the analysis period. By repeating the experiment ν times, the estimation precision of the parameter ω can be increased. This precision depends on the amount of information about ω contained in the state ρ(ωt, θ) and can be quantified using the quantum Fisher information.
Our aim is to maximising the information about the external field ω while minimising the effect of noise. This will result in states |ψ(θ) that are optimally sensitive to the external field while being robust to noise. In particular, we aim to maximising the estimation precision that is related to the quantum Fisher information of the state ρ(ωt, θ) by simultaneously varying the encoder parameters θ and the exposure time t that the probe state spends in the noisy environment. We numerically simulate this procedure in Sec. IV and obtain (near) optimal states for metrology using the estimation precision of ω as a target function while details of an experimental implementation of our procedure have been deferred to Sec. VI. This experimental implementation has an explicit construction of the analysis step and does not rely on the quantum Fisher information.

IV. NUMERICAL SIMULATIONS
We numerically (exactly) simulate the device introduced in the previous section using the software package QuEST which can efficiently simulate quantum circuits including noise processes [42]. We assume that the only source of error is the evolution under the external field due to the process Φ ωt (·) and that the encoder and analysis steps are perfect and require negligible time compared to the sensing time t. These are considerably good approximations since the optimal sensing time t is proportional to the coherence time 1/γ (see below). This optimal time results in a significant buildup of error during the sensing period independently of the decay rate γ as also expected from, e.g., [22,32]. Moreover, the sensing time is significantly longer than the time required by the encoder circuit if γ 1. We assume that each experiment can be repeated ν = T /t times, where T is the overall time of the metrology task.
We simulate a variety of encoder circuits that generate, e.g., GHZ, classical product and squeezed states or arbitrary symmetric states. These states are introduced in more detail in Sec. V A. After initialising the parametrised sensing state |ψ(θ) , the evolution under the external field is modelled using a Kraus-map representation of the process Φ ωt (·) introduced in Eq. (7). QuEST allows for modeling arbitrary one and two-qubit errors [42] via their Kraus map representations and we simulate various different error models in Sec. V B including, e.g., dephasing, amplitude damping and inhomogeneous Pauli errors.
The resulting density matrix ρ(ωt, θ) is then used in the analysis step to estimate the parameter ω. The performance of this task is completely determined by the quantum Fisher information F Q [ρ(ωt, θ)] of this density matrix. Note that numerically calculating the quantum Fisher information of ρ(ωt, θ) avoids simulating the analysis step, however, it is completely equivalent to that. We calculate this quantum Fisher information and the resulting precision by evaluating the circuit at two different evolutions. In particular, both density matrices ρ 0 := Φ 0 (|ψ(θ) ) and ρ 1 := Φ δωt (|ψ(θ) ) are calculated by setting the parameter in Eq. (7) to ω → 0 and to ω → δ ω , respectively, where δ ω 1. The precision is then calculated using the statistical fidelity between the two density matrices from Eq. (6) Here we assume that the experiment can be repeated ν = T /t times, where t is the sensing time (approximately the overall time of executing the circuit once) and T is a constant (overall time of the metrology task). Note that the decay rate γ from Eq. (7) is a parameter that can be set freely in the simulations, however, the product γ/T (∆ω) −2 max is dimensionless and independent of both γ and T , refer to Appendix A and also to [32]. We simulate metrology experiments with arbitrarily fixed γ δ ω and optimise the dimensionless precision γ/T (∆ω) −2 max over the parameters θ and t. We finally obtain states that are (near) optimal for metrology in the presence of noise.

A. Probe states
We simulate a variety of encoder circuits, but we do not aim to directly search in the full, exponentially large state space of N qubits. Note that this problem would require encoder circuits that correspond to arbitrary unitary transformations and would generally require exponentially many, i.e., at least 2 N , parameters to be optimised. Instead, we employ circuits that contain a constant or linear number of parameters in the number of qubits which can still sufficiently well approximate the optimal probe states |ψ(θ) . We also consider special cases of the general encoder circuit that generate, e.g., a family of squeezed states or GHZ states, in order to compare our results to previously known states for metrology.
Results of the optimisations are shown in Fig. 4 for various error models and probe states. In particular, probe states include GHZ (Fig. 4 red) and classical states (Fig. 4 black) that we define as and their only parameters that we optimise are the phase angles θ = φ. Optimising these phase angles improves the metrological performance in the case when noise is not rotationally symmetric around the external field Hamiltonian, e.g., in the case of inhomogeneous Pauli errors. One axis twisted squeezed states (Fig. 4 grey) are obtained [43] by the interaction under the permutation symmetric Hamiltonian z and we define squeezed states via and optimise their parameters θ = (θ 1 , θ 2 , θ 3 ). Here θ 2 generates a global rotation around the x axis to align the squeezing angle perpendicular to the external field Hamiltonian. This unitary transformation can be represented by a quantum circuit the contains parametrised controlled-Z gates and parametrised local rotations of the individual qubits [40]. Data obtained for squeezed states typically show an undulating trend in the number of qubits throughout the graphs. This trend is due to the pairwise entanglement of squeezed states [43]. Optimised symmetric states (Fig. 4 brown) are obtained by a direct search in the symmetric subspace whose dimension is linear in the number of qubits. This subspace is spanned by so-called symmetric Dicke states |J = N/2, m , where N is the number of qubits and J is the total angular momentum and its z projection is m, refer to [44][45][46][47]. Every symmetric state is then a linear combination of Dicke states with complex coefficients c m . We optimise these coefficients in our algorithm under the constraint that their absolute value squares sum up to 1 and θ = {c m }. Note that all states considered so far are symmetric under permutations. In contrast to symmetric states, more general qubit states are obtained via an ansatz circuit (Fig. 4 green) that in general can not reproduce any element of the exponentially large state space, but its parametrisation θ has a tractable scaling. In particular, we use a circuit shown in Fig. 3 that has a linear number of parameters in the number of qubits N . This circuit consists of parametrised controlled-Y rotations between neighbouring pairs of qubits and parameterised local rotations of the individual qubits. Despite its low number of parameters, we found that this circuit can well approximate states that are optimal for metrology under various different error models.

B. Probe states optimised against noise
Dephasing error -It has been known that GHZ states perform equally well as classical product states when undergoing dephasing [22], i.e., if the only source of noise is the stochastic fluctuation of the parameter ω during the evolution period. We simulate metrology experiments in the case when noise is dominated by dephasing. In this special case all superoperators in Eq. (7) commute and the evolution reduces to the explicit equation de that effects all the N qubits (indexed by k) identically and independently. We use the Kraus map representation of the dephasing channel that acts on an individual, single qubit via and we define p(t) := (1 − e −γt )/2 its time-dependent probability. We apply this channel to the initialised probe state |ψ(θ) and calculate the dimensionless precision via the quantum fisher information of the resulting density matrix ρ(ωt, θ) as discussed below Eq. (8). Fig. 4 a) (left) shows the scaling of the dimensionless precision for a variety of different optimised probe states in case of dephasing noise. The dimensionless precision of the previously discussed GHZ and product states can be derived analytically as γ/T (∆ω) −2 max = N/(2e) where e is the Euler number and Fig. 4 a) (left) GHZ (red) and separable (black) states match the analitically derived formulas [22]. This precision has a classical scaling, i.e., linear in the number of qubits N . Note that all states in Fig. 4 a) (left) display a classical, linear scaling in the number of qubits which conforms with the asymptotic bounds on the quantum Fisher information obtained for usual Markovian channels [23,24,40,41,48]. In particular, an upper bound on the quantum Fisher information is saturated asymptotically by squeezed states [22,40,41] in case of dephasing noise. GHZ and separable states, therefore, can be outperformed by using optimised probe states but only up to an enhancement of a constant factor at most e ≈ 2.72 [22,40,41].
The dimensionless precision achieved in our simulations with squeezed states (grey) is nearly optimal and results in a comparable performance to general symmetric states (brown) and ansatz states (green) as also expected from [22,40,41]. Note that ansatz states (green) appear to have slightly lower performance than general symmetric states. This is because the corresponding ansatz circuit has a fixed, finite depth and can only approximate arbitrary qubit states. Our results conform with optimisations performed in [22] for a small number of qubits using symmetric states. Fig. 4 b) (left) shows the optimal sensing times for the various probe states. These optimal sensing times can be derived analytically for the GHZ state [22] (in units of the decay time) as γt opt = (2N ) −1 where N is the number of qubits and for the classical product state as γt opt = 1/2. The near-optimal squeezed (grey), symmetric (brown) and general qubit (green) states tend to spend more time than (2N ) −1 in the noisy environment but less time than 1/2.
Amplitude damping error -We now consider a noise process in which amplitude damping or equivalently spontaneous emission dominates. Similarly as with the dephasing channel, all terms in Eq. (7) commute and the evolution reduces to an analogous form with Eq. (10) but noise is now modelled using the damping superoperators e γtL (k) da ρ := K (k) Ornstein-Uhlenbeck noise We assume that this random fluctuation is described by the Ornstein-Uhlenbeck process in the limit of long correlation times, i.e., by a non-Markovian process. The zero-correlationtime limit yields dephasing from Fig. 4 (left).
that effect all qubits identically and independently. We have used here the Kraus map representation of this channel with the time-dependent Kraus operators and their time-dependent probability is p(t) := 1 − e −γt . Fig. 4 a) (mid.) shows the scaling of the dimensionless precision for a variety of different probe states that were optimised against the amplitude damping error. Note that all curves have a linear, classical scaling in the number of qubits which conforms with the linear asymptotic bound [23,24,41,48] on the quantum Fisher information obtained for this noise channel. Under the amplitude damping error, GHZ states (red) perform significantly better than classical product states (black). Note that in the analysed region (2-8 qubits) squeezed states (grey) closely approach the performance of GHZ states (red). On the other hand, optimised general probe states offer significant improvements. In particular, general symmetric states (brown) have a linear scaling but a steeper slope than GHZ states. Moreover, relaxing permutation-symmetry constraints on the probe state (green) results in further improvements. Although the metrological task is permutation symmetric, i.e., its Hamiltonian and noise model is invariant under permutations, our algorithm can discover non-symmetric states that evidently outperform every symmetric state. These optimised ansatz states (green) are not permutation symmetric for N ≥ 5 and can apparently spend longer time in the environment. Of course, the corresponding optimal measurement basis that saturates the Cramér-Rao bound consists of states that are not permutation symmetric either, refer to Sec. V C. Fig. 4 b) (mid.) shows the optimal probing time. Optimised symmetric states (brown, grey) can spend more time in the noisy environment than GHZ states and perform better. Ansatz states (green) have no permutation symmetry [ Fig. 6 b) (mid.)] for N ≥ 5 and can apparently spend significantly more time in the environment and this time does not appear to significantly decrease as a function of the number of qubits. This advantage of ansatz states results in a significantly better performance then any other symmetric state. Refer to Sec. V C for more details on the resulting optimal states.
Inhomogeneous Pauli error -The errors considered so far were rotationally symmetric with respect to the external field and their superoperators therefore commute with the external field evolution. In the following we consider an error model that contains Pauli errors, such as bit flip, with no axial symmetry. In particular, we explicitly define and fix the process in Eq. (7) at zero external field, i.e., ω = 0 and at the particular time γt = 1 via the Kraus map that acts on each qubit identically and individually. Here α ∈ {x, y, z} and the time-dependent probabilities are asymmetric (inhomogeneous) 2p x = p y = 4p z and their sum is fixed to 3 4 (1 − e −1 ). In the simulations we represent this Kraus map as a superoperator matrix [49] whose matrix logarithm then defines the generator L (k) pa . The superoperator matrix of the entire process in Eq. (7) is calculated via the matrix exponential of the sum −iωtσ pa for bounded time 0 ≤ γt ≤ 1. This time-continuous process therefore interpolates between the identity operation (γt = 0) and Eq. (13) (γt = 1). Fig. 4 a) (right) shows the optimised dimensionless precision for a variety of probe states in case of inhomogeneous Pauli errors. Note that GHZ states (red) appear to be optimal, however, optimised probe states (grey, brown, green) tend to spend more time in the environment then GHZ states for N ≥ 6 as shown on Fig. 4  b). This results in a slightly better performance of general symmetric states (brown). Note that similarly to the amplitude damping channel, permutation-symmetry relaxation occurs [ Fig. 6 b) (right)] for N ≥ 6 and nonsymmetric ansatz states (green) outperform any symmetric state as they can spend even longer time in the envi-  ronment. Although all curves display a classical, linear scaling, it is expected that the steeper slope of ansatz states (green) results in higher improvements in case of an increasing system size.
Ornstein-Uhlenbeck noise -We finally consider a noise model that is dominated by a random fluctuation of the external field that follows the so-called Ornstein-Uhlenbeck process [50]. This noise process is non-Markovian in general and in the limit of long correlation times an improved scaling can be reached when using GHZ states [25]. In particular, the time-dependent external field fluctuation has a zero mean ω (t) = 0 and a time-dependent correlation function where · denotes the expected value, λ −1 is the process' finite correlation time and b is the bandwidth of noise [50]. This process effectively results in a timedependent buildup of a dephasing error via the timedependent probability p(t) = [1 − e −f (t) ]/2 and the noise channel is described by the Kraus-map representation from Appendix B. This channel is analogous with simple dephasing from Eq. (11) up to the time-dependent decay rate γt → f (t). This time-dependent decay rate was derived explicitly in [51] as f (t) := b[t + (e −λt − 1)/λ]/2. Note that this noise model reduces to simple dephasing from Eq. (11) in the limit of zero correlation times, i.e., when b −1 λ −1 and λ −1 is the correlation time. In this case the decay rate is characterised by f (t) ≈ bt/2 the bandwidth of the classical process [51].
We now consider the limit of long correlation times b −1 λ −1 as an example of non-Markovian channels. In this case the time-dependent decay rate reduces to f (t) ≈ bλt 2 /4 and this process is analogous to standard dephasing from Eq. (11) up to the time-dependent probabilities p(t) = [1 − e −(γt) 2 ]/2 with γ = √ bλ/2, refer also to [51,52]. Fig. 5 a) shows the optimised dimensionless precision for various probe states. Note that the classical product state can significantly be outperformed by using entangled quantum states. Note that optimised probe states have an improved scaling, i.e., their dimensionless precision scales as (∆ω) −2 max ∝ N c in the number of qubits with 1 < c ≤ 2 as also expected from [25,52]. The increased, time-dependent buildup of noise forces the system to spend the shortest possible time in the environment as shown on Fig. 5 b). The GHZ state in this case is optimal and has an improved scaling [25,52].

C. Analysis of the optimal states
We analyse the optimised probe states by first calculating and plotting simple measures that quantify their entanglement on Fig. 6 a) and their permutation symmetry on Fig. 6 b). In particular, we calculate an entanglement measure S avg (|ψ ) of the N -qubit system via the where the single-qubit reduced density operator ρ k is obtained via the partial trace of the state |ψ over all qubits except qubit number k. This quantity is related to the Mayer-Wallach measure and quantifies the average entanglement between a single qubit and the rest of the system, refer to [53][54][55]. Fig. 6 a) shows that classical product states (black) are unentangled but all other optimised states are highly entangled. It has been known that states that are less entangled than GHZ states are optimal asymptotically in case of dephasing [22,40,41]. Optimised general symmetric (brown) and ansatz states (green) are slightly less entangled than GHZ states in case of dephasing and amplitude damping errors, and have similar entanglement properties in other error models as GHZ states.
We quantify permutation symmetry by calculating the the average fidelity of all permutations of the state |ψ where P k permutes two qubits and k runs over all distinct permutations with N p = N 2 . Fig. 6 b) shows that all symmetric probe states have a maximal permutation symmetry and only ansatz states (green) can relax this symmetry. Optimal ansatz states (green) clearly show a relaxed permutation symmetry which results in a superior performance (in case of amplitude damping) when compared to symmetric states.
Symmetric states (brown) in Fig. 4 and in Fig. 5 are nearly optimal (except for amplitude damping) and we analyse these states separately. In particular, these state are linear combinations of Dicke states from Eq. (9). Probabilities of their optimised coefficients c m as |c m | 2 are shown for N = 8 qubits in Fig. 7 b). Phase-space representations offer an intuitive way to visualising these permutation symmetric states. In particular, the Wigner function of an arbitrary mixed state is defined as the expectation value of a rotated parity operator Π 0 where phase space is spanned by the rotation angles Ω := (θ, φ) on the sphere and R(Ω) is the rotation operator R(Ω) := e iφJz e iθJy , refer to [56][57][58][59][60] for more details. Fig. 7 a) shows Wigner functions of the optimal symmetric states in case of N = 8 qubits.
It has been known that squeezed states are optimal asymptotically in case of dephasing [22,40,41]. In our simulations, squeezed states are nearly optimal in case of dephasing and Fig. 7 a) (left) shows typical characteristics of spin (over) squeezed states. In particular, a squeezed Gaussian-like distribution is surrounded by interference fringes. Moreover, Fig. 7 b) (left) identifies state-vector coefficients that are related to squeezed states. In particular, the optimal symmetric state consist of a superposition of all Dicke states with a distribution of probabilities peaked at m = 0.
GHZ states are optimal in case of the Ornstein-Uhlenbeck process and Fig. 7 a) (right) clearly identifies the Wigner function of GHZ states while Fig. 7 b) (right) shows an equal superposition of the spin-up and down states.
Symmetric states are suboptimal in case of amplitude damping and the best symmetric state is similar to a GHZ state. In particular, it is a linear combination of the spin-up and down states as shown in Fig. 7 b) (mid. left) but the state has a higher probability of being in the spin-down state. Its Wigner function Fig. 7 a) (mid. left) is similar to Fig. 7 a) (right).
GHZ states are nearly optimal in case of inhomogeneous Pauli errors and Fig. 7 a) (mid. right) shows a Wigner function that is similar to Fig. 7 a) (right).

VI. EXPERIMENTAL IMPLEMENTATION
We consider a hypothetical device depicted on Fig. 8 which has a set of parameters that can be varied extarnally. This device can read out the evolution information after the sensing period using a decoder circuit and a set of projective measurements. Results of ν repeated executions of this device are used to estimate the precision of estimating ω and parameters of the encoder and decoder circuits are variationally optimised to yield the best possible precision (∆ω) −2 max . Similarly as in Sec. III, a probe state |ψ(θ) is initialised using an encoder circuit and this state is then exposed to the noisy environment with the field to be probed. The resulting mixed state ρ(ωt, θ) is now analysed using the combination of a decoder circuit and a set of projective measurements in the computational basis. In particular, a decoding circuit is applied to the state ρ(ωt, θ) that converts the evolution information ωt optimally into probabilities of measuring the classical registers |n at the end of the circuit. These classical registers are indexed using the binary numbers 0 ≤ n ≤ 2 N − 1. The measurement probabilities are given by the expectation values in the computational basis, i.e, in the eigenbasis of the collective Pauli z operator J z : z . Note that the decoder circuit has the effect that it maps the computational basis states |n onto an arbitrary basis U † D |n , therefore mapping J z onto an effective observable O(θ d ) := U † D J z U D , which depends on the decoder parameters θ d .
The result of a single experiment using this setup yields a binary number n, the index of a classical register into which the state has collapsed. Repeating this experiment ν 1 times, the parameter ω can be estimated with a precision at best given by the classical Fisher information of the measurement probabilities in the eigenbasis of the from Eq. (2). The probabilities here can be estimated from the measurement results and their derivatives can be approximated by repeating the experiment at an external field ω + δ ω and calculating a finite difference. Our device can therefore both estimate the parameter ω and its estimation precision (∆ω) CR . Note that this device has a set of parameters θ, θ d and t that can be varied. In particular, maximising over the parameters θ d optimises the observable, in the eigenbasis of which the measurements are effectively performed. If the decoder and encoder circuits are universal, i.e., if U E (θ) and U D (θ d ) span the group SU (2 N ), then this optimisation can find the best possible combination of a sensing state ψ(θ) and the corresponding best measurement strategy. Although the encoder and decoder circuits are not universal and not perfect in a practically relevant experimental implementation, they can still well approximate the precision that we calculated in the simulations via the quantum Fisher information F Q [ρ(ωt, θ)]. Note that the measurement process can be parallelised by executing the task on several identical copies of the device. Superconducting qubits are known as excellent candidates to realise both quantum computers and quantum sensors. High fidelity quantum gate operations and projective measurements have been demonstrated [61][62][63]. These are prerequisite for the quantum computation. On the other hand, superconducting qubits can contain a SQUID-structure, and so the applied magnetic fields can shift the resonant frequency of the superconducting qubits [64]. There are several experimental demonstration to use the superconducting qubit as a sensitive magnetic field sensor [19,65]. Therefore the superconducting qubits would be suitable to demonstrate our proposal.

VII. DISCUSSION AND CONCLUSION
In this work we proposed variational quantum algorithms for finding quantum states that are optimal for quantum metrology in the presence of environmental noise. Ours is not the first study to consider a classical optimisation of quantum states; for example Ref. [66] employs a classical optimisation method to obtain metrologically useful states in case of quantum optics. This method is, however, limited to very small quantum systems, i.e., when the average photon number is smaller than two (due to the computational complexity of the problem). Moreover, this approach does not take the effect of noise into account. In the present study, we adapt state-of-the-art variational techniques to tackle metrology in the presence of noise; moreover, while the results we present so far have been obtained via classical simulations (using the QuEST system) our technique can be operated on real quantum hardware into order to explore beyond the classical reach.
Our study has comprehensively explored systems consisting of up to 8 qubits and numerically simulated experiments in case of various different error models. We found families of optimal quantum states that non-trivially outperform previously known states. In particular, we demonstrated that relaxing permutation symmetry of the probe states offers significant improvements beyond symmetric states. We analysed the resulting optimal states and found that they are usually highly entangled but not necessarily maximally entangled as can also be expected from [22]. We outlined a possible experimental realisation that could be implemented on near-term quantum hardware.
A number of natural extensions are apparent: we mention two examples here. Firstly, the approach here can be extended to consider the case that the hardware used to prepare the metrology state is itself noisy; our technique would then optimally use such hardware, with-orwithout the use of error mitigation techniques. Secondly, it would clearly be interesting to combine the optimisation techniques mentioned here with the error-detecting and error-correcting concepts described in, for example, Refs. [26][27][28][29][30][31].
We provide a Mathematica notebook as an ancillary file that can be used to reproduce all computations contained in this manuscript.
Note added prior to upload: Our results are evidentally timely as we have noted a work, concerning the use of variational quantum algorithms in the context of quantum metrology [67], in the arxiv updates immediately prior to our submission.