Skip to content

[Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning - #6530

Merged
demonsan merged 1 commit into
mainfrom
qichu/kimi-k3-mxfp8-128-gfx1250-tune
Oct 26, 2026
Merged

demonsan merged 1 commit into
mainfrom
qichu/kimi-k3-mxfp8-128-gfx1250-tune

Conversation

@qichu-yun

@qichu-yun qichu-yun commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Kimi-K3 on MI455X (gfx1250) with online per_block_fp8 and E8M0 block scales (ROCm/ATOM#2554) runs its 128x128 blockscale GEMMs on the FlyDSL mxfp8_128 bpreshuffle kernels. No K3 DP8EP8 shape had a tuned row, so every call fell to _flydsl_mxfp8_fallback_kernel. At decode M that pick is 2–36x slower than the best kernel in the catalog, for example 7168x33792 at M=1 takes 725 µs vs 20 µs.

Technical Details

  • One Kimi-K3 table for this GEMM family: aiter/configs/model_configs/kimik3_a8w8_blockscale_mxscale_bpreshuffle_{un,}tuned_gemm.csv, 214 rows sorted by (N, K, M), MI455X, cu_num 256, libtype flydsl, errRatio 0. Config only, no code change.
    • 120 new rows: 8 DP8EP8 shapes x M = 1..16384 (powers of two, so getPaddedM covers any M up to 16384).
    • N is the padded N the model runs: KDA in_proj 49376 -> 49408, MLA fused_qkv_a 2112 -> 2176.
    • 94 rows are the TP8 table of [Config] [GFX1250] Kimi-K3 TP8 gemm tune #6763, moved here unchanged. kimik3tp8_a8w8_blockscale_mxscale_bpreshuffle_{un,}tuned_gemm.csv is removed, so K3 keeps one CSV for this family instead of two. No key appears twice.
  • Each new row is the fastest kernel of flydsl_gemm_mxfp8_128_bpreshuffle_wmma_common that fits the shape, timed with the operands the dispatch passes: x_scale (M, K//128) e8m0 with column-major bytes, as per_group_quant_hip(transpose_scale=True) emits it, and the raw (N//128, K//128) e8m0 w_scale. A-preshuffle kernels are left out, since the dispatch feeds a row-major A.

Test Plan

  • Tuned on 2x MI455X B0 (8 GPUs), FlyDSL 0.3.4.1, torch 2.14 / ROCm 10.2.
  • Cross-checked against an independent CUDA-graph-timed sweep of the same catalog:
    • median time ratio 0.98;
    • the chosen kernel is identical for 57/120 points, and the rest are near-ties.
  • Kimi-K3 DP8EP8 end to end in ATOM, 8k in / 1k out, concurrency 32, plus GSM8K 5-shot.
  • op_tests/tuning_tests/test_csv_validation.py and test_config_shape_collision.py.

Test Result

Per-call GEMM time, best tuned kernel vs the untuned fallback (CUDA-graph replay, single MI455X):

N x K M=1 M=16 M=2048 M=16384
7168x33792 725 -> 20.2 µs 729 -> 23.0 µs 253 -> 236 µs 1715 -> 1670 µs
7168x12288 195 -> 9.1 µs 193 -> 10.3 µs 75.6 -> 76.0 µs 559 -> 529 µs
12288x7168 116 -> 8.6 µs 117 -> 9.5 µs 86.1 -> 81.4 µs 541 -> 526 µs
49408x7168 32.8 -> 27.1 µs 33.8 -> 28.9 µs 454 -> 339 µs 3420 -> 2306 µs

Kimi-K3 DP8EP8 end to end, without -> with a K3 table. This run used the graph-timed cross-check table, not the committed one; see Test Plan for how the two compare.

without with
output tok/s 380.3 591.5
mean TTFT (ms) 3331 2933
mean TPOT (ms) 79.6 50.5
GSM8K strict 0.9621 0.9598 (within noise)

CSV tests on main 4a52e96 with this PR: 46 passed, 0 skipped, 50 subtests passed. The merged a8w8_blockscale_mxscale_bpreshuffle config has 2674 rows, main's 2554 plus the 120 new ones, so all 94 moved TP8 rows are still loaded and no row is dropped as a duplicate.

@qichu-yun
qichu-yun requested a review from a team October 14, 2026 10:33
@github-actions github-actions Bot changed the title [Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning and gfx1250 tuner support [CK] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning and gfx1250 tuner support Oct 14, 2026
@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 6530 --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 added the CK label Oct 14, 2026
@qichu-yun
qichu-yun force-pushed the qichu/kimi-k3-mxfp8-128-gfx1250-tune branch from 66169f6 to 0f1a9ac Compare October 14, 2026 10:37
@qichu-yun qichu-yun added the no-auto-title Opt out of auto labelling PRs label Oct 14, 2026
@qichu-yun qichu-yun changed the title [CK] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning and gfx1250 tuner support [Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning and gfx1250 tuner support Oct 14, 2026
@qichu-yun qichu-yun removed the CK label Oct 14, 2026
@github-actions github-actions Bot added the CK label Oct 14, 2026
@zufayu
zufayu requested a review from coderfeli October 15, 2026 01:51
@qichu-yun
qichu-yun force-pushed the qichu/kimi-k3-mxfp8-128-gfx1250-tune branch 2 times, most recently from 8c7131f to f0e32db Compare October 16, 2026 08:45
@github-actions github-actions Bot added Config and removed CK labels Oct 16, 2026
@qichu-yun qichu-yun changed the title [Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning and gfx1250 tuner support [Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning Oct 16, 2026
@qichu-yun
qichu-yun force-pushed the qichu/kimi-k3-mxfp8-128-gfx1250-tune branch from f0e32db to af3ee5a Compare October 19, 2026 03:20
zejunchen-zejun added a commit that referenced this pull request Oct 21, 2026
…scale + PTPC)

Kimi-K3 served by ATOM as one tensor-parallel group of 8 over two gfx1250
trays with decode context parallel 8 (TP8 + DCP8) quantizes its linears
online: global per_block_fp8 -> gemm_a8w8_blockscale_bpreshuffle with E8M0
scales (the FlyDSL mxfp8_128 kernels, table
a8w8_blockscale_mxscale_bpreshuffle), and kv_b_proj ptpc_fp8 ->
gemm_a8w8_bpreshuffle (FlyDSL WMMA, table a8w8_bpreshuffle). Its TP8 shards
had no tuned rows on gfx1250, so every call fell back to the heuristic
FlyDSL kernel.

model_configs/kimik3tp8dcp8_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv
(94 rows, w_scale_block 128x128), M buckets 1 2 4 8 16 32 48 64 128 256 512
1024 2048 4096 8192 16384:
  N=7168 K=1536  o_proj
  N=6400 K=7168  KDA fused in_proj
  N=2304 K=1536  MLA q_b_proj
  N=8448 K=7168  dense MLP gate_up
  N=7168 K=4224  dense MLP down
  N=1536 K=7168  M <= 64 (M 32 and 128 stay with dsv4's table, same keys)
  N=7168 K=768   M <= 64 (M 32 and 128 stay with dsv4's table, same keys)
model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3tp8dcp8.csv (16 rows):
  N=3072 K=512   MLA kv_b_proj, q_dtype_w torch.float8_e4m3fn
plus the untuned lists of the same shapes. Two more TP8 shapes, 18432x1536
(QREP q_b_proj) and 2176x7168 (fused_qkv_a), are left to
kimik3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv (aiter #6530, which
the K3 images ship): a second row with the same key would make aiter's
config merge raise. No key here repeats a row of another model_configs table.
Not covered: KDA f_b_proj N=1536 K=128 (no FlyDSL kernel takes K=128).

Tuned on MI455X (gfx1250, 256 CU) with
csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_tune.py --libtype flydsl
--preshuffle and csrc/ck_gemm_a8w8_bpreshuffle/gemm_a8w8_bpreshuffle_tune.py
--libtype flydsl, --mp 4. Candidates were timed as one CUDA-graph replay
(torch.profiler recorded no GPU kernels in that container); errRatio 0 for
every row. Against the untuned heuristic kernel: decode M <= 128 3-10x faster
(7168x1536 M=1 31 -> 3.4 us, 1536x7168 57 -> 5.5 us), prefill M 1.0-1.44x.

End to end (ATOM K3 TP8 + DCP8, RCCL all-reduce, 14336 in / 1024 out,
concurrency 32, same requests): output throughput 787.8 -> 882.5 tok/s
(+12.0%), mean TPOT 38.07 -> 34.09 ms, median ITL 25.07 -> 21.15 ms, mean
TTFT 1196 -> 1171 ms; GSM8K 5-shot 0.9613 with these tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
demonsan pushed a commit that referenced this pull request Oct 25, 2026
* [Config] Kimi-K3 TP8 + DCP8 gfx1250 FP8 GEMM tunings (mxfp8_128 blockscale + PTPC)

Kimi-K3 served by ATOM as one tensor-parallel group of 8 over two gfx1250
trays with decode context parallel 8 (TP8 + DCP8) quantizes its linears
online: global per_block_fp8 -> gemm_a8w8_blockscale_bpreshuffle with E8M0
scales (the FlyDSL mxfp8_128 kernels, table
a8w8_blockscale_mxscale_bpreshuffle), and kv_b_proj ptpc_fp8 ->
gemm_a8w8_bpreshuffle (FlyDSL WMMA, table a8w8_bpreshuffle). Its TP8 shards
had no tuned rows on gfx1250, so every call fell back to the heuristic
FlyDSL kernel.

model_configs/kimik3tp8dcp8_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv
(94 rows, w_scale_block 128x128), M buckets 1 2 4 8 16 32 48 64 128 256 512
1024 2048 4096 8192 16384:
  N=7168 K=1536  o_proj
  N=6400 K=7168  KDA fused in_proj
  N=2304 K=1536  MLA q_b_proj
  N=8448 K=7168  dense MLP gate_up
  N=7168 K=4224  dense MLP down
  N=1536 K=7168  M <= 64 (M 32 and 128 stay with dsv4's table, same keys)
  N=7168 K=768   M <= 64 (M 32 and 128 stay with dsv4's table, same keys)
model_configs/a8w8_bpreshuffle_tuned_gemm_kimik3tp8dcp8.csv (16 rows):
  N=3072 K=512   MLA kv_b_proj, q_dtype_w torch.float8_e4m3fn
plus the untuned lists of the same shapes. Two more TP8 shapes, 18432x1536
(QREP q_b_proj) and 2176x7168 (fused_qkv_a), are left to
kimik3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv (aiter #6530, which
the K3 images ship): a second row with the same key would make aiter's
config merge raise. No key here repeats a row of another model_configs table.
Not covered: KDA f_b_proj N=1536 K=128 (no FlyDSL kernel takes K=128).

Tuned on MI455X (gfx1250, 256 CU) with
csrc/ck_gemm_a8w8_blockscale/gemm_a8w8_blockscale_tune.py --libtype flydsl
--preshuffle and csrc/ck_gemm_a8w8_bpreshuffle/gemm_a8w8_bpreshuffle_tune.py
--libtype flydsl, --mp 4. Candidates were timed as one CUDA-graph replay
(torch.profiler recorded no GPU kernels in that container); errRatio 0 for
every row. Against the untuned heuristic kernel: decode M <= 128 3-10x faster
(7168x1536 M=1 31 -> 3.4 us, 1536x7168 57 -> 5.5 us), prefill M 1.0-1.44x.

End to end (ATOM K3 TP8 + DCP8, RCCL all-reduce, 14336 in / 1024 out,
concurrency 32, same requests): output throughput 787.8 -> 882.5 tok/s
(+12.0%), mean TPOT 38.07 -> 34.09 ms, median ITL 25.07 -> 21.15 ms, mean
TTFT 1196 -> 1171 ms; GSM8K 5-shot 0.9613 with these tables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Config] Kimi-K3 gfx1250 bf16 GEMM retune: MoE router gate and TP8 lm_head

With online FP8 quantization, the bf16 GEMMs left in Kimi-K3 TP8 + DCP8
are the MoE router gate (ReplicatedLinear, quant_config=None, M x 896 x
7168, 93 layers) and the TP8 vocab shard of the lm_head (M x 20480 x 7168).
Both reach aiter's tuned_gemm through kimik3_bf16_tuned_gemm.csv. Their
gfx1250 rows picked opus for the router up to M=512 and Triton (gluon,
"auto") everywhere else. The gluon N=896 config is tuned only up to
M_LEQ_512, so prefill took its generic "any" tile.

28 rows of model_configs/kimik3_bf16_tuned_gemm.csv (gfx1250, cu_num 256,
bias False, bf16 in/out) are replaced in place, keeping the same keys. The
untuned list already holds these shapes.

  N=896 K=7168 (router gate), today's row -> new best, same run:
    M=1     opus 5.08 -> flydsl hgemm 4.24 us (1.20x)
    M=2     opus 5.13 -> flydsl 4.25 us (1.21x)
    M=4     opus 5.42 -> flydsl 4.40 us (1.23x)
    M=8     opus 5.53 -> flydsl 4.67 us (1.18x)
    M=16    opus 6.09 -> flydsl 5.34 us (1.14x)
    M=64    opus 7.44 -> flydsl 7.09 us (1.05x)
    M=256   opus 13.41 -> flydsl 10.24 us (1.31x)
    M=512   opus 17.07 -> flydsl 12.92 us (1.32x)
    M=1024  triton 39.98 -> opus 20.97 us (1.91x)
    M=2048  triton 42.87 -> opus 33.30 us (1.29x)
    M=4096  triton 51.38 -> opus 40.53 us (1.27x)
    M=8192  triton 92.39 -> opus 60.05 us (1.54x)
    M=16384 triton 202.49 -> opus 120.07 us (1.69x)
    M=32 and M=128 keep their rows (the best candidate was under 3% faster).
  N=20480 K=7168 (lm_head, TP8 vocab shard):
    M=1     triton 27.09 -> opus 24.25 us (1.12x)
    M=2     triton 27.01 -> opus 24.85 us (1.09x)
    M=4     triton 29.00 -> opus 24.95 us (1.16x)
    M=8     triton 30.80 -> opus 25.86 us (1.19x)
    M=16    triton 31.70 -> opus 26.65 us (1.19x)
    M=32    triton 38.07 -> opus 30.04 us (1.27x)
    M=64    triton 47.08 -> flydsl 35.27 us (1.33x)
    M=128   triton 59.59 -> opus 43.46 us (1.37x)
    M=256   triton 132.73 -> opus 57.08 us (2.33x)
    M=512   triton 175.85 -> opus 102.43 us (1.72x)
    M=1024  triton 361.81 -> opus 168.80 us (2.14x)
    M=2048  triton 412.91 -> opus 305.32 us (1.35x)
    M=4096  triton 879.09 -> opus 548.93 us (1.60x)
    M=8192  triton 1608.15 -> opus 1051.87 us (1.53x)
    M=16384 triton 3393.74 -> opus 2183.59 us (1.55x)

The tuning ran on MI455X (gfx1250, 256 CU) with
csrc/gemm_a16w16/gemm_tuner.py --with-hipblaslt --mp 4. It searched asm,
opus, flydsl, triton, skinny, torch and hipBLASLt; on gfx1250 there are no
asm kernels and hipBLASLt never won. Candidates were timed as one CUDA-graph
replay, because torch.profiler recorded no GPU kernels in that container. A
row was replaced only when the new best beat the row's current kernel by at
least 3% in the same run. errRatio is 0 for every new row.

Opus kids 20175, 20211 and 20309 (lm_head, M <= 32) are not in the
gfx1250 default compile set. A module_deepgemm_opus.so built from the
previous CSVs does not contain them and aborts with "kid ... is not
compiled in the current OPUS module". Rebuild that module once
(AITER_REBUILD=1, or delete aiter/jit/module_deepgemm_opus.so). A fresh JIT
build reads the kids from this CSV. The other new opus kids (21031 21173
21174 21177 21179 21193 21290 21309 21316 21317) are default-compiled, and
the FlyDSL hgemm kernels JIT-compile per kernel.

End to end on ATOM Kimi-K3 TP8 + DCP8 (2 x 4 gfx1250, RCCL all-reduce,
14336 in / 1024 out, concurrency 32, same requests), on top of the FP8
tables of the previous commit:
  output throughput  882.46 -> 893.11 tok/s (+1.2%; untuned FP8 + old
                     bf16 rows: 787.77)
  mean TTFT          1170.93 -> 1142.44 ms
  P99 ITL            266.60 -> 259.21 ms (steps that carry a prefill chunk)
  median ITL         21.15 -> 21.15 ms (decode: router M=32 row unchanged)
  mean TPOT          34.09 -> 33.70 ms
GSM8K 5-shot chat (full): 0.9629 with the tables of both commits (0.9613
with the FP8 tables alone).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* [Config] Kimi-K3 TP8 GEMM tables: drop dcp8 from the file names

The tables hold Kimi-K3's TP8 GEMM shapes. None of them depends on
decode context parallelism, so the names say TP8 only. Pure rename,
contents unchanged:
  kimik3tp8dcp8_a8w8_blockscale_mxscale_bpreshuffle_{tuned,untuned}_gemm.csv
    -> kimik3tp8_a8w8_blockscale_mxscale_bpreshuffle_{tuned,untuned}_gemm.csv
  a8w8_bpreshuffle_{tuned,untuned}_gemm_kimik3tp8dcp8.csv
    -> a8w8_bpreshuffle_{tuned,untuned}_gemm_kimik3tp8.csv

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Kimi-K3 now has one a8w8_blockscale_mxscale_bpreshuffle table,
model_configs/kimik3_a8w8_blockscale_mxscale_bpreshuffle_{tuned,untuned}_gemm.csv,
214 rows sorted by (N, K, M):
  - 120 new rows: 8 DP8EP8 shapes x M = 1..16384 (powers of two)
  - 94 rows of the TP8 table from #6763, moved unchanged; the
    kimik3tp8_a8w8_blockscale_mxscale_bpreshuffle_{tuned,untuned}_gemm.csv
    pair is removed.
No key appears twice, and the merged config holds the same rows as with
two separate files.
@qichu-yun
qichu-yun force-pushed the qichu/kimi-k3-mxfp8-128-gfx1250-tune branch from af3ee5a to 4e3c891 Compare October 26, 2026 06:58
@demonsan
demonsan self-requested a review October 26, 2026 07:04

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

@demonsan
demonsan merged commit ffd08f2 into main Oct 26, 2026
63 checks passed
@demonsan
demonsan deleted the qichu/kimi-k3-mxfp8-128-gfx1250-tune branch October 26, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Config no-auto-title Opt out of auto labelling PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants