Skip to main content

No project description provided

Project description

qumat-qdp

GPU-accelerated quantum state encoding for Apache Mahout Qumat.

Installation

pip install qumat[qdp]

Requires one of:

  • NVIDIA GPU (CUDA path via QdpEngine)
  • AMD GPU with ROCm (AMD path via QdpEngine(backend="amd"))

Recommended environment setup:

python -m venv .venv
source .venv/bin/activate

# Install the GPU runtime for your platform first:
# - NVIDIA users: CUDA-compatible torch / triton
# - AMD users: ROCm-compatible torch / triton

uv sync --active --project qdp/qdp-python --group dev

Use --active so uv reuses the environment that already has the correct GPU runtime stack.

Usage

import qumat.qdp as qdp
import torch

# Initialize the unified QDP engine on GPU 0.
# Choose the backend explicitly.
engine = qdp.QdpEngine(device_id=0, backend="cuda")

# Encode data into quantum state
qtensor = engine.encode([1.0, 2.0, 3.0, 4.0], num_qubits=2, encoding_method="amplitude")

# Zero-copy transfer to PyTorch
tensor = torch.from_dlpack(qtensor)
print(tensor)  # Complex tensor on CUDA

AMD ROCm Usage

import qumat.qdp as qdp
import torch

# Unified AMD engine route
engine = qdp.QdpEngine(device_id=0, precision="float32", backend="amd")
qt = engine.encode(torch.randn(8, 4, device="cuda"), 2, "amplitude")
state = torch.from_dlpack(qt)
print(state.device, state.dtype)  # cuda:0, complex64

The public QdpEngine is a unified Python facade with explicit backend selection:

  • backend="cuda" routes to the Rust _qdp.QdpEngine
  • backend="amd" routes to the Triton AMD engine directly

See qdp/qdp-python/TRITON_AMD_BACKEND.md for Triton AMD setup and validation details.

Encoding Methods

Method Description
amplitude Normalize input as quantum amplitudes
angle Map values to rotation angles (one per qubit)
basis Encode integer as computational basis state
iqp IQP-style encoding with full ZZ entanglement
iqp-z IQP encoding with Z-only diagonal (no ZZ pairs)
phase Per-qubit phase product state via H⊗P(x_k)

Backend support boundary:

  • CUDA (QdpEngine): amplitude, angle, basis, iqp, iqp-z, phase
    • phase is currently only reachable on the CUDA path via host inputs (Python list / NumPy / file / CPU torch tensor). The Python extension's CUDA-tensor validation does not yet allowlist phase; cuda-resident torch tensors must use .cpu() first when targeting phase. Tracked as a follow-up.
  • AMD (QdpEngine(..., backend="amd")): amplitude, angle, basis, iqp, iqp-z, phase

Pipeline / loader dtype (Rust internals)

QuantumDataLoader and run_throughput_pipeline build a Rust PipelineConfig with an encoding plus a dtype (float32 vs float64). The prefetch thread can only keep an end-to-end float32 host batch for encodings whose GPU stack implements the batch f32 path (encode_batch_f32). Today that is amplitude only. Angle and basis still fall back to float64 for that loop until their batch f32 implementations exist. The eventual full matrix (e.g. angle/basis under supports_f32 once kernels are wired) is broader than what the pipeline uses today.

Input Sources

# Python list
qtensor = engine.encode([1.0, 2.0, 3.0, 4.0], 2, "amplitude")

# NumPy array
qtensor = engine.encode(np.array([[1, 2, 3, 4], [4, 3, 2, 1]]), 2, "amplitude")

# PyTorch tensor (CPU or CUDA)
qtensor = engine.encode(torch.tensor([1.0, 2.0, 3.0, 4.0]), 2, "amplitude")

# File formats
qtensor = engine.encode("data.parquet", 10, "amplitude")
qtensor = engine.encode("data.arrow", 10, "amplitude")
qtensor = engine.encode("data.npy", 10, "amplitude")
qtensor = engine.encode("data.pt", 10, "amplitude")

# Remote object storage URLs (requires building with remote-io feature)
qtensor = engine.encode("s3://my-bucket/data.parquet", 10, "amplitude")
qtensor = engine.encode("gs://my-bucket/data.parquet", 10, "amplitude")

Links

License

Apache License 2.0

Download files

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

Source Distribution

qumat_qdp-0.2.0rc1.tar.gz (338.3 kB view details)

Uploaded Source

Built Distributions

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

qumat_qdp-0.2.0rc1-cp312-cp312-manylinux_2_34_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

qumat_qdp-0.2.0rc1-cp311-cp311-manylinux_2_34_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

qumat_qdp-0.2.0rc1-cp310-cp310-manylinux_2_34_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

Details for the file qumat_qdp-0.2.0rc1.tar.gz.

File metadata

  • Download URL: qumat_qdp-0.2.0rc1.tar.gz
  • Upload date:
  • Size: 338.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for qumat_qdp-0.2.0rc1.tar.gz
Algorithm Hash digest
SHA256 c3aa3af699dd8ed6e5038e194ab7d689ceae650d8e65d794a9510ee6a8abde87
MD5 c4ca134fb73e31a180b0b0e6cff94a15
BLAKE2b-256 7b228f1b94128a2322b13125946bcdfe02caba0c1fe8374ab4ce6b58c6fcc910

See more details on using hashes here.

File details

Details for the file qumat_qdp-0.2.0rc1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qumat_qdp-0.2.0rc1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 663e78425943495ff5b4a6f7053cea2361ee15548d2179a1354be0fc311f828e
MD5 347441ee7fde2733cb687b4603f58510
BLAKE2b-256 86b66bcededa2ac39c85552f486db9741a3ae3c20f4883ea4054e4b070fa97bf

See more details on using hashes here.

File details

Details for the file qumat_qdp-0.2.0rc1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qumat_qdp-0.2.0rc1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1db03b66da613a88787c6df3ac57c1da64d593a2b1e09c02e4d062b53a303b1a
MD5 0dec1e2594c1743e01cf387779627b64
BLAKE2b-256 6405363c05752909476e0f1a6e81eeb58e0fcca3d74aae57b88fb8ca9e88cc4a

See more details on using hashes here.

File details

Details for the file qumat_qdp-0.2.0rc1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for qumat_qdp-0.2.0rc1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a0b28433807a76674503b210be179ef8eb71bc30ca96489b49ec88ec9f8fd0d2
MD5 23bf4b357dddd7f1b947ef01e5cd0965
BLAKE2b-256 cc84e6c58eb20438b9556b9338c1bec761bd9fac4607f873aceeec9b8d37cddf

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