Repository navigation
[JIT] Build every listed CU count of each GPU_ARCHS arch - #6844
Conversation
- Replaces the single default count per arch in GFX_CU_NUM_MAP with GFX_CU_NUMS_MAP, a tuple of the CU counts each arch ships with, full GPU first. - Expands each arch in an explicit GPU_ARCHS build to one target per listed count, so one package carries the tuned CK rows for every variant of an arch. - Keeps a non-zero CU_NUM as the single count for every selected arch. - Treats CU_NUM=0 as unset, matching get_cu_num, instead of selecting a count that no tuned row has. - Updates the build target tests for the expanded pairs and checks that the fixture targets stay listed in the map. An arch name alone does not identify the tuned rows a device needs: gfx942 covers 304, 228 and 80 CU parts, and gfx950 covers 256 and 128. Selecting one default count per arch left the other variants on heuristic kernels.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the explicit-architecture build-target expansion across CU counts.
No open issues 🎉
What changed in this PR
This PR expands explicit-architecture JIT builds to include tuned kernels for every listed CU count, allowing one package to support multiple GPU variants of the same architecture.
Changes:
- Replaces single default CU counts with per-architecture tuples and expands build targets accordingly.
- Preserves non-zero
CU_NUMoverrides while treatingCU_NUM=0as unset; native builds and runtime dispatch remain unchanged. - Updates tests for expanded targets, override behavior, and retention of tuning rows across CU counts.
| File | Description |
|---|---|
op_tests/test_gemm_codegen.py |
Checks expanded targets, fixture coverage, and tuning-row retention. |
op_tests/test_build_targets_architecture.py |
Tests multi-count RDNA targets and zero-override behavior. |
aiter/jit/utils/chip_info.py |
Updates the build-target docstring to describe multi-count expansion. |
aiter/jit/utils/build_targets.py |
Defines CU-count tuples and expands explicit build targets. |
Review effort: Balanced
…-nums # Conflicts: # aiter/jit/utils/build_targets.py # op_tests/test_build_targets_architecture.py
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
|
@zufayu after this PR merge. You must set arch_num and cu_num to buiild MI308! |
|
@gyohuangxin FYI |
- Replaces the single default count per arch in GFX_CU_NUM_MAP with GFX_CU_NUMS_MAP, a tuple of the CU counts each arch ships with, full GPU first. - Expands each arch in an explicit GPU_ARCHS build to one target per listed count, so one package carries the tuned CK rows for every variant of an arch. - Keeps a non-zero CU_NUM as the single count for every selected arch. - Treats CU_NUM=0 as unset, matching get_cu_num, instead of selecting a count that no tuned row has. - Updates the build target tests for the expanded pairs and checks that the fixture targets stay listed in the map. An arch name alone does not identify the tuned rows a device needs: gfx942 covers 304, 228 and 80 CU parts, and gfx950 covers 256 and 128. Selecting one default count per arch left the other variants on heuristic kernels.
Motivation
An explicit
GPU_ARCHSbuild kept only the rows for one default count per arch. A gfx942 wheel compiled the rows tuned for 304 CUs and dropped those tuned for 80 CUs. An 80-CU gfx942 device then fell back to heuristic kernels, even though tuned rows for it are in the repo.CU_NUMcan swap the default for a different count, but it applies to every arch inGPU_ARCHSand cannot request two counts of the same arch. So no single package could serve every variant of an arch. This PR is also relevant for the new MI350P, for which there little to no tuned rows currently in AITER.Technical details
GFX_CU_NUM_MAPbecomesGFX_CU_NUMS_MAP: each arch maps to a tuple of the CU counts it ships with, full GPU first.get_build_targets_env()expands each arch inGPU_ARCHSto one(gfx, cu_num)target per listed count, sofilter_tune_dfkeeps the tuned rows for every variant.CU_NUMstill replaces the counts with that one value for every selected arch, as on main.CU_NUM=0means unset, as it does forget_cu_num().GPU_ARCHS, orGPU_ARCHS=native) are unchanged and use the live(gfx, cu_num).Behavior changes
GPU_ARCHSCU_NUMgfx:cu_num)gfx942gfx942gfx950gfx950gfx942;gfx950gfx942;gfx950gfx94280gfx94280gfx942;gfx950304gfx942;gfx950304gfx9500gfx9500The repo currently has no tuned rows for gfx942 at 228 CUs or gfx950 at 128 CUs; those targets pick up rows as they are tuned.
GPU_ARCHS=gfx942now builds the tuned rows for 304, 228 and 80 CUs (previously 304 only);GPU_ARCHS=gfx950builds 256 and 128.CU_NUM=0now selects every listed count; previously it built(gfx, 0), which matches no tuned row.GFX_CU_NUMS_MAPis only built when named withCU_NUM; adding it to the map includes it in default builds.Build cost
Explicit-arch builds now compile the CK instances for every listed count, so build time and
.sosize grow where tuned rows exist for more than one count. Today that is gfx942 (rows at 304 and 80 CUs); gfx950 has no tuned rows at 128 CUs yet, so its build is unchanged.Generated CK sources across all 11 CK GEMM modules:
GPU_ARCHSgfx942gfx950gfx942;gfx950Only four modules generate different sources:
module_gemm_a8w8module_gemm_a8w8_bpreshufflemodule_gemm_a8w8_bpreshuffle_cktilemodule_gemm_a8w8_blockscale_bpreshuffleBuilding those four, one module at a time on an 256-core host (
PREBUILD_KERNELS=1flags, default job count):GPU_ARCHS.sosize, main.sosize, this PRgfx942gemm_a8w8gemm_a8w8_bpreshufflegemm_a8w8_bpreshuffle_cktilegemm_a8w8_blockscale_bpreshufflegfx942;gfx950gemm_a8w8gemm_a8w8_bpreshufflegemm_a8w8_bpreshuffle_cktilegemm_a8w8_blockscale_bpreshuffleIf the increased build time or size for default builds isn't acceptable, another option is to add a new environment variable to determine the behavior of an unset CU_NUM. Something like
UNSET_CU_NUM_BEHAVIOR="default" | "all". With "default" to only select the default cu_num (like current main does), and "all" to select all cu_nums for that arch (what this branch currently does). I didn't want to add a new env-var preemptively, because I can't judge if the build time and size is something to worry about.Test plan
python -m pytest op_tests/test_build_targets_architecture.py: 10 passed (expanded RDNA targets,CU_NUMoverride,CU_NUM=0treated as unset).python op_tests/test_gemm_codegen.py: 62/62 passed with no env, withGPU_ARCHS=gfx950 CU_NUM=0, and withGPU_ARCHS=gfx942 CU_NUM=80. It covers the expanded target lists, the filter keeping every gfx942 row of the fixture CSV, and the fixture targets staying listed in the map.ruffandblackare clean on the touched files.