Metadata-Version: 2.4
Name: openqml
Version: 0.3.0a10
Summary: Differentiable quantum layers and diagnostic-driven quantum circuit interoperability
Author: OpenQML contributors
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/OpenQML-org/OpenQML
Keywords: quantum,machine-learning,pytorch,jax,quantum-computing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Provides-Extra: torch
Requires-Dist: torch>=2.2; extra == "torch"
Provides-Extra: jax
Requires-Dist: jax>=0.4.30; extra == "jax"
Provides-Extra: qiskit
Requires-Dist: qiskit>=1.2; extra == "qiskit"
Requires-Dist: sympy>=1.12; extra == "qiskit"
Provides-Extra: aer
Requires-Dist: qiskit-aer>=0.15; extra == "aer"
Requires-Dist: qiskit>=1.2; extra == "aer"
Requires-Dist: sympy>=1.12; extra == "aer"
Provides-Extra: qasm
Requires-Dist: qiskit[qasm3-import]>=1.2; extra == "qasm"
Requires-Dist: openqasm3[parser]>=1.0; extra == "qasm"
Requires-Dist: sympy>=1.12; extra == "qasm"
Provides-Extra: flax
Requires-Dist: flax>=0.10; extra == "flax"
Requires-Dist: optax>=0.2; extra == "flax"
Requires-Dist: jax>=0.4.30; extra == "flax"
Provides-Extra: symbolic
Requires-Dist: sympy>=1.12; extra == "symbolic"
Provides-Extra: pennylane
Requires-Dist: pennylane>=0.40; extra == "pennylane"
Provides-Extra: cirq
Requires-Dist: cirq-core>=1.4; extra == "cirq"
Requires-Dist: sympy>=1.12; extra == "cirq"
Provides-Extra: all
Requires-Dist: openqml[aer,cirq,flax,jax,pennylane,qasm,qiskit,torch]; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.11; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=6; extra == "dev"
Dynamic: license-file

# OpenQML

OpenQML adds trainable quantum layers to PyTorch and JAX models and converts circuits between Qiskit, PennyLane, Cirq and OpenQASM through a shared intermediate representation.

## Install

```bash
python -m pip install openqml
```

NumPy is the only required dependency. Install the extra for your workflow, for example `python -m pip install 'openqml[torch]'`. Other extras include `jax`, `flax`, `qiskit`, `pennylane`, `cirq`, `aer` and `qasm`; `all` installs every integration.

## One OpenQML import

```python
import openqml as oq

circuit = oq.Circuit(2).ry(oq.Parameter("theta"), 0).cx(0, 1)
value = oq.expectation(circuit, oq.PauliString("ZI"), {"theta": 0.4})
qasm = oq.convert(circuit, target="openqasm3").value
restored = oq.convert(qasm, source="openqasm3", target="ir").value
```

Core operations use the `oq` namespace. Framework integrations load only when accessed:

| Namespace | Use |
| --- | --- |
| `oq.torch` | PyTorch modules and functional quantum layers |
| `oq.jax` | Functional layers with JIT, gradients and mapped execution |
| `oq.flax` | Linen modules with standard parameter trees |

## Hybrid training

```python
import torch
import openqml as oq

model = torch.nn.Sequential(
    torch.nn.Linear(4, 2),
    oq.torch.QuantumLayer.data_reuploading(2, depth=1),
    torch.nn.Linear(2, 1),
)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
optimizer.zero_grad()
loss = model(torch.randn(8, 4)).square().mean()
loss.backward()
optimizer.step()
```

One optimizer updates the classical and quantum parameters. For JAX, construct `oq.jax.QuantumLayer`, initialize weights with `layer.init(key)`, then call `layer(weights, inputs)`. Native tensor backends support higher derivatives; numerical bridges provide first-order JVPs and VJPs.

`oq.ShiftPlan` compiles sparse shift rules and backend lowering once, streams numerical products, and shares repeated points only for backends declaring deterministic expectations. Reuse windows and submitted circuit batches are bounded.

Each expression evaluation visits shared graph nodes once and retains native automatic differentiation. Circuit binding and symbol replacement preserve shared nonlinear expressions across gates and branch bodies.

## Circuit interoperability

Import SDK program objects with `oq.convert(program, target="ir")`. Use `oq.plan_conversion(...)` to inspect compatibility and resource limits before exporting. Plans diagnose unsupported features and conversions that cannot preserve semantics. Layers retain source ownership and support portable checkpoints.

## Architecture

![OpenQML project architecture](https://raw.githubusercontent.com/OpenQML-org/OpenQML/main/docs/architecture.svg)

[Apache license](https://github.com/OpenQML-org/OpenQML/blob/main/LICENSE)
