## Abstract

Spin systems are an attractive candidate for quantum-enhanced metrology. Here we develop a variational method to generate metrological states in small dipolar-interacting spin ensembles with limited qubit control. For both regular and disordered spatial spin configurations the generated states enable sensing beyond the standard quantum limit (SQL) and, for small spin numbers, approach the Heisenberg limit (HL). Depending on the circuit depth and the level of readout noise, the resulting states resemble Greenberger-Horne-Zeilinger (GHZ) states or Spin Squeezed States (SSS). Sensing beyond the SQL holds in the presence of finite spin polarization and a non-Markovian noise environment. The developed black-box optimization techniques for small spin numbers (*N* ≤ 10) are directly applicable to diamond-based nanoscale field sensing, where the sensor size limits *N* and conventional squeezing approaches fail.

### Similar content being viewed by others

## Introduction

Spin systems have emerged as a promising platform for quantum sensing^{1,2,3,4} with applications ranging from tests of fundamental physics^{5,6} to mapping fields and temperature profiles in condensed matter systems and life sciences^{3}. Improving the sensitivity of these qubit sensors has so far largely relied on increasing the number of sensing spins and extending spin coherence through material engineering and coherent control. However, with increasing spin density, dipolar interactions between individual sensor spins cause single-qubit dephasing^{7,8} and, in the absence of advanced dynamical decoupling^{9,10,11}, set a limit to the sensitivity.

Although dipolar interactions in dense spin ensembles lead to complex evolution, they can provide a resource for the creation of metrological states that enable sensing beyond the SQL. Current approaches to create such states (i.e., GHZ states and SSS, see Supplementary Fig.1) either require all-to-all interactions^{12,13,14,15} or single-qubit addressability^{16,17,18}, which are challenging to implement experimentally. An alternative approach that relies on adiabatic state preparation requires less control but results in preparation times that increase exponentially with system size^{19,20}, leaving this method susceptible to dephasing.

Variational methods provide a powerful tool for controlling many-body quantum systems^{21,22,23}. Such methods have been proposed for Rydberg-interacting atomic systems^{24,25} and demonstrated in trapped ions^{26}. However, these techniques rely either on all-to-all interactions (i.e., trapped ions^{26}) or strong coupling within a finite radius (i.e., Rydberg atoms^{24,27,28}) which are generally absent in solid-state spin ensembles. In this work, we develop a variational algorithm that drives dipolar-interacting spin systems [Fig. 1(a)] into highly entangled states. The resulting states can be subsequently used for Ramsey-interferometry-based single parameter estimation^{1}. The required system control relies solely on uniform single-qubit rotations and free evolution under dipolar interactions. Different spatial distributions of the spins (later referred as ‘spin configuration’) including 2D regular arrays and 3D random spin configurations are investigated. The generated states resemble GHZ states or SSS depending on the spin-pattern geometry and the depth of the variational circuit. Experimental imperfections such as finite initialization/readout fidelity and dephasing noise are discussed for the example of a 2D regular array. The requirements on those imperfections for beating the SQL are given. Potential experimental platforms include dipolar-interacting ensembles of nitrogen-vacancy (NV) centers, nitrogen defects in diamond (P1), rare-earth-doped crystals, and ultra-cold molecules.

## Results

### Variational ansatz

As shown in Fig. 1(b), the variational circuit \({{{\mathcal{S}}}}({{{\boldsymbol{\theta }}}})={{{{\mathcal{U}}}}}_{m}...{{{{\mathcal{U}}}}}_{2}{{{{\mathcal{U}}}}}_{1}\) is constructed by *m* layers of unitary operations. Each \({{{{\mathcal{U}}}}}_{i}\) consists of the parameterized control gates

where \({R}_{\mu }(\vartheta )=\exp (-i\vartheta \mathop{\sum }\nolimits_{j = 1}^{N}{S}_{j}^{\mu })\) are single-qubit rotations and \({S}_{j}^{\mu }\)(*μ* ∈ {*x*, *y*, *z*}) is the *μ* component of the *j*-th spin operator. \(D(\tau )=\exp (-i\tau {H}_{{{{\rm{dd}}}}}/\hslash )\) is the time evolution operator of the spin ensemble under dipolar-interaction Hamiltonian \({H}_{{{{\rm{dd}}}}}={\sum }_{i < j}{V}_{ij}(2{S}_{i}^{z}{S}_{j}^{z}-{S}_{i}^{x}{S}_{j}^{x}-{S}_{i}^{y}{S}_{j}^{y})\). The coupling strength between two spins at positions **r**_{i} and **r**_{j} is

with *μ*_{0} the vacuum permeability, ℏ the reduced Planck constant, *γ* the spin’s gyromagnetic ratio, and *β*_{ij} the angle between the line segment connecting (**r**_{i}, **r**_{j}) and the direction of bias magnetic field. An evolutionary algorithm^{29} (Method) is applied on the *m*-layer circuit which contains 3*m* free parameters constituting the vector \({{{\boldsymbol{\theta }}}}=({\tau }_{1},{\vartheta }_{1},{\tau }_{1}^{{\prime} },...\,,{\tau }_{i},{\vartheta }_{i},{\tau }_{i}^{{\prime} },...\,,{\tau }_{m},{\vartheta }_{m},{\tau }_{m}^{{\prime} })\). Each *τ*_{i} is restricted to \({\tau }_{i}\in [0,1/{\bar{f}}_{{{{\rm{dd}}}}}]\) where \({\bar{f}}_{{{{\rm{dd}}}}}\) is the average nearest-neighbor interaction strength for the considered spin configuration. After the metrological relevant states are generated by the variational ansatz, a Ramsey sequence^{1,30,31} is applied to detect the external magnet field signal. During the Ramsey propagation^{1} the spins accumulate a field dependent phase for a time *τ*. Prior to the readout, a *R*_{x}(*π*/2) rotation converts this phase into a signal-dependent *P*_{z} expectation value. For the spin systems in which the dipolar interaction cannot be turned on and off at will, a Waugh-Huber-Haeberlen (WAHUHA) type dynamical decoupling sequence^{7,9,32} is applied to cancel the dipolar interactions during the signal accumulation. The Ansatz in Eq. (1) is the most general set of global single-qubit gates that preserves the initial collective spin direction 〈∑_{i}*S*_{i}〉/∣〈∑_{i}*S*_{i}〉∣, here chosen to be the *x*-direction^{24}, Supplementary Note 1. Although this Ansatz does not enable universal system control^{33,34,35}, Supplementary Discussion, we show that with increasing circuit depth, sensing near the HL can be achieved. A gradient-free black-box optimization algorithm is used for searching the parameter space {** θ**} for an entangler that generates a desired metrological state. As shown in Fig. 1(d), the algorithm samples the parameter space

**following a Gaussian distribution. In each generation, the algorithm iteratively updates the mean and variance of the Gaussian distribution according to the resulting cost function. This semi-random searching process is able to effectively jump out of local maxima.**

*θ*### Metrological cost function

The Ramsey protocol shown in Fig. 1(b) encodes the quantity of interest in the accumulated phase *ϕ* = *ω**t*_{R}, with *ω* the detuning frequency and *t*_{R} the Ramsey sensing time. The Classical Fisher Information (CFI)^{1} quantifies how precisely one can estimate an unknown parameter *ϕ* under a measurement basis. Our variational approach treats the spin systems as a black-box for which the algorithm finds a control sequence that maximizes the CFI associated with the parameter estimation problem

The sum runs over the 2^{N} basis states \(\left\vert z\right\rangle ={\otimes }_{i = 1}^{N}\left\vert {s}_{i}^{z}\right\rangle\), where \({s}_{i}^{z}\) are the eigenvalues of \({S}_{i}^{z}\). \({P}_{z}\equiv \left\vert z\right\rangle \left\langle z\right\vert\) denotes the corresponding measurement operator and *ρ*_{ϕ} the density matrix. The CFI is chosen as cost function because it quantifies the sensitivity of a measurement outcome to an external signal and measures the maximal achievable sensitivity for a given measurement basis^{1,36}. Measurement operators such as parity (\({P}_{z}^{\pi }\)) or total spin polarization (\({P}_{z}^{tot}\)) result in a smaller outcome space and are therefore more efficient in experimental implementations^{25,37,38,39}, but contain less information than *P*_{z}. While we optimize the measurement for *P*_{z} in the main text, the obtained results also hold for measurements of \({P}_{z}^{tot}\) and \({P}_{z}^{\pi }\). We found that when measuring \({P}_{z}^{tot}\) or \({P}_{z}^{\pi }\) the results improve when compared to *P*_{z}. Please check Supplementary Fig. 3 for detailed discussion.

### Numerical results for regular and disordered spin configurations

We start by testing our approach for three distinct regular spin configurations. Figure 2(a) shows the CFI after optimization for spins arranged on a linear chain (blue), a two-dimensional (2D) square lattice (orange), and a circle (green). All three configurations result in states with CFI above the SQL. When multiple circuit layers are added, the CFI further improves. Next, we simulate the case of disordered three-dimensional (3D) spin configurations (later referred as 3D-random). In our simulations the spins are randomly located in a box of length *L* ∝ *N*^{1/3} (constant spin density). Compared to the regular spin array, the disordered case shows a noticeable saturation of the CFI as a function of *N* [Fig. 2(b)]. The *N* at which this saturation occurs can be increased by increasing the circuit depth [Fig. 2(c)]. This result for small *N* is different from the infinite sized systems where time evolution under dipolar interactions *D*(*τ*) alone is not sufficient to generate metrologically useful entangled state (note, dipolar interactions in a 3D-random configuration average to zero, i.e., \(\langle (1-3{\cos }^{2}\theta )\rangle =0\)). We attribute the observed metrological gain in Fig. 2(b) to a finite-size effects for small spin ensembles. This is in stark contrast to the 2D case where dipolar interaction does not average out^{40} or regular 3D patterns^{41}.

### Entanglement characterization

We investigate the *N*-qubit entangled states created by our variational method. The resulting states are visualized by plotting out the phase space quasiprobability distribution of the spin wavefunction in terms of the Wigner function (for more details on how the density matrix of a spin system is connected to the Wigner function, we refer to refs. ^{42,43,44}; examples of Wigner distributions for specific states can be found in Supplementary Fig. 1). Figure 3(a) shows the corresponding Wigner distributions for a regular 2D spin array (top) and the average Wigner distributions for 50 different 3D-random spin configurations (bottom). In both cases, the optimized states resemble GHZ states when *N* is small and *m* is large. For large *N* and small *m*, the states are close to SSS. Non-Gaussian states that provide sensitivity beyond the SSS but lower than GHZ states are also generated. Our algorithm tends to drive the system into a GHZ state that lives in *J* = *N*/2 total angular momentum subspace, as it has the unique property of attaining the HL in Ramsey spectroscopy^{45}.

For quantitatively analysing the build-up of entanglement, the von-Neumann entanglement entropy (\({E}_{{{{\rm{vN}}}}}=-{{{\rm{Tr}}}}({\rho }_{{{{\rm{s}}}}}{\log }_{2}{\rho }_{{{{\rm{s}}}}})\))^{46} is used as a measure for the degree of entanglement between a spin subsystem (\({\rho }_{{{{\rm{s}}}}}={{{{\rm{Tr}}}}}_{{{{\rm{s}}}}}{\rho }_{{{{\rm{tot}}}}}\)) and the remaining system. As an example, we explore one case of a 3D-random configuration of 9 spins. Figure 3(b) shows the von-Neumann entropy of each spin after employing a 2-layer circuit (left) and a 7-layer circuit (right). In the case of *m* = 2, the achieved degree of entanglement is modest with spin No.6 for example showing no substantial entanglement with the surrounding spins. When the circuit depth is increased to 7, all spins display substantial entanglement. While the single-particle entropy detects spins unentangled with the remaining system, it does not determine whether all spins are entangled with each other or entanglement is local. We distinguish these two scenarios by identifying the smallest clusters with *E*_{vN} ≤ 0.4. For *m* = 2, the spin ensemble segments into 5 clusters [Fig. 3(b)], while for *m* = 7 only 2 clusters are found. The results verify that multiple layers are required to overcome the anisotropy of the dipolar interaction [Eq. (2)] when building up entanglement over the entire system. Finally, in Fig. 3(c) we analyze the size of the largest cluster for each of the 50 spin configurations and observe an overall increase of the largest cluster size and a decrease of the variance.

### State preparation time

Minimizing the preparation time is central in practical applications, as it increases bandwidth, reduces decoherence, and enables more measurement repetitions^{1}. Figure 3(d) shows the average state preparation time for 8 spins in 50 different 3D-random configurations as a function of layer number. The preparation time increases with the layer number and is inversely proportional to the average dipole coupling strength of the nearest-neighbor spins \({\bar{f}}_{{{{\rm{dd}}}}}\). Compared to adiabatic methods^{19}, our approach results in an 11 × reduction of the preparation time to reach the same CFI for identical spin number and density (see Supplementary Note 8 for detailed derivation). This is of particular importance when imperfections, such as dephasing, are taken into consideration.

### State preparation under decoherence, initialization, readout and erasure errors

Until now our analysis assumed full coherence and perfect spin initialization and readout. We also assumed the spin configuration is fixed during each run of the optimization. However, dephasing, initialization, readout and erasure errors will be limiting factors in experimental implementations. We next examine the impact of such imperfections on state preparation and sensing. Figure 4(a) and (b) show the optimized CFI in the presence of imperfect initialization and finite readout fidelity for spins on a 2D square lattice. The algorithm is limited by computational resources and able to perform optimization for imperfect initialization for up to 8 spins. Beyond-SQL sensitivity is reached for 75% initialization fidelity (for *N* ≤ 8) and 92% readout fidelity (for *N* ≤ 10), respectively.

For further understanding the impact of readout fidelity on the optimized metrological states, we plot out the resulting states optimized under different readout fidelities. Figure 4(c) indicates that without readout errors, the Wigner distribution of the resulting state is close to a GHZ state. However, with a finite readout error rate, our algorithm drives the system into a state resembling a SSS. When the readout noise is further increased, the SSS transforms into a coherent spin state (CSS). The results agree with the fact that GHZ states are sensitive to single-spin readout errors while SSS are more robust^{47}.

In addition to the discussed spin readout and initialization errors many experimental platforms also suffer from changing spin configurations between consecutive runs. This so-called erasure error is caused by a finite ionization/deionization rate in the case of NV centers^{48,49} and a finite loading possibility in the case of cold molecules^{50}. Figure 4(d) shows the optimized average CFI versus the average number of loaded spins *N*^{*} per cycle. The obtained results indicate that our approach is comparable robust to erasure errors, with beyond-SQL sensitivity for loading efficiencies as low as 50%.

During the state preparation, decoherence (*T*_{2}) reduces entanglement. We assume independent, Markovian dephasing of each spin as described by a Lindblad master equation^{46}. Figure 4(e) shows the CFI for various *T*_{2} times using the previously optimized gate parameters for 2D square lattice. While a finite *T*_{2} decreases the CFI, coherence times exceeding 0.5/*f*_{dd} result in states with beyond-SQL sensitivity for *N* ≤ 8. Here, *f*_{dd} denotes the nearest-neighbor interaction strength for 2D square lattice. For small *T*_{2} the resulting state will converge toward a CSS, which results in a sensitivity set by the SQL.

### Sensitivity in a non-Markovian environment

In addition to impacts on state preparation, dephasing affects performance in Ramsey interferometry. In the presence of spatially uncorrelated Markovian noise, entanglement does not lead to a beyond-SQL scaling^{51,52}. In a non-Markovian environment, this limitation does not hold^{53,54,55}. Such as in a solid-state spin system, slow evolution of nuclear spins leads to correlated noise^{8,56} on the sensing qubit. We examine the performance of our optimized states in a non-Markovian noise environment. We adopt a noise model^{53} in which the amplitude of single-spin coherence reduces according to

where *ν* is the stretch factor set by the noise properties. The time evolution under Ramsey propagation is simulated with a generalized Lindblad master equation^{54}. The sensing performance of optimized states is characterized by the square of the signal-noise-ratio SNR^{2} ∝ CFI_{ω}/*t*_{R} (see Supplementary Notes 2–7). Figure 4(f) shows their performance compared to the CSS and the GHZ states for a *ν* = 2 and *ν* = 4 noise exponent^{8}. The created entangled states provide an advantage over uncorrelated states. For small spin numbers, the SNR follows the HL scaling^{53}.

### Proposed experimental platforms

Candidate systems for realizing the proposed variational approach need to possess long *T*_{2} coherence time, strong dipolar-interacting strength, and high initialization and readout fidelity. Recent developments in solid-state spin systems and ultracold molecules have demonstrated coherence times that exceed dipolar coupling times (\(1/{\bar{f}}_{{{{\rm{dd}}}}}\)) as well as high-fidelity spin initialization and readout. Table 1 lists the experimentally observed parameters for different candidate systems, including NV ensembles, P1 centers in diamond, rare-earth doped crystals, and ultracold molecule tweezer systems.

The listed \({T}_{2}^{({{{\rm{DD}}}})}\) in Table 1 are lower bounds for the actual *T*_{2}. Specifically, \({T}_{2}^{({{{\rm{DD}}}})}\) represent the experimental coherence measured under WAHUHA-type dynamical decoupling, which contains remaining dephasing terms caused by dipolar interaction^{11}. On the other hand, our protocol relies on the presence of dipolar interaction for the generation of the desired entangled states. Therefore dipolar interaction between spins is part of the system Hamiltonian that does not contribute to dephasing during the state preparation. Thus, the relevant coherence is the single particle *T*_{2} in the absence of dipolar spin-spin interacting (see Supplementary Table 1).

## Discussion

This work introduces a variational circuit that efficiently generates entangled metrological states in a dipolar-interacting spin system. The required system parameters are within the reach of several experimental platforms. When directly running this variational method on an experimental platform, metrological states can be generated without the prior knowledge of the actual spin locations. While this study remains limited to small system sizes (*N* ≤ 10, limited by computational resource), our results are of immediate interest to nanoscale quantum sensing where spatial resolution is paramount and the finite sensor size limits the number of spins that can be utilized. Specific examples include the investigation of 2D materials^{57,58,59,60}, structures and dynamics of magnetic domains^{61,62}, vortex structures in superconductivity^{63,64}, and magnetic resonance spectroscopy on individual proteins and DNA molecules^{65,66,67,68}.

Extending our investigation to *N* > 10 can either be achieved by utilizing symmetries in regular arrays or directly testing our optimization algorithms on an actual experimental platform. The developed method is also potentially applicable to preparing other highly entangled states relevant to quantum computing and quantum communication.

## Method

### Gradient-free optimization: CMA-ES

The optimization in the 3*m* dimensional parameter space is highly non-convex [Fig. 1(d)] due to the large inhomogeneity of the interaction strength. In our setting, the previously used Dividing Rectangles algorithm^{22,24} cannot converge to a beyond-SQL result despite large number of iterations. We address this challenge by using the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) as our optimization algorithm^{29}. CMA-ES balances the exploration and exploitation process when searching in the parameter space so that convergence is reached after <~2000 generations for *N*, *m* ≤ 10. This corresponds to about 10^{8} repetitions of the Ramsey experiment, which can be further reduced if collective measurement observables are measured (Supplementary Fig. 3).

We reduce the complexity of the optimization by restricting *τ*_{i} within \([0,1/{\bar{f}}_{{{{\rm{dd}}}}}]\) where \({\bar{f}}_{{{{\rm{dd}}}}}\) is the average nearest-neighbor interaction strength for the considered spin configuration. Setting a large parameter searching range for the interaction gates’ time *τ*_{i} would potentially ensure the global maximum CFI location is included in the parameter space. However, when the upper bound of *τ*_{i} is much bigger than \(1/{\bar{f}}_{{{{\rm{dd}}}}}\), the evolution of neighboring spin pairs is fast when sweeping *τ*_{i}. This would introduce a huge amount of local maximum points in the parameter search so that it is impractical for the black-box optimization algorithm to converge to that global maximum point. A good value for \({\bar{f}}_{{{{\rm{dd}}}}}\) can be estimated from the doping level of the spin defects (NV, P1, rare-earth ions) or the distance between the cold molecule tweezers. Measuring the fast oscillation frequency in Ramsey experiments will also provide an estimate of the \({\bar{f}}_{{{{\rm{dd}}}}}\).

## Data availability

All relevant data supporting the main conclusions and figures of the document are available from the corresponding author on reasonable request.

## Code availability

All relevant code is available from the corresponding author upon reasonable request.

## Change history

### 03 May 2024

A Correction to this paper has been published: https://doi.org/10.1038/s41534-024-00843-8

## References

Degen, C. L., Reinhard, F. & Cappellaro, P. Quantum sensing.

*Rev. Mod. Phys.***89**, 035002 (2017).Barry, J. F. et al. Sensitivity optimization for NV-diamond magnetometry.

*Rev. Mod. Phys.***92**, 015004 (2020).Schirhagl, R., Chang, K., Loretz, M. & Degen, C. L. Nitrogen-vacancy centers in diamond: nanoscale sensors for physics and biology.

*Annu. Rev. Phys. Chem.***65**, 83–105 (2014).Tetienne, J.-P. Quantum sensors go flat.

*Nat. Phys.***17**, 1074–1075 (2021).Hensen, B. et al. Loophole-free Bell inequality violation using electron spins separated by 1.3 kilometres.

*Nature***526**, 682–686 (2015).Marti, G. E. et al. Imaging optical frequencies with 100

*μ*Hz precision and 1.1*μ*m resolution.*Phys. Rev. Lett.***120**, 103201 (2018).Yan, B. et al. Observation of dipolar spin-exchange interactions with lattice-confined polar molecules.

*Nature***501**, 521–525 (2013).Childress, L. et al. Coherent dynamics of coupled electron and nuclear spin qubits in diamond.

*Science***314**, 281–285 (2006).Waugh, J. S., Huber, L. M. & Haeberlen, U. Approach to high-resolution NMR in solids.

*Phys. Rev. Lett.***20**, 180 (1968).Mehring, M.

*Principles of high resolution NMR in solids*(Springer Science & Business Media, 2012).Choi, J. et al. Robust dynamic hamiltonian engineering of many-body spin systems.

*Phys. Rev. X***10**, 031002 (2020).Pedrozo-Pe nafiel, E. et al. Entanglement on an optical atomic-clock transition.

*Nature***588**, 414–418 (2020).Kitagawa, M. & Ueda, M. Squeezed spin states.

*Phys. Rev. A***47**, 5138 (1993).Li, Z. et al. Collective spin-light and light-mediated spin-spin interactions in an optical cavity.

*PRX Quant.***3**, 020308 (2022).Bilitewski, T. et al. Dynamical generation of spin squeezing in ultracold dipolar molecules.

*Phys. Rev. Lett.***126**, 113401 (2021).Koczor, B., Endo, S., Jones, T., Matsuzaki, Y. & Benjamin, S. C. Variational-state quantum metrology.

*N. J. Phys.***22**, 083038 (2020).Chen, S., Raha, M., Phenicie, C. M., Ourari, S. & Thompson, J. D. Parallel single-shot measurement and coherent control of solid-state spins below the diffraction limit.

*Science***370**, 592–595 (2020).Neumann, P. et al. Multipartite entanglement among single spins in diamond.

*Science***320**, 1326–1329 (2008).Cappellaro, P. & Lukin, M. D. Quantum correlation in disordered spin systems: Applications to magnetic sensing.

*Phys. Rev. A***80**, 032311 (2009).Choi, S., Yao, N. Y., and Lukin, M. D., Quantum metrology based on strongly correlated matter Preprint at https://arxiv.org/abs/1801.00042 (2017).

Cerezo, M. et al. Variational quantum algorithms.

*Nat. Rev. Phys.***3**, 625–644 (2021).Kokail, C. et al. Self-verifying variational quantum simulation of lattice models.

*Nature***569**, 355–360 (2019).Ebadi, S. et al. Quantum optimization of maximum independent set using Rydberg atom arrays.

*Science***376**, 1209–1215 (2022).Kaubruegger, R. et al. Variational spin-squeezing algorithms on programmable quantum sensors.

*Phys. Rev. Lett.***123**, 260505 (2019).Kaubruegger, R., Vasilyev, D. V., Schulte, M., Hammerer, K. & Zoller, P. Quantum variational optimization of Ramsey interferometry and atomic clocks.

*Phys. Rev. X***11**, 2160 (2021).Marciniak, C. D. et al. Optimal metrology with programmable quantum sensors.

*Nature***603**, 604–609 (2022).Borish, V., Marković, O., Hines, J. A., Rajagopal, S. V. & Schleier-Smith, M. Transverse-field Ising dynamics in a Rydberg-dressed atomic gas.

*Phys. Rev. Lett.***124**, 063601 (2020).Bernien, H. et al. Probing many-body dynamics on a 51-atom quantum simulator.

*Nature***551**, 579–584 (2017).Hansen, N. The CMA evolution strategy: a tutorial Preprint at https://arxiv.org/abs/1604.00772 (2016).

Ramsey, N. F. A molecular beam resonance method with separated oscillating fields.

*Phys. Rev.***78**, 695 (1950).Taylor, J. M. et al. High-sensitivity diamond magnetometer with nanoscale resolution.

*Nat. Phys.***4**, 810–816 (2008).Zhou, H. et al. Quantum metrology with strongly interacting spin systems.

*Phys. Rev. X***10**, 031003 (2020).Schirmer, S. G., Fu, H. & Solomon, A. I. Complete controllability of quantum systems.

*Phys. Rev. A***63**, 063410 (2001).Albertini, F. & D’Alessandro, D. The lie algebra structure and controllability of spin systems.

*Linear Algebra Appl.***350**, 213–235 (2002).Albertini, F. & D’Alessandro, D. Subspace controllability of multi-partite spin networks.

*Syst. Control. Lett.***151**, 104913 (2021).Kobayashi, H., Mark, B. L. & Turin, W.

*Probability, random processes, and statistical analysis*(Cambridge University Press, 2011).Davis, E., Bentsen, G. & Schleier-Smith, M. Approaching the heisenberg limit without single-particle detection.

*Phys. Rev. Lett.***116**, 053601 (2016).Strobel, H. et al. Fisher information and entanglement of non-gaussian spin states.

*Science***345**, 424–427 (2014).Colombo, S. et al. Time-reversal-based quantum metrology with many-body entangled states.

*Nat. Phys.***18**, 925–930 (2022).Davis, E. J. et al. Probing many-body noise in a strongly interacting two-dimensional dipolar spin system Preprint at https://arxiv.org/abs/2103.12742 (2021).

Perlin, M. A., Qu, C. & Rey, A. M. Spin squeezing with short-range spin-exchange interactions.

*Phys. Rev. Lett.***125**, 223401 (2020).Hillery, M., O’Connell, R. F., Scully, M. O. & Wigner, E. P. Distribution functions in physics: Fundamentals.

*Phys. Rep.***106**, 121–167 (1984).Dowling, J. P., Agarwal, G. S. & Schleich, W. P. Wigner distribution of a general angular-momentum state: applications to a collection of two-level atoms.

*Phys. Rev. A***49**, 4101 (1994).Koczor, B., Zeier, R. & Glaser, S. J. Fast computation of spherical phase-space functions of quantum many-body states.

*Phys. Rev. A***102**, 062421 (2020).Giovannetti, V., Lloyd, S. & Maccone, L. Quantum metrology.

*Phys. Rev. Lett.***96**, 010401 (2006).Nielsen, M. A. and Chuang, I. L.

*Quantum Computation and Quantum Information: 10th Anniversary Edition*(Cambridge University Press, 2010). https://doi.org/10.1017/CBO9780511976667.Davis, E., Bentsen, G., Li, T. & Schleier-Smith, M. Advantages of interaction-based readout for quantum sensing.

*Adv. Photon. Quant. Comput. Mem. Commun. X***10118**, 101180Z (2017).Doherty, M. W. et al. The nitrogen-vacancy colour centre in diamond.

*Phys. Rep.***528**, 1–45 (2013).Razinkovas, L., Maciaszek, M., Reinhard, F., Doherty, M. W. & Alkauskas, A. Photoionization of negatively charged NV centers in diamond: Theory and ab initio calculations.

*Phys. Rev. B***104**, 235301 (2021).Cheuk, L. W. et al. Observation of collisions between two ultracold ground-state caf molecules.

*Phys. Rev. Lett.***125**, 043401 (2020).Demkowicz-Dobrzański, R., Kołodyński, J. & Guţă, M. The elusive heisenberg limit in quantum-enhanced metrology.

*Nat. Commun.***3**, 1063 (2012).Escher, B., de Matos Filho, R. & Davidovich, L. General framework for estimating the ultimate precision limit in noisy quantum-enhanced metrology.

*Nat. Phys.***7**, 406–411 (2011).Chin, A. W., Huelga, S. F. & Plenio, M. B. Quantum metrology in non-markovian environments.

*Phys. Rev. Lett.***109**, 233601 (2012).Smirne, A., Kołodyński, J., Huelga, S. F. & Demkowicz-Dobrzański, R. Ultimate precision limits for noisy frequency estimation.

*Phys. Rev. Lett.***116**, 120801 (2016).Matsuzaki, Y., Benjamin, S. C. & Fitzsimons, J. Magnetic field sensing beyond the standard quantum limit under the effect of decoherence.

*Phys. Rev. A***84**, 012103 (2011).Le Dantec, M. et al. Twenty-three–millisecond electron spin coherence of erbium ions in a natural-abundance crystal.

*Sci. Adv.***7**, 51 (2021).Casola, F., Van Der Sar, T. & Yacoby, A. Probing condensed matter physics with magnetometry based on nitrogen-vacancy centres in diamond.

*Nat. Rev. Mater.***3**, 1–13 (2018).Vool, U. et al. Imaging phonon-mediated hydrodynamic flow in WTe2.

*Nat. Phys.***17**, 1216–1220 (2021).Jenkins, A. et al. Imaging the breakdown of ohmic transport in graphene.

*Phys. Rev. Lett.***129**, 087701 (2022).Palm, M. L. et al. Imaging of submicroampere currents in bilayer graphene using a scanning diamond magnetometer.

*Phys. Rev. Appl.***17**, 054008 (2022).Tetienne, J. P. et al. The nature of domain walls in ultrathin ferromagnets revealed by scanning nanomagnetometry.

*Nat. Commun.***6**, 6733 (2015).Gross, I. et al. Real-space imaging of non-collinear antiferromagnetic order with a single-spin magnetometer.

*Nature***549**, 252–256 (2017).Pelliccione, M. et al. Scanned probe imaging of nanoscale magnetism at cryogenic temperatures with a single-spin quantum sensor.

*Nat. Nanotechnol.***11**, 700–705 (2016).Scheidegger, P. J., Diesch, S., Palm, M. L. & Degen, C. Scanning nitrogen-vacancy magnetometry down to 350 mk.

*Appl. Phys. Lett.***120**, 224001 (2022).Staudacher, T. et al. Nuclear magnetic resonance spectroscopy on a (5-nanometer) 3 sample volume.

*Science***339**, 561–563 (2013).Shi, F. et al. Single-protein spin resonance spectroscopy under ambient conditions.

*Science***347**, 1135–1138 (2015).Shi, F. et al. Single-DNA electron spin resonance spectroscopy in aqueous solutions.

*Nat. Methods***15**, 697–699 (2018).Lovchinsky, I. et al. Nuclear magnetic resonance detection and spectroscopy of single proteins using quantum logic.

*Science***351**, 836–841 (2016).Shields, B. J., Unterreithmeier, Q. P., de Leon, N. P., Park, H. & Lukin, M. D. Efficient readout of a single spin state in diamond via spin-to-charge conversion.

*Phys. Rev. Lett.***114**, 136402 (2015).Zu, C. et al. Emergent hydrodynamics in a strongly interacting dipolar spin ensemble.

*Nature***597**, 45–50 (2021).Degen, M. et al. Entanglement of dark electron-nuclear spin defects in diamond.

*Nat. Commun.***12**, 3470 (2021).Merkel, B., Fari na, P. C. & Reiserer, A. Dynamical decoupling of spin ensembles with strong anisotropic interactions.

*Phys. Rev. Lett.***127**, 030501 (2021).Raha, M. et al. Optical quantum nondemolition measurement of a single rare earth ion qubit.

*Nat. Commun.***11**, 1605 (2020).

## Acknowledgements

We thank D. DeMille, D. Freedmann, A. Bleszynski Jayich, S. Kolkowitz, T. Li, Z. Li, R. Kaubruegger, Y. Huang, Q. Xuan, Z. Zhang, S. von Kugelgen, C-J. Yu, Y. Bao, P. Gokhale, N.Leitao, L.Martin and H.Zhou for helpful discussions. The investigation of sensing performance and state preparation under noise is based upon work supported by Q-NEXT (Grant No. DOE 1F-60579), one of the U.S. Department of Energy Office of Science National Quantum Information Science Research Centers. T.-X.Z. and P.C.M. acknowledge support by National Science Foundation (NSF) Grant No. OMA-1936118 and OIA-2040520, and NSF QuBBE QLCI (NSF OMA-2121044). S.Z. acknowledges funding provided by the Institute for Quantum Information and Matter, an NSF Physics Frontiers Center (NSF Grant PHY-1733907). Z.M. and F.T.C. acknowledge support by EPiQC, an NSF Expedition in Computing, under grants CCF-1730082/1730449; in part by STAQ under grant NSF Phy-1818914; in part by the US DOE Office of Advanced Scientific Computing Research, Accelerated Research for Quantum Computing Program.; and in part by NSF OMA-2016136. The authors are also grateful for the support of the University of Chicago Research Computing Center for assistance with the numerical simulations carried out in this work.

## Author information

### Authors and Affiliations

### Contributions

T.-X.Z., A.L., and J.R. designed and wrote the numerical simulations. T.-X.Z., A.L., J.R., S.Z., M.K., and Z.M. analyzed the results. F.T.C., A.A.C., L.J. and P.C.M. provided guidance. P.C.M. developed the idea and supervised the project. All authors contributed to discussing the results and writing the paper.

### Corresponding author

## Ethics declarations

### Competing interests

F.T.C. is the Chief Scientist for Quantum Software at ColdQuanta and an advisor to Quantum Circuits, Inc. The authors declare that there are no other competing interests.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Zheng, TX., Li, A., Rosen, J. *et al.* Preparation of metrological states in dipolar-interacting spin systems.
*npj Quantum Inf* **8**, 150 (2022). https://doi.org/10.1038/s41534-022-00667-4

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41534-022-00667-4