Repository navigation
[FlyDSL] [gfx1250] Kimi-K3 TP1 decode: mxfp8_128 rows for every M bucket up to 1024, cluster_m 3/5 candidates - #8586
Draft
zejunchen-zejun wants to merge 2 commits into
Draft
zejunchen-zejun wants to merge 2 commits into
zejunchen-zejun wants to merge 2 commits into
Conversation
…ket up to 1024 The PD decode node (DP8EP8, attention at TP1) runs its dense A8W8 GEMMs at M = 5 tokens x requests per rank, about 120 to 960 for c192 to c1536. The K3 mx128 table had only power-of-two M rows for these TP1 shapes, so M=315 ran the M=512 tile and M=640/960 the M=1024 tile; KDA f_b (12288x128) had no row; and the o_proj / dense down M128 rows and the dense gate_up M256 row launch a compute tile taller than part of the M range they serve. 194 rows added, 44 replaced over 9 shapes, kernels from #8246's space: - 210 rows >= 3% faster than today's launch for their bucket in an ABBA A/B; - 16 rows replace kernels that do not fit every M of their bucket; - 12 rows pin today's kernel where a replaced power-of-two row would make the buckets falling through to it more than 1% slower. Every row fits both ends of its bucket (kernel_fits_shape). Dense FFN M=1024 rows (#8557) and rows above M=1024 are unchanged. Main-stream decode GEMMs per step (one CUDA graph, per-layer weights): -11.4% at c192, -14.9% at c512, -19.9% at c1024, -20.0% at c1536. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r rows At M=315 (c512) a 128-row tile gives 3 M-tiles, which no power-of-two cluster_m covers, so each M-tile read the whole weight on its own. A cluster of 3 (or 5) M-tiles shares each weight read through TDM multicast. - Eight opt-in candidates with cluster_m 3 or 5 appended to kernels_list (existing kernelIds unchanged); kernel_fits_shape accepts the compute clusters (3, 1) and (3, 4) they use. - Eight rows at M 160 and 320, each >= 3% faster than the previous row for its bucket in an ABBA A/B: kda_in_proj M320 1.11x, o_proj M320 1.15x, mla_q_b M160 1.10x, mla_gate M320 1.10x, mla_q_b M320 1.06x, kda_f_b M160 1.06x, shexp_down M160 / M320 1.04x. - All 457 such variants of the decode buckets' best kernels were launched once on hardware first, at both ends of their bucket: none hung, all but one _nlb variant (rejected before launch) matched the FP32 reference. - Variants at M640 that were faster alone gave no gain inside the decode step (0.0% with the table order shuffled), so they are not included. Decode-step proxy (main-stream GEMMs, 4 GPUs): c512 -26.0% against the old table (was -14.9% with the previous commit), c256 -14.6%. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Draft
2 of 3 tasks
ZLkanyo009
added a commit
to ZLkanyo009/aiter
that referenced
this pull request
Nov 25, 2026
Port the tuning by zejunchen-zejun from ROCm#8586, ROCm#8601 and ROCm#8634, with the required ROCm#8246 implementation and two inherited qkv_a rows. Resolve overlapping dense/f_b choices in favor of the peer workload coverage; retain our remaining dense, DSpark and PTPC contributions. Preserve the dev underfilled-compute guard, fallback policy, existing ROCm#8348 latent rows, and unrelated architecture rows. GPU validation of the combined dev revision is still pending. Source-PR: ROCm#85868311172 Source-PR: ROCm#86010d0c8d7 Source-PR: ROCm#86341f962ee Dependency-PR: ROCm#8246ccc4270 Signed-off-by: Ling Zhang <[email protected]>
aoli26
added a commit
that referenced
this pull request
Nov 26, 2026
…to the K3 TP1 table Table: this branch's row is kept unless the PR's row was measured faster, inside the K3 decode step for the shapes that step runs (4 serial runs agreeing) and by a 3-pass isolated A/B for shared down and dense gate_up. 27 rows of the PR are taken (8 of them new buckets); two of them name cluster_m 3 / 5 kernels, whose kernelId is the one of this branch's catalog. Candidate list: this branch's is kept. It already holds 7 of the PR's 8 cluster_m 3 / 5 candidates among its npot families; the eighth (t64x128x512 cm3 _qe) is used by no row taken here.
5 of 10 tasks
gbyu-amd
pushed a commit
that referenced
this pull request
Dec 1, 2026
#8978) * K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows (#8778 @ ea7a5d8) #8778 (aoli26; base main; open) applied to k3-455-dev as its net change on its 19 files at head ea7a5d8 (2026-11-26T14:47:07Z), 3-way against the PR's main base adbb6ac. The 8 files k3-455-dev had changed (all only by #8246 @ 15808c7) take the PR's version, so all 19 files equal the PR head. It carries the newer #8246 (ccc4270), the table PRs #8579 / #8586 / #8601 and main's #8566 (its compute guard, which #8778 replaces); no other main change rides in. Validated in the K3 1P1D integration branch (aiter zejun/k3-455-dev 627e1eb) on 16 MI455X (wuhuikx/LLM-Booster#578). The PR head has moved on since (204ce9d: merges of #8246 @ 0d6cf15 and of main, which brings #8737); those can follow when #8778 lands. Co-authored-by: zejunchen-zejun <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update K3 FP8 kernels to c997 and add exact-M tuning Preserve the existing dev wrappers and bucket tables. Add 162 accepted retuned exact configurations and 3 c997-default compatibility records, with CPU dispatch coverage for all 675 measured points. Backport the three kernel files from c99781c without merging main history. Integrated-head GPU validation remains outstanding. --------- Co-authored-by: aoli26 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zhang <[email protected]>
gbyu-amd
pushed a commit
that referenced
this pull request
Dec 3, 2026
#8978) * K3 TP1 a8w8 GEMM: compute N tail, underfilled tiles, aligned A-scale loads, retuned rows (#8778 @ ea7a5d8) #8778 (aoli26; base main; open) applied to k3-455-dev as its net change on its 19 files at head ea7a5d8 (2026-11-26T14:47:07Z), 3-way against the PR's main base adbb6ac. The 8 files k3-455-dev had changed (all only by #8246 @ 15808c7) take the PR's version, so all 19 files equal the PR head. It carries the newer #8246 (ccc4270), the table PRs #8579 / #8586 / #8601 and main's #8566 (its compute guard, which #8778 replaces); no other main change rides in. Validated in the K3 1P1D integration branch (aiter zejun/k3-455-dev 627e1eb) on 16 MI455X (wuhuikx/LLM-Booster#578). The PR head has moved on since (204ce9d: merges of #8246 @ 0d6cf15 and of main, which brings #8737); those can follow when #8778 lands. Co-authored-by: zejunchen-zejun <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> * Update K3 FP8 kernels to c997 and add exact-M tuning Preserve the existing dev wrappers and bucket tables. Add 162 accepted retuned exact configurations and 3 c997-default compatibility records, with CPU dispatch coverage for all 675 measured points. Backport the three kernel files from c99781c without merging main history. Integrated-head GPU validation remains outstanding. --------- Co-authored-by: aoli26 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zhang <[email protected]> (cherry picked from commit 1cc9d02) Rebase onto main 12-03: the 19 files keep this commit's content; only main's later changes are added: the AOT launcher factories of #8678 (mxfp8 / batched wrappers launch gemm_a8w8_launcher.lazy(), _gemm_a8w8_compute_bound_launcher.lazy(), splitk_reduce_launcher.lazy(); _lazy_import keeps _data_ptr), #7449's deferred split-K entry points and #8636's ragged-K fallback. gemm_a8w8_gfx1250.py: this commit's rank0 split-K epilogue and flush_addr (it already carries #8737's flush). gemm_op_a8w8.py: main's #8566 guard in get_mxscale_bpreshuffle_config (no padded row below a compute kernel's M tile) is removed, as on the #8778 head, because the c997 compute kernel serves underfilled tiles; test_gemm_host_dispatch_cache.py takes #8778's test_mxscale_compute_row_serves_underfilled_m_tile in place of main's two guard tests. kimik3 mxscale tuned CSV: this commit's rows (626 changed or added) replayed by key; the result equals this commit's table. Rebase onto main 12-03: main #7449 moved the bpreshuffle row lookup into _bpreshuffle_config(XQ, WQ); this commit's Kimi-K3 exact-row lookup there needs x_scale, w_scale and Y, so _bpreshuffle_config takes them (the deferred split-K path passes a meta tensor of the output's shape and dtype, so it picks the same row as gemm_a8w8_bpreshuffle). Rebase onto main 12-03: op_tests/test_gemm_a8w8_mxfp8_bpreshuffle.py counts reduce launches through splitk_reduce_launcher.lazy (main #8678 replaced _compile_splitk_reduce).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fills the Kimi-K3 mxfp8_128 bpreshuffle table for the TP1 GEMMs of the PD decode (D) node at every M bucket up to 1024, and adds 8 opt-in candidates whose
cluster_mis 3 or 5.gfx1250/k3-flydsl-fp8-gemm, and the diff is the K3 CSV plus the candidate list.Motivation
The D node runs these GEMMs unsplit. It is DP8EP8 + MegaMoE with
--enable-dp-attention, so the attention and dense projections run at TP1.M per rank is about 120 to 960 for c192 to c1536. With DSpark k=4 every request adds 5 tokens a step, so M ≈ 5 × concurrency / 8.
The table had only power-of-two M rows for these shapes.
getPaddedMrounds M up to a multiple of 16 (M ≤ 256) or 32 (M ≤ 1024). When that bucket has no row, M falls through to the next power of two.KDA
f_b(12288×128) had no row and ran the untuned heuristic.Three rows launch a compute kernel whose
tile_mis taller than part of the M range they serve:compute_t128x128x128 … sk4_cm1_cn4compute_t256x256x128 … cm1_cn4kernel_fits_shaperejects such launches ("must not launch when M < tile_m (cluster barrier hang on decode M)"), but the dispatcher does not check.gpu_recovery=0.Power-of-two clusters miss the c512 tile count. At M=315 a 128-row tile gives 3 M-tiles, so no power-of-two
cluster_mfits and each M-tile reads the whole weight alone. A cluster of 3 M-tiles shares each weight read through TDM multicast.Changes
1.
aiter/configs/model_configs/kimik3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv: 456 → 654 rows.2.
aiter/ops/flydsl/gemm_tune/flydsl_gemm_mxfp8_128_bpreshuffle_wmma_common.pycluster_m3 or 5 are appended tokernels_list, the way [HIP] [CK] [FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows #8246 appended its opt-in K3 candidates. Existing kernelIds are unchanged (9719 → 9727).kernel_fits_shapeaccepts the compute clusters (3, 1) and (3, 4) they use.cluster_mis a launch argument, and the multicast masks (compute_mcast_masks_runtime, bitx + cm·y) do not assume a power of two. So no kernel code changes.How a row was chosen
kernel_fits_shapeat both ends of the bucket, so no M the row serves drops its cluster or runs a compute tile taller than M.f_b.mla_q_bM 544–608 would otherwise run 0.60× through the new M1024 row.cluster_m3, 5, 10 or 15, dividing the M-tile count at both ends of a decode bucket) were each launched once on hardware first, at both ends of their bucket. None hung, and all but one matched the FP32 reference; that one is an_nlbvariant, rejected before launch.Performance
Setup
rocm/fw-bringup:gfx1250-atom-k3-20261120, with its aiter switched to this branch's kernels, candidates and table. FlyDSL 0.5.0.Decode-step proxy
Largest gains
compute_t128x256x128 cm3: the 3 M-tiles share each W read. It is called 68 times a step.compute_t256x256x128cm2/cm4.cm3, fused split-K 2). It is called 92 times a step.Per shape at the bucket of each concurrency (µs per call; ABBA of today's launch against the new one where the kernel changed)
t128x256x256_mw2_nw2_nb3_sk1_cm1_cn1t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1@M512C_t128x256x128_mw2_nw2_nb3_sk1_cm3_cn1@m320t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1@M512C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn1@m480t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1@m1024t128x256x128_mw2_nw2_nb3_sk1_cm1_cn1@m640t256x256x128_mw2_nw2_nb4_sk1_cm1_cn1@m1024C_t256x256x128_mw2_nw2_nb2_sk1_cm4_cn1@m960C_t128x128x128_mw2_nw2_nb4_sk4_cm1_cn4@m128t128x128x256_mw2_nw2_nb4_sk4_cm1_cn1_fsk@m128C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn4@M256C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn4_fsk@M160C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn4@M256C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn4_fsk@m240C_t128x128x128_mw2_nw2_nb4_sk1_cm4_cn4@M512C_t128x256x128_mw2_nw2_nb3_sk2_cm3_cn1_fsk@m320C_t128x128x128_mw2_nw2_nb4_sk1_cm4_cn4@M512C_t128x256x128_mw2_nw2_nb3_sk2_cm4_cn1_fsk@M512C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4@m1024C_t256x256x128_mw2_nw2_nb4_sk2_cm1_cn2_fsk@m640C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1@m128t128x128x256_mw2_nw2_nb4_sk2_cm1_cn1_fsk@m128C_t128x128x128_mw2_nw2_nb4_sk1_cm2_cn4C_t128x128x128_mw2_nw2_nb4_sk1_cm2_cn4C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4@M512t64x128x256_mw2_nw2_nb3_sk1_cm5_cn2@m320C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4@M512C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn1@m480C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn4@m1024C_t128x256x128_mw2_nw2_nb3_sk1_cm1_cn4@m640C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn4@m1024C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn2@m960heuristic (no row)@MNonet32x64x128_mw2_nw2_nb2_sk1_cm4_cn2@m128heuristic (no row)@MNonet32x128x128_mw2_nw2_nb2_sk1_cm5_cn1@M160heuristic (no row)@MNonet64x32x128_mw4_nw1_nb2_sk1_cm4_cn4@m240heuristic (no row)@MNonet64x128x128_mw1_nw4_nb2_sk1_cm1_cn1@m320heuristic (no row)@MNonet128x128x128_mw2_nw2_nb2_sk1_cm4_cn1@m480heuristic (no row)@MNonet64x128x128_mw1_nw4_nb2_sk1_cm1_cn1@m640heuristic (no row)@MNonet128x128x128_mw2_nw2_nb2_sk1_cm4_cn1@m960t64x128x256_mw1_nw4_nb4_sk4_cm1_cn1_fsk@m128t32x32x512_mw2_nw2_nb4_sk1_cm4_cn4@m128t64x128x256_mw1_nw4_nb4_sk4_cm1_cn1_fsk@M160t64x32x1024_mw4_nw1_nb3_sk1_cm1_cn4@M160t64x128x256_mw1_nw4_nb3_sk4_cm2_cn1_fsk@m240t64x64x512_mw2_nw2_nb4_sk1_cm4_cn2@m240t64x128x256_mw2_nw2_nb3_sk4_cm2_cn1_fsk@m320t64x64x512_mw2_nw2_nb4_sk1_cm1_cn2@m320t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1_qe@M512C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn1_fsk@m480C_t128x128x128_mw2_nw2_nb4_sk2_cm8_cn1_fskt128x128x256_mw2_nw2_nb4_sk1_cm1_cn1@m1024t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1@m960t128x128x256_mw2_nw2_nb4_sk1_cm8_cn1t64x128x256_mw2_nw2_nb3_sk1_cm1_cn4@M160t64x128x256_mw2_nw2_nb3_sk1_cm3_cn1@M160C_t128x256x128_mw2_nw2_nb4_sk1_cm8_cn2@m240t256x128x256_mw2_nw2_nb3_sk1_cm1_cn1@m240C_t128x256x128_mw2_nw2_nb4_sk1_cm4_cn1@m320C_t128x256x128_mw2_nw2_nb4_sk1_cm3_cn1@m320C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn2@M512C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn1@m480C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn2@m1024C_t256x256x128_mw2_nw2_nb2_sk1_cm1_cn2@m640C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn2@m1024C_t256x256x128_mw2_nw2_nb4_sk1_cm1_cn2_ps2@m960t64x64x512_mw2_nw2_nb3_sk1_cm1_cn1@m128t64x64x512_mw2_nw2_nb4_sk1_cm1_cn1@m128t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1@M256t64x128x512_mw1_nw4_nb3_sk1_cm3_cn1_qe@M160t64x128x512_mw1_nw4_nb3_sk1_cm1_cn1@M256C_t128x128x128_mw2_nw2_nb4_sk2_cm2_cn4_fsk@m240C_t128x128x128_mw2_nw2_nb4_sk1_cm4_cn4@M512C_t128x128x128_mw2_nw2_nb4_sk1_cm3_cn4@m320C_t128x128x128_mw2_nw2_nb4_sk1_cm4_cn4C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn4@m1024C_t128x256x128_mw2_nw2_nb3_sk1_cm4_cn1@m960t128x128x128_mw2_nw2_nb3_sk1_cm1_cn1@m128t128x256x128_mw2_nw2_nb3_sk1_cm1_cn1@m128C_t256x256x128_mw2_nw2_nb4_sk1_cm1_cn4@M256 (tile taller than M)C_t128x256x128_mw2_nw2_nb3_sk1_cm2_cn1@M160C_t256x256x128_mw2_nw2_nb4_sk1_cm1_cn4@M256 (tile taller than M)C_t128x256x128_mw2_nw2_nb3_sk1_cm2_cn1@m240C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn4C_t256x256x128_mw2_nw2_nb4_sk1_cm2_cn4C_t256x256x128_mw2_nw2_nb4_sk1_cm4_cn2@m1024C_t256x256x128_mw2_nw2_nb4_sk1_cm1_cn4@m640C_t256x256x128_mw2_nw2_nb4_sk1_cm4_cn2C_t128x128x128_mw2_nw2_nb4_sk4_cm1_cn4@m128t128x128x256_mw2_nw2_nb4_sk4_cm1_cn1_fsk@m128C_t128x256x128_mw2_nw2_nb3_sk4_cm2_cn4@M256C_t128x256x128_mw2_nw2_nb3_sk4_cm2_cn2_fsk@M256C_t128x256x128_mw2_nw2_nb3_sk4_cm2_cn4@M256C_t128x256x128_mw2_nw2_nb3_sk4_cm2_cn2_fsk@m240C_t256x256x128_mw2_nw2_nb2_sk4_cm2_cn4C_t256x256x128_mw2_nw2_nb2_sk4_cm2_cn4C_t256x256x128_mw2_nw2_nb2_sk2_cm4_cn4@m1024C_t256x256x128_mw2_nw2_nb4_sk2_cm1_cn1_fsk@m640C_t256x256x128_mw2_nw2_nb2_sk2_cm4_cn4Testing
kernelIdmatches itskernelNameinkernels_list.kernel_fits_shape. Before this change, 253 M did not (o_proj 63, dense down 63, dense gate_up 127).AITER_LOG_TUNED_CONFIG=1.gemm_a8w8_blockscale_bpreshuffleat every M from 1 to 1024 for all 9 shapes (9216 calls), with 0 failures:Not covered: M above 1024 (prefill), kv_b (PTPC) and the BF16 GEMMs.
🤖 Generated with Claude Code