Repository navigation
[ROCm] For SPIRV: replace preprocessor checks for gfx9xx with builtin_amdgcn_processor_is() - #172476
lakhinderwalia wants to merge 13 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/172476
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 2 New FailuresAs of commit f48e7ca with merge base 018bf86 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Pull request overview
This PR replaces compile-time preprocessor checks for AMD GPU architectures (gfx90a, gfx942, gfx950) with runtime checks using __builtin_amdgcn_processor_is() to support SPIRV compilation. The changes enable device-specific code paths to be selected at runtime rather than compile-time, which is necessary for SPIRV's architecture-agnostic compilation model.
Changes:
- Replaced
#if defined(__gfx90a__),#if defined(__gfx942__), and#if defined(__gfx950__)preprocessor directives with runtime__builtin_amdgcn_processor_is()checks - Removed the
CDNA2_OR_LATERmacro in favor of runtime architecture detection - Updated atomic operations and kernel implementations to use conditional runtime branching
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| aten/src/ATen/native/cuda/layer_norm_kernel.cu | Replaced compile-time gfx90a checks with runtime checks for reciprocal operations, introducing lambda functions for cleaner code organization |
| aten/src/ATen/native/cuda/int4mm.cu | Removed CDNA2_OR_LATER macro and moved architecture checks to runtime within the kernel function |
| aten/src/ATen/native/cuda/ScatterGatherKernel.cu | Converted preprocessor-based atomic operation selection to runtime branching |
| aten/src/ATen/native/cuda/MemoryAccess.cuh | Added runtime check for gfx942-specific non-temporal load optimizations |
| aten/src/ATen/native/cuda/KernelUtils.cuh | Replaced preprocessor checks with runtime conditionals in atomic add implementations, utilizing __builtin_amdgcn_is_invocable |
| aten/src/ATen/native/cuda/Indexing.cu | Converted preprocessor-based atomic operation selection to runtime branching |
| aten/src/ATen/native/cuda/CUDALoops.cuh | Replaced preprocessor checks for gfx942 with runtime branching for thread work size selection |
| aten/src/ATen/cuda/Atomic.cuh | Converted gfx908-specific atomic operations to runtime checks |
Comments suppressed due to low confidence (1)
aten/src/ATen/native/cuda/KernelUtils.cuh:82
- Extra space in namespace declaration. Should be 'at::native' not 'at:: native'.
namespace at:: native {
|
@pytorchbot rebase -b main |
|
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
|
Successfully rebased |
394ff09 to
1647da7
Compare
|
@pytorchbot rebase -b main Rebasing after the other amdgcnspirv PR landed. |
|
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
|
@pytorchbot revert -c nosignal -m "broke nightly builds https://github.com/pytorch/pytorch/actions/runs/24179438750/job/70568465816" |
|
@pytorchbot successfully started a revert job. Check the current status here. |
… builtin_amdgcn_processor_is() (#172476)" This reverts commit d408262. Reverted #172476 on behalf of https://github.com/jeffdaily due to broke nightly builds https://github.com/pytorch/pytorch/actions/runs/24179438750/job/70568465816 ([comment](#172476 (comment)))
|
@lakhinderwalia your PR has been successfully reverted. |
This PR was reopened (likely due to being reverted), so your approval was removed. Please request another review.
__builtin_amdgcn_is_invocable incorrectly reports the mfma_f32_16x16x16bf16_1k intrinsic as available on gfx908 (CDNA1), but the LLVM backend cannot select it, causing a "Cannot select" error during multi-target compilation. Add preprocessor guards to exclude gfx908 at compile time while preserving __builtin_amdgcn_is_invocable for forward-compatible feature detection on all other architectures. Co-Authored-By: Claude Opus 4.6 (1M context)
|
@pytorchbot merge -i |
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
Merge startedYour change will be merged while ignoring the following 2 checks: pull / linux-jammy-py3.14-clang18 / test (dynamo_wrapped, 1, 3, lf.linux.2xlarge), pull / linux-docs / build-docs-python-false Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…_amdgcn_processor_is() (pytorch#172476) Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html Fixes pytorch#172467 Pull Request resolved: pytorch#172476 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
…_amdgcn_processor_is() (pytorch#172476) Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html Fixes pytorch#172467 Pull Request resolved: pytorch#172476 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
… builtin_amdgcn_processor_is() (pytorch#172476)" This reverts commit d408262. Reverted pytorch#172476 on behalf of https://github.com/jeffdaily due to broke nightly builds https://github.com/pytorch/pytorch/actions/runs/24179438750/job/70568465816 ([comment](pytorch#172476 (comment)))
…_amdgcn_processor_is() (pytorch#172476) Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html Fixes pytorch#172467 Pull Request resolved: pytorch#172476 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
…_amdgcn_processor_is() (pytorch#172476) Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html Fixes pytorch#172467 Pull Request resolved: pytorch#172476 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
… builtin_amdgcn_processor_is() (pytorch#172476)" This reverts commit d408262. Reverted pytorch#172476 on behalf of https://github.com/jeffdaily due to broke nightly builds https://github.com/pytorch/pytorch/actions/runs/24179438750/job/70568465816 ([comment](pytorch#172476 (comment)))
…_amdgcn_processor_is() (pytorch#172476) Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html Fixes pytorch#172467 Pull Request resolved: pytorch#172476 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
Ref: https://rocm.docs.amd.com/projects/llvm-project/en/develop/conceptual/spirv.html
Fixes #172467
cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang