Quantum Machine Learning
Quantum machine learning uses quantum states, circuits or measurements to learn from examples. A circuit can estimate a similarity between inputs, produce a classification score, generate samples, or process quantum systems whose information has not yet been reduced to classical measurement records. These are different learning problems. Their usefulness depends on what the input contains, how it is supplied, which prediction is needed and how well the learned model performs on new examples.
This page develops kernels, variational classifiers and Born models through small calculations. It separates three questions: can the model represent a useful predictor, can training find it, and does it generalize? Conditional quantum speedups and classical simulation results address particular tasks; neither settles all three questions for an arbitrary dataset.
Helpful background. Algorithmic primitives explains coherent input access and measurement outputs; variational algorithms introduces parameterized circuits and gradients; and random variables supplies expectations and independent sampling.
Quantum learning and the predicted quantity
Section titled “Quantum learning and the predicted quantity”Let have a distribution . A supervised learner uses examples to choose a predictor from a family . A loss specifies what counts as a good prediction. A class label, a real-valued score and an estimated class probability are different outputs: the same circuit can support each, but the decision rule and loss change.
Other tasks have other outputs. A generative model may supply samples without efficiently evaluating their probabilities. A quantum-state learner may predict a few observables without reconstructing a density matrix. Producing a quantum state does not automatically give a classical list of its amplitudes. This distinction matters because reading a long output can remove a saving in an intermediate calculation. Biamonte and collaborators survey the main model families Biamonte et al. (2017).
For ordinary prediction, training examples determine the fitted parameters; validation examples help choose such features as the encoding or regularization; fresh test examples estimate the selected model’s performance. Using test outcomes to tune the model makes those outcomes part of training or selection. Independent testing is then needed again. Measurement shots estimate a circuit expectation; new labeled examples estimate performance across a population. More shots on the same examples do not replace more examples.
Classical features and quantum input access
Section titled “Classical features and quantum input access”The word data can refer to resources that support very different operations.
| Input supplied | What the learner can do | What still takes work |
|---|---|---|
| Explicit classical array | Read, copy and preprocess entries | Reading the array and preparing its quantum encoding |
| Classical samples | Draw examples from a distribution | Obtaining enough examples; arbitrary entry queries need additional access |
| Reversible value oracle | Query values coherently, such as | Constructing the memory or circuit, finite precision and each invocation |
| Amplitude preparation unitary | Prepare ; use its inverse if available | Normalization, synthesis and repeated executions |
| Copies of an unknown quantum state | Measure available systems, jointly if permitted | Preparing or transmitting copies and retaining quantum coherence |
Copies of do not supply an implementation of its preparation unitary or inverse. Similarly, separate measurements of incoming systems do not supply a quantum memory that can later perform joint measurements. Such distinctions are assumptions in an algorithm, not interchangeable ways of describing its input. See quantum oracles.
An amplitude encoding of a nonzero vector is
Padding unused basis states permits qubits. However, an arbitrary pure state has real parameters after normalization and global phase. With ordinary gates acting on a bounded number of qubits, generic exact preparation cannot have a gate count logarithmic in : a short circuit has too few independent parameters. Specially structured families can be much cheaper. Shende, Bullock and Markov discuss general synthesis; Grover and Rudolph give a construction for efficiently integrable distributions Shende et al. (2006), Grover and Rudolph (2002).
The encoding also discards information. Vectors and , for any nonzero complex scalar , give the same density operator. A predictor given only these amplitude states cannot distinguish their norms or global phases. If a label depends on , that norm must be supplied separately or encoded in another way. This is an information loss, even with perfect gates and unlimited training.
Basis and angle encodings
Section titled “Basis and angle encodings”Basis encoding stores a discrete input as a computational-basis string; continuous features require quantization. Angle encoding places features in rotations. For example,
Its density operator is periodic in with period . Thus and cannot have different labels if this state is the learner’s only input. Rescaling and restricting the input domain are consequential model choices.
Repeated encoding, called data re-uploading, trades circuit depth for more expressive dependence on the input. One-qubit constructions can approximate rich classifiers, but this is a statement about the available family, not about how quickly training reaches a useful member Pérez-Salinas et al. (2020). Entanglement can enrich a feature map while making its useful similarities harder to resolve. The relevant question is which distinctions in the data remain measurable and help predict the label.
Quantum kernels as measurable similarities
Section titled “Quantum kernels as measurable similarities”A feature map associates each input with a density operator . Define the Hilbert–Schmidt kernel
For pure features this is . For general mixed states it is not Uhlmann fidelity: for instance, , whereas a state’s fidelity with itself is one. The pure-state overlap construction and its relation to classical feature spaces are developed by Schuld and Killoran and by Havlíček and collaborators Schuld and Killoran (2019), Havlíček et al. (2019).
The training Gram matrix is positive semidefinite. For complex coefficients , let . Then
This property lets a classical kernel method fit the predictor after the quantum device supplies similarities. For example, kernel ridge regression with regularization has a solution
Here the objective is ; the unnormalized sum convention fixes the definition of . Differentiating gives , which the displayed coefficients satisfy. If is singular, coefficients can be nonunique but the corresponding fitted function is unchanged by a null-space component. The regularizer makes this classical fit well behaved; it does not make the quantum similarities cheap to obtain.
Estimation noise and new inputs
Section titled “Estimation noise and new inputs”A SWAP test on independent preparations of and gives
For independent ancilla measurements, Hoeffding’s inequality gives
For estimated entries, using for each suffices to make all errors at most with probability at least , by a union bound. With exact pure-state preparation the diagonal is known to be one, so only training entries need estimation; mixed-state purities need not be known. Each new prediction generally needs additional similarities to the training inputs. Finite-shot overlap estimates can even be negative, although the true density-operator overlap is nonnegative.
Symmetrizing a noisy matrix and removing negative eigenvalues can stabilize fitting. It does not automatically define consistent similarities for new inputs. For example, a training matrix is positive, but appending a purported normalized feature with overlaps gives
It cannot be a Gram matrix. Predicting with such estimates is still a possible numerical procedure, but the exact kernel interpretation has been lost. A consistent explicit feature representation, or a specified extension of a repaired matrix to new inputs, addresses a different problem from repairing the training matrix alone.
Local features and the information they omit
Section titled “Local features and the information they omit”One alternative is a projected kernel,
where denotes a chosen reduced state. This is a Gaussian kernel on a vector of local matrix entries. Even estimated entries produce a positive Gram matrix if each input is assigned one common feature vector and all pairs use those vectors. Independent pairwise estimates lack that automatic guarantee.
Local features can be easier to measure, but may remove the target signal. The orthogonal Bell states have identical one-qubit reduced states. Their global pure-state overlap is zero, while a kernel using only their individual-qubit reductions is one. No classical fit can recover the missing sign from those features alone.
Some global kernels concentrate near a common value as system size grows, making relevant differences expensive to measure. Thanasilp and collaborators prove such results under specified expressivity, entanglement, measurement or noise conditions; they are not a theorem that every quantum kernel fails Thanasilp et al. (2024).
Variational classifiers and two meanings of error
Section titled “Variational classifiers and two meanings of error”A parameterized quantum channel produces . In the unitary case, . For a Hermitian observable , define
The positive operators , for , form a binary POVM. If its outcome itself is the predicted label, then
Thus this linear loss is exactly the expected error of the stochastic measurement classifier. It is not the error of a deterministic rule such as . The latter estimates an expectation from many shots and then applies a threshold, with a specified tie rule. A score on a positive example gives stochastic error and ideal zero-threshold deterministic error zero. Finite shots can still cause the estimated score to cross the threshold.
The Born probability is also not automatically a calibrated class probability: among examples assigned probability for the positive class, the fraction with a positive label should be approximately . This must be checked separately. Thresholds, encodings and regularizers are chosen using training or validation data, before final testing.
Worked classifier: fitting two points and predicting three
Section titled “Worked classifier: fitting two points and predicting three”Prepare and measure . Direct multiplication gives . Take the two training examples and and the population uniform on those examples plus . Use the stochastic loss above. Both training losses equal ; the middle population loss is . Consequently,
The training minimum is at modulo . It has zero training loss but population loss . The best population angle is instead modulo , giving . Training did not include the middle example and therefore optimized a different average.
Exact expected errors of the stochastic measurement classifier. The dashed curve averages two training examples; the solid curve averages the three-point population. Their distinct minima arise from which examples are included, with no shot noise or optimizer failure. The training set here is chosen deterministically, so this calculation is not a probabilistic generalization guarantee.
At ,
The deterministic classifier using the signs of the same exact scores instead has training error zero and population error . Reporting one of these errors while implementing the other classifier would be incorrect.
Generalization and measurement precision
Section titled “Generalization and measurement precision”For a fixed predictor, population risk is ; empirical risk is the average over the observed training examples. Suppose the examples are iid, the loss is in , and the finite class is fixed independently of the sample. Hoeffding’s inequality and a union bound give, simultaneously for all with probability at least ,
Because the statement holds for the whole class, it also holds for a member selected using the training data. For a single predictor fixed independently of the evaluation sample, error tolerance and failure probability , the sufficient count is . This is a count of independent examples, not shots on one example. If itself is estimated from finite-shot circuit means, its additional estimation error must be included.
Continuous circuit families require a capacity bound rather than substituting an infinite class size into this expression. For fixed encodings, bounded observable losses and independently parameterized channels acting on a bounded number of qubits, Caro and collaborators obtain representative high-probability scaling
If each channel is reused at most times, the corresponding scaling is , with constants and confidence terms suppressed. The number of independent trainable channels and the number of uses are different. Architecture selection also requires its own capacity term Caro et al. (2022).
A small gap does not ensure small risk if the training risk is large. These bounds also do not guarantee optimization, calibration or good predictions after the input distribution changes. Class imbalance can make overall accuracy misleading; class-specific errors and calibration answer additional questions.
Resolving a gradient
Section titled “Resolving a gradient”For a parameter appearing once in a Pauli rotation, the parameter-shift rule is
With independent outcomes in at each shift, . Thus is a sufficient worst-case condition for a signal of magnitude to be at least estimator standard deviations. It is not a necessary count, nor does “three standard deviations” itself imply a Gaussian tail probability.
A distribution-free alternative follows by applying Hoeffding to the independent weighted outcomes. For nonzero ,
These estimates concern measurement of a particular gradient. A small gradient may reflect a stationary point, an unsuitable encoding, or concentration under specific ansatz/noise assumptions. It does not by itself establish a barren plateau or poor generalization. The more general shift rules and trainability conditions are explained in variational algorithms.
A three-point kernel calculation
Section titled “A three-point kernel calculation”For and , the overlap is . Hence
Its antisymmetric eigenvector has eigenvalue one; the symmetric subspace gives . All eigenvalues are positive and their product is . The corresponding SWAP probabilities are , or .
For pure one-qubit states, . The projected kernel with therefore has neighboring entries and endpoint entry . Its determinant is
To turn a similarity matrix into a predictor, give the three inputs labels . With , kernel ridge regression gives
All three fitted signs are correct, although regularization keeps the scores away from the labels. This finite fit says nothing yet about new examples. The following NumPy calculation also evaluates one new point:
import numpy as np
x = np.array([0.0, np.pi / 4, np.pi / 2])states = np.array([[np.cos(t), np.sin(t)] for t in x])K = np.abs(states @ states.T) ** 2y = np.array([1.0, -1.0, 1.0])a = np.linalg.solve(K + 0.5 * np.eye(3), y)x_new = np.pi / 8state_new = np.array([np.cos(x_new), np.sin(x_new)])k_new = np.abs(states @ state_new) ** 2print(K @ a) # [3/7, -2/7, 3/7]print(k_new @ a) # (6 - 5*sqrt(2))/14This small feature map is easy to compute classically. Its purpose is to show exactly where state preparation, overlap measurement and classical fitting enter a kernel method.
Born models and learning from quantum systems
Section titled “Born models and learning from quantum systems”A quantum circuit Born model defines
Measurement supplies samples from ; it need not give an efficient exact evaluation of . A loss based on samples makes different demands from a likelihood requiring those probabilities. Coyle and collaborators study an Ising Born machine and conditional sampling hardness; hardness of sampling does not ensure that training finds a useful target distribution Coyle et al. (2020).
For a concrete two-qubit model, apply on the first qubit, then a CNOT from the first to the second. The state is . It has , and zero probability on . For a target uniform on , maximum mean discrepancy with the delta kernel reduces to
At the loss is and its derivative is ; at the generated distribution matches the target. Sampling a complicated state is unnecessary for this task.
Quantum data can create a different opportunity. A learner retaining quantum systems can perform joint measurements that are unavailable after every system has been separately measured and discarded. Huang and collaborators prove exponential sample separations for specified learning-from-experiments tasks under such access assumptions Huang et al. (2022). Related results distinguish predicting well on average under a fixed input distribution from predicting uniformly well on every input; the latter can require very different resources Huang, Kueng and Preskill (2021). These are statements about the permitted quantum experiments, not automatic speedups for a classical table of features.
When quantum computation changes learning cost
Section titled “When quantum computation changes learning cost”Hard simulation of a feature state does not imply hard prediction of its labels. A classical learner may exploit a few observable features, labels, low-rank structure or the geometry of the data without reconstructing the state. This distinction is central to the analysis of Huang and collaborators Huang et al. (2021).
Dequantization replaces a quantum subroutine with a classical algorithm under specified assumptions. Tang’s recommendation algorithm uses classical sample-and-query access analogous to the strong data access in the quantum proposal; it changes the comparison for that task, not for every learning problem Tang (2019). Rank, conditioning, approximation error and the requested output still matter. Conversely, Liu, Arunachalam and Temme construct a classical-data classification problem with a quantum kernel speedup conditional on the hardness of discrete logarithms Liu et al. (2021). The positive and negative results concern different assumptions and can both hold.
For a practical comparison, include input preparation, all training attempts, measurement repetitions and classical fitting. Separate training cost from the cost of another prediction:
A training advantage can differ from an inference advantage after many uses. State-preparation setup is similarly amortized only over the uses actually made. Noise can bias features or scores; mitigation may reduce bias while increasing sampling cost. Comparing methods at the same prediction error is more informative than comparing qubit counts alone.
Useful comparisons include simple predictors, well-tuned classical models and methods that exploit known structure. Bowles, Ahmed and Schuld discuss how model selection and classical baselines affect QML benchmarks Bowles et al. (2024). For experimental comparisons see algorithmic benchmarking; for changing research questions see quantum machine-learning frontiers.
Exercises
Section titled “Exercises”1. Information lost in an amplitude encoding
Section titled “1. Information lost in an amplitude encoding”An encoder supplies only the amplitude states of and , with labels and , respectively. Can any measurement classifier distinguish them? What is the minimum average error with equal prior probabilities? Explain why the number of qubits also does not determine generic loading time.
Solution
Both density operators are the same, because normalization removes the factor two. Every POVM has identical outcome probabilities on them, even with any fixed number of copies. With equal priors the minimum error is . The norm or some other distinguishing feature must be supplied to solve this task. Separately, qubits can hold amplitudes, but an arbitrary complex pure state has real parameters. Generic exact loading with bounded-size gates requires enough adjustable parameters to describe that family; logarithmic width does not give logarithmic preparation cost.
2. A positive training matrix and an impossible new feature
Section titled “2. A positive training matrix and an impossible new feature”Prove is positive semidefinite. Then show that appending with self-overlap one to is inconsistent with any Gram representation, despite all entries lying in .
Solution
For , . The proposed extended matrix has eigenvalues ; the last is negative. Its determinant is . Thus valid individual ranges and a positive training matrix do not guarantee globally compatible similarities. Independent finite-shot errors must be considered at prediction time as well as fitting.
3. Stochastic and deterministic classifier errors
Section titled “3. Stochastic and deterministic classifier errors”For the one-qubit worked classifier at , calculate training and population risks for both the single-shot measurement label and the sign of the exact expectation. Find the angles minimizing the stochastic training and population risks.
Solution
The stochastic risks are and . The exact scores on the three inputs are ; only the middle example has the wrong sign. Deterministic training error is therefore zero and population error is . The training minimum is at modulo . Since , the population minimum is at modulo , with value . These results use the explicitly chosen finite distribution, not an iid generalization theorem.
4. A two-qubit generator
Section titled “4. A two-qubit generator”Derive the state obtained by on qubit zero followed by , starting at . For a target uniform on , derive its delta-kernel squared MMD and evaluate the loss and derivative at .
Solution
The rotation gives ; CNOT changes the second term to . The two probabilities sum to one. Hence
At it is ; differentiation gives there.
5. A uniform generalization bound
Section titled “5. A uniform generalization bound”For a fixed class of 20 predictors, iid examples, losses in , and , calculate the uniform gap bound. What follows if the training-selected predictor has empirical risk ?
Solution
The gap is . With probability at least over the training sample, every predictor obeys the bound, so the selected predictor has . This assumes the exact bounded losses used in the theorem; finite-shot estimates add their own error. The bound applies to the same population distribution. Without a further assumption, it gives no bound after an arbitrary distribution shift.
6. Gradient precision and a sign error bound
Section titled “6. Gradient precision and a sign error bound”Two independent shifted means use shots each with outcomes in . For a gradient magnitude , find a sufficient worst-case count for three standard deviations of separation. Separately find a count ensuring wrong-sign probability at most using the stated Hoeffding bound.
Solution
The variance criterion gives shots per shift, or 22500 preparations in total. It does not itself assign a Gaussian tail probability. The distribution-free sign bound gives , whose ceiling is 7490 per shift. These are two different sufficient criteria. A smaller actual variance can reduce the count, while bias or dependent samples would require a different analysis.
7. Amortizing training cost
Section titled “7. Amortizing training cost”In common units, method Q costs and method C costs for predictions. When is Q cheaper? If every Q prediction additionally requires input loading costing four units, does the crossover survive?
Solution
Without the extra loading, Q is cheaper when , or . At 3300 the costs are equal. Including loading gives Q cost , which exceeds for every . The prediction count and which operations must be repeated determine whether amortization helps.
8. A distinction invisible to local kernels
Section titled “8. A distinction invisible to local kernels”For , calculate the global overlap kernel and the projected kernel using both one-qubit reduced states. Can a classifier using only those local features identify the sign?
Solution
The global states are orthogonal, so . Tracing out either qubit gives for both signs. Every reduced-state distance vanishes, hence . The local feature vectors are identical and cannot distinguish the signs. A joint observable can: has expectation on and on .
References
Section titled “References”- J. Biamonte, P. Wittek, N. Pancotti, P. Rebentrost, N. Wiebe, and S. Lloyd, “Quantum machine learning,” Nature 549, 195–202 (2017), doi:10.1038/nature23474.
- J. Bowles, S. Ahmed, and M. Schuld, “Better than classical? The subtle art of benchmarking quantum machine learning models,” arXiv:2403.07059 (2024), doi:10.48550/arXiv.2403.07059.
- M. C. Caro, H.-Y. Huang, M. Cerezo, K. Sharma, A. Sornborger, L. Cincio, and P. J. Coles, “Generalization in quantum machine learning from few training data,” Nature Communications 13, 4919 (2022), doi:10.1038/s41467-022-32550-3.
- B. Coyle, D. Mills, V. Danos, and E. Kashefi, “The Born supremacy: quantum advantage and training of an Ising Born machine,” npj Quantum Information 6, 60 (2020), doi:10.1038/s41534-020-00288-9.
- L. Grover and T. Rudolph, “Creating superpositions that correspond to efficiently integrable probability distributions,” arXiv:quant-ph/0208112 (2002), arXiv:quant-ph/0208112.
- V. Havlíček, A. D. Córcoles, K. Temme, A. W. Harrow, A. Kandala, J. M. Chow, and J. M. Gambetta, “Supervised learning with quantum-enhanced feature spaces,” Nature 567, 209–212 (2019), doi:10.1038/s41586-019-0980-2.
- H.-Y. Huang, M. Broughton, J. Cotler, S. Chen, J. Li, M. Mohseni, H. Neven, R. Babbush, R. Kueng, J. Preskill, and J. R. McClean, “Quantum advantage in learning from experiments,” Science 376, 1182–1186 (2022), doi:10.1126/science.abn7293.
- H.-Y. Huang, M. Broughton, M. Mohseni, R. Babbush, S. Boixo, H. Neven, and J. R. McClean, “Power of data in quantum machine learning,” Nature Communications 12, 2631 (2021), doi:10.1038/s41467-021-22539-9.
- H.-Y. Huang, R. Kueng, and J. Preskill, “Information-theoretic bounds on quantum advantage in machine learning,” Physical Review Letters 126, 190505 (2021), doi:10.1103/PhysRevLett.126.190505.
- Y. Liu, S. Arunachalam, and K. Temme, “A rigorous and robust quantum speed-up in supervised machine learning,” Nature Physics 17, 1013–1017 (2021), doi:10.1038/s41567-021-01287-z.
- A. Pérez-Salinas, A. Cervera-Lierta, E. Gil-Fuster, and J. I. Latorre, “Data re-uploading for a universal quantum classifier,” Quantum 4, 226 (2020), doi:10.22331/q-2020-02-06-226.
- M. Schuld and N. Killoran, “Quantum machine learning in feature Hilbert spaces,” Physical Review Letters 122, 040504 (2019), doi:10.1103/PhysRevLett.122.040504.
- V. V. Shende, S. S. Bullock, and I. L. Markov, “Synthesis of quantum-logic circuits,” IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 25, 1000–1010 (2006), doi:10.1109/TCAD.2005.855930.
- E. Tang, “A quantum-inspired classical algorithm for recommendation systems,” in Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, 217–228 (2019), doi:10.1145/3313276.3316310.
- S. Thanasilp, S. Wang, M. Cerezo, and Z. Holmes, “Exponential concentration in quantum kernel methods,” Nature Communications 15, 5200 (2024), doi:10.1038/s41467-024-49287-w.