[QDP] Collapse the per-encoder matrix into one generic encode path
qdp-core
- New `gpu::kernels` module: a `Kernel` trait with one `launch` on
device-resident data, `Input` (host f64/f32 slice, or a device pointer
on a stream), `Shape`, and a single `encode` driver that validates,
uploads (dual-stream pipeline for large host batches), allocates and
launches. A single sample is a batch of one.
- Launches are asynchronous: `launch` returns a `Pending` holding the
buffers the queued kernels read and checks that need device results
(validation flags, norm flags), settled after one stream sync. The
Parquet streaming path therefore keeps copy/compute overlap for every
encoding.
- One descriptor per encoding (amplitude, angle, basis, iqp, phase),
each launching its kernels through `qdp_kernels::registry`. The
amplitude and IQP host launch orchestration moved into the
descriptors. Amplitude uses the wide single-sample reduction for one
sample and a CPU norm with one kernel for small single host samples;
its finalize kernel raises a flag and writes 0 for zero or non-finite
norms. Basis casts host indices on the CPU and uploads int64. The angle
encoder went from 868 lines to under 90.
- `QdpEngine::encode(input, shape, num_qubits, encoding)` replaces the
24 named encode methods. Host-batch and f64/int64 device-pointer
shorthands live on in `compat.rs`. Float32 host input under a float64
engine is widened on the CPU first.
- The streaming Parquet path is generic over `Kernel`, supports every
encoding, and encodes into the engine's precision through a bounded
float64 staging buffer. Samples that cannot be normalised stay zero
rows, as before.
- `gpu::validation` queues flag kernels through the registry; basis
indices can be cast on the device from float64 as well as float32.
- `Encoding::vector_len` delegates to `Kernel::sample_size`.
- `QuantumEncoder`, `gpu/encodings/*` and `encoding/{amplitude,angle,
basis}.rs` are deleted. The transitional host launchers pass a null
flag to the finalize kernel.
qdp-python
- `PyInput::from_py` converts lists, NumPy (f64 and f32), CPU tensors
and CUDA tensors into an `Input`; `QdpEngine.encode` is one call.
CUDA tensor dtype acceptance is derived from `Kernel::supports`, so
phase now encodes from a CUDA tensor and basis accepts float64 indices.
Tests
- Rust tests use `encode_single`, `encode_batch` or the generic path;
device-pointer tests call `encode` with `Input::Device`. Parquet tests
that download complex128 use a float64 engine, since streaming now
honours engine precision. NumPy float32 input is accepted; the dtype
error test uses float16. The parity grid covers phase on the device.
The goal of the Apache Mahoutâ„¢ project is to build an environment for quickly creating scalable, performant machine learning applications.
For additional information about Mahout, visit the Mahout Home Page
Qumat is a high-level Python library for quantum computing that provides:
pip install qumat
with QDP (Quantum Data Plane) support
pip install qumat[qdp]
from qumat import QuMat qumat = QuMat({"backend_name": "qiskit", "backend_options": {"simulator_type": "aer_simulator"}}) qumat.create_empty_circuit(num_qubits=2) qumat.apply_hadamard_gate(0) qumat.apply_cnot_gate(0, 1) qumat.execute_circuit()
import qumat.qdp as qdp engine = qdp.QdpEngine(device_id=0) qtensor = engine.encode([1.0, 2.0, 3.0, 4.0], num_qubits=2, encoding_method="amplitude")
Please see the NOTICE.txt included in this directory for more information.