Probe optimization for quantum metrology via closed-loop learning control

Experimentally achieving the precision that standard quantum metrology schemes promise is always challenging. Recently, additional controls were applied to design feasible quantum metrology schemes. However, these approaches generally does not consider ease of implementation, raising technological barriers impeding its realization. In this paper, we circumvent this problem by applying closed-loop learning control to propose a practical controlled sequential scheme for quantum metrology. Purity loss of the probe state, which relates to quantum Fisher information, is measured efficiently as the fitness to guide the learning loop. We confirm its feasibility and certain superiorities over standard quantum metrology schemes by numerical analysis and proof-of-principle experiments in a nuclear magnetic resonance system.


INTRODUCTION
Much of quantitative science deals with measuring a certain parameter, say ϕ, of a physical process precisely. Typically, this involves subjecting suitably engineered probe states to the physical process, and using measurement readout to recover an estimate of ϕ. The central limit theorem states that repeated applications of this procedure can improve our estimate, such that the resulting standard error scales as 1= ffiffiffi ffi N p in the number of particles N. Remarkably, quantum technologies allow us to surpass this standard limit. By using suitably entangled probes, we can reach the Heisenberg limit-suppressing Δϕ, such that it scales as 1/N 1-3 . This quadratic scaling advantage can drastically reduce the resources required for precision measurement, and continues to catalyze rapid developments in the field of quantum metrology [4][5][6][7][8][9][10][11][12][13][14][15] .
While quantum metrology is well understood at the theoretical level, its physical application to large-scale quantum systems faces significant challenges [16][17][18][19][20][21][22][23] . Consider the iconic task of estimating the phase ϕ of some unitary process U ϕ ¼ e ÀiHϕ . In this setting, the theory tells us how to determine the optimal quantum probe ρ for any possible Hamiltonian H. However, when H acts on a many-body system, this optimal probe is typically a complex, entangled many-body state. Engineering this probe is often nontrivial, especially in the advent of limited access to the physical operations used to synthesize such probes 16 . Meanwhile, many realistic means of initializing such probes involve applying a sequence of controls, whose operational effects are not fully characterized 21,[24][25][26] . These issues are further exacerbated by the exponentially growing size of the Hilbert space-making direct implementation of complex metrological schemes extremely challenging.
Here, we propose a closed-loop learning protocol that circumvents these issues. The resulting protocol has the following desirable features: (a) It does not require us to analytically solve for the optimal probe, nor possess prior knowledge of how this probe can be synthesized from available physical controls. These aspects are optimized through the learning process. (b) It does not require us to know the precise effects of these physical controls, nor implement tomography on the resulting quantum probes. (c) It does not require any computation involving matrix representations of H, avoiding the curse of dimensionality. These features combined allow a versatile procedure for finding improved metrology protocols, ideal for complex many-body settings. We demonstrate a proof-of-principle experiment using nuclear magnetic resonance (NMR), illustrating the viability of this approach with present-day quantum technology.

RESULTS
Framework of closed-loop learning-assisted quantum metrology Here, we consider estimating the phase ϕ of a general N-body unitary process U ϕ ¼ e ÀiHϕ . Each metrology protocol begins with a probe initialized in some easily prepared state ρ 0 on N probestypically a product state where each probe is initialized in some default state 0 j i. The goal then is to implement a control-a sequence of physical operations that we apply to the N-probe system, transforming ρ 0 to some candidate entangled state ρ C . By acting U ϕ on each probe, we end up with ρ ϕ , which encodes information regarding ϕ (see Fig. 1a). The efficacy of each candidate probe ρ C is typically quantified by the quantum Fisher information F Q 2 . The rationale is that after repeating this process through ν independent runs, the standard error to which we can estimate ϕ is bounded below by 1= ffiffiffiffiffiffiffiffi νF Q p . This lower bound is tight, and can always be saturated using an ideal measurement scheme.
The particular benefit of quantum metrology is that use of suitably entangled ρ C enables one to reduced uncertainty of ϕ much more quickly than conventional strategies. One iconic case, for example, is when U ϕ corresponds to applying an identical unitary process e ÀiHϕ to each individual probe. In such scenarios, use of non-entangled ρ C results in F Q that scales linearly with N, 1 such that sensing ϕ to some desired Δ requires N > O(1/Δ 2 ) probes. In contrast, if ρ C is appropriately entangled, F Q scales as N 2 , enabling the Heisenberg limit scaling of N > O(1/Δ). The goal of quantum metrology can thus be split into two distinct tasks: 1. Determine the control sequence C that synthesizes some near-optimal state ρ C whose corresponding quantum Fisher information F Q (ρ C ) is made as large as possible. 2. Use the control sequence to synthesize ρ C , which can then be injected as input to U ϕ for purposes of estimating ϕ.
Here, our primary focus is the first task, with an understanding that our resulting control sequences can be used to synthesize the appropriate states to perform metrology. This is highly nontrivial for general H. Notably, the dimensions of H grow exponentially with N, making analytical methods for finding the optimal ρ C computationally intractable. Meanwhile, C is described by an ordered list of readily accessible elementary operations (e.g., pulse sequences). Inferring how these can be chained together to generate a given ρ C is generally highly nontrivial, especially when the exact physical effect of each elementary operation on the probe state is not known. Typical means of optimizing F Q (ρ C ) are further hampered by difficulty in evaluating the efficacy of a candidate control sequence C. Given ρ ϕ , evaluation of the corresponding efficacy F Q (ρ C ) involves an optimization over all possible measurement bases -a task whose complexity also scales exponentially with system size.
In our protocol, we first tackle the difficulty in evaluating efficacy by using relations between quantum Fisher information and purity loss. Let ρ avg = ∫P x ρ ϕ + x dx, where P x is some probability distribution with mean 0 and standard deviation Δx. Meanwhile, setting ΔγðΔxÞ ¼ Trðρ 2 C Þ À Trðρ 2 avg Þ. Then, recent results 27 established that in the limit where Δx ≪ 1, the quantum Fisher information F Q (ρ C ) with respect to ϕ satisfies Physically, ρ avg represents the resulting ensemble state when the aforementioned metrology procedure is applied to a unitary U ϕ , such that ϕ undergoes stochastic fluctuations of magnitude Δx. Thus, Δγ(Δx) captures the purity loss of the resultant state induced by these fluctuations. Equation (1) then states that the efficacy of a metrology protocol is bounded below by the rate in which its output state loses purity when subject to stochastic noise in the parameter we are trying to sense. Therefore, we can effectively use F L Q as a proxy for the efficacy of a probe. The advantage is that purity loss is far more amendable to direct measurement than quantum Fisher information 28 . To evaluate the efficacy of a candidate C, we apply two pairs of the control sequence in parallel to obtain two copies of ρ C . The rate of purity loss of the resulting outputs when subject to stochastic noise on ϕ can then be experimentally measured by application of suitable controlled-SWAP gates-coherently swapping output pairs controlled on an ancillary quantum mechanical degree of freedom (see Fig. 1c). We refer to this quantum algorithm as the quantum efficacy estimator, which can now be coupled with a suitable closed-loop learning algorithm for automated discovery of increasingly effective control sequences for sensing ϕ (see Fig. 1b).
In practice, we can use many different learning algorithms, ranging from simple direct search algorithms 29 to more complex evolutionary algorithms 30 . Here, we found the Nelder-Mead algorithm 31 to be particularly effective for our experiments. The entire learning process can then be summarized as follows: we begin by initializing a population of n + 1 control sequences at random, and make use of the quantum efficacy estimator to sort Fig. 1 Schematic diagram of closed-loop learning-assisted practical quantum metrology. a General procedure of quantum metrology, including probe state preparation (applying controls to the initial probe state to generate a candidate probe ρ C ), encoding some parameter ϕ by application of U ϕ to ρ C , and measurement readout. b A candidate control sequence C is evaluated for efficacy through quantum information processing. This involves using C to prepare copies of the candidate probe state ρ C , half of which are transformed into ρ avg . The purities of ρ C and ρ avg are then measured, and their difference-the purity loss-is used as a proxy for efficacy. c Illustrates implementation of this process in experiment. The parameter encoding with fluctuations in the dotted box are switched off to determine the purity of ρ C , and on to determine the purity of ρ avg . Their difference is fed into a classical computer running a Nelder-Mead algorithm that generates candidate control sequences for subsequent iterations. In our experiment, this process is automated, such that control fields are tuned automatically at each iteration. them in the order of decreasing efficacy, denoted C ðgÞ ¼ fC ðgÞ 0 ; C ðgÞ 1 ; ; C ðgÞ nþ1 g, with g = 0 indicating the 0th iteration. Meanwhile n is generally chosen to scale linearly with the number of actions (controls) we can apply in each particular time-step (e.g., if we have access to local rotations along x-and yaxis on N qubits, then n scales linearly with N). Once the initial population is set, the Nelder-Mead algorithm then stipulates a systematic method to generate a new candidate control through geometric considerations-which replaces the worst performer C ðgÞ nþ1 to form the population in the next iteration, which is then again sorted by decreasing efficacy to obtain C ðgþ1Þ . The exact mechanics of this algorithms involve mapping each control sequence into a vertex in some suitable convex space, the details of which are found in "Methods." At each iteration g, the control sequence with maximum purity loss is denoted as C (g) . The procedure is then continued until some designated stopping condition, such as when the purity loss of C (g) becomes sufficiently stable over multiple rounds, or when a set number of iterations are reached. Once the stopping condition is hit, the C (g) with maximum efficacy is delivered as the recommended control sequence.
This optimization process scales as a polynomial with respect to the number of free parameters that specifies a candidate control sequence. This latter condition is typically true for realistic settings, where (1) we are typically limited to one and two-body interactions, such that the number of possible control sequences we have at any particular point in time scales at most scales quadratically with N, (2) we are reasonably restricted to the reachable states within polynomial resource, such that the amount of time it takes to synthesize them does not scale exponentially with N. The protocol also has a number of other key advantages. First, at no stage does it require tomography of candidate probe states, either before or after the action of U ϕ . Second, it does not require complete mathematical knowledge of how the control sequences act on the Hilbert space. Finally, the algorithm automatically accounts for potentially physical anomalies, such as drift Hamiltonians when optimizing the control sequences of synthesizing the probe state. Each of these tasks would typically require a classical computer an exponential amount of time to address. Thus, the learning procedure inherits all the advantages of closed-loop learning-easily adaptable to diverse physical architectures [32][33][34] .
Example of sensing with spin chains We illustrate these advantages numerically for a scenario with spin chains featuring unavoidable spin-spin interactions. Consider the case where we have access to N-qubit spin chains, and we wish to use them to estimate the strength of some external magnetic field in the z-axis. This problem aligns with estimating the phase ϕ of represents the angular momentum operator of the ith spin. If non-entangled qubits are used, the achieved Fisher information will scale as N. In contrast, the use of appropriately entangled probes can lead a quantum Fisher information F Q that scales as N 2 , enabling us to achieve the Heisenberg limit. While theory would enable us to work out the optimal probe, the catch here is that our control on the spin system is limited. First, the chain evolves naturally according to nearest-neighbor Ising coupling H S ¼ 2πJ (J is the coupling strength). Second, our control of the system is limited to a sequence of local I x and I y interactions, whose strength we can adjust M times. What is then the optimal way to adjust our control fields? The question is nontrivial. Fig. 2 Numerical simulations of the closed-loop learning algorithm when sensing with spin chains. a, b each illustrate the performance of our closed-loop learning algorithms for the respective cases where (Δx) 2 = 0.01 and (Δx) 2 = 0.001. In both graphs, the horizontal axis denotes iteration number g. The solid lines represent optimal quantum Fisher information achieved at each iteration, while the dashed lines represent the bound stipulated by purity loss (i.e., F L Q ). We see that both begin at low values at g = 0 as expected for random probes, and improve markedly during the learning process. c, d illustrate that the efficacy of the discovered probes approaches the Heisenberg limit, indicating their near optimality. Meanwhile, setting Δx to be smaller seemed to be marginally more advantageous, likely owing to the closer agreement between purity loss and quantum Fisher information in this regime. In e, we show a table of the fidelity between the quantum probe states generated and the closest theoretically optimal probe.
To apply our algorithm, we first formally describe C. Here, each time we adjust the control field, we have M(2N + 1) free parameters. (1) The goal is to find some near-optimal sequence, such that from some easily prepared initial probe Ψ i j i the resulting probe state Ψ f j i ¼ U C Ψ i j i is near optimal for estimating ϕ.
For sufficiently low N (of up 7), it is feasible to simulate our algorithm classically. In Fig. 2a, b, we plot the maximum F L Q and F Q with respect to the particle number for two possible choices of Δx. Observe that the purity loss becomes a better proxy for quantum Fisher information when Δx is reduced, in agreement with Eq. (1). Indeed, at (Δx) 2 = 0.001, the relationship is almost exact. As such, our learning protocols produce results within 1% of the Heisenberg limit when using (Δx) 2 = 0.001.
To further verify the effectiveness of our algorithm, we compare the results of our algorithm with that of the theoretical optimal. In this specific case, theory indicates that the N-party entangled are the optimal probes -saturating the Heisenberg limit 35 . Executing our closed-loop learning algorithm, we note that the learned optimal probe state Ψ f j i closely approximates these NOON states. In Fig. 2c, we list the fidelity 〈Ψ t |Ψ f 〉 between Ψ f j i and theoretical optimal Ψ t j i. For small qubit numbers, the agreement is complete (fidelity = 1). While limitations in computational resources (in evaluating F Q for example) do slowly degrade the fidelity as we increase particle number, there is still a match of over 0.95 when N = 7.
The algorithm, itself, however, is not designed to run purely on classical computers. Indeed, the computational costs to do so scale exponentially with N. Tracking the dynamics of controls, and resulting purity loss becomes quickly intractable. However, when the algorithm is executed on a quantum processor, such information does not need to be tracked. In particular, we do not need to know the mathematical descriptions of the controls, nor the strength of the internal spin-spin interactions.
Proof-of-principle experiment Our proof-of-principle experiment was conducted on a Bruker Avance III 400 MHz spectrometer using the sample diethylfluoromalonate at room temperature. This three-qubit NMR processor consists of three spins 13 C, 1 H, and 19 F. Label these as qubits 1, 2, and 3. This process enables us to engineer controlled-SWAP gates that coherently swaps between qubits 2 and 3, controlled on qubit 1 (see "Methods" and Supplementary Note 3). Thus provided, we can initialize both qubits 2 and 3 in a designated state ρ; we can also experimentally measure the purity Trðρ 2 Þ 28 . This processor is thus capable of realizing the quantum efficacy estimator for single qubit probes.
We illustrate the use of this device to estimate ϕ, encoded within the single qubit unitary U ϕ ¼ e ÀiIzϕ . Here, the probe state is a single spin, which we can rotate along x and y directions. Assume M total pulse segments, each candidate control sequence is now described by 2M free parameters, The resulting propagator could be expressed as U C = U M …U 2 U 1 with Note that we have omitted the Δt[m], which was present in numerical simulation for the general N case, as the lack of a drift Hamiltonian makes this unnecessary. Our goal is then to find a control sequence C such that U C 0 j i has maximal quantum Fisher information with respect to ϕ.
We implement our closed-loop learning algorithm with a population of n = 7, and M = 3 pulse segments. Each pulse sequence was set to T = Mτ = 30 μs. The key difference here from numerics is that the efficacy is now evaluated directly using our NMR processor. For a particular candidate control sequence C, we first initialize each of qubits 2 and 3 of our processor into the state 0 j i. The control sequence C is then applied to both qubits, setting them each to some resulting candidate probe state ρ C . Application of the controlled-SWAP circuit then enables estimation of γ C ¼ Trðρ 2 C Þ (see Fig. 1c).
In a, we plot the candidate probes discovered during iterations 1, 10, 20, and 25, as overhead projections on the Bloch sphere. Here ðφ; sin δÞ are effectively mapped to polar coordinates-such that sin δ becomes the magnitude (displacement of the point from the center), and φ is the angle relative to the x-axis. The points in each plot are color coded according to their efficacy. The plots then directly depict the convergence of the sequentially discovered candidate probes to the optimal probe (demarcated by δ = π/2). b plots the purity loss of these probe state (round circles with values given by axis on the left), together with the blue line indicating the bound stipulated by maximal purity loss out of all candidates in each iteration (solid blue line). The red line plots (with values given by axis on the right) the quantum Fisher information achievable by the associated probe state, should it be used to sense ϕ. These results illustrate that the learning algorithm converges quickly to near-optimal values by the tenth iteration. Meanwhile, c plots the associated control fields in the x and y directions (orange and pink bars) used to general the optimal probe of iterations 1, 10, 20, and 25.
Determination of γ avg ¼ Trðρ 2 avg Þ requires us to simulate the effects of applying U ϕ + X , where X is Gaussian distribution with standard deviation Δx. This is a little more complex in the NMR regime, but can be done using a variation of stratified sampling (see "Methods"). Once done, we can then directly evaluate the efficacy estimator Δγ = γ C − γ avg (see Fig. 1b). Thus, our NMR processor is able to function as an effective quantum efficacy estimator.
This gives us all the tools in place for a quantum-assisted closed-loop learning algorithm. To begin, we generated a random selection of seven control sequences, denoted as C ð0Þ . By evaluating their efficacy using the NMR processor, and feeding results into the Nelder-Mead algorithm, we can systematically produce subsequent populations C ð1Þ , C ð2Þ , …. We emphasize that the entire procedure was fully automated, such that this procedure can proceed ad infinitum without intervention till stopping conditions are met.
In our experiment, we set the stopping condition as g = 25. Figure 3b plots the resulting purity loss of various control sequences in C ðgÞ for each iteration g. Meanwhile, Fig. 3c shows the sliced control sequences along x and y directions for the maximum purity loss in the 1st, 10th, 20th, and 25th iteration. We see these control sequences quickly converge, and the resulting purity loss becomes almost maximal within 10 iterations.
To verify that optimizing purity loss indeed optimizes the efficacy of the probe, we experimentally extracted the best candidate probe state, ρ ðgÞ C , in each iteration from a full three-qubit state tomography 36 (see Supplementary Note 3). The corresponding quantum Fisher information F ðgÞ Q are obtained in Fig. 3b, illustrating the increments in efficacy of the probes closely follow that of increments in purity loss. Moreover, the final quantum Fisher information obtained is 0.9967 ± 0.0014 (statistical results over the last eight iterations), which is very close to the theoretical maximum of 1. Finally, Fig. 3a illustrates candidate probes at various iterations, illustrating how our controls quickly converge on engineering probe states that are maximal coherent with respect the computational basis-the requirement for a probe to be optimal for estimating ϕ.

DISCUSSION
Here, we proposed a quantum-enhanced machine learning protocol for synthesizing effective probes for the purposes of quantum metrology. The protocol enables an automated method to discover what control sequences one should apply to manybody quantum system-in order to steer into a state ideally suited for probing the phase ϕ of some unitary process e ÀiHϕ . We experimentally realized a proof-of-principle experiment using a three-qubit NMR processor, where the device was able to discover control sequences that prepare probe states whose sensitivity to a desired ϕ (as measured by quantum Fisher information) is within 1% of theoretical optimal values. Our numerics indicate that this methodology can remain effective when engineering probes involving a large number of entangled qubits-even when these qubits possess uncontrollable spin-spin interactions.
There are a number of open questions. The first is the issue of noise. One of the benefits of our approach is that it automatically accounts for noise during the control process, and naturally finds the optimal control sequence that accounts for such noise. However, the evaluation of purity loss does require the addition of an extra controlled-SWAP gate, and extra noise introduced at this stage can potentially skew the results. Fortunately, our analysis (see "Methods") demonstrates that the protocol is highly resistant to one dominant source of noise in NMR-dephasing, such that any amount of dephasing noise can be corrected for by repeating our purity estimation protocol by some fixed number that does not scale with the size of the system. Sensitivity to other noise sources needs further investigation, and will likely require full tomographical data of the experimentally realized controlled-SWAP gate to correct.
As with all learning algorithms for solving intractable problems, there are of course caveats. The main one is that our algorithm will not always efficiently find the optimal probe. Like all optimization processes, the Nelder-Mead algorithm can be potentially trapped in local optima. Thus, one particular important line of future study would be the performance landscape of purity loss. In instances where this landscape is not ideal, our techniques can support multiple pathways for modification. Nelder-Mead, for example, could be replaced with genetic algorithms, neural networks, or other means of machine learning [37][38][39] . Meanwhile, there may exist other indicators of efficacy that outperform purity loss in certain settings. Thus, our closed-loop architecture could be modified to incorporate many possible alternative means of quantum-aided probe design.
Meanwhile, there will always be an ultimate limit to such learning algorithms. The reason is that there is a polynomial equivalence between time-complexity in optimal control and quantum gate complexity 40,41 . Coupled with knowledge that most quantum circuits cannot be efficiently decomposed into fundamental gates, this means that the optimal probes can easily lie outside the set of states that can be synthesized through a control sequence with free parameters that grow as a polynomial of N. In such instances, an ideal solution simply does not exist. However, such situations may in fact represent scenarios where such learning protocols are most useful-for its optimization represents all control sequences that can be implemented in some bounded amount of time. As such, the solution presented could be a good approximation for the best quantum probe we can synthesize with limited computation power.

Purity measurement in NMR
To establish the purity of ρ ðgÞ avg , we made use of stratified sampling. Let x k be drawn by the stratified sampling method from the discretized Gaussian distribution with K samples and a variance of (Δx) 2 = 1.0721.
In our experiments, we divided the Gaussian distribution into K = 9 stratas, such that Trðρ xj ρ xk Þ ¼ 1 Hence, estimation of the purity Tr½ðρ ðgÞ avg Þ 2 was achieved by measuring the purity of each term of Trðρ xj ρ xk Þ using the scheme of Fig. 1c, where qubit 2 and 3, respectively, were prepared in ρ xj and ρ xk .

The Nelder-Mead algorithm
The Nelder-Mead algorithm functions by performing a series of geometric transformations on a simplex iteratively to get closer to the optimal control sequence. The simplex is a geometric shape consisting of n + 1 vertices, and each vertex represents a candidate control sequence C i with i = 1, 2, . . . , n + 1. Here, n should be the product of the directions of the control sequence and and its sliced numbers. Note that n is closely related to the number of vertices. Based on the following defined performance function (relate to the efficacy estimator) with respect to each candidate control, namely f ðC i Þ ¼ 1 À Δγðρ Ci Þ, this algorithm attempts to replace the worst vertex by a new better one according to the geometric transformations reflection, expansion, contraction, and shrinkage. X. Yang et al.
Concretely, we describe the procedure of the Nelder-Mead algorithm used in this study.
Step 1: Randomly generate an initial simplex with vertices C 1 ; C 2 ; ; C nþ1 f g and calculate their performance functions The amplitude of C i in each slice is set in the range [−1000, 1000].
Step 2: Sort the vertices so that f(C 1 ) ≤ f(C 2 ) ≤ ⋯ ≤ f(C n + 1 ), calculate the centroid of the best n points by C ¼ P n i¼1 C i .
Step 3: Calculate the reflected point, C r ¼ C þ αðC nþ1 À C n Þ, evaluate the performance function f r = f(C r ), where the reflection factor is set as α = 1.
Step 4: Replace the worst vertex C n + 1 and its corresponding performance function f n + 1 by the generated better one according to one of the following conditions: evaluate its performance f e = f(C e ), where the expansion factor is set where the contraction factor is set as β = 0.5. Let C n + 1 = C c , where δ is the shrinkage factor and set as 0.5. (3b) if f r ≥ f n + 1 , calculate the inside contracted point, where the contraction factor is set as β = 0.5. Let C n + 1 = C c , where δ is the shrinkage factor and set as 0.5.
Step 5: Check the stopping conditions, if not satisfied, change the iteration number with g = g + 1 and continue at Step 2.

Effects of decoherence
Here, we analyze the effect of decoherence in algorithm. This is because our process for benchmarking the efficacy of a control sequence makes use of the same quantum device that will be used to during the actual metrological process. Specifically, each iteration of the learning algorithm can be casted as the following procedures: (A) Synthesize two copies of candidate probe states ρ C corresponding to a candidate control sequence C. (B) Synthesize two copies of the state ρ avg , by first preparing a second pair of copies of the candidate probe state ρ C , and then applying the physical encoding process of parameter ϕ subject to stochastic fluctuations separately to each copy. (C) Estimate the purity loss due to stochastic fluctuations by experimentally measuring the purity of the resulting states from step (A) to step (B). We can now consider the impact of docoherence in each of these three steps. The first thing to note is that decoherence in steps (A) and (B), respectively, represent the intrinsic decoherence of our probe preparation device and that of the physical process it is trying to sense. As such, their inclusion in our learning process is actually desired. That is, as the device that is used to estimate the efficacy of the probes is the device that will eventually be used for metrology, we naturally want all decoherence within this device to be accounted for while benchmarking the efficacy of candidate control sequences. A similar argument also holds for decoherence when applying the physical process, as this decoherence will also exist during sensing.
Given these considerations, the only undesired decoherence is that which occurs during estimation of purity loss (step (C)). This procedure is done via the SWAP test, summarized as follows: (i) Take two copies of ρ C , and one ancillary qubit initialized in state þ j i ¼ ð 0 j i þ 1 j iÞ= ffiffi ffi 2 p . (ii) Apply a controlled-SWAP gate to swap the pair of ρ C , add a Hadmard gate to the ancillary qubit, and measure the expectation value 〈I z 〉 of ancillary control qubit in the I z basis (see Fig. 1c), to estimate Trðρ 2 C Þ. (iii) Repeat the above procedure for ρ avg to estimate Trðρ 2 avg Þ. (iv) The difference Δγ ¼ Trðρ 2 C Þ À Trðρ 2 avg Þ is then used to estimate the efficacy of the control sequence C.
Noise and decoherence during this procedure can affect the accuracy in which we estimate purity loss. In general, its effect is likely nontrivial, and tomography will be needed to work out what noise introduces to 〈I z 〉 so that this error can be corrected for.
In the case of NMR, the dominant source arises from dephasing. This dephasing noise can be described by a non-unitary channel ε i ðρÞ ¼ ð1 À pÞρ þ 4pI i z ρI i z that acts on each qubit seperately, where I i z denotes the angular momentum operator acting on the ith qubit and p is the strength of the dephasing. Following an error analysis similar to that of other NMR experiments that employ controlled gates 42 , we see that this noise does not change the relative order of our purity loss estimates. That is, provided there is a sufficient number of repetitions, our conclusion of which control sequence has greater purity loss between two candidates will not change under dephasing.
In particular, let hI z i p denote the expectation value of I z under dephasing strength p, then our measured purity has expectation value hI z i p ¼ ð1 À pÞ 2 hI z i with variance bounded above by 1. To correctly compare two probe states whose purity loss differs by at most δ requires each purity measurement to have a variance <δ 2 /4 (as differences in purity loss involve four additive purity measurements). This is guaranteed provided we repeat our measurement process of order 4 δð1ÀpÞ 2 times-a overhead of 1/(1 − p) 2 compared to the case where there is no decoherence. Notably, this overhead does not scale with N, and thus the protocol remains efficient. In our experiment, p is~0.025, thus we are able to discern rank control sequences whose purity loss differ by >0.045.