[ROCm] Build CK GEMM/SDPA per-arch and disable them for gfx1250 - #3567
Open
pragupta wants to merge 1 commit into
Open
[ROCm] Build CK GEMM/SDPA per-arch and disable them for gfx1250#3567pragupta wants to merge 1 commit into
pragupta wants to merge 1 commit into
Conversation
composable_kernel has no gfx1250 support, so its CK GEMM and CK SDPA
kernels fail to compile when targeting that arch. Previously the only
lever was the global USE_ROCM_CK_GEMM / USE_ROCM_CK_SDPA options, so
disabling CK for gfx1250 also disabled it for every other arch in the
same (commonly multi-arch) build.
Instead, build the CK kernels for every requested arch except gfx1250 by
filtering --offload-arch on the CK targets, and only fall back to fully
disabling CK when gfx1250 is the sole arch.
1. aten/src/ATen/CMakeLists.txt
- gfx1250-only guard: when gfx1250 is the only entry in
PYTORCH_ROCM_ARCH there is no supported arch left to build CK for,
so turn USE_ROCM_CK_GEMM and USE_ROCM_CK_SDPA off (via
caffe2_update_option, which writes the cache and is therefore seen
by caffe2/CMakeLists.txt). This runs before the CK blocks below.
- ck_sdpa: filter --offload-arch to drop gfx1250.
- CK GEMM: move the ck*.hip / bgemm_kernels sources out of the main
torch_hip sources into a dedicated, --offload-arch-filtered ck_gemm
library (mirrors the existing mslk/ck_sdpa pattern). The library
gets USE_ROCM_CK_GEMM defined on the target since it is no longer a
global flag.
2. cmake/Dependencies.cmake
- Stop adding -DUSE_ROCM_CK_GEMM to the global HIP flags. Applied
unconditionally here it ran before aten/src/ATen/CMakeLists.txt, so
the gfx1250-only guard could not retract it.
3. caffe2/CMakeLists.txt
- Apply USE_ROCM_CK_GEMM as a conditional target definition on
torch_hip and link ck_gemm, mirroring how USE_ROCM_CK_SDPA is
already handled. This makes the define honor the gfx1250-only guard.
Net behavior: a multi-arch build containing gfx1250 keeps CK GEMM/SDPA
for the other archs and skips only gfx1250; a gfx1250-only build cleanly
builds with CK GEMM/SDPA disabled (no empty --offload-arch compile and no
unresolved CK symbols); builds without gfx1250 are unchanged.
This change was co-authored with Claude.
(cherry picked from commit 92e6d4e)
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.
composable_kernel has no gfx1250 support, so its CK GEMM and CK SDPA kernels fail to compile when targeting that arch. Previously the only lever was the global USE_ROCM_CK_GEMM / USE_ROCM_CK_SDPA options, so disabling CK for gfx1250 also disabled it for every other arch in the same (commonly multi-arch) build.
Instead, build the CK kernels for every requested arch except gfx1250 by filtering --offload-arch on the CK targets, and only fall back to fully disabling CK when gfx1250 is the sole arch.
aten/src/ATen/CMakeLists.txt
cmake/Dependencies.cmake
caffe2/CMakeLists.txt
Net behavior: a multi-arch build containing gfx1250 keeps CK GEMM/SDPA for the other archs and skips only gfx1250; a gfx1250-only build cleanly builds with CK GEMM/SDPA disabled (no empty --offload-arch compile and no unresolved CK symbols); builds without gfx1250 are unchanged.
This change was co-authored with Claude.
(cherry picked from commit 92e6d4e)
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist