QuantumUQ
QuantumUQ -- Uncertainty Quantification for Quantum Machine Learning
Measure shot noise, epistemic uncertainty, calibration, and noise sensitivity in PennyLane and Qiskit models.
pip install quantumuq
Predictive entropy falling as shot count increases, measured identically
across both backends via the same Predictor interface:
Installation
pip install quantumuq
# With optional Qiskit Aer support:
pip install "quantumuq[aer]"
Quick examples
PennyLane:
from quantumuq import wrap_qnode, ShotBootstrap
import pennylane as qml
import numpy as np
dev = qml.device("default.qubit", wires=2, shots=1000)
@qml.qnode(dev)
def circuit(x, params):
qml.AngleEmbedding(x, wires=[0, 1])
qml.StronglyEntanglingLayers(params, wires=[0, 1])
return qml.probs(wires=[0, 1])
# 2 qubits -> 4 outcomes (|00>,|01>,|10>,|11>); collapse to 2 classes.
def probs_4_to_2(p):
p = np.asarray(p)
if p.ndim == 1:
return np.array([p[0] + p[1], p[2] + p[3]])
return np.stack([p[:, 0] + p[:, 1], p[:, 2] + p[:, 3]], axis=-1)
params = 0.1 * np.random.default_rng(0).standard_normal((1, 2, 3))
predictor = wrap_qnode(
circuit, task="classification", n_classes=2, params=params, postprocess=probs_4_to_2
)
uq = ShotBootstrap(n_samples=16, shots=1000, seed=0)
uq_model = predictor.with_uq(uq)
dist = uq_model.predict_dist(np.random.randn(4, 2))
print(dist.mean.shape, dist.std.shape)
Qiskit:
from quantumuq import wrap_qiskit_sampler, ShotBootstrap
from qiskit.circuit import Parameter, QuantumCircuit
from qiskit.primitives import StatevectorSampler
import numpy as np
theta = Parameter("theta")
qc = QuantumCircuit(1)
qc.ry(theta, 0)
qc.measure_all()
def feature_map(X: np.ndarray):
return [[float(x[0])] for x in np.atleast_2d(X)]
# A Generator instance (not a plain int) makes the sampler's RNG state
# advance across calls, so repeated ShotBootstrap draws actually differ.
sampler = StatevectorSampler(seed=np.random.default_rng(0))
predictor = wrap_qiskit_sampler(
sampler,
circuit=qc,
task="classification",
n_classes=2,
feature_map=feature_map,
)
uq = ShotBootstrap(n_samples=8, shots=1000, seed=0)
uq_model = predictor.with_uq(uq)
dist = uq_model.predict_dist(np.random.randn(4, 1))
print(dist.mean.shape, dist.std.shape)
Methods & metrics
- Uncertainty methods:
ShotBootstrap,DeepEnsemble,NoiseProfile - Metrics (classification):
nll,brier,ece,predictive_entropy - Metrics (regression):
rmse,gaussian_nll - Persistence:
UQModel.save()/UQModel.load()checkpoint a fitted model's trained parameters and method config for both PennyLane and Qiskit predictors
Benchmark suite
quantumuq.benchmarks trains a small reference variational classifier and
sweeps shot count, reporting accuracy and calibration metrics
reproducibly -- so a paper can cite a fixed benchmark rather than "we used
a Python package."
pip install "quantumuq[benchmarks]" # adds scikit-learn, for iris/breast_cancer
quantumuq-benchmark --backend pennylane --dataset moons --shots 100,500,1000,10000
- Datasets:
moons(no extra dependency),iris(binary subset),breast_cancer-- all reduced to 2 features so the same small reference circuit applies to each;iris/breast_cancerrequire scikit-learn. - Backends:
pennylane(gradient-trained) andqiskit(SPSA-trained, since Qiskit circuits aren't differentiable through this library). - Metrics per shot count: accuracy,
nll,ece,brier,predictive_entropy, and meanShotBootstrapuncertainty. --output results.csvsaves the full table. The same functionality is available from Python viaquantumuq.benchmarks.run_benchmark(...).
This is a lightweight harness, not a rigorous ML pipeline -- see
quantumuq.benchmarks.run_benchmark's docstring for the exact
simplifications (fixed single train/test split, dataset subsampling for
consistent runtime, a shared 2-feature/2-qubit circuit architecture).
Quantum kernel classifiers and hybrid QNN models, and depolarizing/readout
noise sweeps, are natural extensions not yet implemented.
Examples
Runnable notebooks live in
examples/notebooks/:
00_pennylane_quickstart.ipynb-- classification withShotBootstrapon PennyLane01_qiskit_quickstart.ipynb-- classification withShotBootstrapandNoiseProfileon Qiskit02_pennylane_training_ensemble.ipynb--DeepEnsembleover trained PennyLane models03_qiskit_training_spsa.ipynb-- training a Qiskit circuit with SPSA04_shots_sweep_noise_profile.ipynb--NoiseProfileshot sweeps05_ece_calibration_bugfix.ipynb-- calibration withece(), including the confidence=1.0 edge case06_uqmodel_persistence.ipynb--UQModel.save()/load()checkpointing07_qiskit_v2_primitives.ipynb--BaseSamplerV2/BaseEstimatorV2usage and seeding gotchas08_pennylane_community_demo.ipynb-- "How Confident Should You Be in a Quantum Classifier?", a PennyLane Community Demo
Roadmap
- Richer model adapters (more flexible outputs, calibration hooks)
- Additional metrics and visualization utilities
- Optional integrations with experiment tracking tools
- Benchmark suite: quantum kernel classifiers and hybrid QNN models, depolarizing/readout noise sweeps (currently shot-count only)
License
MIT License. See LICENSE for details.
Code of Conduct
This project adheres to the Qiskit Code of Conduct. See CODE_OF_CONDUCT.md.
Citation
If you use QuantumUQ in academic work, please cite (also available via
GitHub's "Cite this repository" button, backed by CITATION.cff):
@article{Catak_2026,
title={QuantumUQ: A Library for Uncertainty Quantification in Quantum Machine Learning},
url={http://dx.doi.org/10.36227/techrxiv.177205048.88644983/v1},
DOI={10.36227/techrxiv.177205048.88644983/v1},
publisher={Institute of Electrical and Electronics Engineers (IEEE)},
author={Catak, Ferhat Ozgur},
year={2026},
month=feb
}
Metadata
Release files for quantumuq 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| quantumuq-0.4.1.tar.gz | 761.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| quantumuq-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 789.7 kB
Release files / quantumuq-0.4.1.tar.gz
| Download URL | quantumuq-0.4.1.tar.gz |
|---|---|
| Size | 761.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf23e8e8c53c8c4fba262892d1e88bc87662ba80c03e142ce68bdaa5f5bddad9
|
|
BLAKE2b-256 checksum How to use checksums |
0eb5d0ef8e01bd54594ad9d5d53f6bc612e8fb216b09753369306f86db5b6d98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logRelease files / quantumuq-0.4.1-py3-none-any.whl
| Download URL | quantumuq-0.4.1-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fe1cfe1632146c508dcf8710b7dac429476efa8bcfdf4a325aa3eb5fe58b546
|
|
BLAKE2b-256 checksum How to use checksums |
1a3800529d6815c6dde10372e510064d64ae1f4e8cfc798e7bbfd7a6db2560f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency log