Quantum neural networks (QNN) explained: QNN vs hybrid QNN (HQNN), and how to test whether the quantum layer helps
A quantum neural network (QNN) is a parametrized quantum circuit trained like a neural network: the data sets gate angles, measured expectation values are the output, and a classical optimiser tunes the remaining angles. A hybrid QNN (HQNN) puts that circuit between classical layers and trains everything together, which is how almost every QNN on tabular data is built today. Whether the circuit helps is an empirical question with a direct test: swap it for a classical block of the same width and parameter count and see whether the score drops. In our two runs on public data, with a 5-qubit circuit on a noiseless simulator, it did not, and the same test runs on your own data.
Updated
At a glance
- What a QNN is
- A parametrized quantum circuit used as a trainable model: features become rotation angles, measured expectation values become the output, and an optimiser tunes the other angles.
- What a hybrid QNN (HQNN) is
- A QNN placed between classical layers, usually a linear adapter in front and a linear head behind, with all weights trained together by one optimiser.
- What the circuit can represent
- With angle encoding, a truncated Fourier series in the inputs, whose frequencies are set by how the data is encoded[3].
- What the evidence says
- On small classical datasets, tuned classical models usually win, and removing the entanglement often does not hurt[6].
- How to tell whether the circuit helps
- Replace it with a classical block of the same width and parameter count, train both on the same splits and seeds, and compare the paired scores.
- Our two runs (5 qubits, noiseless simulator)
- On machine-failure and card-fraud data, gradient boosting scored highest, and the classical twin of the circuit scored as well as the hybrid or better: at this size the circuit added nothing measurable.
What a quantum neural network is
The name is an analogy, not a description: there are no neurons in a QNN. It is a circuit of rotation gates and entangling gates on a few qubits, some of whose angles come from the data and some of which are trainable weights. Measuring a Pauli operator on each qubit gives expectation values between −1 and 1, and those numbers are the model's output. Farhi and Neven proposed this kind of model for supervised classification on near-term processors[1], and Mitarai and coauthors described the same loop under the name quantum circuit learning: a classical optimiser adjusts the circuit parameters until the measured output fits the labels[2].
What such a model can learn is decided mostly by the encoding. When each feature enters once as a rotation angle, the model is a Fourier series in the inputs with only the lowest frequencies available; encoding the same features several times, between trainable blocks, widens the spectrum[3]. That repeated encoding is called data reuploading, and with enough of it even a single qubit can in principle approximate any classifier[4]. A large Hilbert space on its own buys nothing: the function class is what the encoding and the measurements allow.
Training uses gradients like any network. On a simulator they are exact; on hardware each gradient is estimated from repeated runs, usually with the parameter-shift rule, so it carries shot noise. Deep or wide random circuits also meet barren plateaus, where gradients shrink exponentially with the number of qubits and training stalls[5]. This is one reason practical QNNs stay at a handful of qubits and a shallow depth.
QNN vs hybrid QNN vs classical neural network
The three are often compared as if they were rivals. In practice the hybrid form is a classical network with a small quantum block inside, and the useful comparison is between that block and a classical block of the same size.
| Pure QNN | Hybrid QNN (HQNN) | Classical neural network | |
|---|---|---|---|
| Where the data enters | Straight into gate angles, usually one qubit per feature | Through a classical layer that maps the features onto the qubits | Into the first linear layer |
| Trainable parameters | Only the circuit's angles | Classical weights plus the circuit's angles; the circuit is usually the smaller part | Weights and biases |
| What limits the function class | The encoding and the depth of the circuit | The classical layers and the encoding | Width, depth and activation functions |
| Cost on a classical computer | Exponential in the number of qubits for exact simulation, small at a few qubits | The same for the circuit, plus the network | Linear in the number of weights |
| Gradients | Exact on a simulator; parameter shift or SPSA on hardware | Backpropagation through the classical part, the same as a QNN for the circuit | Backpropagation |
| Where it is used today | Research on small, often quantum, data | Most published QNN results on tabular, image and time-series data | Everywhere |
Hybrid QNNs in eigenkit, and what eigenkit does not do
eigenkit builds hybrid QNNs as scikit-learn estimators: HQNC classifies, HQNR regresses, and both train the classical and quantum weights together on the built-in simulator. How the pieces fit is described once, on the docs page HQNN: the shared pipeline, and the estimators differ only in what surrounds the circuit (the catalogue). RecurrentHQNC puts an LSTM or GRU in front for sequences, and GenericClassifier trains any PyTorch module you write, which is how the classical twin in the test below is built.
What eigenkit does not ship: a pure QNN estimator with no classical layers (the nearest is CustomQuantumClassifier, whose circuit you give as a list of blocks, still followed by a linear head); an amplitude-encoding hybrid layer out of the box (the built-in layers use angle encoding); and training on hardware as the default path. Gradients on a QPU backend are off unless you set enable_gradients=True, and the documented workflow is to train on a simulator and run the trained model on a QPU.
How to test whether the quantum layer helps: the ablation
A hybrid model can beat a classical baseline because of its classical layers, its input scaling or its training setup, with the circuit contributing nothing. The ablation isolates the circuit. It is the same method as removing a layer from any network to see what it does.
Fix the hybrid network
Write down every layer: adapter, scaling, circuit (qubits, depth, ansatz), head. Count the circuit's trainable parameters. eigenkit's strong ansatz has three angles per qubit per layer, so five qubits at depth 2 hold 30.
Build its classical twin
Replace the circuit with a classical block of the same input and output width and, as far as possible, the same parameter count. For a five-qubit circuit,
Linear(5, 5)followed byTanhhas 30 parameters and returns values in , like a Pauli-Z expectation value. Keep everything else identical.Train both the same way
Same splits, same seeds, same tuning grid, same epochs, same threshold rule. Use several seeds, five at least, because the spread between seeds is often larger than the effect you are looking for.
Compare the pairs, not the means
For each seed, subtract the twin's score from the hybrid's. Report the mean difference with a confidence interval and a paired test. If the interval includes zero, the run has not shown that the circuit helps.
Put strong classical models next to both
Gradient boosting, a random forest and logistic regression, tuned with the same budget. A circuit that beats its twin but loses to boosting is a finding about model design, not a reason to deploy it.
Only then try hardware
Shot noise and gate noise change the circuit's output. Evaluate the trained model on a QPU only after the simulator result is worth keeping.
HQNC, its classical twin and four baselines
import math
import warnings
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from torch import nn
from eigenkit import HQNC, GenericClassifier, MinMaxNorm
from eigenkit.benchmark import compare, quick_baselines
warnings.simplefilter("ignore", UserWarning) # adapter and joblib notices, both expected here
N_FEATURES, N_QUBITS = 30, 5
train = dict(epochs=20, lr=0.01, show_progress=False)
hqnc = HQNC(in_features=N_FEATURES, n_qubits=N_QUBITS, depth=2,
variational_type="strong", n_classes=2, **train)
# The same network with the circuit swapped for Linear(5, 5) + Tanh:
# same width, same 30 parameters, output in [-1, 1] like a Z expectation.
ablation = GenericClassifier(
model=nn.Sequential(
nn.Linear(N_FEATURES, N_QUBITS),
MinMaxNorm(N_QUBITS, min_val=0.0, max_val=math.pi),
nn.Linear(N_QUBITS, N_QUBITS), nn.Tanh(),
nn.Linear(N_QUBITS, 2),
),
in_features=N_FEATURES, n_classes=2, **train,
)
models = {"HQNC": hqnc, "Classical ablation": ablation}
names = ["SVC", "Random forest", "Logistic regression", "kNN"]
models.update(zip(names, quick_baselines()))
models = {name: make_pipeline(StandardScaler(), m) for name, m in models.items()}
result = compare(models=models, dataset="breast_cancer_wisconsin",
metrics=["accuracy", "roc_auc"], n_seeds=3)
print(result.table()) # mean ± std over three splits, one row per modelRuns in a few seconds on a laptop CPU with pip install eigenkit[torch,benchmark]. Breast cancer is easy for every model, so the table shows the method, not a verdict: on the run we checked, logistic regression scored highest on both metrics, and HQNC and its classical twin were within each other's seed-to-seed spread.
Evidence 1: machine failures (AI4I 2020)
Our run on the synthetic AI4I 2020 milling data[7], at the real failure rate of 3.4%, five seeds, test PR-AUC (average precision). The full setup is on the predictive maintenance page.
| Model | PR-AUC | Trainable parameters | Of which in the circuit |
|---|---|---|---|
| HQNC, 5-qubit circuit | 0.587 ± 0.085 | 87 | 30 |
| Classical twin (circuit replaced) | 0.565 ± 0.058 | 87 | 0 |
| Plain MLP of the same size | 0.534 ± 0.087 | 90 | 0 |
| Gradient boosting | 0.782 ± 0.022 | tree ensemble | 0 |
Run hqnn-predictive-maintenance of 2026-11-03, mean and spread over 5 seeds, on AI4I 2020 Predictive Maintenance Dataset (Matzka 2020), target 'Machine failure'. Per seed, HQNC minus its twin is 0.022 ± 0.044 PR-AUC (paired t-test = 0.32), and the 95% interval includes zero: no measurable effect of the circuit. HQNC does beat the plain MLP of its size, but so does its classical twin, so that gain comes from the shape of the pipeline (the bounded block between two linear layers), not from the circuit.
Evidence 2: card fraud at the real fraud rate (OpenML 1597)
Our run on the public card-transaction dataset[8], with validation and test splits at the real fraud rate of 0.17%, five seeds. The full setup is on the fraud detection page.
| Model | PR-AUC | Trainable parameters | Of which in the circuit |
|---|---|---|---|
| HQNC, 5-qubit circuit | 0.731 ± 0.068 | 197 | 30 |
| Classical twin (circuit replaced) | 0.762 ± 0.061 | 197 | 0 |
| Logistic regression | 0.779 ± 0.045 | 31 | 0 |
| Gradient boosting | 0.825 ± 0.031 | tree ensemble | 0 |
Run hqnn-fraud-detection of 2026-11-03, mean and spread over 5 seeds, on creditcard (OpenML 1597): card transactions of European cardholders, September 2013 (Dal Pozzolo, Caelen, Johnson, Bontempi 2015), target 'Class'. Here the classical twin scores higher than the circuit: HQNC minus twin is -0.030 ± 0.041 PR-AUC per seed ( = 0.17). Both runs use a noiseless simulator, so hardware noise could only lower the circuit's score. The two runs side by side, with the backbone variants, are on HQNN vs classical neural network.
What would change this result
Both runs measure one setup: a 5-qubit circuit at depth 2, with each feature encoded once, between classical layers, on an exact noiseless simulator, against tuned classical models on tabular data. The result holds for that setup. Three changes could move it, and the ablation above is how to tell whether one did.
The encoding. With each feature entering once, the circuit can only represent a low-order Fourier series in the inputs[3]. Re-uploading the data between trainable blocks widens that series[4], and eigenkit's Reupload layer is the place to start. Whether the extra capacity helps on your data is what the paired comparison with a classical twin answers.
Width. A wider circuit gives the quantum layer a larger share of the model and more room to differ from a classical block of the same width, but it costs more to simulate, and random wide circuits meet barren plateaus[5]. The barren plateaus page shows how to measure the gradient of your circuit before you train it.
The data. Both datasets are classical and tabular, the setting where a large independent benchmark also found classical models ahead[6]. Data that comes from quantum systems is the case with more theoretical support, and the decision guide explains why and how to test it.
Run it on a real QPU with EigenOrbit RouterThe trained HQNC from either run, scored on its test split on a real QPU, to measure what shot and gate noise cost the circuit.In eigenkit: pip install "eigenkit[router]", then provider=RouterConfig(device=...) (docs).
Questions
What is a quantum neural network in simple terms?
It is a small quantum circuit used as a trainable model. Input features set the angles of some gates, other gate angles are weights, and measuring the qubits gives the output. A classical optimiser adjusts the weights until the output fits the training labels, the same loop as for an ordinary neural network.
What is an HQNN?
HQNN stands for hybrid quantum neural network: a parametrized quantum circuit placed between classical layers, usually a linear layer in front that maps the features onto the qubits and a linear head behind, with all weights trained together by one optimiser. In eigenkit the hybrid classifier is called HQNC and the hybrid regressor HQNR.
What does QNN stand for?
Quantum neural network. In machine learning papers it means a parametrized quantum circuit trained on data. A hybrid QNN, often shortened to HQNN, combines that circuit with classical layers and trains them together.
What is the difference between a QNN and a hybrid QNN?
A pure QNN is only the circuit: features go straight into gate angles and the measured values are the prediction. A hybrid QNN wraps the circuit in classical layers, typically a linear layer that maps many features onto a few qubits and a linear head after the measurement. Almost every QNN applied to real tabular data is hybrid, because the number of qubits limits how many features a pure QNN can take.
Are quantum neural networks better than classical neural networks?
Not on the evidence so far. In a large benchmark of popular quantum classifiers on small datasets, out-of-the-box classical models did better overall. In our own runs on machine-failure and card-fraud data, with a 5-qubit circuit on a noiseless simulator, gradient boosting scored higher than the hybrid quantum classifier, and replacing its circuit with a classical block of the same size did not lower the score. Wider circuits, other encodings and data from quantum systems are where that could change, and the ablation on this page is how to check.
How do I know whether the quantum layer in my model helps?
Run an ablation. Replace the circuit with a classical block of the same width and parameter count, such as a linear layer followed by tanh, keep everything else the same, and train both on the same splits with several seeds. If the paired difference is not clearly above zero, the circuit is not what makes the model work.
Can quantum neural networks run on real quantum hardware?
Small ones can: a few qubits and a shallow circuit fit on today's devices. Training on hardware is slow because every gradient needs many repeated runs, so the usual workflow is to train on a simulator and evaluate the trained model on a QPU, where shot and gate noise lower the score.
Sources
- E. Farhi, H. Neven. Classification with quantum neural networks on near term processors. arXiv preprint, 2018. arXiv:1802.06002.
- K. Mitarai, M. Negoro, M. Kitagawa, K. Fujii. Quantum circuit learning. Physical Review A 98, 032309, 2018. arXiv:1803.00745.
- M. Schuld, R. Sweke, J. J. Meyer. Effect of data encoding on the expressive power of variational quantum machine learning models. Physical Review A 103, 032430, 2021. arXiv:2008.08605.
- A. Pérez-Salinas, A. Cervera-Lierta, E. Gil-Fuster, J. I. Latorre. Data re-uploading for a universal quantum classifier. Quantum 4, 226, 2020. arXiv:1907.02085.
- J. R. McClean, S. Boixo, V. N. Smelyanskiy, R. Babbush, H. Neven. Barren plateaus in quantum neural network training landscapes. Nature Communications 9, 4812, 2018. arXiv:1803.11173.
- J. Bowles, S. Ahmed, M. Schuld. Better than classical? The subtle art of benchmarking quantum machine learning models. arXiv preprint, 2024. arXiv:2403.07059.
- S. Matzka. AI4I 2020 Predictive Maintenance Dataset. UCI Machine Learning Repository, dataset 601, 2020.
- A. Dal Pozzolo, O. Caelen, G. Bontempi. creditcard (credit card fraud detection). OpenML, dataset 1597, 2015.
Run it yourself with eigenkit
eigenkit is EigenOrbit's open-source Python library: write a circuit once, run it on any simulator or QPU, and test it against a classical baseline on your own data before you invest in it or rule it out.
$ pip install eigenkit