Repository navigation
[Config] [Bugfix] Add Kimi-K3.1 gfx950 TP1 BF16 GEMM rows so PP prefill stops falling back to hipBLASLt stream-K - #8245
Conversation
Kimi-K3.1 served with a PP8 x TP1 prefill runs every BF16 linear unsharded. Nine of those (N, K) shapes have no tuned row, so tgemm falls back to torch / hipBLASLt, whose heuristic picks stream-K (SK3) kernels. Under P/D load one of them never finishes: a workgroup spins in label_SK_Fixup and the prefill stage hangs. Add 125 FlyDSL rows (M = 1..8192, powers of two, for the gl=1 bucket) for the KDA in_proj / o_proj / f_b_proj, MLA kv_b_proj, the dense layer-0 MLP and lm_head at TP1. (M=128, 7168x12288) is already tuned in bf16_tuned_gemm.csv and is not repeated. Signed-off-by: Jasen2201 <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
There was a problem hiding this comment.
🟡 Changes recommended
Large padded-M inputs can trigger 32-bit output-index overflow and incorrect stores, with additional unresolved compatibility and tuning-coverage issues.
5 open issues
What changed in this PR
Adds Kimi-K3.1 TP1 BF16 GEMM tuning coverage on gfx950, directing prefill workloads to FlyDSL instead of the hipBLASLt fallback associated with hangs.
Changes:
- Add 125 FlyDSL configurations for nine TP1 shape families across M buckets from 1 to 8192.
- Add matching tuner inputs while reusing the existing canonical tuned entry for
(128,7168,12288).
| File | Description |
|---|---|
aiter/configs/model_configs/kimik3_bf16_untuned_gemm.csv |
Adds 125 TP1 GEMM shapes to the model’s tuning inputs. |
aiter/configs/model_configs/kimik3_bf16_tuned_gemm.csv |
Adds 125 BF16 FlyDSL selections for gfx950 GPUs with 256 compute units. |
Review effort: Balanced
… 7168, 12288) shape The gfx950 FlyDSL HGEMM computes its output offset as Int32 `global_row * n + global_col`, and getPaddedM(gl=1) reuses an M=8192 row for every larger M. For lm_head (N = 163840) that passes 2^31 output elements from M = 13108. Keep lm_head rows to M <= 4096 so larger M takes the torch path. Also list (128, 7168, 12288) in the untuned shapes: its tuned row lives in bf16_tuned_gemm.csv, but a retune reads only this list. Signed-off-by: Jasen2201 <[email protected]>
Conflict: aiter/configs/model_configs/kimik3_bf16_tuned_gemm.csv, where main (ROCm#8245) appended the Kimi-K3.1 TP1 rows and this branch appended the merged fused_qkv_a + g_proj rows (N 3808, K 7168). Both sets kept, main's first; no duplicate (gfx, cu_num, M, N, K, bias, dtype, outdtype, scaleAB, bpreshuffle) key in this file or across the bf16 tuned GEMM tables. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…4098) (cherry picked from commit b34b6b8) Rebase onto main 12-03: kimik3_bf16_tuned_gemm.csv conflicted with main's gfx950 row updates (#8317 / #8245 / #8915). Replayed by row key: the 32 gfx1250 rows this commit adds are inserted; its 15 gfx950 edits were number formatting only (a CSV round-trip) and are left as main has them. Same rows as the PR head 3b64098.


Summary
Adds 124 gfx950 FlyDSL rows to
kimik3_bf16_tuned_gemm.csv(and their shapes tokimik3_bf16_untuned_gemm.csv). They cover the nine BF16 GEMM shapes that Kimi-K3.1 runs unsharded on a TP1 prefill stage, at M = 1, 2, 4, …, 8192 (thegl=1padded-M buckets);lm_headstops at M = 4096 (see Changes).Motivation
Kimi-K3.1 P/D with a PP8 × TP1 prefill (one GPU per stage) runs every BF16 linear at TP1. The existing Kimi-K3 rows cover the TP8 shards only, so these nine shapes fall through to
torch_gemm→F.linear→ hipBLASLt. hipBLASLt's heuristic then picks stream-K kernels. Under P/D load one of them never finishes, and the prefill stage hangs with no error.Cijk_Alik_Bljk_BBS_BH_Bias_HA_S_SAV_UserArgs_MT256x240x64_..._SK3_..., grid 64512.label_SK_Fixup.TORCH_BLAS_PREFER_HIPBLASLT=0(rocBLAS) avoids it, but that is an environment workaround and changes every untuned torch GEMM in the process.With these rows, the stage never takes the torch path for these shapes.
Changes
aiter/configs/model_configs/kimik3_bf16_tuned_gemm.csv: +124 rows, alllibtype=flydsl,gfx950,cu_num=256,bias=False, bf16 → bf16.aiter/configs/model_configs/kimik3_bf16_untuned_gemm.csv: the same 124 shapes, plus(128, 7168, 12288).(M=128, N=7168, K=12288)is already tuned inbf16_tuned_gemm.csv, so its tuned row is not repeated (no duplicate-shape key). The shape is still listed in the untuned CSV so a retune covers it.lm_headrow at M = 8192. The FlyDSL epilogue computes its output offset in Int32, andgl=1reuses an M=8192 row for every larger M. For N = 163840 that passes 2^31 output elements from M = 13108. With no M=8192 row, M > 4096 takes the torch path. In ATOM,lm_headruns only on sampled rows.in_proj(q, k, v, g +b_proj+f_a_proj)o_projf_b_projgate_up(2 × 3072 × 2), MLAg_projdownkv_b_projgate_up(layer 0)down(layer 0)lm_headPerformance (if applicable)
MI355X (gfx950, 256 CUs),
rocm/atom-dev:nightly_202611171508(aiter b9e08da).torchpath (hipBLASLt heuristic), measured by the same tuner with--libtype torch.27 rows are slower than the hipBLASLt default, mostly at mid M (16–1024). The worst are:
These rows were tuned with FlyDSL candidates limited to the 1,136 kernels that already win a gfx950 BF16 row in aiter's tables. A triton + opus pass over the 27 slower rows beat FlyDSL on 3 of them, by 1–10%. Those rows were left out, because an opus row names its kernel by catalog index. A full-catalog FlyDSL pass (~3,500 candidates per shape) was not run. I kept these rows anyway, because the alternative for these shapes is a hipBLASLt path that can hang.
Testing
Tested on MI355X (gfx950). Single node, Kimi-K3.1 with a 16-layer cut. Prefill PP4 × TP1 (GPUs 0–3) → decode TP4 × DCP4 (GPUs 4–7) over Mooncake. lm_eval GSM8K, 3-shot, C64, 1319 requests. Accuracy is meaningless on a 16-layer model; the runs only check the hang. ATOM main 9b2e67b7f plus the Kimi-K3.1 PP → DCP P/D PRs ROCm/ATOM#3464, ROCm/ATOM#3465 and ROCm/ATOM#3479.
..._MT256x240x64_..._SK3_...spinning inlabel_SK_FixupTORCH_BLAS_PREFER_HIPBLASLT=0lm_headM=8192 row, which no K3.1 call reaches), defaultAITER_LOG_LEVEL=INFOshows 0 "not found tuned config" lines on the prefill stageserr_ratio≤ 0.026 against the torch reference, at the tuner'serrRatio=0.05._HGEMM_KERNEL_REon current main. 74 of them already appear in aiter's tuned tables.Documentation
Tuned-config rows only.
Dependencies
Breaking Changes
None. The rows only match gfx950 / 256 CU / these nine (N, K) shapes, which had no row before.
PR Self-Review
Reviewed revision
e12f0a5
Behavior and intent
For Kimi-K3.1's TP1 shapes,
get_GEMM_A16W16_confignow returns a FlyDSL row instead of the torch default, so these GEMMs no longer reach hipBLASLt's stream-K kernels. No other shape changes.Validation and unverified scope
PR-specific question
Changed op tests
None.