Repository navigation
[Config] [FlyDSL] [gfx1250] Kimi-K3 TP1 decode mx128 rows (on #8246) - #8579
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
… f_b Kimi-K3 runs its attention at TP1 on the DP8EP8 decode node (DP attention), so every rank reads the full N x K weights. The tuned table only held the power-of-two M rows of these shapes, so M = 315 ran the M = 512 tile, M = 640 the M = 1024 tile, and f_b (12288 x 128) had no row at all. Rows for the decode buckets M <= 640 of seven TP1-only shapes: kda_in_proj 49408x7168, o_proj 7168x12288, mla_gate / shexp_gate_up 12288x7168, kda_f_b 12288x128, shexp_down 7168x6144, dense FFN 67584x7168 and 7168x33792. 81 rows added, 12 replaced. Every candidate of the #8246 space that launches over the whole bucket was timed with cold weights (rotating copies >= 2 GB) as CUDA-graph replays. The top candidates were then re-timed against the kernel the runtime picks today in 7 interleaved rounds. A row is written only when its median paired ratio is <= 0.97 and every round is faster. Public entry, M = 1..1024 on all nine K3 TP1 shapes: errRatio <= 0.017 vs the FP32 reference and graph replay bitwise equal to eager. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mla_qkv_a 2176x7168 and mla_q_b 18432x1536 have the same N and K at TP1 and TP8, so these rows also change the TP8 decode picks of #8246's retune. They come from the same cold-weight CUDA-graph sweep and paired re-timing as the previous commit. 11 rows added, 13 replaced; most qkv_a gains are 8-22 %. Co-Authored-By: Claude Opus 5.5 <[email protected]>
aoli26
added a commit
that referenced
this pull request
Nov 26, 2026
Conflict in the K3 mxfp8_128 table only. Both sides tuned the same decode buckets, so the resolution keeps this branch's row unless the PR's row was measured faster inside the K3 decode step (all GEMMs of a step in one CUDA graph, per-layer weights, 4 serial runs agreeing): 3 rows of the PR are taken as they are (f_b M384, mla_qkv_a M112, mla_q_b M256).
aoli26
added a commit
that referenced
this pull request
Nov 26, 2026
… slower inside the step In the K3 decode step (all GEMMs of a step in one CUDA graph, per-layer weights) 11 rows of this branch's table lose although they won the isolated back-to-back A/B. Ten go back to the kernel their bucket ran before this branch (f_b M80/112/128, mla_gate M192/208/240, mla_q_b M448/576/832/864); mla_q_b M208 (a new bucket) takes the kernel PR #8579 serves it from its M256 row. 4 serial runs agree, 1.8-14 us per call; rows written by the repo tuner.
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
Kimi-K3 mx128 (E8M0 1x128 / 128x128, (16,16)-preshuffled W) rows for the decode M range of the TP1 GEMMs that the DP8EP8 decode node runs: there, attention runs at TP1 (DP attention), so every rank reads the full N x K weights. Stacked on #8246 (base branch
gfx1250/k3-flydsl-fp8-gemmatccc4270): the rows use its fused split-K, runtime cluster_m and opt-in (_qe/_nlb) kernels. The diff is the K3 table only.4577577: seven TP1-only shapes (kda_in_proj, o_proj, mla_gate / shexp_gate_up, kda_f_b, shexp_down, dense FFN gate_up / down). 81 rows added, 12 replaced.84a741a: mla_qkv_a 2176x7168 and mla_q_b 18432x1536. These N/K are the same at TP8, so this commit also changes [HIP] [CK] [FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows #8246's TP8 decode picks of those two shapes. It is kept separate so it can be dropped or re-checked on its own. 11 rows added, 13 replaced.Motivation
The table had only power-of-two M rows for the large TP1 shapes, so the padded-M lookup sent M = 257..512 to the M = 512 row and M = 513..1024 to the M = 1024 row. K3 runs decode at M = 300..315 per rank at c512 and ~640 at c1024.
kda_f_b_proj(12288x128) had no row at all and ran the untuned fallback. In the 1124 c512 decode breakdown the dense A8W8 GEMMs take 10.2 ms of the ~67 ms step; kda_in_proj and o_proj are 87 % of that.Changes
aiter/configs/model_configs/kimik3_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csvonly.Method:
kernels_listthat fits, i.e. split_k 1 or fused, row-major A, which is 1.1k–7.5k per (shape, M).uscolumn is the CUDA-graph per-call time.Performance
gfx1250 (256 CU), 1120 K3 image, cold weights, CUDA graph, µs per call. Today's pick → this PR; unchanged where only one number is shown. The paired median ratio of 7 rounds decided each changed cell.
Decode-step proxy. This replays the main-stream dense GEMMs of one K3 decode step: 24 MLA layers (qkv_a, q_b, gate, o_proj) and 68 KDA layers (in_proj, f_b, o_proj). Each layer has its own weights, all calls go in one CUDA graph, and the old and new tables are run alternately twice.
At M=315, kda_in_proj goes from 6.41 to 5.03 ms/step, o_proj from 2.83 to 2.21 ms/step and kda_f_b from 0.24 to 0.18 ms/step. The shared-expert pair on the side stream is unchanged at M=315.
Testing
gemm_a8w8_blockscale_bpreshuffle, every M = 1..1024 for all nine shapes on the new table, 9,216 cases.op_tests/tuning_tests/test_config_shape_collision.pyandtest_csv_validation.py: 52 passed.*_a8w8_blockscale_mxscale_bpreshuffle_tuned_gemm.csv.resolve_cluster_mfor every M = 1..1024. The new rows add no launch thatkernel_fits_shapewould refuse.Notes for review
84a741adisagrees with some of [HIP] [CK] [FlyDSL] [gfx1250] Fused split-K for the generic a8w8 GEMM; retune K3 mx128 rows #8246's qkv_a / q_b picks at the same (M, N, K).kernel_fits_shapeforbids this ("cluster barrier hang on decode M"). They ran correctly in every test here and are the fastest choice there, so either the rule is stale or a hazard remains. Please confirm.🤖 Generated with Claude Code