Skip to content

[Triton/Gluon] [CI] Load GEMM configs from <arch>/<cu_num>cu/ first - #7096

Closed
jiaryang wants to merge 7 commits into
ROCm:mainfrom
jiaryang:triton/gemm-config-cu-dir
Closed

jiaryang wants to merge 7 commits into
ROCm:mainfrom
jiaryang:triton/gemm-config-cu-dir

Conversation

@jiaryang

@jiaryang jiaryang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The Triton/Gluon config tree has one folder for each arch. A gfx1250 GEMM config tuned on one partition size is not correct for a different size. For example, MI450 DPX has 96 CUs in each partition and SPX has 192 CUs. The tuned CSV tables already select rows by cu_num. This PR gives the JSON configs the same selection.

Modifications

config_utils.py:

  • get_config_cu_num() returns device_info.get_num_sms(). This is chip_info.get_cu_num(), the value that the tuned CSV rows use. The CU_NUM environment variable overrides it.
  • get_config_cu_num() returns None when it cannot read the CU count.
  • resolve_config_dir() has a new cu_num= argument. With it, the function builds configs/<arch>/<cu_num>cu/<backend>/<op>/<d_type>.

gemm_config_utils.py:

  • get_gemm_config() reads DEFAULT.json and each specialized file from configs/<arch>/<cu_num>cu/<backend>/gemm/<d_type>/ first.
  • When a file is not in that folder, the loader reads it from the CU-agnostic folder.
  • The loader never reads a file from the folder of a different CU count. The CSV lookup also matches cu_num exactly.
  • cu_num is part of the cache key.
  • Only get_gemm_config() reads the <cu_num>cu/ folder. Families with their own loader, for example the grouped GEMM, do not.

Tuning tools:

  • The harness records the CU count of the device in each result.
  • sweep_configs.py --cu-dir and write_best_configs.py --cu-dir plan from the <cu_num>cu/ files and install into the <cu_num>cu/ folder.
  • The baseline uses the installed config of the folder that the sweep writes.
  • A DEFAULT_FALLBACK seed file takes M_BOUNDS from the DEFAULT.json that the loader merges with it.
  • The install uses only results that were timed at the CU count of the device.
  • sweep_configs.py does not resume a run that has results from a different CU count.
  • verify_configs.py prints the two folders.

.github/scripts/select_triton_tests.py accepts the optional <cu_num>cu level in the path.

Docs: configs/AGENTS.md, aiter/ops/triton/README.md, the tuning README.md and .github/instructions/aiter-ops-triton.instructions.md describe the <cu_num>cu/ folder.

When there is no <cu_num>cu/ folder, the loader returns the same configs as before.

Accuracy Tests

op_tests/triton_tests/utils/test_gemm_config_cu_dir.py is a new file with 21 tests.

Loader tests:

  • The file in <cu_num>cu/ has priority.
  • When that file is missing, the loader uses the CU-agnostic file.
  • The loader reads DEFAULT.json from <cu_num>cu/.
  • The loader ignores the folder when the CU count is different or cannot be read.
  • resolve_config_dir(cu_num=) rejects values that are not positive integers.

Tuning tool tests:

  • The plan and the install read the <cu_num>cu/ DEFAULT.json and file.
  • A DEFAULT_FALLBACK seed takes M_BOUNDS from its DEFAULT.json.
  • The baseline uses the config of the folder that the install writes.
  • --cu-dir installs only results that were timed at this CU count.
  • A sweep does not resume results from a different CU count.

Speed Tests and Profiling

At runtime, this PR changes only the config loader. The tuning tools do not run in inference. get_config_cu_num() is cached. The LRU cache

get_gemm_config() reads DEFAULT.json and each specialized file from
configs/<arch>/<cu_num>cu/<backend>/gemm/<d_type>/ when the file is there,
else from the CU-agnostic folder. cu_num is chip_info.get_cu_num() (CU_NUM
overrides it), the value tuned CSV rows are keyed on, so a config tuned on
one partition size is not served to another.

resolve_config_dir() takes cu_num; write_best_configs.py and sweep_configs.py
take --cu-dir; select_triton_tests.py accepts the extra path level.
@jiaryang
jiaryang requested review from a team and a balanced review from Copilot October 28, 2026 14:09
@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 7096 --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.

@github-actions github-actions Bot changed the title [Triton/Gluon] Load GEMM configs from <arch>/<cu_num>cu/ first [Triton/Gluon] [CI] Load GEMM configs from <arch>/<cu_num>cu/ first Oct 28, 2026

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.

🟡 Changes recommended

CU-specific configuration handling can reuse 96-CU tuning results as 192-CU winners, ignore CU_NUM overrides, and load incorrect defaults, risking installation and selection of mismatched configurations.

3 open issues
What changed in this PR

This PR adds CU-count-specific GEMM config lookup for Triton/Gluon, so GPU partitions can use separately tuned configs while retaining per-file fallback to CU-agnostic configs.

Changes:

  • Add CU detection, optional CU-specific paths, and CU-aware GEMM cache keys.
  • Extend tuning tools and CI test selection to support the new directory level.
  • Document the layout and add loader precedence, fallback, and validation tests.
File Description
op_tests/​triton_tests/​utils/​test_gemm_config_cu_dir.py Tests CU lookup, fallback, and input validation.
aiter/​ops/​triton/​utils/​gemm_config_utils.py Adds CU-first file lookup and CU-aware caching.
aiter/​ops/​triton/​utils/​config_utils.py Adds CU detection and optional CU directory paths.
aiter/​ops/​triton/​utils/​_triton/​tuning/​write_best_configs.py Adds CU-specific config installation.
aiter/​ops/​triton/​utils/​_triton/​tuning/​verify_configs.py Prints both config search directories.
aiter/​ops/​triton/​utils/​_triton/​tuning/​sweep_configs.py Passes --cu-dir to the installer.
aiter/​ops/​triton/​utils/​_triton/​tuning/​kernels.py Prefers CU-specific files when seeding configs.
aiter/​ops/​triton/​configs/​AGENTS.md Documents CU-specific layout and loader behavior.
.github/​scripts/​select_triton_tests.py Recognizes CU-specific config paths for test selection.

Review effort: Balanced

Comment thread aiter/ops/triton/utils/config_utils.py Resolved
The harness records the device's CU count in the plan and in every result.
sweep_configs.py does not resume results timed at another CU count, and
write_best_configs.py --cu-dir only installs results timed at this device's
CU count. seed_table() and load_defaults() read DEFAULT.json from
<arch>/<cu_num>cu/ first, as the loader does, so a new file takes the
M_BOUNDS and "any" bucket the loader would otherwise use.

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.

- sweep_configs.py --cu-dir passes --cu-dir to the harness, which then
  builds the space, bounds and baseline keys from the <cu_num>cu/
  DEFAULT.json and file, as the --cu-dir install does.
- A resume is refused when any ready record has another CU count, not
  only the first one.
- read_records() drops records of another CU count before keeping the last
  record per candidate, so a later timing at another CU count does not
  hide this one.
- The install checks the scope it wrote: the CU-agnostic folder without
  --cu-dir, <cu_num>cu/ first with it.
Add the CU-specific GEMM config folder to the Triton README, the tuning README and the Copilot instructions for aiter/ops/triton.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 15:26

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.

@jiaryang
jiaryang requested a review from azaidy October 28, 2026 15:39
…DEFAULT.json

The loader merges a DEFAULT_FALLBACK file over DEFAULT.json, so a file without M_BOUNDS uses the M_BOUNDS of DEFAULT.json. seed_table() now does the same, so the install and family_bounds() use the bounds that the loader walks.
…all writes

The baseline ran through the wrapper's config=None path, which reads this device's <cu_num>cu/ folder first. A sweep without --cu-dir installs into the CU-agnostic folder, so on a device with a <cu_num>cu/ file the baseline was another scope's config. installed_baseline() reads the install scope and launches that config when the wrapper would serve a different one.
…et_gemm_config() loads

The grouped GEMM has its own loader and reads only the CU-agnostic DEFAULT.json.
@azaidy
azaidy requested a review from Boss2002n October 28, 2026 16:03
Copilot AI balanced review requested due to automatic review settings October 28, 2026 16:05

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.

🔵 Needs a closer look

Human assessment is needed for resume-path edge cases that can ignore valid CU-tagged results or overwrite faster CU-specific configurations without retiming.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Boss2002n

Copy link
Copy Markdown
Contributor

#7105
I have resolved this in the above PR - so if u dont mind it can we close this?

@jiaryang

Copy link
Copy Markdown
Contributor Author

Will address via #7105

@jiaryang jiaryang closed this Oct 29, 2026
@jiaryang
jiaryang deleted the triton/gemm-config-cu-dir branch October 29, 2026 02:10
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.

3 participants