Repository navigation
[Config] [FlyDSL] Kimi-K3 gfx1250 mxfp8_128 blockscale GEMM tuning - #6530
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
66169f6 to
0f1a9ac
Compare
8c7131f to
f0e32db
Compare
f0e32db to
af3ee5a
Compare
…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]>
* [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.
af3ee5a to
4e3c891
Compare
Motivation
Kimi-K3 on MI455X (gfx1250) with online
per_block_fp8and 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
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.getPaddedMcovers any M up to 16384).kimik3tp8_a8w8_blockscale_mxscale_bpreshuffle_{un,}tuned_gemm.csvis removed, so K3 keeps one CSV for this family instead of two. No key appears twice.flydsl_gemm_mxfp8_128_bpreshuffle_wmma_commonthat fits the shape, timed with the operands the dispatch passes:x_scale(M, K//128) e8m0 with column-major bytes, asper_group_quant_hip(transpose_scale=True)emits it, and the raw (N//128, K//128) e8m0w_scale. A-preshuffle kernels are left out, since the dispatch feeds a row-major A.Test Plan
op_tests/tuning_tests/test_csv_validation.pyandtest_config_shape_collision.py.Test Result
Per-call GEMM time, best tuned kernel vs the untuned fallback (CUDA-graph replay, single MI455X):
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.
CSV tests on main
4a52e96with this PR: 46 passed, 0 skipped, 50 subtests passed. The mergeda8w8_blockscale_mxscale_bpreshuffleconfig 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.