OpenQML
OpenQML is a Python library for training quantum–classical models, working with portfolio scenarios and moving quantum circuits between frameworks. You can build and simulate a circuit with NumPy, then use the same circuit in a PyTorch or JAX model.
PyPI · API reference · Changelog
Run your first circuit
Install the core package on Python 3.10 or later.
python -m pip install openqml
import openqml as oq
bell = oq.Circuit(2).h(0).cx(0, 1)
print(oq.sample(bell, shots=1000, seed=7))
print(oq.expectation(bell, "ZZ"))
The first line of output counts 00 and 11. The second gives their exact
Z correlation, 1.0. Bit strings and Pauli words both start with qubit 0.
OpenQML selects an available backend automatically.
Export the same circuit with oq.convert(bell, target="openqasm3").value.
OpenQASM export and local simulation are included in the core package.
Qiskit and OpenQASM 3 can exchange measurement-controlled loops and bounded
dynamic indices through the shared circuit representation.
Runtime loops and addressed wires · Circuit formats and supported operations
Install openqml[torch], openqml[jax] or openqml[flax] for training.
SDK integrations can also be combined, for example openqml[qiskit,cirq].
Platform and backend details
Train a hybrid model
With openqml[torch] installed, you can fit a small classifier directly from
Python lists. The two inputs below are the bits of an XOR problem.
import openqml as oq
x = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]] * 8
y = [0, 1, 1, 0] * 8
model = oq.Model(task="classification", hidden_features=8, depth=2)
model.fit(x, y, epochs=10)
print(model.predict_proba(x[:2]))
Use Model for fitting, validation and checkpoints. If you already have a
training loop, add a quantum layer to your existing PyTorch, JAX or Flax model.
The layer exposes its parameters to the framework optimizer.
Models · Training and gradients
To choose a predictor for deployment, compare the fitted model with your
strongest classical alternatives on a separate calibration set.
model.select_predictor(...) returns a callable predictor and the paired loss
evidence under a common cost ceiling. Selecting a predictor
Allocate a portfolio
Each row of returns is one observation and each column is one asset.
Here the allocator caps either asset at 70% of the portfolio.
import openqml as oq
returns = [[0.01, -0.02], [-0.01, 0.03], [0.02, 0.01]]
portfolio = oq.finance.allocate(returns, caps=0.7, fees=0.001)
print(portfolio.weights)
For multi-period research, scenario plans model how allocations, cash and fees change along each path. Walk-forward evaluation fits on past observations and scores the next period. Portfolio construction, risk and pricing
Execution options
The CPU simulator samples Clifford circuits directly and evaluates Pauli words
without building a statevector. For general circuits, NumPy fuses local gates
and consecutive diagonal rotations. Use oq.statevector(circuit) when you need
every amplitude. The MPS backend also supports circuits with modest
entanglement and reports a readout error bound when truncation is enabled.
On Linux x86-64, openqml[gpu] provides native Triton kernels for supported
NVIDIA GPUs. Use CUDA binding tensors with backend="torch" to keep both the
state and its gradients on the device.
Execution backends · Memory budgets and readout accuracy
Metadata
Release files for openqml 0.42.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openqml-0.42.2.tar.gz | 540.5 kB | With provenance | Details for openqml-0.42.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openqml-0.42.2-py3-none-any.whl | Python 3 | none | any | Details for openqml-0.42.2-py3-none-any.whl |
Total release size: 1.2 MB
Release files / openqml-0.42.2.tar.gz
| Download URL | openqml-0.42.2.tar.gz |
|---|---|
| Size | 540.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd7e333e2bc5264d049964ed7efe7aab9aadf1c5f3c90f5396661520e820e999
|
|
BLAKE2b-256 checksum How to use checksums |
b62a35ea058c5cf8e30f435999461404e8b030bdb38ff051d624bf48e10c4b1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logRelease files / openqml-0.42.2-py3-none-any.whl
| Download URL | openqml-0.42.2-py3-none-any.whl |
|---|---|
| Size | 643.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
063d5990156704fd3ff35246a895ecd895781ad459cdb703668ebac655387610
|
|
BLAKE2b-256 checksum How to use checksums |
f8a280fd6a756799998624aa870d3317e169e07af623dee269ba7d17ceadc84e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logSecurity for openqml 0.42.2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for openqml-0.42.2.tar.gz
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 Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.