torchqml
PyTorch Quantum Machine Learning with cuQuantum - Fast Adjoint Differentiation
Features
- Adjoint Differentiation: O(G) gradient calculation using cuQuantum's
custatevecand optimized C++ kernels. - PyTorch Native: Fully integrated with
torch.autogradandtorch.nn. - High Performance: Custom C++/CUDA extension reusing cuStateVec/cuBLAS handles for minimize overhead.
Performance
TorchQML outperforms PennyLane's lightning.gpu backend significantly on NVIDIA GPUs (measured on T4):
| Qubits | Layers | TorchQML (ms) | PennyLane (ms) | Speedup |
|---|---|---|---|---|
| 4 | 5 | 5.72 | 16.99 | 3.0x |
| 8 | 10 | 13.18 | 48.69 | 3.7x |
| 12 | 10 | 24.29 | 69.65 | 2.9x |
Installation
pip install .
Usage
import torch
import torchqml as tq
# Build circuit
qc = tq.QuantumCircuit(2)
qc.h(0)
qc.ry(0, param_index=0)
qc.cx(0, 1)
# Parameters
params = torch.tensor([[0.5]], requires_grad=True)
# Expectation
exp_val = qc.expectation(params, tq.Z(0))
# Backward
exp_val.backward()
print(params.grad)
Metadata
Release files for torchqml 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchqml-0.1.7.tar.gz | 58.3 kB | Without provenance | Details for torchqml-0.1.7.tar.gz |
Release files / torchqml-0.1.7.tar.gz
| Download URL | torchqml-0.1.7.tar.gz |
|---|---|
| Size | 58.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
154f430849ef00e8055694f13688a6990efc339889f37fbf3f13f236adfd228d
|
|
BLAKE2b-256 checksum How to use checksums |
cb1263a5917baa1a2a2c3f1704be7eeda9bd390a872b0116583c27c2f980399f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for torchqml 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.