Repository navigation
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
|
The bug fix in commit 1 looks correct — delegating to chip_info.get_cu_num() aligns the tuner with runtime dispatch. No-op on CDNA, clean fix. For the tuned config rows: many of them are likely redundant due to the runtime's M-padding fallback. get_CKGEMM_config in gemm_op_a8w8.py:416-458 tries three lookups in order:
So if a raw M pads (gl=0) to an aligned M that's already in the CSV, and both map to the same kernel, the raw-M row is redundant — runtime will fall through to the padded entry automatically. Looking at the existing gfx950 data, ~74% of rows are eliminable by this logic. Most M values within a (N, K) pair resolve to the same dominant kernel; only a handful of small-M entries genuinely need a different kernel than their padded neighbor. Suggest keeping only: (a) gl=0-aligned M values, and (b) raw M values whose best kernel actually differs from their padded target's kernel. This would likely reduce the 358 rows to ~90-100 without any performance or correctness impact — runtime dispatch covers the rest via fallback. |
|
Addressed in 3 commits:
|
fa6699a to
b44ad01
Compare
|
Hi @pds-amd , it seems some gfx950 rows are removed unsafely (perf regressions)28 of the removed rows are not redundant, and dropping them changes the kernel the runtime dispatch actually selects. Root cause — the redundancy check in test_tuned_config_csv.py (and the removal script mirroring it) does not match the runtime fallback semantics in get_CKGEMM_config / gemm_a8w8_bpreshuffle.cu: Runtime tries gl ∈ [None, 0, 1] and returns on the first padded-M key that exists (existence only — kernel is irrelevant). |
|
please move the gfx1201 shape in aiter/configs/model_configs/a8w8_blockscale_tuned_gemm_gfx1201.csv, also add a untuned file. |
b44ad01 to
4ce76b4
Compare
|
Reworked to keep the blast radius minimal:
A broader clean-up of existing CSVs could be undertaken as future work based on this added test. |
4ce76b4 to
4dfcfea
Compare
There was a problem hiding this comment.
🟡 Not ready to approve
The PR description’s claims about which CSV was updated (and the added row count) do not match the actual files committed, so the description/results need to be aligned with the implementation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Fixes RDNA (gfx11xx/gfx12xx) GEMM tuning key mismatches by aligning the tuner’s (gfx, cu_num, M, N, K) keying with the runtime’s chip_info-based CU count, and adds initial gfx1201 (RDNA4) a8w8_blockscale tuned coverage via a new model-config CSV.
Changes:
- Update
BaseTuner.get_cu_num()to useaiter.jit.utils.chip_info.get_cu_num()so tuned rows key by true CU count (not torch’s WGP count on RDNA). - Add gfx1201 tuned and untuned shape CSVs under
aiter/configs/model_configs/. - Add a new pytest that detects tuned rows that are redundant under the
get_CKGEMM_configfallback chain.
File summaries
| File | Description |
|---|---|
| op_tests/test_tuned_config_csv.py | Adds a static CSV-level redundancy check mirroring get_CKGEMM_config’s fallback probing behavior. |
| aiter/utility/base_tuner.py | Switches tuner CU detection to chip_info to match runtime dispatch key construction on RDNA GPUs. |
| aiter/configs/model_configs/a8w8_blockscale_untuned_gemm_gfx1201.csv | Adds the gfx1201 untuned shape list used for tuning coverage. |
| aiter/configs/model_configs/a8w8_blockscale_tuned_gemm_gfx1201.csv | Adds gfx1201 tuned rows keyed by cu_num=64 for runtime merge/lookup. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
4dfcfea to
67d8bd2
Compare
67d8bd2 to
ec7a1d8
Compare
BaseTuner.get_cu_num() used torch multi_processor_count, which on RDNA (gfx11xx/gfx12xx) reports WGPs (half the CU count). The runtime resolves cu_num via chip_info.get_cu_num() (true CU count), so tuner-written keys (gfx, cu_num, M, N, K) never matched at runtime and every RDNA row silently fell back to the default kernel. Delegate get_cu_num() to the same chip_info accessor. No-op on CDNA (gfx942/gfx950).
…l_configs Adds first RDNA4 (gfx1201, cu_num=64) tuned coverage for a8w8_blockscale as model_configs files, leaving the canonical CSV (gfx950) untouched: - model_configs/a8w8_blockscale_tuned_gemm_gfx1201.csv (255 rows), merged into the family at runtime by core.get_config_file. - model_configs/a8w8_blockscale_untuned_gemm_gfx1201.csv (matching untuned). Rows are pruned of entries redundant under get_CKGEMM_config's fallback, which probes [gl=None, gl=0, gl=1] and returns the first key that EXISTS (target kernel irrelevant). op_tests/test_tuned_config_csv.py enforces this: a row is redundant iff its first existing gl0/gl1 fallback target carries the same kernel (with a pm==M self-probe guard). Verified every tuned shape plus a dense non-tuned M sweep across all (N,K) resolve to an identical kernel with the pruned set (0 mismatches). Shapes from an RDNA4 diffusion-inference sweep (FLUX / FLUX.2, qwen-image, stablediffusion-3.5, wan2.2, z-image, ...).
ec7a1d8 to
1c9e1eb
Compare
|
@yzhou103 - could you please re-approve? The CI failure is unrelated to this work. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
aiter/configs/model_configs/a8w8_blockscale_tuned_gemm_gfx1201.csv:2
- [verified] The normal explicit-target build path still rejects
GPU_ARCHS=gfx1201:get_build_targets_env()only accepts architectures inGFX_CU_NUM_MAP(aiter/jit/utils/build_targets.py:39-43), which has no gfx1201 entry. Thus a clean gfx1201 build cannot generate the registry needed by these rows and fails before tuning/config integration. Author must add the gfx1201 CU default/target handling to the build path (with the corresponding CK support) or avoid shipping CK rows that cannot be built.
gfx1201,64,333,2432,2432,ck,5,0,42.0445,a8w8_blockscale_1x128x128_256x16x128x128_8x16_16x16_1x2_16x16x1_8x32x1_1x16x1x16_8_1x2_intrawave_v1,93.69,198.46,0.0
aiter/utility/base_tuner.py:477
- [verified] This now calls
chip_info.get_cu_num(), whose implementation scans every GPU reported by rocminfo and asserts that all CU counts are identical. On a host exposing, for example, gfx1201/64 and gfx950/256, tuning the selected device raisesAssertionErrorbefore producing a config, whereas the previous implementation queriedtorch.cuda.current_device()only. Author must preserve device-specific CU selection or explicitly reject and document heterogeneous-device tuning.
return _chip_get_cu_num()
op_tests/test_tuned_config_csv.py:103
- [verified] This new regression test is outside
op_tests/tuning_tests/, but.github/workflows/tuning-tests.yaml:88-96invokes only the explicitly listedop_tests.tuning_tests.*modules and no workflow command matches this file. Thus the redundancy check is not run in CI and can regress unnoticed. Author must add this test to a CI command (or place it under the existing tuning-test suite) so the guard is enforced.
@pytest.mark.parametrize("csv_path", TUNED_CONFIG_CSVS)
def test_no_redundant_rows(csv_path):
redundant = _find_redundant_rows(csv_path)
| @@ -0,0 +1,256 @@ | |||
| gfx,cu_num,M,N,K,libtype,kernelId,splitK,us,kernelName,tflops,bw,errRatio | |||
| gfx1201,64,333,2432,2432,ck,5,0,42.0445,a8w8_blockscale_1x128x128_256x16x128x128_8x16_16x16_1x2_16x16x1_8x32x1_1x16x1x16_8_1x2_intrawave_v1,93.69,198.46,0.0 | |||
There was a problem hiding this comment.
🔵 Needs a closer look
It changes GPU-arch gating and runtime dispatch behavior where a misconfiguration could cause hard-to-debug runtime failures (e.g., unsafe launches), so it warrants final human validation despite good test additions.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Lite
| with open(REPO_ROOT / csv_path) as f: | ||
| for r in csv.DictReader(f): | ||
| key = ( |
| csv_triton = _make_temp_csv(f""" | ||
| gfx,cu_num,M,N,K,kernelId,libtype,splitK,us,kernelName,tflops,bw,errRatio | ||
| {gfx},{cu_num},{m},{n},{k},-1,triton,0,10.0,,100.0,500.0,0.0 | ||
| """) |
| def _fallback_target(rows: dict, gfx, cu, M, N, K): | ||
| """ | ||
| Mirror get_CKGEMM_config's probe order for a row's own shape: the runtime | ||
| tries gl=0 then gl=1 and returns the FIRST key that EXISTS (kernel of the | ||
| target is not consulted). Returns (padded_M, kernelName) of that target, or | ||
| None if neither exists. The gl=None probe is the row itself and is excluded. | ||
| """ |
|
No activity for 15 days, so this is now labelled |

Motivation
Offline GEMM tuning is inert on RDNA GPUs (gfx11xx/gfx12xx). Every tuned
a8w8_blockscalerow is a silent miss at runtime, so the op always falls back to the default kernel (... not found tuned config ..., will use default config!), and--run_configreportsNo shapes to benchmark. This PR fixes the root cause and adds the first RDNA4 (gfx1201) tuned coverage for this family.Technical Details
Two commits:
1.
fix(tuner): key tuned configs by true CU count on RDNATuned GEMM rows are keyed by
(gfx, cu_num, M, N, K). The runtime lookup (aiter.ops.gemm_op_a8w8.get_CKGEMM_config) resolvescu_numviaaiter.jit.utils.chip_info.get_cu_num()(rocminfoCompute Unit), butBaseTuner.get_cu_num()readtorch.cuda.get_device_properties().multi_processor_count. On RDNA that value is the WGP count = half the true CU count (gfx1201 Radeon AI PRO R9700: torch reports32, actual CU count is64). So the tuner stamped rows withcu_num=32while the runtime looked them up withcu_num=64; the keys never matched.Fix: delegate
get_cu_num()(andget_gfx()) to the samechip_infoaccessors the runtime uses, so the tuner and the lookup can never disagree. No tuner subclass overridesget_cu_num, so this covers every family. No-op on CDNA, where CU and WGP counts coincide (e.g. the existinggfx950,256configs resolve correctly today and are unaffected).2.
feat(gemm_a8w8_blockscale): add gfx1201 (RDNA4) tuned config via model_configsAdds 255 gfx1201 (
cu_num=64) tuned rows as a newaiter/configs/model_configs/a8w8_blockscale_tuned_gemm_gfx1201.csv, with the matchingmodel_configs/a8w8_blockscale_untuned_gemm_gfx1201.csv. The canonicalaiter/configs/a8w8_blockscale_tuned_gemm.csvis not modified — the runtime mergesmodel_configs/*into the family viaget_config_file. First RDNA4 coverage for this family.Shapes come from an RDNA4 diffusion-inference sweep spanning multiple models (FLUX / FLUX.2 t2i/i2i/multi, FLUX.2-klein, flux-kontext, qwen-image, qwen-image-edit, stablediffusion-3.5, wan2.2, z-image).
Rows are pruned against the
get_CKGEMM_configfallback chain (gl=None/gl=0/gl=1, first existing key wins, target kernel irrelevant), so no row duplicates what runtime dispatch would already resolve.op_tests/test_tuned_config_csv.py, added here and requiring no GPU, enforces this for the gfx1201 file.Every added row was verified through the production op (not just the tuner's direct-kernel check) via
test_run_config.pyon gfx1201. Six tiny-M shapes (M ∈ {1,2,8}:(8,3840,3840),(1,4864,2432),(2,4864,2432),(8,10240,3840),(1,14592,2432),(2,14592,2432)) were intentionally excluded: they mismatch therun_torchreference through the production op for both the tuned and the default kernel, so the discrepancy is independent of tuning (a kernel- or reference-side issue at very small M) and is left to fall back to the default.Test Plan
test_csv_validation.py— CSV integrity (dedup key(cu_num,M,N,K),us > 0,errRatio <= 0.2, no conflict markers).test_config_shape_collision.py— family-wide runtime merge (canonical +model_configs/) is duplicate-free on the runtime key.test_tuned_config_csv.py(added) — no gfx1201 row is redundant under theget_CKGEMM_configfallback chain; no GPU required.test_run_config.py(a8w8_blockscale) on gfx1201 — runs the production op for every tuned shape; expects 0 MISMATCH/ERROR.chip_info.get_gfx_runtime()/get_cu_num()vstorch.multi_processor_counton gfx1201.Test Result
chip_info.get_gfx_runtime() = gfx1201,get_cu_num() = 64;torch.multi_processor_count = 32.--run_config->No shapes to benchmark.After: loads all rows at
cu_num=64, setsAITER_CONFIG_GEMM_A8W8_BLOCKSCALE, and benchmarks every shape.test_csv_validation.py(a8w8_blockscale): PASS -- canonical file unchanged at 6630gfx950,256rows; the 255 newgfx1201,64rows live inmodel_configs/; allus > 0, allerrRatio <= 0.2, 0 duplicates on(cu_num,M,N,K).test_config_shape_collision.py(a8w8_blockscale): PASS, 0 collisions -- runtime merge of the canonical file + 10model_configs/files is duplicate-free; both planted-duplicate / clean self-check controls pass.test_tuned_config_csv.py: PASS -- 0 redundant rows in the gfx1201 file.run_torchreference -- 0 MISMATCH, 0 ERROR (equivalent totest_run_config.py's check).chip_info==torch.multi_processor_count); existinggfx950,256rows resolve as before.Submission Checklist