OpenQML
PyPI · CI · Documentation
Trainable quantum circuits and tensor-network layers for PyTorch, JAX and Flax.
Installation
Requires Python 3.10 or later. Install the PyTorch integration to run the example below:
python -m pip install --upgrade "openqml[torch]"
Other options: openqml[jax], openqml[flax], or openqml for the NumPy core.
The core depends on NumPy, packaging and psutil; training frameworks and quantum SDKs are optional.
Train a PyTorch model
import torch
from torch import nn
import openqml as oq
device = "cuda" if torch.cuda.is_available() else "cpu"
model = nn.Sequential(
oq.torch.TensorNetworkAdapter(16, num_qubits=8, num_outputs=4, device=device),
nn.Linear(16, 2, device=device),
)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
x = torch.randn(32, 16, device=device)
target = torch.randint(0, 2, (32,), device=device)
optimizer.zero_grad()
logits = model(x)
loss = nn.functional.cross_entropy(logits, target)
loss.backward()
optimizer.step()
print(logits.shape) # torch.Size([32, 2])
TensorNetworkAdapter(16, ...) preserves the last dimension: (..., 16) → (..., 16).
Its MPO projections and quantum tree train together through ordinary autograd.
Choose an interface
| Task | Interface |
|---|---|
| Add quantum features | TreeQuantumLayer |
| Train an existing circuit | QuantumLayer; set execution_method="tensor-network" for native contraction |
| Factor a dense projection | TensorTrainLinear.from_dense(weight, bias) |
| Build a quantum policy | QuantumActorCritic with PPO/SAC objectives |
These layers are available under oq.torch, oq.jax and oq.flax.
JAX uses layer.init(key) and layer(parameters, inputs); Flax uses Linen init/apply.
Dense import returns a module in PyTorch, (layer, parameters) in JAX, and (module, variables) in Flax.
Execution and documentation
Automatic circuit execution prefers a configured compatible QPU, then GPU, then CPU. Native tensor layers run on their selected framework device. There is no fixed circuit-width ceiling; memory, contraction width and work budgets determine capacity.
Tensor networks · Hybrid training · Quantum RL · Circuit conversion · QPU configuration
License
Metadata
Release files for openqml 0.7.0
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.7.0.tar.gz | 232.9 kB | With provenance | Details for openqml-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openqml-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for openqml-0.7.0-py3-none-any.whl |
Total release size: 508.0 kB
Release files / openqml-0.7.0.tar.gz
| Download URL | openqml-0.7.0.tar.gz |
|---|---|
| Size | 232.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbb87fb5733affe5b02581a10ead32c1588c7172f3c79a42a9e9c832db19ec42
|
|
BLAKE2b-256 checksum How to use checksums |
6e2138a6539d93e650cc398e17b82c30064093a6cede22b3a0ffb65326a17d37
|
| 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 1, 2026.
Transparency logRelease files / openqml-0.7.0-py3-none-any.whl
| Download URL | openqml-0.7.0-py3-none-any.whl |
|---|---|
| Size | 275.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ddcfcbef529434f5e429b748fafc844d38eecbae5d95c9498912348512cf45ed
|
|
BLAKE2b-256 checksum How to use checksums |
894b770b4d3c23331e8501f50c001db909c55f0d4ff3a94c4fff142d6611ddb7
|
| 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 1, 2026.
Transparency logSecurity for openqml 0.7.0
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for openqml-0.7.0.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 1, 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.