QuantumUQ: uncertainty quantification for quantum machine learning
QuantumUQ is an open-source Python library that measures how much you can trust a quantum machine learning model's predictions: shot noise, model uncertainty, calibration and noise sensitivity, with the same interface for Qiskit and PennyLane. It is written by Ferhat Ozgur Catak, MIT-licensed, and listed in the IBM Qiskit ecosystem.
GitHub · PyPI · Documentation · Paper (Nordic Machine Intelligence, 2026)
pip install quantumuq
pip install "quantumuq[aer]" # optional Qiskit Aer support
Worked example: is my quantum classifier's confidence reliable?
A quantum classifier outputs probabilities estimated from a finite number of measurement shots. Two different things can go wrong with them: the estimate can be noisy (too few shots), and the model can be miscalibrated (its confidence does not match how often it is right). The question is which one you have, because more shots only fix the first.
The script below trains QuantumUQ's small reference classifier (2 qubits, 2 layers) on the two-moons dataset in PennyLane, then re-measures the same trained model on 45 test points at 100, 1,000 and 10,000 shots, using ShotBootstrap for measurement uncertainty and ece, brier and nll for calibration.
"""Is my quantum classifier's confidence reliable?
Worked example from https://www.ozgurcatak.net/quantumuq.html
Requires: pip install quantumuq pennylane (tested with QuantumUQ 0.4.1, PennyLane 0.45.1, Python 3.12)
"""
import numpy as np
from quantumuq import wrap_qnode, ShotBootstrap, ece, brier, nll
from quantumuq.benchmarks.datasets import load_moons
from quantumuq.benchmarks.models import train_pennylane_vqc
# 1. Data: two-moons (200 points), subsample 150, 70/30 train/test split, fixed seed
data = load_moons(random_state=0)
rng = np.random.default_rng(0)
keep = rng.choice(len(data.X), 150, replace=False)
X, y = data.X[keep], data.y[keep]
perm = rng.permutation(len(X))
test, train = perm[:45], perm[45:]
# 2. Train QuantumUQ's reference variational classifier (2 qubits, 2 layers) in PennyLane
qnode, params, postprocess = train_pennylane_vqc(X[train], y[train], seed=0)
predictor = wrap_qnode(qnode, task="classification", n_classes=2,
params=params, postprocess=postprocess)
# Cross-entropy cannot tell the two class labels apart, so training may converge
# with them swapped. Detect that once on the training set (as run_benchmark does).
p_train = predictor.with_uq(ShotBootstrap(n_samples=1, shots=1000, seed=0)).predict_dist(X[train]).mean
swap = (p_train.argmax(1) == y[train]).mean() < 0.5
# 3. Re-measure the same trained model at three shot budgets
print(f"{'shots':>6} {'accuracy':>9} {'mean conf':>9} {'ECE':>6} {'Brier':>6} {'NLL':>6} {'shot std':>9}")
for shots in (100, 1_000, 10_000):
dist = predictor.with_uq(ShotBootstrap(n_samples=8, shots=shots, seed=0)).predict_dist(X[test])
p = dist.mean[:, ::-1] if swap else dist.mean
acc = (p.argmax(1) == y[test]).mean()
print(f"{shots:>6} {acc:>9.2f} {p.max(1).mean():>9.2f} {ece(y[test], p):>6.3f} "
f"{brier(y[test], p):>6.3f} {nll(y[test], p):>6.3f} {dist.std.mean():>9.4f}")
Download: quantumuq-reliability-example.py. Runs in about two minutes on a laptop CPU.
Result
ShotBootstrap spread of the predicted probability (lower = more precise)
Gap between confidence and accuracy (lower = more honest)
| Shots | Accuracy | Mean confidence | ECE | Brier | NLL | Shot std |
|---|---|---|---|---|---|---|
| 100 | 0.62 | 0.69 | 0.134 | 0.369 | 0.533 | 0.0405 |
| 1,000 | 0.62 | 0.69 | 0.144 | 0.366 | 0.529 | 0.0118 |
| 10,000 | 0.58 | 0.69 | 0.180 | 0.368 | 0.531 | 0.0035 |
One run on a simulator, QuantumUQ 0.4.1, PennyLane 0.45.1, Python 3.12. Because measurement shots are random, numbers change slightly from run to run; the pattern does not.
How to read it
- More shots make the measurement more precise. The ShotBootstrap spread falls from 0.040 to 0.012 to 0.0035, about a factor of √10 for every tenfold increase in shots, as finite-shot statistics predict.
- More shots do not make the model more honest. The model is 69% confident on average at every shot budget but right only about 60% of the time, so it is overconfident. Calibration error stays between 0.13 and 0.18 and does not improve with shots; the differences between rows are test-set noise.
- What to do about it. A calibration gap is set by training: architecture, data and loss. Spending your hardware budget on more shots will not close it. QuantumUQ measures the gap; correcting it (for example with temperature scaling) is on the library's roadmap.
This is the same distinction my research formalises: how many measurements a quantum model needs before its predictions can be trusted, and what more measurements cannot buy. See measurement-budget allocation with finite-shot generalisation guarantees and the quantum technologies for security page.
What QuantumUQ measures
- Uncertainty methods:
ShotBootstrap(finite-shot measurement uncertainty),DeepEnsemble(model uncertainty across independently trained circuits),NoiseProfile(how predictions vary over repeated measurements and shot settings). - Classification metrics: negative log-likelihood (
nll), Brier score (brier), expected calibration error (ece), predictive entropy. - Regression metrics:
rmse,gaussian_nll. - Backends: PennyLane QNodes, Qiskit samplers and estimators (including V2 primitives), through one
Predictorinterface. - Benchmark suite:
quantumuq-benchmarksweeps shot counts on reference datasets and reports accuracy and calibration, so a paper can cite a fixed benchmark.
Cite QuantumUQ
@article{Catak_2026,
title = {QuantumUQ: A Library for Uncertainty Quantification in Quantum Machine Learning},
author = {Catak, Ferhat Ozgur},
journal = {Nordic Machine Intelligence},
volume = {6},
number = {1},
year = {2026},
publisher = {University of Oslo},
doi = {10.5617/nmi.13217}
}