Skip to content

[Config] [GFX1250] Kimi-K3 TP8 gemm tune - #6763

Merged
demonsan merged 4 commits into
mainfrom
zejun/k3-tp8dcp8-gemm-tune
Oct 25, 2026
Merged

demonsan merged 4 commits into
mainfrom
zejun/k3-tp8dcp8-gemm-tune

Conversation

@zejunchen-zejun

Copy link
Copy Markdown
Contributor

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

zejunchen-zejun and others added 2 commits October 21, 2026 06:57
…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]>
…_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]>
@zejunchen-zejun zejunchen-zejun changed the title Zejun/k3 tp8dcp8 gemm tune [GFX1250] Kimi-K3 TP8 gemm tune Oct 21, 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 6763 --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.

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]>
@zejunchen-zejun
zejunchen-zejun marked this pull request as ready for review October 21, 2026 07:37
@zejunchen-zejun
zejunchen-zejun requested review from a team and a balanced review from Copilot October 21, 2026 07:37

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot changed the title [GFX1250] Kimi-K3 TP8 gemm tune [Config] [GFX1250] Kimi-K3 TP8 gemm tune Oct 21, 2026
@zufayu
zufayu requested a review from demonsan October 22, 2026 01:16
Copilot AI balanced review requested due to automatic review settings October 22, 2026 02:00

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 7be01d1 into main Oct 25, 2026
@demonsan
demonsan deleted the zejun/k3-tp8dcp8-gemm-tune branch October 25, 2026 12:29
qichu-yun added a commit that referenced this pull request Oct 26, 2026
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.
demonsan pushed a commit that referenced this pull request Oct 26, 2026
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.
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