QDP (Quantum Data Plane) is a GPU-accelerated library for encoding classical data into quantum states.
nvcc --version to verify)pip install qumat[qdp]
For development (from source):
git clone https://github.com/apache/mahout.git
cd mahout/qdp/qdp-python
uv venv -p python3.10 && source .venv/bin/activate
uv sync --group dev && uv run maturin develop
import torch
from qumat.qdp import QdpEngine
engine = QdpEngine(0) # GPU device 0
data = [0.5, 0.5, 0.5, 0.5]
qtensor = engine.encode(data, num_qubits=2, encoding_method="amplitude")
# Convert to PyTorch (zero-copy)
tensor = torch.from_dlpack(qtensor) # Note: can only be consumed once
| Method | Constraint | Example |
|---|---|---|
amplitude |
data length ≤ 2^num_qubits | encode([0.5, 0.5, 0.5, 0.5], num_qubits=2, encoding_method="amplitude") |
angle |
data length = num_qubits | encode([0.1, 0.2, 0.3, 0.4], num_qubits=4, encoding_method="angle") |
basis |
data length = num_qubits | encode([1, 0, 1, 1], num_qubits=4, encoding_method="basis") |
engine.encode("data.parquet", num_qubits=10, encoding_method="amplitude") # also: .arrow, .npy, .pt, .pb
precision="float64" for higher precision: QdpEngine(0, precision="float64")float64 dtype| Problem | Solution |
|---|---|
| Import fails | Activate venv: source .venv/bin/activate |
| CUDA errors | Run cargo clean in qdp/ and rebuild |
| Out of memory | Reduce num_qubits or use precision="float32" |