Repository navigation
Conversation
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.
🏷️ 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.
🟡 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
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.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved CU-specific handling can use incorrect sweep metadata, reuse candidates across CU counts, discard valid timings, and roll back valid installations.
7 open issues
Reusing the runs directory after switching from 96 to 192 CUs can resume old results and install… When the CU-specific default has different keys orM_BOUNDS, the sweep still uses CU-agnostic… · New A legacyreadyrecord withoutcu_numhides later CU-tagged records, so a 192-CU sweep can reuse… · Newread_records()keeps only the last record per config, so this filter loses a valid 96-CU timing… · New If the matching CU-specific bucket differs from a new winner, an install without--cu-diris… · New Whenchip_infocannot be imported,get_num_sms()ignoresCU_NUM=96and can return a device… With--cu-dir,seed_table()andload_defaults()still read the baseDEFAULT.json, so…
Review effort: Balanced
- 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.
There was a problem hiding this comment.
🟡 Changes recommended
The fallback seed fails to inherit the selected default’s M_BOUNDS, causing tuning at M=32 to write an ignored M_LEQ_32 bucket and installation to roll back.
1 open issue
7 resolved since last review
Reusing the runs directory after switching from 96 to 192 CUs can resume old results and install… If the matching CU-specific bucket differs from a new winner, an install without--cu-diris…read_records()keeps only the last record per config, so this filter loses a valid 96-CU timing… A legacyreadyrecord withoutcu_numhides later CU-tagged records, so a 192-CU sweep can reuse… When the CU-specific default has different keys orM_BOUNDS, the sweep still uses CU-agnostic… Whenchip_infocannot be imported,get_num_sms()ignoresCU_NUM=96and can return a device… With--cu-dir,seed_table()andload_defaults()still read the baseDEFAULT.json, so…
Review effort: Balanced
…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.
There was a problem hiding this comment.
🔵 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
|
#7105 |
|
Will address via #7105 |


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()returnsdevice_info.get_num_sms(). This ischip_info.get_cu_num(), the value that the tuned CSV rows use. TheCU_NUMenvironment variable overrides it.get_config_cu_num()returnsNonewhen it cannot read the CU count.resolve_config_dir()has a newcu_num=argument. With it, the function buildsconfigs/<arch>/<cu_num>cu/<backend>/<op>/<d_type>.gemm_config_utils.py:get_gemm_config()readsDEFAULT.jsonand each specialized file fromconfigs/<arch>/<cu_num>cu/<backend>/gemm/<d_type>/first.cu_numexactly.cu_numis part of the cache key.get_gemm_config()reads the<cu_num>cu/folder. Families with their own loader, for example the grouped GEMM, do not.Tuning tools:
sweep_configs.py --cu-dirandwrite_best_configs.py --cu-dirplan from the<cu_num>cu/files and install into the<cu_num>cu/folder.DEFAULT_FALLBACKseed file takesM_BOUNDSfrom theDEFAULT.jsonthat the loader merges with it.sweep_configs.pydoes not resume a run that has results from a different CU count.verify_configs.pyprints the two folders..github/scripts/select_triton_tests.pyaccepts the optional<cu_num>culevel in the path.Docs:
configs/AGENTS.md,aiter/ops/triton/README.md, the tuningREADME.mdand.github/instructions/aiter-ops-triton.instructions.mddescribe 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.pyis a new file with 21 tests.Loader tests:
<cu_num>cu/has priority.DEFAULT.jsonfrom<cu_num>cu/.resolve_config_dir(cu_num=)rejects values that are not positive integers.Tuning tool tests:
<cu_num>cu/DEFAULT.jsonand file.DEFAULT_FALLBACKseed takesM_BOUNDSfrom itsDEFAULT.json.--cu-dirinstalls only results that were timed at this 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