The applications of quantum-enabled technologies are compelling and already demonstrating significant impacts, especially in the realm of sensing1,2,3,4,5 and metrology6. However, in nearly all applications the phenomenon of decoherence—effectively the randomization of a quantum system’s state by the environment—limits the viability of quantum technologies. In the case of qubits, fundamental building blocks in many applications, the net result is that the useful lifetime of the qubit state is shortened, reducing their deployability for quantum information7, quantum simulation8,9,10,11,12,13 or other applications. Methodologies for stabilising qubits against decoherence represent a critical need in quantum technology.

Control engineering14 techniques are emerging as a promising alternative to engineering passive robustness at the device level in realising stable quantum systems15,16,17,18. Beyond widely adopted open-loop control18,19,20, a qubit subjected to stochastic evolution of its phase degree of freedom—dephasing (inset Fig. 1a )—can be stabilised by cyclically performing measurements on the qubit and then compensating for the measured phase evolution in a feedback loop21,22,23. However, so far, feedback control24,25,26,27,28 has largely been limited by state-collapse under projective measurement, mandating access to weak measurements22 or ancilla states29, or largely sacrificing useful quantum coherence in the controlled system23.

Figure 1: Prediction of the future evolution of a qubit subject to stochastic dephasing.
figure 1

(a) The average, random phase evolution of the qubit during each measurement under the influence of an engineered noise trace, φA, is probed via Ramsey spectroscopy and a projective measurement performed before the qubit state is reinitialised and the process repeated (Supplementary Methods). Time is represented in discrete increments of Δt, approximately corresponding to the measurement time. Values of tk≤0 refer to past measurements used to make predictions and tk>0 refer to future predictions. Noise possesses a quasi-white power spectral density up to frequency cut-off ωc, which we sample at ωs=40ωc. Future qubit evolution is calculated offline based on these measurements. Data labelled ‘n=1*’ correspond to traditional feedback (no prediction). (inset) Bloch sphere representation of randomization of qubit phase. (b) Correlation between φM(tk) and φA(tk) represented as a scatter plot for all measurements in this data set. Ellipses are guides to the eye calculated to have major and minor axis determined by the eigenvectors of the data’s covariance matrix. The Pearson product-moment correlation coefficient, r, is calculated to quantify the quality of the measurements—here 97%. (c) Normalized r.m.s. errors between φA(tk) and φP(tk) as a function of past measurements and discrete steps forward in time, averaged over all elements of the data set. Data are normalized to the lowest overall value in the field and are presented using a logarithmic scale to highlight differences over a broad dynamic range. The first row corresponds to traditional feedback.

Figure 2: Experimental time-division multiplexing for qubit stabilization against dephasing.
figure 2

(a) Schematics showing the key aspects of the implementation. Noise is continuously injected into the system. Measurements are taken up to t0 and processed in real-time to predict future evolution of the qubit phase many time steps ahead, φP(tk). From t0 measurement-free compensation based on φP(tk) is applied during each discrete time step (light green arrows) up to tk when a diagnostic measurement is performed to verify the accuracy of the prediction/correction process. Full details appear in Supplementary Methods. (b) Probe and stabilization cycles of a time-division multiplexed measurement using n=100 past measurements and prediction/correction up to k=50 time steps ahead. Green shading indicates reduced residual phase errors. (c) r.m.s. results from time-division multiplexed measurements for different tk and n compared against traditional feedback and averaged over 50 unique stabilization periods. Data are normalized to the r.m.s. of φA indicated by the horizontal dashed line. The other dotted/dashed lines are simulations. Markers represent the averaged results of diagnostic measurements. For these data ωs=40ωc.

Our objective is to enhance the performance of incoherent feedback stabilization (that is, using only classical information) of a qubit experiencing dephasing while also relaxing the need for projective measurements. Our approach is based on predictive control; a variety of techniques in filtering14,30,31,32 and machine learning33 allow the estimation of future state evolution based on past measurement outcomes of the system. Here, we deploy a well established algorithm from machine learning to learn about a random dephasing process affecting a qubit, and then predict the impact of future dephasing based only on standard projective measurements. We use this information to perform real-time stabilization of the qubit state during periods in which the qubit is unsupervised but still subject to stochastic dephasing. Our method exploits the presence of commonly encountered temporal correlations in the dephasing process34 to allow future prediction; no deterministic model of qubit state evolution is required. To the best of our knowledge, despite its ubiquity in classical settings, predictive control has not been employed in the context of quantum-coherent technologies.


Supervised learning based on qubit-phase measurements

In the language of machine learning, we consider the qubit’s instantaneous phase which we would like to predict at a future discretized time, tk, as labels, φP(tk), and an arbitrary number, n, of previous measurements, φiM (indexed by i and obtained by any appropriate method), as their associated features. We then calculate a linear combination of the features with optimized weighting coefficients, w={w}i,k, as a prediction of the label, . Based on measured features, the entries of w are optimized for each time step, tk, reflecting the time-varying correlations in the dephasing process, captured through the power spectrum.

We demonstrate prediction of a qubit’s state subject to stochastic dephasing by performing experiments using the ground-state hyperfine states, |F=0, mF=0> and |F=1, mF=0>, in trapped 171Yb+ ions as a qubit with transition frequency near 12.6 GHz. A coherent superposition of the qubit states in the measurement basis induced by microwave control35 evolves freely under the influence of an engineered dephasing interaction larger than any intrinsic noise in our experimental system (Supplementary Methods). In general we work in a regime where the noise evolves slowly during a single measurement period TM, but we allow the rate at which measurements of qubit-phase evolution are taken—the sampling frequency ωs—to vary relative to the highest frequency in the noise power spectrum, ωc (c.f. Fig. 3f). The dephasing noise processes presented here are all derived from a flat-top frequency power spectrum with characteristic cut-off at ωc. More complex spectra are discussed in Supplementary Discussion and demonstrate similar performance.

Figure 3: Experimental comparison of long-term stabilization using traditional and predictive feedback.
figure 3

(a) Schematics showing the key aspects of our cyclic feedback implementation using overlapping measurements. (bd) Demonstration of feedback accuracy for different sampling frequencies ωs quantified in units of ωc, presented through correlation plots (c.f. Fig. 1c) for traditional feedback (blue) and prediction (magenta). Data presented are derived from Fig. 1a. (e) Measured sample variance for various protocols as a function of the number of cycles. Data are normalized to the sample variance of the uncorrected (free-running) signal at 1,000 samples. Each line represents data taken for one particular noise realization and thick lines represent the ensemble average. The inset shows an example suppression of variance over measurement outcomes using predictive against traditional feedback (normalized to the noise amplitude). (f) Sample variance at N=1,000 as a function of sampling frequency ωs in units of ωc, normalized to the sample variance of the uncorrected signal. The measurement time is fixed and ωs varied through introduction of dead time between measurements. Dotted lines display simulations and markers the measurement results averaged over ten noise realizations. Error bars represent the s.d. of the mean and the shaded areas show the maximum spread of outcomes. For fixed noise parameters varying ωs serves as a proxy for changing the ratio of (Supplementary Discussion). Simulations and measurements in all panels use n=20.

An important aspect of our approach is that measurements providing data serving as features may be performed through any suitable protocol. For instance, performing a series of p projective measurements on a single qubit to obtain ensemble-averaged information simply sets the scale of the measurement period, , with the duration of a single experiment. Here, we employ a projective measurement that captures statistical information through a spatial ensemble. The impact of such differences is explicitly captured in the sampling frequency of the measurement process.

Forward prediction of stochastic qubit-phase evolution

We begin by accumulating a series of projective measurements of the qubit’s phase under engineered dephasing. These serve as training data for the algorithm to optimize the coefficients in w. We then perform another series of measurements (shown, Fig. 1a) under application of a different noise process possessing similar statistical characteristics as used in acquiring the training data. This approach ensures that our estimates of prediction accuracy are conservative and exhibit reasonable model robustness and generality. Performing the learning algorithm on a single data set can enhance performance of the prediction algorithm but introduces extreme sensitivity to the input model, ultimately reducing prediction efficacy in the presence of variations in the detailed form of the noise.

An example engineered noise trace in time with overlaid measurement outcomes, φM, is depicted in Fig. 1a, with 97% correlation between φM and the applied phase φA (Fig. 1b). Beyond time t0 we predict future labels of qubit-phase evolution φP(tk), up to step t150 using a variable number, n, of past measurements and the trained coefficients in w. Calculated predictions approximate φA well, reproducing key features including inflection points, maxima and minima as a function of tk. Our knowledge of the noise is used exclusively for quantitative evaluation of prediction efficacy—it does not enter into the machine-learning algorithm in any form.

Prediction accuracy increases with n, as the algorithm learns more about the temporal correlations in φA. For values of kn, corresponding to prediction times exceeding the range over which the algorithm possesses knowledge about the noise features, the prediction quality diminishes. In addition, over very large values of tk the prediction tends towards the mean of the noise. Comparing predictive estimation to a ‘traditional feedback’ model, in which future estimates are based simply on the last measured value φM(t0), the algorithm shows a distinct advantage as it allows for temporal evolution of the noise in the future.

The quantitative benefits of predictive estimation relative to traditional feedback, and the large tk behaviour of the predictive algorithm are succinctly captured in the root-mean-square (r.m.s.) prediction error averaged over the entire data set, , and calculated as a function of tk and n (Fig. 1c). This demonstrates that even over a large ensemble of predictions the algorithm’s advantages remain robust. We now move on to provide examples of real-time qubit stabilization in which the incorporation of future state prediction shows significant advantages over existing techniques.

Time-division multiplexed decoherence suppression

As described above, a reliance on feedback involving frequent projective measurements renders a qubit effectively useless for quantum information or other applications, but omission of stabilization techniques in the presence of dephasing noise may lead to phase errors and eventually to total decoherence. To mitigate the effect of dephasing, we tailor an approach in which we temporally multiplex the necessary measurement and actuation operations in distinct probe and stabilization periods respectively (Fig. 2a,b). During the probe period, a fixed number of measurements are taken and processed in real time. From these measurement outcomes the algorithm produces a prediction of the future time-dependent evolution of the noise during the subsequent stabilization period up to some tk; the qubit is dedicated exclusively to measurement of the dephasing process in the probe period. During the stabilization period, corrections are applied during each discrete time step to compensate the predicted stochastic phase evolution, but no measurements are conducted; this permits periods of unsupervised evolution during which the qubit is useful and stabilised against dephasing.

As an example we set the objective of maintaining zero net qubit-phase accumulation (in the rotating frame) during each time step of the stabilization period such that arbitrary high-fidelity operations may be conducted on the qubit; here we apply only the identity. Diagnostic measurements are performed after a variable number of corrections to demonstrate the efficacy of this approach but would not ordinarily be required. Two representative S probe/stabilization cycles are displayed in Fig. 2b showing a reduction in integrated phase error of about 70% after a stabilization delay of t50 during the first cycle and a reduction of about 85% during the second. These improvements are partially limited by measurement fidelity, as illustrated in the ensemble-averaged data (Fig. 2c). Predictive compensation in all tested regimes is superior to corrections based only on traditional feedback down to measurement fidelity limits. Compared against numerical simulations we see that for small tk the algorithm can provide large relative gains.

Predictive estimation inside a periodic feedback loop

In a second application we employ real-time predictive control in a metrological context. Qubits realised in atoms are frequently used as stable references against which local oscillators (LOs) may be disciplined36. However, stochastic evolution of the LO frequency between interrogations leads to imperfect corrections in the feedback loop. This scenario is commonly encountered when classical processing, actuation and system reinitialisation introduce dead time, producing an effective lag in the feedback loop which degrades the long-term stability of the locked oscillator37. The impact of rapid fluctuations in the LO frequency relative to dead time is generally referred to as the Dick effect38, and represents a significant limiting phenomenon in passive frequency standards using atomic references. The correspondence between LO-induced instabilities in frequency references and dephasing in qubits39 thus invites the application of predictive control in a setting where periodic interrogation and projective measurement are native to the feedback loops used in precision frequency metrology.

The usefulness of predictive estimation in improving correction accuracy inside a feedback loop is demonstrated in Fig. 3b–d, where we plot the predicted phase φP(tk) (based on two different techniques) against the applied phase error φA(tk). A prediction with unity correlation to the applied noise would form a diagonal line along φP=φA (similar to Fig. 1b), while imperfect predictions—hence imperfect corrections—result in a dispersion of points around this line in an ellipse.

We vary the sampling frequencies ωs as a proxy for introducing a variable dead time in the feedback loop (Supplementary Discussion). In a regime where the LO-induced dephasing process evolves slowly, quantified as ωsωc, both φM(t0) and the predicted phase φP(tk) show positive correlation to φA(tk) (Fig. 3b). As we decrease ωs, noise evolution during the dead time leads to diminishing correlation between the prediction and actual noise, causing the ellipses to rotate and broaden—a manifestation of the Dick effect.

Predictive estimates are compared with the traditional feedback model described above. For ωs approaching the Nyquist limit we observe that the traditional prediction can become anticorrelated with the rapidly evolving applied noise (blue ellipse, Fig. 3d), which in real-world applications would lead to an unstable system under feedback. By contrast, using optimized predictions, the decrease in correlation is much slower and the machine-learning algorithm prevents the prediction from ever becoming anticorrelated with the applied dephasing noise. In circumstances tested we always find the optimal prediction correlation rP>rT for traditional feedback. Corrections used to discipline the qubit or LO based on predictive estimation can therefore possess enhanced average accuracy relative to traditional feedback.

We now implement real-time evaluation of φP(tk) inside a feedback loop, demonstrating the ability to improve the individual corrections and ultimately achieve improved long-term stability of the locked qubit. In our experiment we set n=20, calculate φP(tk) on the fly, and cyclically correct based on these predictions (Fig. 3a), again comparing against traditional feedback. The long-term stability achieved under both methods is calculated via the sample variance40 over a variable number of feedback cycles (Fig. 3e).

Over the range of dead times explored experimentally, the use of optimized predictive feedback, in which future estimates are updated as new measurements are acquired in real time, yields net enhancements over the free-running LO (Fig. 3e,f). This includes regimes near the Nyquist limit where rapid evolution of the noise can result in feedback-induced instability as in Fig. 3d. Over most of this range and for the noise parameters we have employed, performance gains over traditional feedback are 2 × using optimized predictive feedback—a metrologically significant improvement using only enhanced software in the stabilization. Similar performance enhancements have been observed for a wide range of noise spectra and parameters (Supplementary Discussion).

Predictive estimation applied to intrinsic system noise

Finally, with quantitative evaluation of these techniques in hand using engineered noise, we move on to a study of the intrinsic dephasing noise in our system, which arises due to a combination of LO phase noise and magnetic field fluctuations. We perform thousands of sequential projective measurements on the free-running qubit–LO system and process predictions offline. The spectrum of measured fluctuations combines a 1/f2 type low-frequency tail with an approximately white plateau, resulting in significant spectral weight near the measurement cycle time. We perform an analysis similar to that presented in Fig. 1, with prediction accuracy quantified using the r.m.s. error between predictions and the future measurement outcomes as a function of tk (Fig. 4a).

Figure 4: Application of predictive qubit state estimation to intrinsic system noise.
figure 4

(a) r.m.s. errors between predictions, φP and actual values φ(A) for various numbers of past measurements and discrete steps forward in time, averaged over the whole set of validation data. The r.m.s. values are normalized to the r.m.s.d. of the uncorrected data from zero. The bottom row (1*) corresponds to traditional feedback. (b) Sample variance of the corrected measurements averaged over 5,000 cycles, as a function of past measurements used for prediction, normalized to the sample variance of the uncorrected system. The expected sample variance obtained by performing traditional feedback is added for comparison. Data are split into two subsets, where the first 70% serve for training purposes and the remaining 30% are used for validation. (Inset) Power spectrum of a series of projective measurements on the free-running qubit–LO system. The data is overlaid with a smoothed version to visualize the general trend. The maximum frequency in the spectrum corresponds to our sampling frequency and is about 1.7 Hz.

Our machine-learning algorithm enhances the prediction of future qubit evolution by 30% relative to the r.m.s. error of the uncorrected measurements. We achieve similar performance gains relative to both traditional feedback and the free-running system in calculated sample variance over thousands of correction cycles based on predicted qubit phase, Fig. 4b. In this case the rapid evolution of the noise causes traditional feedback to produce a larger sample variance than free evolution—a situation similar to that experienced in Fig. 3d. The calculated performance enhancements of our method on the intrinsic system noise are significant and show that our algorithm possesses the capability to improve the stability against the noise background in our system.


In this work we have demonstrated the ability to deploy machine-learning techniques to predict and pre-emptively compensate for stochastic qubit dephasing. By exploiting temporal correlations in noise processes, we are able to suppress dephasing during periods when probing the qubit state is not possible, even though we have no deterministic model of the qubit’s evolution. Implementing this approach requires neither additional quantum resources nor extra experimental hardware. Instead we rely on software-based machine-learning techniques, which extract optimal performance from information that would have already been collected during common experimental implementations. It has been shown numerically that it is possible to implement an analytical solution to maximally exploit noise correlations captured through the noise power spectrum41. However in our experimental demonstration the ease of implementation lends itself to use for large values of k and n where prediction is extended far into the future and the computational requirement of large matrix inversions make analytic techniques impractical. In addition, deviations from the idealization of noise characteristics represented by use of a simple power spectral density, as well as correlations appearing in the measurement process, are easily captured by the machine-learning algorithm but invisible to such analytic approaches.

The capability to suppress errors in quantum systems undergoing stochastic evolution has direct implications for the metrology and quantum information communities. In particular the ability to suppress the magnitude of residual dephasing errors makes this technique an attractive complement to open-loop dynamic error suppression for quantum information. Any reduction in the strength of the effective noise experienced by the qubit exponentially improves the fidelity of an operation implemented using dynamic error suppression20. Even in the limit of quasi-static noise, reducing the magnitude of the dephasing error experienced during a dynamically protected operation will improve the ultimate fidelity achievable in a nontrivial quantum logic operation42. The complementarity between open- and closed-loop stabilization is a common theme in control engineering and translates well to the current setting. Future experiments will involve an expansion to a greater variety of machine-learning algorithms for system characterization and stabilization, and treatment of more complex control scenarios with non-commuting noise terms in the qubit Hamiltonian, nonlinearities in the control, and use of various measurement bases.

Data availability

Data published in this article and the computer code used for simulation is available from the authors.

Additional information

How to cite this article: Mavadia, S. et al. Prediction and real-time compensation of qubit decoherence via machine learning. Nat. Commun. 8, 14106 doi: 10.1038/ncomms14106 (2017).

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