Repository navigation
[Config] gfx1250 FlyDSL bf16 GEMM rows for Kimi-K2 TP8 - #7070
Conversation
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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟡 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.
…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.
There was a problem hiding this comment.
🟡 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
* [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]>
* [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]>


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 atcu_num=96:model_configs/for 2112x7168, 384x7168 and 512x7168 are allcu_num=256.Thus each call uses the gfx1250 fallback. The fallback is the Gluon
gemm_a16w16kernel withDEFAULT.jsonor the Gluon JSON of the shape.Modifications
This PR changes configs only. It does not change a kernel.
cu_num=96rows tomodel_configs/kimik2_bf16_tuned_gemm.csv.kimik2_bf16_untuned_gemm.csv.Tuning:
csrc/gemm_a16w16/gemm_a16w16_tune.pytuned the nine dense shapes for M = 1 to 256 on MI450 (DPX, 96 CUs).--with-hipblaslt). opus has noa16w16/gfx1250/96registry. asm and skinny have no gfx1250 kernels.Row selection:
tgemm.mmlooks up a tuned CSV row before the Gluon fallback.Merge this PR after #7096 and #6573.
Accuracy Tests
err_ratio0.0).op_tests/tuning_tests/test_csv_validation.pyandtest_config_shape_collision.pypass.tgemm.mmruns each row with flydsl (AITER_LOG_TUNED_CONFIG=1).F.linear.Speed Tests and Profiling
Setup:
tgemm.mm.For Kimi-K2 TP8 decode at concurrency 4 / 16 / 64:
The rows need flydsl 0.4.0.
setup.pypins 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