Skip to content

[Triton/Gluon] [Config] gfx1250 Gluon GEMM configs for Kimi-K2 TP8 - #6573

Merged
azaidy merged 11 commits into
ROCm:mainfrom
jiaryang:config/gfx1250-kimi-k2-gluon-gemm
Oct 29, 2026
Merged

azaidy merged 11 commits into
ROCm:mainfrom
jiaryang:config/gfx1250-kimi-k2-gluon-gemm

Conversation

@jiaryang

@jiaryang jiaryang commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Self-Review

Reviewed revision

c61e6b9

Behavior and intent

Kimi-K2 TP8 on gfx1250 with 96 CUs (MI450 DPX) gets tuned Gluon configs for ten GEMM shapes: 8 gemm_a16w16 (N, K) and 2 batched_gemm_a16w16 (B=8). Before this PR these shapes used the gfx1250 DEFAULT.json or configs tuned for other models, which are slow at the small-M decode buckets on a 96-CU partition. The files are in configs/gfx1250/96cu/. #7105 reads that tree only when it has a DEFAULT.json, so this PR adds byte-identical copies of the plain gfx1250 Gluon DEFAULT.json to both trees. Only devices with 96 CUs read the new tree; other CU counts keep the plain tree.

Validation and unverified scope

Validated:

Not yet verified on this head:

PR-specific question

Workload keys, all backend="gluon" on gfx1250 with 96 CUs:

  • GEMM-A16W16: N=2112 K=7168, N=1536 K=1536, N=7168 K=1024, N=512 K=7168, N=7168 K=256, N=384 K=7168, N=4608 K=7168, N=7168 K=2304.
  • BATCHED_GEMM-A16W16: B=8 N=512 K=128, B=8 N=128 K=512.

Unrelated shapes: on CU counts other than 96 nothing changes, because the 96cu/ tree is not read. On 96 CUs a tree is read whole, so the shapes that only have a file in the plain tree (64 gemm_a16w16, 5 batched_gemm_a16w16) now get the 96cu/ DEFAULT.json, which is byte-identical to the plain DEFAULT.json. This is the fallback the CU-tree rule intends; the CPU check above lists these shapes.

Changed op tests

None

@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 6573 --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.

Kimi-K2 at TP8 has dense bf16 GEMM shapes and MLA-absorb batched GEMM
shapes with no gfx1250 Gluon config, so they run on DEFAULT.json:

- gemm_a16w16 (N, K): q_b (1536, 1536), kv_b (2048, 512), shared expert
  down (7168, 256), o_proj (7168, 1024), and the layer-0 dense MLP
  (4608, 7168) and (7168, 2304).
- batched_gemm_a16w16 B=8: absorb q (N=512, K=128) and absorb v
  (N=128, K=512), 8 heads per GPU at TP8.

Each M bucket was picked by CUDA-graph timing on MI455X over the configs
already shipped for gfx1250 in neighbouring buckets; buckets with no
faster candidate keep the DEFAULT.json config.

Signed-off-by: Yang, JiaRong <[email protected]>
@jiaryang
jiaryang force-pushed the config/gfx1250-kimi-k2-gluon-gemm branch from fc87e6c to 5457386 Compare October 22, 2026 07:08
@jiaryang
jiaryang marked this pull request as ready for review October 22, 2026 08:26
@jiaryang
jiaryang requested review from a team and a balanced review from Copilot October 22, 2026 08: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.

🟡 Changes recommended

All six dense config files omit the required waves_per_eu field from every bucket.

1 open issue
What changed in this PR

This PR adds shape-specific gfx1250 Gluon GEMM configs for Kimi-K2 at TP8, replacing default config selection for dense and MLA-absorb operations.

Changes:

  • Adds six dense bf16 GEMM configs with M-based buckets.
  • Adds two batched GEMM configs for eight heads per GPU.
  • Changes only config data; no kernels or wrappers change.

All paths below are relative to aiter/ops/triton/configs/gfx1250/gluon/gemm/.

File Description
gemm_a16w16/​GEMM-A16W16-N=7168-K=256.json Shared expert down-projection config.
gemm_a16w16/​GEMM-A16W16-N=7168-K=2304.json Layer-0 dense MLP down-projection config.
gemm_a16w16/​GEMM-A16W16-N=7168-K=1024.json Attention output-projection config.
gemm_a16w16/​GEMM-A16W16-N=4608-K=7168.json Layer-0 dense MLP expansion config.
gemm_a16w16/​GEMM-A16W16-N=2048-K=512.json KV projection config.
gemm_a16w16/​GEMM-A16W16-N=1536-K=1536.json Query projection config.
batched_gemm_a16w16/​BATCHED_GEMM-A16W16-B=8-N=512-K=128.json MLA query-absorb config.
batched_gemm_a16w16/​BATCHED_GEMM-A16W16-B=8-N=128-K=512.json MLA value-absorb config.

Review effort: Balanced

@azaidy

azaidy commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@jiaryang which triton version did you use for tuning?

Copilot AI balanced review requested due to automatic review settings October 23, 2026 15:52

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

The dense GEMM configs omit waves_per_eu, which the family schema requires in every bucket.

2 open issues

Review effort: Balanced

@azaidy azaidy assigned azaidy and unassigned ahmed-bsod Oct 23, 2026
…he full search space

Retune the eight Kimi-K2 TP8 shapes of this PR with sweep_configs.py
(--backend gluon) over the full gfx1250 Gluon search space, one sweep
per M bucket from 1 to 128, on MI450 in DPX mode (96 CUs per partition):

- every entry now carries waves_per_eu, as DEFAULT.json does;
- the files are DEFAULT_FALLBACK, so the buckets from 256 to 4096 come
  from DEFAULT.json; M_LEQ_8192 keeps the first version's config, with
  the waves_per_eu the wrapper used for it (0).

Cold-L2 CUDA-graph time against DEFAULT.json (main has no file for these
shapes), M = 4 / 16 / 64:

  q_b      (1536, 1536)  1.04 / 1.01 / 1.10x
  o_proj   (7168, 1024)  1.59 / 1.34 / 1.86x
  sh_down  (7168,  256)  1.90 / 1.53 / 1.11x
  l0_gu    (4608, 7168)  1.30 / 1.21 / 1.48x
  l0_down  (7168, 2304)  1.59 / 1.57 / 1.71x
  kv_b     (2048,  512)  1.02 / 1.03 / 1.03x
  bmm_q    B=8 (512, 128)  1.46 / 1.37 / 2.36x
  bmm_v    B=8 (128, 512)  1.25 / 1.28 / 1.25x

Signed-off-by: Yang, JiaRong <[email protected]>
…expert gate_up configs for Kimi-K2 TP8

Kimi-K2 TP8 also runs three shapes that already have gfx1250 Gluon files
(from the DeepSeek-R1 and router configs): fused_qkv_a_proj_with_mqa
(N=2112, K=7168), the MoE router (N=384, K=7168) and the shared-expert
gate_up (N=512, K=7168). Retune their M buckets from 1 to 128 the same
way, keeping every larger bucket; the kept buckets get the waves_per_eu
the wrapper used for them (0).

Cold-L2 CUDA-graph time against the current files, M = 4 / 16 / 64:

  qa_kva   (2112, 7168)  1.56 / 1.81 / 1.50x
  router   ( 384, 7168)  1.09 / 1.17 / 1.06x
  sh_gu    ( 512, 7168)  1.10 / 1.25 / 1.67x

Signed-off-by: Yang, JiaRong <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 13:22

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

Target-GPU correctness remains independently unverified, and latency comparisons against the existing configs are still pending.

1 open issue
2 resolved since last review

Review effort: Balanced

@jiaryang

Copy link
Copy Markdown
Contributor Author

@jiaryang which triton version did you use for tuning?

Using Triton: 3.8.0+git76940ad3 (rocm/sgl-dev:v0.5.22-rocm10-mi45x-20261022).

@jiaryang
jiaryang requested a review from azaidy October 27, 2026 00:51
@jiaryang

Copy link
Copy Markdown
Contributor Author

@azaidy already add the waves_per_eu key and update triton version, could you help to take a look, thanks.

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

The configs depend on unmerged loader PR #7096, and integrated accuracy and base/head latency require validation on a gfx1250 96-CU partition unavailable in this review environment.

3 open issues

Review effort: Balanced

@jiaryang

Copy link
Copy Markdown
Contributor Author

@azaidy I updated the PR as discussed:

  • The ten files are in configs/gfx1250/96cu/. The loader change in [Triton/Gluon] [CI] Load GEMM configs from <arch>/<cu_num>cu/ first #7096 reads this folder. The CU-agnostic gfx1250 files do not change.
  • Some buckets were not faster than main through tgemm.mm after tuning. These buckets keep the main DEFAULT.json entry.
  • The any bucket of the N=2112, 384 and 512 files is a copy from the CU-agnostic file. Only M = 1 to 128 has new tuning.

End to end with #7096 and #7070, Kimi-K2 TP8 on MI450 DPX (8k input / 1k output, concurrency 4): the median TPOT is 17.83 ms on main and 16.46 ms with the three PRs. GSM8K 5-shot is 0.935 on main and 0.940 with the three PRs.

Could you review it again?

azaidy
azaidy previously approved these changes Oct 29, 2026

@azaidy azaidy 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.

LGTM!

Copilot AI balanced review requested due to automatic review settings October 29, 2026 03:35

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

Both new 96-CU family folders lack DEFAULT.json, causing resolve_config_dir() to fall back to the plain folders and ignore all ten new configs.

2 open issues
2 resolved since last review

Review effort: Balanced

@yifehuan

Copy link
Copy Markdown
Contributor

Both new 96-CU config directories (gemm_a16w16 and batched_gemm_a16w16) are missing DEFAULT.json, so the current loader from #7105 falls back to the CU-agnostic directories and ignores all ten tuned files. Please add a byte-identical copy of the corresponding family’s DEFAULT.json to each directory, then verify that the tuned configs are selected on gfx1250 with 96 CUs and that other shapes retain the intended fallback behavior.

yifehuan pushed a commit that referenced this pull request Oct 29, 2026
* [FlyDSL] [Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8

Kimi-K2 at TP8 on gfx1250 in DPX mode (96 CUs per partition) has no
tuned bf16 GEMM row for its dense shapes: the gfx1250 rows in
model_configs/ are all cu_num=256, so tgemm.mm falls back to the Gluon
gemm_a16w16 kernel with DEFAULT.json (or the shape's Gluon JSON).

Tune the nine dense shapes for M = 1 to 256 with gemm_a16w16_tune.py on
MI450 (DPX, cu_num=96) over flydsl, torch and hipblaslt (opus has no
gfx1250/96 registry; asm and skinny have no gfx1250 kernels), and keep a
flydsl row only where it beats the current Gluon path by more than 3% in
cold-L2 CUDA-graph time (the Gluon tuning harness timing). Every winner
is flydsl; the other 19 buckets stay on the Gluon fallback.

  gemm (N, K)                         rows
  qkv_a  fused_qkv_a_proj (2112, 7168)   9
  router MoE gate         ( 384, 7168)   9
  sh_gu  shared gate_up   ( 512, 7168)   9
  sh_dn  shared down      (7168,  256)   8
  o_proj                  (7168, 1024)   9
  l0_gu  layer-0 gate_up  (4608, 7168)   7
  l0_dn  layer-0 down     (7168, 2304)   8
  kv_b                    (2048,  512)   2  (M = 64, 256)
  q_b                     (1536, 1536)   1  (M = 256)

Cold-L2 CUDA-graph time against main (A/B alternated on one GPU, median
of 10 rounds), speedup at M = 4 / 16 / 64:

  qkv_a  1.39 / 1.80 / 1.83x    router 1.49 / 1.47 / 1.17x
  sh_gu  1.36 / 1.46 / 2.19x    sh_dn  1.80 / 1.41 / 0.99x (not kept)
  o_proj 1.46 / 1.15 / 1.60x    l0_gu  1.11 / 1.10 / 1.48x
  l0_dn  1.32 / 1.34 / 1.55x

Per decode step these GEMMs take 0.63 / 0.72 / 1.19 ms less at
concurrency 4 / 16 / 64 (kernel time x calls per step, 61 layers).
Needs flydsl 0.4.0, the version setup.py pins.

Signed-off-by: Yang, JiaRong <[email protected]>

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that lose to the 96-CU Gluon configs

Removes 30 gfx1250 FlyDSL rows (M <= 128 of N,K = 2112,7168 / 4608,7168 /
7168,256 / 7168,1024 / 7168,2304) whose shapes run faster on the Gluon
configs of #6573; a CSV row takes precedence over the Gluon
default, so these rows would replace the faster kernel.

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that only tie the 96-CU Gluon configs

o_proj (7168x1024) M=4 and 8, shared expert down (7168x256) M=32 and
layer-0 gate_up (4608x7168) M=1 and 2 are within 4% of the Gluon path
with the 96-CU configs, inside the run-to-run spread, so they do not meet
the 3% bar the other rows were kept on. 27 gfx1250 rows remain.

---------

Signed-off-by: Yang, JiaRong <[email protected]>
…EMM trees

ROCm#7105 reads a <cu_num>cu/ tree only when it has a DEFAULT.json, so
without one the ten Kimi-K2 files in 96cu/gluon/gemm/gemm_a16w16 and
96cu/gluon/gemm/batched_gemm_a16w16 are never read.

Both DEFAULT.json files are byte-identical copies of the ones in
gfx1250/gluon/gemm/, as configs/AGENTS.md asks for a new tree.

Signed-off-by: Yang, JiaRong <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:17
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision c61e6b942a78 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

Kimi-K2 TP8 on gfx1250 with 96 CUs (MI450 DPX) gets tuned Gluon configs for ten GEMM shapes: 8 `gemm_a16w16` (N, K) and 2 `batched_gemm_a16w16` (B=8). Before this PR these shapes used the gfx1250 `DEFAULT.json` or configs tuned for other models, which are slow at the small-M decode buckets on a 96-CU partition. The files are in `configs/gfx1250/96cu/`. #7105 reads that tree only when it has a `DEFAULT.json`, so this PR adds byte-identical copies of the plain gfx1250 Gluon `DEFAULT.json` to both trees. Only devices with 96 CUs read the new tree; other CU counts keep the plain tree.

Validation and unverified scope

Validated:
- Config selection with the #7105 loader, on CPU (`get_gemm_config(..., backend="gluon", cu_num=96)`, arch gfx1250, M = 1 to 16384): each of the ten shapes is served from its `96cu/` file, and `is_tuned` is True for its tuned buckets. With `cu_num=None` (the plain tree) the selection is the same as main.
- Accuracy of each shape and bucket against an fp32 torch reference (rel 1.8e-3, M = 1 to 128, and M = 8192 for the dense shapes); `op_tests/tuning_tests/test_config_shape_collision.py` passes.
- Kernel and end-to-end speed with the same files through #7096 (see Speed Tests): Kimi-K2 TP8 8k/1k concurrency 4, TPOT 17.83 ms on main and 16.46 ms with this PR, #7096 and #7070; GSM8K 0.935 and 0.940.

Not yet verified on this head:
- `verify_configs.py --expect-tuned` and the kernel timings through #7105 on a 96-CU partition.
- End-to-end Kimi-K2 TP8 TPOT and GSM8K with #7105.

PR-specific question

Workload keys, all `backend="gluon"` on gfx1250 with 96 CUs:
- `GEMM-A16W16`: N=2112 K=7168, N=1536 K=1536, N=7168 K=1024, N=512 K=7168, N=7168 K=256, N=384 K=7168, N=4608 K=7168, N=7168 K=2304.
- `BATCHED_GEMM-A16W16`: B=8 N=512 K=128, B=8 N=128 K=512.

Unrelated shapes: on CU counts other than 96 nothing changes, because the `96cu/` tree is not read. On 96 CUs a tree is read whole, so the shapes that only have a file in the plain tree (64 `gemm_a16w16`, 5 `batched_gemm_a16w16`) now get the `96cu/` `DEFAULT.json`, which is byte-identical to the plain `DEFAULT.json`. This is the fallback the CU-tree rule intends; the CPU check above lists these shapes.

Changed op tests

None

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

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.

🔵 Needs a closer look

The gfx1250/96-CU defaults affect shapes beyond Kimi-K2, while exact-head accuracy and base/head latency checks through the merged loader remain pending on GPU hardware unavailable in this review environment.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 11:21

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

Exact-head accuracy and base/head latency still need validation on gfx1250 with 96 CUs and the merged loader, including runtime effects of default configs for untuned shapes.

1 open issue

Review effort: Balanced

@jiaryang

Copy link
Copy Markdown
Contributor Author

Thanks @yifehuan, both items are done.

  • DEFAULT.json: added byte-identical copies of the plain gfx1250 Gluon DEFAULT.json to gfx1250/96cu/gluon/gemm/gemm_a16w16/ and batched_gemm_a16w16/ (7a4fd5f).
  • Config selection on MI450 DPX (96 CUs), head c61e6b9: verify_configs.py --backend gluon --expect-tuned for all ten shapes at M = 1, 4, 16, 64, 128 (50 runs) reads the 96cu/ tree and reports is_tuned True every time.
  • End to end, Kimi-K2 TP8: I logged every config file the server looks up. With the two DEFAULT.json files, it reads the ten shape files and both DEFAULT.json from 96cu/ and no plain Gluon file; without them it reads none from 96cu/. At 8k/1k concurrency 4, back-to-back runs give TPOT 16.55 ms without the files and 16.14 / 16.28 ms with them (TTFT 422 -> 397 ms), and GSM8K is 0.937 / 0.936.

@azaidy azaidy 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.

LGTM!

@azaidy
azaidy merged commit 07ff5f3 into ROCm:main Oct 29, 2026
68 checks passed
@jiaryang
jiaryang deleted the config/gfx1250-kimi-k2-gluon-gemm branch October 29, 2026 15:42
erizheng-amd added a commit that referenced this pull request Oct 30, 2026
This shape was tuned on a 96-CU partition, and gfx1250/96cu already has a
tuned GEMM-A16W16-N=2112-K=7168.json (#6573), so the 256-CU file goes back
to its main version.

Co-authored-by: Cursor <[email protected]>
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
* [FlyDSL] [Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8

Kimi-K2 at TP8 on gfx1250 in DPX mode (96 CUs per partition) has no
tuned bf16 GEMM row for its dense shapes: the gfx1250 rows in
model_configs/ are all cu_num=256, so tgemm.mm falls back to the Gluon
gemm_a16w16 kernel with DEFAULT.json (or the shape's Gluon JSON).

Tune the nine dense shapes for M = 1 to 256 with gemm_a16w16_tune.py on
MI450 (DPX, cu_num=96) over flydsl, torch and hipblaslt (opus has no
gfx1250/96 registry; asm and skinny have no gfx1250 kernels), and keep a
flydsl row only where it beats the current Gluon path by more than 3% in
cold-L2 CUDA-graph time (the Gluon tuning harness timing). Every winner
is flydsl; the other 19 buckets stay on the Gluon fallback.

  gemm (N, K)                         rows
  qkv_a  fused_qkv_a_proj (2112, 7168)   9
  router MoE gate         ( 384, 7168)   9
  sh_gu  shared gate_up   ( 512, 7168)   9
  sh_dn  shared down      (7168,  256)   8
  o_proj                  (7168, 1024)   9
  l0_gu  layer-0 gate_up  (4608, 7168)   7
  l0_dn  layer-0 down     (7168, 2304)   8
  kv_b                    (2048,  512)   2  (M = 64, 256)
  q_b                     (1536, 1536)   1  (M = 256)

Cold-L2 CUDA-graph time against main (A/B alternated on one GPU, median
of 10 rounds), speedup at M = 4 / 16 / 64:

  qkv_a  1.39 / 1.80 / 1.83x    router 1.49 / 1.47 / 1.17x
  sh_gu  1.36 / 1.46 / 2.19x    sh_dn  1.80 / 1.41 / 0.99x (not kept)
  o_proj 1.46 / 1.15 / 1.60x    l0_gu  1.11 / 1.10 / 1.48x
  l0_dn  1.32 / 1.34 / 1.55x

Per decode step these GEMMs take 0.63 / 0.72 / 1.19 ms less at
concurrency 4 / 16 / 64 (kernel time x calls per step, 61 layers).
Needs flydsl 0.4.0, the version setup.py pins.

Signed-off-by: Yang, JiaRong <[email protected]>

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that lose to the 96-CU Gluon configs

Removes 30 gfx1250 FlyDSL rows (M <= 128 of N,K = 2112,7168 / 4608,7168 /
7168,256 / 7168,1024 / 7168,2304) whose shapes run faster on the Gluon
configs of #6573; a CSV row takes precedence over the Gluon
default, so these rows would replace the faster kernel.

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that only tie the 96-CU Gluon configs

o_proj (7168x1024) M=4 and 8, shared expert down (7168x256) M=32 and
layer-0 gate_up (4608x7168) M=1 and 2 are within 4% of the Gluon path
with the 96-CU configs, inside the run-to-run spread, so they do not meet
the 3% bar the other rows were kept on. 27 gfx1250 rows remain.

---------

Signed-off-by: Yang, JiaRong <[email protected]>
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
…6573)

* [Triton/Gluon] [Config] gfx1250 Gluon GEMM configs for Kimi-K2 TP8

Kimi-K2 at TP8 has dense bf16 GEMM shapes and MLA-absorb batched GEMM
shapes with no gfx1250 Gluon config, so they run on DEFAULT.json:

- gemm_a16w16 (N, K): q_b (1536, 1536), kv_b (2048, 512), shared expert
  down (7168, 256), o_proj (7168, 1024), and the layer-0 dense MLP
  (4608, 7168) and (7168, 2304).
- batched_gemm_a16w16 B=8: absorb q (N=512, K=128) and absorb v
  (N=128, K=512), 8 heads per GPU at TP8.

Each M bucket was picked by CUDA-graph timing on MI455X over the configs
already shipped for gfx1250 in neighbouring buckets; buckets with no
faster candidate keep the DEFAULT.json config.

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Retune the Kimi-K2 TP8 gfx1250 configs over the full search space

Retune the eight Kimi-K2 TP8 shapes of this PR with sweep_configs.py
(--backend gluon) over the full gfx1250 Gluon search space, one sweep
per M bucket from 1 to 128, on MI450 in DPX mode (96 CUs per partition):

- every entry now carries waves_per_eu, as DEFAULT.json does;
- the files are DEFAULT_FALLBACK, so the buckets from 256 to 4096 come
  from DEFAULT.json; M_LEQ_8192 keeps the first version's config, with
  the waves_per_eu the wrapper used for it (0).

Cold-L2 CUDA-graph time against DEFAULT.json (main has no file for these
shapes), M = 4 / 16 / 64:

  q_b      (1536, 1536)  1.04 / 1.01 / 1.10x
  o_proj   (7168, 1024)  1.59 / 1.34 / 1.86x
  sh_down  (7168,  256)  1.90 / 1.53 / 1.11x
  l0_gu    (4608, 7168)  1.30 / 1.21 / 1.48x
  l0_down  (7168, 2304)  1.59 / 1.57 / 1.71x
  kv_b     (2048,  512)  1.02 / 1.03 / 1.03x
  bmm_q    B=8 (512, 128)  1.46 / 1.37 / 2.36x
  bmm_v    B=8 (128, 512)  1.25 / 1.28 / 1.25x

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Retune the gfx1250 qa_kva, router and shared-expert gate_up configs for Kimi-K2 TP8

Kimi-K2 TP8 also runs three shapes that already have gfx1250 Gluon files
(from the DeepSeek-R1 and router configs): fused_qkv_a_proj_with_mqa
(N=2112, K=7168), the MoE router (N=384, K=7168) and the shared-expert
gate_up (N=512, K=7168). Retune their M buckets from 1 to 128 the same
way, keeping every larger bucket; the kept buckets get the waves_per_eu
the wrapper used for them (0).

Cold-L2 CUDA-graph time against the current files, M = 4 / 16 / 64:

  qa_kva   (2112, 7168)  1.56 / 1.81 / 1.50x
  router   ( 384, 7168)  1.09 / 1.17 / 1.06x
  sh_gu    ( 512, 7168)  1.10 / 1.25 / 1.67x

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Move the new Kimi-K2 Gluon GEMM configs to gfx1250/96cu/

* [Triton/Gluon] [Config] Keep the CU-agnostic gfx1250 GEMM configs, put the 96-CU retunes in 96cu/

The fused_qkv_a (2112, 7168), router (384, 7168) and shared expert gate_up
(512, 7168) retunes move to configs/gfx1250/96cu/; the CU-agnostic files
are back to their main contents.

* [Triton/Gluon] [Config] Keep main's configs where the 96-CU retune is not faster

The 96-CU copies of the N=2112, 384 and 512 (K=7168) files take the "any"
bucket (M > 8192) from the CU-agnostic file again, with waves_per_eu 0,
instead of DEFAULT.json's.

q_b (N=1536, K=1536) M_LEQ_1, M_LEQ_4 and M_LEQ_16 and shared expert down
(N=7168, K=256) M_LEQ_64 go back to the DEFAULT.json entries main uses: in
tgemm.mm on MI450 (DPX, 96 CUs) the retuned ones were 4-11% slower.

* [Triton/Gluon] [Config] Add DEFAULT.json to the gfx1250 96-CU Gluon GEMM trees

#7105 reads a <cu_num>cu/ tree only when it has a DEFAULT.json, so
without one the ten Kimi-K2 files in 96cu/gluon/gemm/gemm_a16w16 and
96cu/gluon/gemm/batched_gemm_a16w16 are never read.

Both DEFAULT.json files are byte-identical copies of the ones in
gfx1250/gluon/gemm/, as configs/AGENTS.md asks for a new tree.

Signed-off-by: Yang, JiaRong <[email protected]>

---------

Signed-off-by: Yang, JiaRong <[email protected]>
azaidy pushed a commit that referenced this pull request Nov 11, 2026
…with rotating weights; LM-head files (#7289)

* gfx1250 gluon gemm_a16w16 compute_bound: register-store epilogues, chosen per config entry (REGISTER_STORE)

The compute_bound kernel ended with the gfx1250 B1 pattern: the tile is staged in LDS
(ds_store), a workgroup barrier, then tensor_store_from_lds, whose LDS read can miss
the waves' ds_stores on gfx1250 (no documented wait or fence closes it; B1a-B1c).
A config entry may now pick the epilogue with "REGISTER_STORE":
  0 the LDS-staged TDM store (default: every existing entry is unchanged),
  1 buffer stores straight from the WMMA layout (as the bandwidth_bound kernel),
  2 coalesced register store: convert_layout to a blocked layout of 16-byte
    vectors along N (an ordinary ds_store/barrier/ds_load round trip), then
    buffer stores rebased to the block in int64.
AITER_GFX1250_A16W16_STORE=<0|1|2> overrides every entry (A/B only).

Cost vs the TDM store at gpt-oss's existing entries (gfx1250 DPX partition, bf16,
bias): mode 2 +0..5 % at M 256-8192, -24 % at O M=64 (30.1 -> 22.9 us), -12 % at QKV
M=16; mode 1 +3..16 % at M >= 256.

Plan: perf1101 P1 (B1 prerequisite of the large-M a16w16 dispatch)

* gfx1250 gluon gemm_a16w16: gpt-oss large-M buckets (M_BOUNDS to 32768), retuned 4096/8192, TP2 shape files

gpt-oss's QKV (N5120 K2880), O (N2880 K4096) and router (N128 K2880) files stopped at
M_LEQ_8192 and the loader searched only the standard bounds, so every prefill batch
above 8192 tokens (chunk 16384: 94 % of 70k/300 prefill batches, 12 % at 8k/1k c64
with mixed chunk) ran the 'any' entry, bandwidth_bound 128x128x64. The TP2 shapes
(QKV N2560 K2880, O N2880 K2048) had no file at all and ran DEFAULT.json at every M.

- QKV and O: M_BOUNDS up to 32768; M_LEQ_4096/8192/16384/32768 = compute_bound
  256x256x64, 4 buffers, 8 warps, waves_per_eu 1, coalesced register store
  (REGISTER_STORE 2: no new LDS-staged TDM store epilogue). Best of 126 candidates
  at M 16384 (BLOCK_K dividing K), and faster than the old 4096/8192 entries.
- Router: M_BOUNDS to 32768; M_LEQ_8192/16384/32768 = compute_bound 128x128x64,
  4 buffers, 4 warps, register store.
- TP2 QKV and O: new files with DEFAULT_FALLBACK (DEFAULT.json keeps M <= 128):
  M_LEQ_256..1024 = compute_bound 128x128x64, 2048..32768 = 256x256x64, register store.

Kernel time, old file -> new (us, bf16 + bias, one gfx1250 DPX partition, A-B-A):
  QKV  M 7500 340 -> 302, 8192 365 -> 307, 16384 3278 -> 618, 32768 6567 -> 1230
  O    M 7500 288 -> 246, 8192 293 -> 249, 16384 2643 -> 503, 32768 5252 -> 1020
  router M 8192 26.7 -> 18.9, 16384 101.5 -> 26.9
  TP2 QKV M 1024 51.5 -> 26.4, 7500 843 -> 167, 16384 1684 -> 308
  TP2 O   M 1024 43.9 -> 21.0, 7500 719 -> 132, 16384 1453 -> 267
Other buckets unchanged. fp32-reference max rel err 0.003 (same as before); CUDA-graph
replay bitwise equal over 6000 calls per shape at M 8192/9000/16384/16385.

Plan: perf1101 P1 (large-M a16w16 dispatch; router separately; TP2 files added)

* gfx1250 gluon gemm_a16w16 compute_bound: share the register-store code, validate the store mode

Review follow-up (perf1101 P1, codex round 1, findings 3-4): REGISTER_STORE outside
{0, 1, 2} is rejected (ValueError on the host, static_assert in the kernel) instead of
falling to the TDM store; the two register-store modes share one store helper; the
store layout helper drops its unused BLOCK_M; the comment states the override's scope
(non-persistent gluon compute_bound launches; unset in serving).
Same kernels, same outputs: P1's correctness check passes unchanged (55 shape/M
cases, old vs new bitwise equal, 2,000 replayed calls each); mode-2 store cost at the
shipped 256x256 tile 1.012-1.014 of the TDM store.

Plan: perf1101 P1 (review round 1)

* gfx1250 gluon gemm_a16w16: gpt-oss band starts without regressions (O 2049-3072, TP2 129-1536, 2049-3072)

Review follow-up (perf1101 P1, codex round 1, finding 2): a dense A-B-A over every
changed band showed four band starts slower than the old schedule (O M 2049 +16 %,
TP2 QKV M 1025 +9 %, TP2 O M 2049 +5 %, M 257 +3 %): 256x256 tiles just past a
bound leave most of a tile empty. Per-band sweep of eight register-store tiles:
  O (TP1): new bound 3072, M_LEQ_3072 = 128x128x64 (2049-3072: 0.91-0.95 of old).
  TP2 QKV: new bound 1536; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024/1536 = 128x128x64, M_LEQ_2048 = 256x256x64.
  TP2 O:   new bound 3072; M_LEQ_256 = 128x64x64, M_LEQ_512 = 128x128x128,
           M_LEQ_1024 = 128x128x64, M_LEQ_2048 = 256x256x64, M_LEQ_3072 = 128x128x64.
All compute_bound, 4 buffers, 4 warps (256x256: 8 warps), coalesced register store.
Dense A-B-A (TP1 20 M from 2048 to 32768, TP2 28 M from 128 to 32768): new/old
0.17-1.01 everywhere, no point above 1.02. Old vs new outputs bitwise equal at every
band boundary (65 cases, same K order); 2,000 replayed calls each, 0 mismatches.

Plan: perf1101 P1 (review round 1)

* gfx1250 gluon gemm_a16w16: move the TP2 gpt-oss shape files into the 96-CU tree (pure git mv)

They were tuned on a 96-CU DPX partition, and since #6573 a 96-CU device reads
configs/gfx1250/96cu/gluon/gemm/gemm_a16w16/ whole: in the plain tree no DPX
device ever loaded them (configs/AGENTS.md, CU trees).

* gfx1250 gluon gemm_a16w16: the gpt-oss QKV, O and router entries go in the 96-CU tree

The retuned QKV (N 5120, K 2880), O (N 2880, K 4096) and router (N 128, K 2880)
tables were measured on a 96-CU DPX partition, which reads only the 96cu tree,
so on main they were never used there (Copilot, #7288). The 96cu files hold
these tables whole (buckets this PR did not retune keep #6921's values); the
plain-tree files go back to main's, so devices that read the plain tree see no
change from this PR.

* gfx1250 gluon gemm_a16w16: let the tuner search and keep REGISTER_STORE

The tuner's keys are the union of the family DEFAULT.json's keys, and
write_best_configs.py writes only those keys into a bucket. Neither gluon
DEFAULT.json (plain or 96cu) had REGISTER_STORE, so the tuner never searched it
and a retuned bucket silently lost it, going back to the LDS + TDM-store
epilogue (Copilot, #7288). Every DEFAULT bucket now says REGISTER_STORE 0 (what
it already meant; bandwidth_bound pops and ignores it) and SEARCH_SPACE offers
0, 1, 2.

* gfx1250 gluon gemm_a16w16: black

* gfx1250 gluon gemm_a16w16: test the REGISTER_STORE epilogues through the public wrapper

Modes 0/1/2 on fp16 and bf16, bias on and off, at the gpt-oss bucket edges
(1025, 2049, 3073) and with partial M and N tiles (M 1, 97, 300; N 200); the
AITER_GFX1250_A16W16_STORE override for each mode; an invalid override (3) and
an invalid entry value (5) raise ValueError (Copilot, #7288).  73 passed on
gfx1250 (MI450 DPX partition, 96 CU).

* gfx1250 gluon gemm_a16w16: test the tuned gpt-oss entries and their 96-CU lookup

A 96-CU lookup of the QKV, O, router and TP2 shapes at M 4096-32768 must land on
tuned compute_bound entries (on the PR as filed it landed on the 96cu
DEFAULT's untuned bandwidth_bound rows), and every gpt-oss shape
must compute the right result at M 1, 64, 1000, 2049, 3073 and 8192 through the
tuned lookup.

* gfx1250 gluon gemm_a16w16: read the 96-CU gpt-oss tables as gfx1250

The lookup test passed cu_num=96 and left the arch as the runner's, so MI35X asked for a gfx950 Gluon default that is not in the tree.

* gfx1250 gluon gemm_a16w16: gpt-oss decode buckets and LM-head tuning, stacked on the REGISTER_STORE PR

Rebuilt on top of pr-gfx1250-gemm-a16w16-large-m-regstore so the shared commits are not duplicated.
Only the gpt-oss decode buckets, the LM-head shape files and the 96-CU lookup test differ from that branch.

* gfx1250 gluon gemm_a16w16: drop the hardware-bug notes from the store comments
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
* [FlyDSL] [Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8

Kimi-K2 at TP8 on gfx1250 in DPX mode (96 CUs per partition) has no
tuned bf16 GEMM row for its dense shapes: the gfx1250 rows in
model_configs/ are all cu_num=256, so tgemm.mm falls back to the Gluon
gemm_a16w16 kernel with DEFAULT.json (or the shape's Gluon JSON).

Tune the nine dense shapes for M = 1 to 256 with gemm_a16w16_tune.py on
MI450 (DPX, cu_num=96) over flydsl, torch and hipblaslt (opus has no
gfx1250/96 registry; asm and skinny have no gfx1250 kernels), and keep a
flydsl row only where it beats the current Gluon path by more than 3% in
cold-L2 CUDA-graph time (the Gluon tuning harness timing). Every winner
is flydsl; the other 19 buckets stay on the Gluon fallback.

  gemm (N, K)                         rows
  qkv_a  fused_qkv_a_proj (2112, 7168)   9
  router MoE gate         ( 384, 7168)   9
  sh_gu  shared gate_up   ( 512, 7168)   9
  sh_dn  shared down      (7168,  256)   8
  o_proj                  (7168, 1024)   9
  l0_gu  layer-0 gate_up  (4608, 7168)   7
  l0_dn  layer-0 down     (7168, 2304)   8
  kv_b                    (2048,  512)   2  (M = 64, 256)
  q_b                     (1536, 1536)   1  (M = 256)

Cold-L2 CUDA-graph time against main (A/B alternated on one GPU, median
of 10 rounds), speedup at M = 4 / 16 / 64:

  qkv_a  1.39 / 1.80 / 1.83x    router 1.49 / 1.47 / 1.17x
  sh_gu  1.36 / 1.46 / 2.19x    sh_dn  1.80 / 1.41 / 0.99x (not kept)
  o_proj 1.46 / 1.15 / 1.60x    l0_gu  1.11 / 1.10 / 1.48x
  l0_dn  1.32 / 1.34 / 1.55x

Per decode step these GEMMs take 0.63 / 0.72 / 1.19 ms less at
concurrency 4 / 16 / 64 (kernel time x calls per step, 61 layers).
Needs flydsl 0.4.0, the version setup.py pins.

Signed-off-by: Yang, JiaRong <[email protected]>

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that lose to the 96-CU Gluon configs

Removes 30 gfx1250 FlyDSL rows (M <= 128 of N,K = 2112,7168 / 4608,7168 /
7168,256 / 7168,1024 / 7168,2304) whose shapes run faster on the Gluon
configs of ROCm#6573; a CSV row takes precedence over the Gluon
default, so these rows would replace the faster kernel.

* [FlyDSL] [Config] Drop the Kimi-K2 gfx1250 rows that only tie the 96-CU Gluon configs

o_proj (7168x1024) M=4 and 8, shared expert down (7168x256) M=32 and
layer-0 gate_up (4608x7168) M=1 and 2 are within 4% of the Gluon path
with the 96-CU configs, inside the run-to-run spread, so they do not meet
the 3% bar the other rows were kept on. 27 gfx1250 rows remain.

---------

Signed-off-by: Yang, JiaRong <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…OCm#6573)

* [Triton/Gluon] [Config] gfx1250 Gluon GEMM configs for Kimi-K2 TP8

Kimi-K2 at TP8 has dense bf16 GEMM shapes and MLA-absorb batched GEMM
shapes with no gfx1250 Gluon config, so they run on DEFAULT.json:

- gemm_a16w16 (N, K): q_b (1536, 1536), kv_b (2048, 512), shared expert
  down (7168, 256), o_proj (7168, 1024), and the layer-0 dense MLP
  (4608, 7168) and (7168, 2304).
- batched_gemm_a16w16 B=8: absorb q (N=512, K=128) and absorb v
  (N=128, K=512), 8 heads per GPU at TP8.

Each M bucket was picked by CUDA-graph timing on MI455X over the configs
already shipped for gfx1250 in neighbouring buckets; buckets with no
faster candidate keep the DEFAULT.json config.

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Retune the Kimi-K2 TP8 gfx1250 configs over the full search space

Retune the eight Kimi-K2 TP8 shapes of this PR with sweep_configs.py
(--backend gluon) over the full gfx1250 Gluon search space, one sweep
per M bucket from 1 to 128, on MI450 in DPX mode (96 CUs per partition):

- every entry now carries waves_per_eu, as DEFAULT.json does;
- the files are DEFAULT_FALLBACK, so the buckets from 256 to 4096 come
  from DEFAULT.json; M_LEQ_8192 keeps the first version's config, with
  the waves_per_eu the wrapper used for it (0).

Cold-L2 CUDA-graph time against DEFAULT.json (main has no file for these
shapes), M = 4 / 16 / 64:

  q_b      (1536, 1536)  1.04 / 1.01 / 1.10x
  o_proj   (7168, 1024)  1.59 / 1.34 / 1.86x
  sh_down  (7168,  256)  1.90 / 1.53 / 1.11x
  l0_gu    (4608, 7168)  1.30 / 1.21 / 1.48x
  l0_down  (7168, 2304)  1.59 / 1.57 / 1.71x
  kv_b     (2048,  512)  1.02 / 1.03 / 1.03x
  bmm_q    B=8 (512, 128)  1.46 / 1.37 / 2.36x
  bmm_v    B=8 (128, 512)  1.25 / 1.28 / 1.25x

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Retune the gfx1250 qa_kva, router and shared-expert gate_up configs for Kimi-K2 TP8

Kimi-K2 TP8 also runs three shapes that already have gfx1250 Gluon files
(from the DeepSeek-R1 and router configs): fused_qkv_a_proj_with_mqa
(N=2112, K=7168), the MoE router (N=384, K=7168) and the shared-expert
gate_up (N=512, K=7168). Retune their M buckets from 1 to 128 the same
way, keeping every larger bucket; the kept buckets get the waves_per_eu
the wrapper used for them (0).

Cold-L2 CUDA-graph time against the current files, M = 4 / 16 / 64:

  qa_kva   (2112, 7168)  1.56 / 1.81 / 1.50x
  router   ( 384, 7168)  1.09 / 1.17 / 1.06x
  sh_gu    ( 512, 7168)  1.10 / 1.25 / 1.67x

Signed-off-by: Yang, JiaRong <[email protected]>

* [Triton/Gluon] [Config] Move the new Kimi-K2 Gluon GEMM configs to gfx1250/96cu/

* [Triton/Gluon] [Config] Keep the CU-agnostic gfx1250 GEMM configs, put the 96-CU retunes in 96cu/

The fused_qkv_a (2112, 7168), router (384, 7168) and shared expert gate_up
(512, 7168) retunes move to configs/gfx1250/96cu/; the CU-agnostic files
are back to their main contents.

* [Triton/Gluon] [Config] Keep main's configs where the 96-CU retune is not faster

The 96-CU copies of the N=2112, 384 and 512 (K=7168) files take the "any"
bucket (M > 8192) from the CU-agnostic file again, with waves_per_eu 0,
instead of DEFAULT.json's.

q_b (N=1536, K=1536) M_LEQ_1, M_LEQ_4 and M_LEQ_16 and shared expert down
(N=7168, K=256) M_LEQ_64 go back to the DEFAULT.json entries main uses: in
tgemm.mm on MI450 (DPX, 96 CUs) the retuned ones were 4-11% slower.

* [Triton/Gluon] [Config] Add DEFAULT.json to the gfx1250 96-CU Gluon GEMM trees

ROCm#7105 reads a <cu_num>cu/ tree only when it has a DEFAULT.json, so
without one the ten Kimi-K2 files in 96cu/gluon/gemm/gemm_a16w16 and
96cu/gluon/gemm/batched_gemm_a16w16 are never read.

Both DEFAULT.json files are byte-identical copies of the ones in
gfx1250/gluon/gemm/, as configs/AGENTS.md asks for a new tree.

Signed-off-by: Yang, JiaRong <[email protected]>

---------

Signed-off-by: Yang, JiaRong <[email protected]>
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.

7 participants