Repository navigation
[QDP] Builder backends name GPUs only; every encode result is a QdpTensor - #1505
Merged
Merged
Conversation
…nsor Signed-off-by: 400Ping <jiekaichang@apache.org>
ryankert01
approved these changes
Oct 13, 2026
ryankert01
left a comment
Member
There was a problem hiding this comment.
lg, I thought it probably be okay.
ryankert01
enabled auto-merge (squash)
October 13, 2026 16:16
4 tasks done
400Ping
disabled auto-merge
October 14, 2026 04:17
Signed-off-by: Jie-Kai Chang <jiekaichang@apache.org>
2 of 3 tasks
400Ping
added a commit
that referenced
this pull request
Nov 2, 2026
Three workflows went red on main after #1505 merged: - Wheel Build: the wheel smoke test still imported `qumat_qdp._backend`, which #1505 removed in favour of `qumat_qdp._native`. - Python Testing: #1551 landed `testing/qdp_python/test_engine_init.py` after #1505 branched, importing `is_cuda_available`, which #1505 renamed to `is_native_cuda_available`. - Pre-commit (ty): `test_triton_amd_backend.py` asserted `.shape` on a `QdpTensor`, which has no such attribute; and the `type: ignore[misc]` on `_QdpDataset` in `loader.py` became unused after the refactor. Signed-off-by: Jie-Kai Chang <jiekaichang@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issues
Related: #1177, #1189 (origin of the PyTorch reference), #1155, #1292 (AMD route), #1320, #1323 (CPU fallback being removed), #1414 (
_qdpimportable ≠ GPU usable), #1467, #1331 (reference the old names / removed helper), #1477 / #1483 (overlapping files, see below).Changes
Why
QDP is GPU-only, but the Python builders made it look like it was not:
QuantumDataLoader/QdpBenchmarktook.backend("pytorch"), which ran the pure-PyTorch reference fromtorch_ref.py— on CPU when no CUDA device was found. The reference was added in Add pure-PyTorch reference implementations #1189 as a benchmark baseline ("to compare with current impl"), not as a backend, yet it was listed next to the real one and people concluded "QDP runs on CPU with the PyTorch backend"."rust"on the builders and"cuda"onQdpEngine.QuantumDataLoader.backend("auto")silently fell back to PyTorch (and therefore CPU) when_qdpwas missing, contradicting the docs ("PyTorch is not used as an automatic fallback").QdpEngine(backend="amd")exists ([Feature][QDP] Add AMD GPU support via Triton backend #1155).Backend/BACKEND/force_backendand theQdpTensorfacade were exported but never used by any production code;Backend.PYTORCHreinforced the misconception._qdptensor while the AMD route returned atorch.Tensor, so switching backends changed the result type.How
Backend selection (
loader.py,api.py).backend()on both builders takes"cuda"(default) or"amd"; the loader also takes"auto"."auto"picks"cuda"when_qdp.cuda_available()is true, else"amd"whenis_triton_amd_available()is true, else raisesRuntimeError. No CPU fallback."rust"and"pytorch"are rejected withValueError.torch_ref.pyis unchanged and still used directly by the benchmark scripts and parity tests.QuantumDataLoader._create_amd_iterator(synthetic and.npy/.pt/.pthsources, batches built on CPU and moved by the engine) andQdpBenchmark._run_throughput_amd(Python loop overTritonAmdEngine.encode).QdpBenchmarkdefaults to f32, matchingQdpEngineand the native synthetic loader; the AMD loader mirrors the native precision rules (synthetic f32, files f64,.dtype()honoured).Result type (
backend.py,loader.py,tensor.py)QdpEngine.encode()and every loader backend returnQdpTensor;.valueis the backend-native object (_qdp.QuantumTensoron CUDA,torch.Tensoron AMD),.backendis"cuda"or"amd".torch.from_dlpack(qt)andqt.to_torch()work on both.QdpTensor.__dlpack__forwards extra DLPack keyword arguments (max_version, …).Removed / renamed
Backend,BACKEND,force_backend,get_backend,require_backend,get_torchdeleted;_backend.py→_native.pykeeping onlyget_qdp()._select_torch_device(qumat_qdp: intersect GPU compute capability with PyTorch's arch list #1323) deleted: the only path that used it is gone.RustQdpEngine→NativeQdpEngine;is_cuda_available→is_native_cuda_available.Docs
python-api.md: backend model rewritten around"cuda"/"amd"/"auto", result type anddtype()documented, PyTorch reference no longer presented as an encoder.getting-started.md,concepts.md,python-api.md(stale since [QDP] Close AMD-vs-CUDA encoder parity: add iqp, iqp-z, phase #1292);TRITON_AMD_BACKEND.mdno longer mentions the non-existentQuantumTensorWrapper.qumat_qdp._backendremoved fromdocs/api/qumat_qdp.yml.Tests
test_fallback.py→test_backend_selection.py: selector validation andautorouting, runnable without a GPU.qdp/qdp-python/tests/test_amd_builders.py(@pytest.mark.rocm): AMD loader synthetic and file sources, precision,autoon a ROCm host, benchmark throughput/latency — realTritonAmdEngine, no fakes.QdpTensorcontract.Breaking changes
.backend("rust")→.backend("cuda");.backend("pytorch")removed.QuantumDataLoader.backend("auto")raises instead of falling back to PyTorch.Backend,BACKEND,force_backendremoved fromqumat_qdp.RustQdpEngine→NativeQdpEngine;is_cuda_available→is_native_cuda_available.QdpEngine.encode()andQuantumDataLoaderreturnQdpTensoron every backend (use.valuefor the native object).QdpBenchmarkdefault dtype is f32.qumat_qdp._backend→qumat_qdp._native.Checklist