Skip to content

[Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8 - #7070

Merged
yifehuan merged 4 commits into
ROCm:mainfrom
jiaryang:config/gfx1250-kimi-k2-flydsl-csv
Oct 29, 2026
Merged

yifehuan merged 4 commits into
ROCm:mainfrom
jiaryang:config/gfx1250-kimi-k2-flydsl-csv

Conversation

@jiaryang

@jiaryang jiaryang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Kimi-K2 at TP8 on gfx1250 in DPX mode runs its dense bf16 GEMMs through tgemm.mm. DPX mode has 96 CUs in each partition. No Kimi-K2 shape has a gfx1250 row at cu_num=96:

  • The gfx1250 rows in model_configs/ for 2112x7168, 384x7168 and 512x7168 are all cu_num=256.
  • The other shapes have no gfx1250 rows.

Thus each call uses the gfx1250 fallback. The fallback is the Gluon gemm_a16w16 kernel with DEFAULT.json or the Gluon JSON of the shape.

Modifications

This PR changes configs only. It does not change a kernel.

  • It adds 27 gfx1250 cu_num=96 rows to model_configs/kimik2_bf16_tuned_gemm.csv.
  • It adds the shapes to kimik2_bf16_untuned_gemm.csv.

Tuning:

  • csrc/gemm_a16w16/gemm_a16w16_tune.py tuned the nine dense shapes for M = 1 to 256 on MI450 (DPX, 96 CUs).
  • The tuner compared flydsl, torch and hipblaslt (--with-hipblaslt). opus has no a16w16/gfx1250/96 registry. asm and skinny have no gfx1250 kernels.
  • flydsl was faster than torch and hipblaslt in each bucket.

Row selection:

Merge this PR after #7096 and #6573.

shape N, K rows (M)
MoE router 384, 7168 9 (1 to 256)
shared expert gate_up 512, 7168 9 (1 to 256)
fused_qkv_a_proj_with_mqa 2112, 7168 2 (64, 256)
kv_b 2048, 512 2 (64, 256)
shared expert down 7168, 256 1 (256)
o_proj 7168, 1024 1 (256)
layer-0 gate_up 4608, 7168 1 (256)
layer-0 down 7168, 2304 1 (256)
q_b 1536, 1536 1 (256)

Accuracy Tests

  • Each row passed the tuner check against the torch reference (err_ratio 0.0).
  • op_tests/tuning_tests/test_csv_validation.py and test_config_shape_collision.py pass.
  • With the merged config, tgemm.mm runs each row with flydsl (AITER_LOG_TUNED_CONFIG=1).
  • The max relative error against an fp32 reference is 3.5e-3. This is the same as the error of torch bf16 F.linear.

Speed Tests and Profiling

Setup:

shape N, K speedup
MoE router 384, 7168 1.18 to 1.37x (M 1 to 128), 2.22x (M 256)
shared expert gate_up 512, 7168 1.07 to 1.27x (M 1 to 128), 1.75x (M 256)
fused_qkv_a_proj_with_mqa 2112, 7168 1.03x (M 64), 1.19x (M 256)
kv_b 2048, 512 1.39x (M 64), 1.61x (M 256)
M = 256 rows of the other shapes 1.16 to 2.87x

For Kimi-K2 TP8 decode at concurrency 4 / 16 / 64:

  • With these rows, the dense GEMMs use approximately 0.13 / 0.15 / 0.14 ms less time in each step than with [Triton/Gluon] [Config] gfx1250 Gluon GEMM configs for Kimi-K2 TP8 #6573 only.
  • With all three PRs, the dense GEMMs use 0.70 / 0.78 / 1.23 ms less time in each step than on main.
  • These values are the kernel time multiplied by the calls in each step, for 61 layers.
  • The values do not include kv_b, because absorbed-MLA decode does not run it.

The rows need flydsl 0.4.0. setup.py pins this version. With flydsl 0.3.4.1, the gfx1250 FlyDSL kernel does not import.

End to end, with all three PRs: Kimi-K2-Thinking-MXFP4 TP8 on MI450 DPX, sglang, 8k input / 1k output, concurrency 4. Main and the three PRs ran in A-B-B-A order on the same node. The median TPOT is 17.83 ms on main and 16.46 ms with the three PRs (−7.7%). The GSM8K 5-shot accuracy is 0.935 on main and 0.940 with the three PRs, with no invalid answers.

Checklist

  • Format your code according to the project's code style.
  • Add unit tests (config only).

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]>
@jiaryang
jiaryang requested review from a team and a balanced review from Copilot October 28, 2026 06:08
@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 7070 --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 [FlyDSL] [Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8 [Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8 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

The enabled FlyDSL rows can corrupt strided outputs, mishandle graph-capture counters, and select an unsupported architecture in multi-target builds.

4 open issues
What changed in this PR

This configuration-only PR routes selected Kimi-K2 TP8 bf16 GEMMs through FlyDSL on gfx1250 GPUs with 96 compute units, replacing the Gluon fallback for those buckets.

Changes:

  • Adds 62 tuned FlyDSL entries across nine dense GEMM shapes.
  • Adds 53 shape entries to the untuned configuration.
  • Leaves buckets without new tuned entries on the existing fallback; no kernel code changes.
File Description
aiter/​configs/​model_configs/​kimik2_bf16_untuned_gemm.csv Expands the Kimi-K2 bf16 tuning shape list.
aiter/​configs/​model_configs/​kimik2_bf16_tuned_gemm.csv Adds gfx1250, 96-CU FlyDSL selections and tuning metrics.

Review effort: Balanced

…U 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.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 14:20

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.

…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.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 14:51

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 changes depend on still-open PRs #6573 and #7096 and need correctness and performance validation on 96-CU hardware against the eventual merged configuration.

5 open issues

Review effort: Balanced

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

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 prerequisite config tree lacks the required DEFAULT.json, so omitted buckets may use CU-agnostic settings instead of the 96-CU baseline used to select these rows.

1 open issue
5 resolved since last review

Review effort: Balanced

@yifehuan yifehuan 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

@yifehuan
yifehuan merged commit e2381c4 into ROCm:main Oct 29, 2026
54 checks passed
@jiaryang
jiaryang deleted the config/gfx1250-kimi-k2-flydsl-csv branch October 29, 2026 15:42
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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants