Skip to main content

Online quantum machine learning package, using PyTorch.

Project description

online-qml

online-qml is a PyTorch based package for quantum extreme learning machines (QELM) simulations. It is with online shadow training readouts.

The distribution name is online-qml; the import name is online_qml.

Installation

Clone and sync with uv

Clone the repository, then sync the project environment:

git clone https://github.com/alex180500/online-qml.git
cd online-qml
uv sync

The default uv sync installs:

  • package dependencies;
  • development tools from the dev dependency group;
  • the CPU PyTorch build from https://download.pytorch.org/whl/cpu.

To install the default CPU environment without development tools:

uv sync --no-dev

Supported PyTorch backends for local uv sync are:

Backend Command
CPU uv sync
CPU, no dev tools uv sync --no-dev
CUDA 12.6 uv sync --no-group cpu --extra cu126
CUDA 12.8 uv sync --no-group cpu --extra cu128
CUDA 13.0 uv sync --no-group cpu --extra cu130

The cpu group is enabled by default. Disable it when selecting a CUDA extra, otherwise uv will reject the sync because two Torch backends were requested.

Install as a dependency with pip

When online-qml is installed with pip, only the package dependencies are installed. The local uv dependency groups, including dev and cpu, are not installed by downstream projects.

Install the desired PyTorch build first, then install online-qml:

python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch>=2.11"
python -m pip install online-qml

For CUDA, use the matching PyTorch wheel index:

Backend PyTorch install command
CPU python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch>=2.11"
CUDA 12.6 python -m pip install --index-url https://download.pytorch.org/whl/cu126 "torch>=2.11"
CUDA 12.8 python -m pip install --index-url https://download.pytorch.org/whl/cu128 "torch>=2.11"
CUDA 13.0 python -m pip install --index-url https://download.pytorch.org/whl/cu130 "torch>=2.11"

Then install online-qml:

python -m pip install online-qml

Do not rely on pip install "online-qml[cu130]" by itself to select the CUDA wheel index. Package extras can request torch, but pip package metadata cannot carry the uv source-index routing from this repository.

Current focus

  • generate Haar pure states and random Naimark POVMs;
  • train OST and prior-frame readout layers;
  • train dense pseudoinverse/ridge baselines;
  • evaluate Haar bias and variance;
  • study state-frame and measurement-frame distances.

Minimal example

import torch
from online_qml.estimators import ShadowReadoutEstimator
from online_qml.quantum import (
    sample_dm,
    sample_observable,
    sample_povm,
    shots_outcome,
)

states = sample_dm(1000, d=2, dtype=torch.cdouble)
povm = sample_povm(16, d=2, dtype=torch.cdouble)
outcomes = shots_outcome(povm, states, shots=1)
obs = sample_observable(1, d=2, kind="proj", dtype=torch.cdouble)

est = ShadowReadoutEstimator(
    n_out=16,
    d=2,
    dtype=torch.float64,
    methods=("ost", "state_prior_ost"),
)
est.update_single_shot(outcomes[:, 0], states)
layers = est.layers(obs)
W_ost = layers["ost"]
W_state_prior = layers["state_prior_ost"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

online_qml-0.6.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

online_qml-0.6.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file online_qml-0.6.1.tar.gz.

File metadata

  • Download URL: online_qml-0.6.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for online_qml-0.6.1.tar.gz
Algorithm Hash digest
SHA256 78bfd0ffab7b256a89c8fbaff64f2a835ac8f7e350c39e4db20d421d48be2deb
MD5 1732e714e79f21dbe83b20106240926c
BLAKE2b-256 4f95f7836be720a7f1b297c8edbdc1bdfe70a928e946d35f6ff2c41bc1e3277d

See more details on using hashes here.

File details

Details for the file online_qml-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: online_qml-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for online_qml-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 270b283125bb281b50200309378230df6c043ccf9a4301d72df1f0b2411025d3
MD5 af7c9057f17d9faa51f80535a14ccf8d
BLAKE2b-256 035654db5641a63cdae6e510b2d6833dbf4d6cc3658adc5a343bcb7eddb614ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page