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

Measurement uncertainty
ShotBootstrap spread of the predicted probability (lower = more precise)
Measurement uncertainty: 0.0405, 0.0118, 0.0035 at 100, 1,000 and 10,000 shots0.000.010.020.030.040.051001,00010,000measurement shots per prediction100 shots: 0.04051,000 shots: 0.011810,000 shots: 0.00350.04050.0035
Calibration error (ECE)
Gap between confidence and accuracy (lower = more honest)
Calibration error (ECE): 0.134, 0.144, 0.180 at 100, 1,000 and 10,000 shots0.000.050.100.150.201001,00010,000measurement shots per prediction100 shots: 0.1341,000 shots: 0.14410,000 shots: 0.1800.1340.180
ShotsAccuracyMean confidenceECEBrierNLLShot std
1000.620.690.1340.3690.5330.0405
1,0000.620.690.1440.3660.5290.0118
10,0000.580.690.1800.3680.5310.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

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

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}
}