Repository navigation
Conversation
`Capability` gated impls on `torch.cuda.get_device_capability()`. On a
ROCm build that is not a CUDA compute capability — it is the AMD GPU ISA
version, derived positionally from the gfx target (clr
`hipamd/src/hip_device.cpp`: `major = isa.versionMajor()`, and
`gcnArch = major*100 + minor*10 + stepping`, so 9*100+4*10+2 = gfx942).
Those values collide with NVIDIA sm numbers. On an MI300A:
gcnArchName = gfx942:sramecc+:xnack-
get_device_capability = (9, 4)
Capability(min_cc=(9,0)).is_satisfied() -> True # a Hopper gate
21 AMD targets report a tuple identical to an NVIDIA generation (8 report
sm_90, 7 sm_103, 2 sm_120). Nothing is mis-dispatched today only because
every cc-gated impl also needs an NVIDIA-only module that fails to import
on AMD, but the gate is unsound and blocks registering any rocm-* impl.
- cc gates are CUDA-only: unsatisfied on a ROCm build, with a reason.
Same guard as PyTorch's `IS_SM90` (testing/_internal/common_cuda.py)
and xformers `AttentionOpBase` (v0.0.28.post3 ops/fmha/common.py:371).
- Add `archs`, gating on the existing `infer_device_arch()`, which
already returns cdna3/hopper/ascend910/pvc but was wired to nothing.
Evaluated outside the CUDA block so NPU/XPU impls can gate themselves.
- `archs` and `min_cc`/`max_cc` are mutually exclusive, rejected at
construction: the combination is unsatisfiable on every device.
- A CPU device selector no longer resolves to accelerator 0.
- Include the device arch in the `available_impls` memo key; it is not
derivable from (device, cc).
Tests simulated NVIDIA devices by mocking the capability but never the
platform, so several asserted NVIDIA semantics while passing on AMD for
the wrong reason; they now pin a non-ROCm build. New tests cover the ROCm
cc gate, the arch gate, device selectors, the exclusivity check, and
dispatch-level filtering and memo keys.
Signed-off-by: Patel, Nilaykumar K <NilaykumarKantibhai.Patel@amd.com>
This branch has not been deployed
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.
Summary
On ROCm,
torch.cuda.get_device_capability()returns the AMD GPU ISA version (gfx942 →(9, 4), gfx90a →(9, 0), same as an H100), soCapability(min_cc=...)can pass on AMD hardware. On an MI300A,Capability(min_cc=(9, 0)).is_satisfied()isTrueon main.min_cc/max_ccare now CUDA-only (unsatisfied on a ROCm build).archsgate on the existinginfer_device_arch(); exclusive withmin_cc/max_cc.available_implsmemo key includes the device arch.Same guard as PyTorch (
IS_SM90,torch/testing/_internal/common_cuda.py) and xformers.Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergencemake testandmake test-convergencewere not run in full: no kernel or op code changed.