Skip to main content

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
Adjust quantum capacity QuantumLayer.multiscale(bond_qubits=..., depth=...)
Train an existing circuit QuantumLayer; set execution_method="tensor-network" for native contraction
Factor a dense projection TensorTrainLinear.from_dense(weight, bias)
Accumulate training gradients oq.torch.HybridTrainer / oq.jax.make_train_step
Train a quantum policy QuantumActorCritic and PPOTrainer

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. AdaptiveMPSBackend offers explicit approximation with checked observable-error bounds. compile_program retains SDK-supported dynamic loops; convert uses portable circuit IR.

Training and execution · Tensor networks · Hybrid training · Quantum RL · Circuit conversion · QPU configuration

License

Apache-2.0.

Metadata

Release files for openqml 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openqml 0.8.0
File Size Uploaded Provenance Actions
openqml-0.8.0.tar.gz 256.1 kB With provenance Details for openqml-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openqml 0.8.0
File Interpreter ABI Platform Actions
openqml-0.8.0-py3-none-any.whl Python 3 none any Details for openqml-0.8.0-py3-none-any.whl

Total release size: 558.5 kB

Release files / openqml-0.8.0.tar.gz

Download URL openqml-0.8.0.tar.gz
Size 256.1 kB
Tags Source
SHA-256 checksum
How to use checksums
495ce61620c1d4fd3bf9d77479f50b4e2cad1b00f565c15a95ef419d4eadaaf7
BLAKE2b-256 checksum
How to use checksums
64ff1dc421b51145ecc6fdf8d81cabd5b9301cf05b024fef71079a0b950eb362
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 log

Release files / openqml-0.8.0-py3-none-any.whl

Download URL openqml-0.8.0-py3-none-any.whl
Size 302.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ded23886359cfd38baf8622cedaf5d2b389e5f5029ff89b31ef1cbed4f8c37a0
BLAKE2b-256 checksum
How to use checksums
f94752c44e14eda80936447ecfbc6bf165ce94684d07b420b6ca7a2e76e79cd5
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 log

Security for openqml 0.8.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.

Select from 2 files

Attestation for openqml-0.8.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 log

A 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.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page