Metadata-Version: 2.4
Name: openqml
Version: 0.42.2
Summary: Quantum-classical hybrid AI, quantitative research and cross-framework quantum programming
Author: OpenQML contributors
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/OpenQML-org/OpenQML
Keywords: quantum,machine-learning,quantitative-finance,pytorch,jax,interoperability
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: packaging>=23
Requires-Dist: psutil>=5.9
Requires-Dist: numpy>=1.24
Provides-Extra: torch
Requires-Dist: torch>=2.4.1; (platform_system != "Darwin" or platform_machine != "x86_64") and extra == "torch"
Requires-Dist: torch>=2.2; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "torch"
Requires-Dist: numpy<2,>=1.26; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "torch"
Provides-Extra: jax
Requires-Dist: jax>=0.4.30; extra == "jax"
Requires-Dist: optax>=0.2; extra == "jax"
Provides-Extra: qiskit
Requires-Dist: qiskit[qasm3-import]>=1.2; extra == "qiskit"
Requires-Dist: sympy>=1.12; extra == "qiskit"
Provides-Extra: aer
Requires-Dist: qiskit[qasm3-import]>=1.2; extra == "aer"
Requires-Dist: qiskit-aer>=0.15; extra == "aer"
Requires-Dist: sympy>=1.12; extra == "aer"
Provides-Extra: gpu
Requires-Dist: torch>=2.4.1; (platform_system != "Darwin" or platform_machine != "x86_64") and extra == "gpu"
Requires-Dist: torch>=2.2; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "gpu"
Requires-Dist: numpy<2,>=1.26; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "gpu"
Requires-Dist: triton<4,>=3.4; (platform_system == "Linux" and platform_machine == "x86_64") and extra == "gpu"
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: jax>=0.4.30; extra == "flax"
Requires-Dist: flax>=0.10; extra == "flax"
Requires-Dist: optax>=0.2; extra == "flax"
Provides-Extra: symbolic
Requires-Dist: sympy>=1.12; extra == "symbolic"
Provides-Extra: compute
Requires-Dist: cotengra<0.8,>=0.7.5; (python_version < "3.11" or (platform_system == "Darwin" and platform_machine == "x86_64")) and extra == "compute"
Requires-Dist: autoray<0.8,>=0.7.2; (python_version < "3.11" or (platform_system == "Darwin" and platform_machine == "x86_64")) and extra == "compute"
Requires-Dist: cotengra>=0.8.3; (python_version >= "3.11" and (platform_system != "Darwin" or platform_machine != "x86_64")) and extra == "compute"
Requires-Dist: autoray>=0.8.4; (python_version >= "3.11" and (platform_system != "Darwin" or platform_machine != "x86_64")) and extra == "compute"
Provides-Extra: pennylane
Requires-Dist: pennylane>=0.40; extra == "pennylane"
Requires-Dist: sympy>=1.12; 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: torch>=2.4.1; (platform_system != "Darwin" or platform_machine != "x86_64") and extra == "all"
Requires-Dist: torch>=2.2; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "all"
Requires-Dist: numpy<2,>=1.26; (platform_system == "Darwin" and platform_machine == "x86_64") and extra == "all"
Requires-Dist: jax>=0.4.30; extra == "all"
Requires-Dist: flax>=0.10; extra == "all"
Requires-Dist: optax>=0.2; extra == "all"
Requires-Dist: qiskit[qasm3-import]>=1.2; extra == "all"
Requires-Dist: qiskit-aer>=0.15; extra == "all"
Requires-Dist: pennylane>=0.40; extra == "all"
Requires-Dist: cirq-core>=1.4; extra == "all"
Requires-Dist: openqasm3[parser]>=1.0; extra == "all"
Requires-Dist: sympy>=1.12; extra == "all"
Requires-Dist: cotengra<0.8,>=0.7.5; (python_version < "3.11" or (platform_system == "Darwin" and platform_machine == "x86_64")) and extra == "all"
Requires-Dist: autoray<0.8,>=0.7.2; (python_version < "3.11" or (platform_system == "Darwin" and platform_machine == "x86_64")) and extra == "all"
Requires-Dist: cotengra>=0.8.3; (python_version >= "3.11" and (platform_system != "Darwin" or platform_machine != "x86_64")) and extra == "all"
Requires-Dist: autoray>=0.8.4; (python_version >= "3.11" and (platform_system != "Darwin" or platform_machine != "x86_64")) and 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 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](https://pypi.org/project/openqml/) · [API reference](https://github.com/OpenQML-org/OpenQML/blob/main/docs/api.md) · [Changelog](https://github.com/OpenQML-org/OpenQML/blob/main/CHANGELOG.md)

## Run your first circuit

Install the core package on Python 3.10 or later.

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

```python
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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/interoperability.md#runtime-loops-and-addressed-wires) · [Circuit formats and supported operations](https://github.com/OpenQML-org/OpenQML/blob/main/docs/interoperability.md)

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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/runtime.md)

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

```python
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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/models.md) · [Training and gradients](https://github.com/OpenQML-org/OpenQML/blob/main/docs/hybrid-training.md)

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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/hybrid-training.md#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.

```python
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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/finance.md)

## 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](https://github.com/OpenQML-org/OpenQML/blob/main/docs/runtime.md) · [Memory budgets and readout accuracy](https://github.com/OpenQML-org/OpenQML/blob/main/docs/compute.md)

[Apache-2.0 license](https://github.com/OpenQML-org/OpenQML/blob/main/LICENSE) · [Contributing](https://github.com/OpenQML-org/OpenQML/blob/main/CONTRIBUTING.md) · [Governance](https://github.com/OpenQML-org/OpenQML/blob/main/GOVERNANCE.md) · [Security](https://github.com/OpenQML-org/OpenQML/blob/main/SECURITY.md)
