Skip to content

[JIT] Build every listed CU count of each GPU_ARCHS arch - #6844

Merged
amd-ruitang3 merged 4 commits into
mainfrom
relbers/arch-all-cu-nums
Nov 3, 2026
Merged

amd-ruitang3 merged 4 commits into
mainfrom
relbers/arch-all-cu-nums

Conversation

@RElbers

@RElbers RElbers commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

An explicit GPU_ARCHS build 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_NUM can swap the default for a different count, but it applies to every arch in GPU_ARCHS and 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_MAP becomes GFX_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 in GPU_ARCHS to one (gfx, cu_num) target per listed count, so filter_tune_df keeps the tuned rows for every variant.
  • A non-zero CU_NUM still replaces the counts with that one value for every selected arch, as on main. CU_NUM=0 means unset, as it does for get_cu_num().
  • Native builds (no GPU_ARCHS, or GPU_ARCHS=native) are unchanged and use the live (gfx, cu_num).
  • Runtime dispatch is unchanged: the lookup already keys on the live CU count, so a package holding several counts picks the right row.

Behavior changes

Build GPU_ARCHS CU_NUM Included tuning rows (gfx: cu_num)
main gfx942 unset gfx942: 304
this PR gfx942 unset gfx942: 304, 228, 80
main gfx950 unset gfx950: 256
this PR gfx950 unset gfx950: 256, 128
main gfx942;gfx950 unset gfx942: 304; gfx950: 256
this PR gfx942;gfx950 unset gfx942: 304, 228, 80; gfx950: 256, 128
main gfx942 80 gfx942: 80
this PR gfx942 80 gfx942: 80
main gfx942;gfx950 304 gfx942: 304; gfx950: 304 (no tuned rows)
this PR gfx942;gfx950 304 gfx942: 304; gfx950: 304 (no tuned rows)
main gfx950 0 gfx950: 0 (no tuned rows)
this PR gfx950 0 gfx950: 256, 128

The 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=gfx942 now builds the tuned rows for 304, 228 and 80 CUs (previously 304 only); GPU_ARCHS=gfx950 builds 256 and 128.
  • CU_NUM=0 now selects every listed count; previously it built (gfx, 0), which matches no tuned row.
  • A CU count missing from GFX_CU_NUMS_MAP is only built when named with CU_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 .so size 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_ARCHS main this PR
gfx942 575 813
gfx950 869 869
gfx942;gfx950 911 1031

Only four modules generate different sources:

  • module_gemm_a8w8
  • module_gemm_a8w8_bpreshuffle
  • module_gemm_a8w8_bpreshuffle_cktile
  • module_gemm_a8w8_blockscale_bpreshuffle

Building those four, one module at a time on an 256-core host (PREBUILD_KERNELS=1 flags, default job count):

GPU_ARCHS Module Build time, main Build time, this PR .so size, main .so size, this PR
gfx942 gemm_a8w8 66.5 s 80.1 s 48.4 MB 88.8 MB
gemm_a8w8_bpreshuffle 38.9 s 92.0 s 5.9 MB 44.3 MB
gemm_a8w8_bpreshuffle_cktile 93.8 s 168.3 s 10.5 MB 49.3 MB
gemm_a8w8_blockscale_bpreshuffle 32.5 s 41.9 s 0.7 MB 8.2 MB
Total 231.7 s 382.3 s 65.5 MB 190.7 MB
gfx942;gfx950 gemm_a8w8 247.8 s 263.0 s 334.1 MB 340.8 MB
gemm_a8w8_bpreshuffle 200.9 s 221.3 s 55.6 MB 93.5 MB
gemm_a8w8_bpreshuffle_cktile 537.4 s 577.7 s 255.1 MB 323.7 MB
gemm_a8w8_blockscale_bpreshuffle 80.5 s 81.3 s 15.2 MB 16.3 MB
Total 1066.6 s 1143.3 s 660.0 MB 774.3 MB

If 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_NUM override, CU_NUM=0 treated as unset).
  • python op_tests/test_gemm_codegen.py: 62/62 passed with no env, with GPU_ARCHS=gfx950 CU_NUM=0, and with GPU_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.
  • ruff and black are clean on the touched files.

- 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.
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6844 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@RElbers
RElbers marked this pull request as ready for review October 22, 2026 21:10
@RElbers
RElbers requested a review from a team October 22, 2026 21:10
@github-actions github-actions Bot changed the title Build every listed CU count of each GPU_ARCHS arch [JIT] Build every listed CU count of each GPU_ARCHS arch Oct 22, 2026
@github-actions github-actions Bot added the JIT label Oct 22, 2026
@RElbers RElbers added the ci:all label Oct 22, 2026
@zufayu
zufayu requested a review from amd-ruitang3 October 23, 2026 01:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_NUM overrides while treating CU_NUM=0 as 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
Copilot AI balanced review requested due to automatic review settings November 3, 2026 11:58
@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 7cf8f8ac405e · mode shadow

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

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What changes in dependency, cache or compilation behavior, and how did you verify both a clean build and an existing-cache path?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_build_targets_architecture.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_gemm_codegen.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the multi-CU build-target expansion.

No open issues 🎉

Review effort: Balanced

@amd-ruitang3
amd-ruitang3 merged commit 4726326 into main Nov 3, 2026
@amd-ruitang3
amd-ruitang3 deleted the relbers/arch-all-cu-nums branch November 3, 2026 17:08
@amd-ruitang3

Copy link
Copy Markdown
Contributor

@zufayu after this PR merge. You must set arch_num and cu_num to buiild MI308!

@amd-ruitang3

Copy link
Copy Markdown
Contributor

@gyohuangxin FYI

shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants