qumat_qdp: intersect GPU compute capability with PyTorch's arch list#1323
Merged
Conversation
ryankert01
approved these changes
May 18, 2026
Member
ryankert01
left a comment
There was a problem hiding this comment.
Make sense! Let copilot double check for me.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes #1320 by ensuring PyTorch device selection accounts for the GPU's compute capability against the installed wheel's compiled arch list, avoiding opaque cudaErrorNoKernelImageForDevice failures on older GPUs (e.g., Pascal sm_61 against a sm_70+ wheel). Introduces a shared _select_torch_device helper in qumat_qdp.loader, reuses it in the benchmark path, and mirrors the logic in test skip predicates.
Changes:
- Add
_select_torch_device(torch, device_id)inloader.pythat validatesdevice_id, intersects device capability withtorch.cuda.get_arch_list(), and warns + falls back to CPU on mismatch. - Replace duplicated CUDA selection logic in
QdpBenchmark._run_throughput_pytorchwith the shared helper. - Add
_torch_cuda_usable()intest_torch_ref.pyand use it in the two GPU-only test skipifs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| qdp/qdp-python/qumat_qdp/loader.py | New _select_torch_device helper; loader uses it for pytorch backend device pick. |
| qdp/qdp-python/qumat_qdp/api.py | Benchmark throughput path delegates to the shared helper instead of duplicated logic. |
| testing/qdp_python/test_torch_ref.py | New _torch_cuda_usable() mirroring the helper's capability check, applied to GPU-only test skipifs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ryankert01
pushed a commit
that referenced
this pull request
May 20, 2026
8 tasks
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.
Fixes Issue #1320 .
Adds
_select_torch_device(torch, device_id)inqumat_qdp.loader. It:"cpu"when CUDA isn't available,ValueErroron out-of-rangedevice_id(preserves priorcontract),
torch.cuda.get_device_capability(device_id)againsttorch.cuda.get_arch_list()and falls back to"cpu"with a clearwarnings.warnwhen the device'ssm_NNisn't in the list,f"cuda:{device_id}".Both
qumat_qdp.loader.QuantumDataLoader._create_pytorch_iteratorandqumat_qdp.api.QdpBenchmark._run_throughput_pytorchuse the new helper(the latter previously duplicated the same incomplete selection logic).
testing/qdp_python/test_torch_ref.pygets a mirror helper_torch_cuda_usable()used by the two@skipifs that previously onlychecked
is_available().After this change, on an incompatible GPU:
to CPU and pass (each emits one
UserWarning),"CUDA not available or GPU compute capability not supported by this PyTorch build".Verified on Linux + GTX 1060 (sm_61) with PyTorch wheel targeting
sm_70+: tests that previously errored with
cudaErrorNoKernelImageForDevicenow pass or skip cleanly.