Repository navigation
[Perf] Integrate Kimi K3 TP1 GEMM tuning and dependencies on k3-455-dev - #8635
Open
ZLkanyo009 wants to merge 31 commits into
Open
ZLkanyo009 wants to merge 31 commits into
ZLkanyo009 wants to merge 31 commits into
Conversation
…) + opt-in one-shot all-reduce (ROCm#8015 @ 9ca30e9, head 2026-11-16T06:39:30Z) Applied as the PR diff onto the rebased 1116 tree; PR state: draft. Conflict resolved: custom_all_reduce.py constants block -- kept main's _LAMPORT_AR_1SHOT_MAX_BYTES (aiter ROCm#7927, native gfx1250 Lamport all-reduce, merged 11-17) and this PR's opt-in _LAMPORT_AR_MAX_SIZE side by side (different names, both used).
ROCm#8012 @ c3b4113, head 2026-11-16T06:45:00Z) Applied as the PR diff onto the rebased 1116 tree; PR state: draft. Conflicts resolved by keeping both sides (both PRs add different opt-in routes next to each other): communicator_cuda.py (ROCm#8015 Lamport one-shot check, then this PR's INT4 two-shot check), custom_all_reduce.py (constants, both symm_mem inits, both init methods), custom_all_reduce_gfx1250.h / pybind (main's ROCm#7927 allreduce_lamport and fused AR+RMS+quant declarations kept next to this PR's q4 declarations).
…7990 @ ec44f53, head 2026-11-18T06:41:04Z) Applied as the PR diff onto the rebased 1116 tree; PR state: open. Conflict: op_tests/op_benchmarks/triton/bench_kda.py (benchmark script only) conflicts with ROCm#7916's one-token benchmark columns; kept the ROCm#7916 version of that file, so ROCm#7990's kda_gating benchmark columns are NOT in this tree (its kernel, entry, config and test_kda_gating.py are).
…nel (kda_replayssm_conv) (cherry picked from commit 50d0667520a8c0ea3f74e5bdc93734bc2fd2882d)
…ROCm#8181 @ 2d34816, head 2026-11-19T06:16:25Z) Applied as the diff 2037a77..2d34816 (2 files) onto the rebased 1116 tree; PR state: open, author gbyu-amd, base main.
…uperseded by main's ROCm#7927 ROCm#8015 (head 9ca30e9) added CustomAllreduce.should_lamport_ar(inp) / lamport_all_reduce(inp), gated by AITER_CUSTOM_AR_LAMPORT_AR_MAX_SIZE, and a CudaCommunicator.all_reduce branch that took them first. Main's ROCm#7927 (2d9ab91, 2026-11-17) defines methods of the same names with a two_shot argument and selects the Lamport one-shot / two-shot inside custom_all_reduce (select_lamport_ar). Applied together, main's definitions came later in the class and shadowed ROCm#8015's, so the communicator branch ran main's one-shot up to the inbox cap whatever the env said. Main's route is kept: AITER_CUSTOM_AR_LAMPORT_AR_MAX_SIZE is no longer read. ROCm#8015's Lamport inbox on the torch.symm_mem transport stays, so main's Lamport kernels also serve the cross-node group. Not GPU-validated.
@ 15808c7, head 2026-11-19T10:14:52Z) Applied as the diff ce334d0..15808c7 (26 files) onto the rebased 1116 tree; PR state: open, author aoli26, base main. Squash-applied: ROCm#8246's branch merges main (ce334d0, this tree's base) and carries rebased copies of aoli26's ROCm#7827 (head 9d38b5c, every added line present here) and ROCm#7868 (head 570805d; 3 of its added lines are superseded by ROCm#8246's later edits), so this one diff applies the ROCm#7827 -> ROCm#7868 -> ROCm#8246 stack as ROCm#8246 has it.
…fc7e8, head 2026-11-19T13:20:38Z) Snapshot of ROCm#8189 (all 6 files, PR diff against its main base). For Kimi-K3 it supplies the stage-1 fused kernel's flag tiles for more than 4 source ranks: without it the S1F stage-1 kernel fails to compile at EP8 ("vector index 4 out of range for numel 4" in s1f_stage1.ready_of). Needed with ROCm#8483 for S1F on the K3 DP8EP8 decode node (wuhuikx/LLM-Booster#722). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nas and run SiTUv2 in the stage-1 kernel (ROCm#8483 @ 45fbfb7, head 2026-11-23T06:55:24Z) Snapshot of ROCm#8483. The stage-1 compact plan sizes its per-m-tile LDS table by the S1F receive cap instead of the arena (Kimi-K3 EP8 at 16384 tokens a rank: 569 KiB -> 73 KiB, limit 320 KiB), and SiTUv2 runs in the stage-1 kernel with its betas. Validated with ROCm#8189 on two MI455X trays: K3 DP8EP8 serving with AITER_MEGA_S1F=1, every decode step on s1f_stage1, GSM8K unchanged (wuhuikx/LLM-Booster#722 comment 7121412936). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Transplant dense E8M0, f_b, DSpark, and PTPC rows from PRs ROCm#8557, ROCm#8561, ROCm#8566, and ROCm#8626. Include the underfilled compute lookup guard and its host regressions; retain dev fallback selection. Signed-off-by: Ling Zhang <[email protected]>
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]>
Add q_b M256, gate_up M64/M256, and o_proj/down M64/M256 rows, and update the q_b/gate_up M128 selections. All nine candidates have independently accepted exact-M numerical and paired performance results on a3005ac with FlyDSL 0.5.3 and the native 20261120 image. Leave measurement cells blank; recipe-bound timings and TFLOPS are recorded in the review manifest. Kernel implementation and dispatch guards remain unchanged. Public entry and borrowed-M validation of this CSV delta is pending; this local commit is preparation for that stage. Refs: wuhuikx/LLM-Booster#710 Signed-off-by: Ling Zhang <[email protected]>
Add the measured M128/N163840/K7168 FlyDSL TDM row. Skip borrowed TDM rows on gfx1250-strict, whose wrapper does not support that architecture. Normal gfx1250 and existing native strict rows retain their selection rules.
This was referenced Nov 25, 2026
ZLkanyo009
marked this pull request as ready for review
November 25, 2026 14:09
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
The
k3-455-devbranch lacks the newer Kimi K3 TP1 GEMM selections and their FlyDSL dependencies. This PR integrates the pinned changes below, adds nine DSpark configurations, and adds a K3 BF16 lm_head M128 selection with a narrow strict-architecture borrowing guard. The DSpark configurations have accepted BF16 and FP16 public correctness results. The lm_head delta adds its row and prevents unsupported borrowed gfx1250 TDM rows from overriding the strict fallback. Incremental rows add main q_b M3072 (#8703), DSpark gate_up M96 (#8706), DSpark o_proj M96 (#8709), and DSpark down M96 (#8710), with separate main/dev evidence below.Base:
76c9cdc18cf504657bc7d97a3c65211e0df22e33. Latest composition-reviewed head:d76003126235dfb24569e490d15f71c8ac606706. Prior targeted shared GPU validation remains bound to4451e7639c4ae4d0d56dd1ffe7870bc5d1892f17. FlyDSL remains 0.5.3.Integrated scope
1b113f7573aea30c2382806d1333ca2e58cd58b89b757837831117259c3e0d0c8d7690841f962ee30fea3023befb42aa4451e7639c4a15bdebaa0c877ca2956434123649f511146e9cc5825de2821f1f280801f42d646f5d97b7c672ef743682d76003126235#8246 at
ccc42704c331supplies the parser, launcher, generic schedules, candidate catalog, and tests required by #8586. Two inherited qkv_a rows, M4096/M5120 at N2176/K7168, are included. #8586's newer decode policy replaces the older #8579 policy, including omission of eight old explicit rows.Overlap decisions:
cm2_cn4; f_b M128 uses [FlyDSL] [gfx1250] Kimi-K3 TP1 decode: mxfp8_128 rows for every M bucket up to 1024, cluster_m 3/5 candidates #8586's ID2682. These inherited choices were selected for workload coverage, without a new paired comparison.FlyDSL gains
_cp,_qe,_nlb, and 12 appended candidates with prior IDs preserved. Opt-in schedules stay excluded from batched candidate selection. The generic A8W8 default row schedule changes, which also affects PTPC and batched users. The actual-M < tile_mcompute guard and dev fallback selection remain intact. Public APIs are unchanged; shared dispatch keys and padded lookup extend the impact beyond exact tuned shapes. E8M0 keys contain neither model identity nor output dtype.DSpark down M96 incremental selection
Commit
d76003126235dfb24569e490d15f71c8ac606706appends one E8M0 kernel130 row at M96/N7168/K14336 and preserves every prior table byte. Actual five-table dev lookup changes 4,558 to 4,559 keys. Only M81-96 change from fallback222 to130; M80/M97 retain their original selections. Every affected M passes the current catalog's raw shape predicate.The original dev measurement on
a3005ac8, independently accepted at 2026-11-25T18:15:45.650738+00:00, is 145.136849 to 35.018910 us, 135.940708 to 563.410054 TFLOPS, 314.452789% throughput increase, and 75.856514% median paired latency reduction at M96. It retains its original seven ABBA/seven A/A protocol, full-K correctness evidence and original verification time. CSV timing cells remain blank.Main PR #8710 separately validates allocating/out BF16/FP16 public paths at M80/81/96/97 (32 full-output checks), and same-main paired backend timing at M81/M96 (75.113480% / 74.979805% median paired latency reduction). Those measurements belong to parent
3fd42598and candidatec672ef74.Independent composition review verifies the actual dev table/lookup and unchanged relevant generic backend files relative to the measured dev source. Main and dev differ in the generic GEMM implementation, launcher, tensor shim, catalog and op module; the main measurements are not relabelled as new dev results. No combined-head GPU run, model/E2E result or full main/dev source equivalence is claimed. Existing shared validation remains bound to its original head.
DSpark o_proj M96 incremental selection
Commit
2d646f5d97b7ca4a8ebd07b85a3face0b6948a3eappends one E8M0 kernel130 row at M96/N7168/K8192 and preserves every prior table byte. Actual five-table dev lookup changes 4,557 to 4,558 keys. Only M81-96 change from fallback222 to130; M80/M97 retain their original selections. Every affected M passes the current catalog's raw shape predicate.The original dev measurement on
a3005ac8, independently accepted at 2026-11-25T18:00:47.277580+00:00, is 86.726546 to 21.291381 us, 129.998134 to 529.523610 TFLOPS, 307.331702% throughput increase, and 75.457422% median paired latency reduction at M96. It retains its original seven ABBA/seven A/A protocol, full-K correctness evidence and original verification time. CSV timing cells remain blank.Main PR #8709 separately validates allocating/out BF16/FP16 public paths at M80/81/96/97 (32 full-output checks), and same-main paired backend timing at M81/M96 (74.450254% / 73.964076% median paired latency reduction). Those measurements belong to parent
3fd42598and candidate1f1f2808.Independent composition review verifies the actual dev table/lookup and unchanged relevant generic backend files relative to the measured dev source. Main and dev differ in the generic GEMM implementation, launcher, tensor shim, catalog and op module; the main measurements are not relabelled as new dev results. No combined-head GPU run, model/E2E result or full main/dev source equivalence is claimed. Existing shared validation remains bound to its original head.
DSpark gate_up M96 incremental selection
Commit
9cc5825de2829d0d1dfd83a253d225589fcafd49appends one E8M0 kernel132 row at M96/N28672/K7168 and preserves every prior table byte. Actual five-table dev lookup changes 4,556 to 4,557 keys. Only M81-96 change from fallback222 to132; M80/M97 retain their original selections. Every affected M passes the current catalog's raw shape predicate.The original dev measurement on
a3005ac8, independently accepted at 2026-11-25T17:40:30.961189+00:00, is 79.682313 to 42.341139 us, 495.216700 to 931.954426 TFLOPS, 88.191235% throughput increase, and 46.951314% median paired latency reduction at M96. It retains its original seven ABBA/seven A/A protocol, full-K correctness evidence and original verification time. CSV timing cells remain blank.Main PR #8706 separately validates allocating/out BF16/FP16 public paths at M80/81/96/97 (32 full-output checks), and same-main paired backend timing at M81/M96 (46.472668% / 45.086849% median paired latency reduction). Those measurements belong to parent
3fd42598and candidate3649f511.Independent composition review verifies the actual dev table/lookup and unchanged relevant generic backend files relative to the measured dev source. Main and dev differ in the generic GEMM implementation, launcher, tensor shim, catalog and op module; the main measurements are not relabelled as new dev results. No combined-head GPU run, model/E2E result or full main/dev source equivalence is claimed. Existing shared validation remains bound to its original head.
q_b M3072 incremental selection
Commit
7ca295643412332bbbc2001ae8a8752854369667appends exactly one E8M0 row from #8703 and preserves every prior CSV byte. Actual five-table source replay changes 4,555 to 4,556 keys. For N18432/K1536, only M3009 through M3072 change to kernel1069; tested source boundaries M3008 and M3073 retain the existing selection. The dev baseline is kernel1064; main uses kernel1060, so their gains are separate.The original dev measurement on
a3005ac8(independently accepted at 2026-11-25T13:56:45.743813+00:00) is kernel1064 to1069 at M3072: 43.092641 to 40.824138 us, 4036.563396 to 4260.865830 TFLOPS, 5.556767% throughput increase, and 5.268934% median paired latency reduction. It uses the existing seven ABBA/seven A/A protocol and full-K output checks. Numeric CSV timing cells remain blank.#8703 separately validates BF16/FP16 allocating/out public paths at M3008/3009/3072/3073 (32 full-output comparisons), plus same-main backend performance at M3009 and M3072. Those results are bound to main
3fd42598and candidate15bdebaa; they do not measure this integrated dev commit. Local composition review verifies the actual dev lookup, every affected candidate's shape legality, unchanged E8M0 compute code relative to the measured dev source, and the relevant public bridge/selection functions. No new combined-branch GPU run, whole-bucket timing, model/E2E gain, or full-source equivalence is claimed. The existing shared regression below remains evidence for its original head.DSpark q_b M192: already covered in dev
Independent main PR #8705 (
9601e4b1, parent3fd42598) adds the M192/N12288/K1536 row selecting kernel210. Same-main backend measurements at M177/M192 show 6.63%/7.64% throughput increases and 6.13%/7.48% median paired latency reductions; BF16/FP16 public validation covers M176/177/192/193 with 32 full-output checks. These remain main-specific results.Actual five-table source lookup at this dev head already selects kernel210 from the existing M256 row across the complete M177-192 interval and at M176/M193. Replaying the proposed M192 addition confirms it changes no selected kernel, backend or split-K in that interval. The existing dev M256 selection therefore covers this tuning choice, and no redundant M192 row or new dev commit is added. The old exploratory a3005 baseline209 and the main PR's baseline209 do not describe this current dev default. This is source selection evidence, not a new integrated GPU or performance measurement.
Nine-row performance
gfx1250, 256 CUs, image
rocm/fw-bringup:gfx1250-atom-k3-20261120, sourcea3005ac8, FlyDSL 0.5.3. Full TP1 N/K, E8M0 scales, BF16 output; same-process paired ABBA comparisons, seven rounds and null controls, with rotating weights. These are exact-M full-wrapper measurements; public padding correctness was validated separately on3023befb. The reduction column is the median paired reduction, so it can differ from the ratio of the two aggregate latency columns.TFLOPS =
2*M*N*K/(us*1e6). CSV measurement cells are left blank to avoid mixing benchmark protocols. These are GEMM results, not model/E2E improvements. Earlier #8586/#8601/#8634 proxy results retain their source-version scope and must not be added together as a measurement of this combined branch.lm_head selection and validation boundary
The new BF16 row uses the complete non-interleaved TDM 128x256x128, two-stage, split-K1, w4x4 configuration for N163840/K7168. Native padded lookup also selects it at the tested M65/112/113/127 points. Borrowed TDM rows are now skipped on gfx1250-strict, preserving its existing fallback; explicit native strict TDM rows are outside this change's support claim.
The source candidate
74a3cafcpassed native CPU checks for all 33 BF16 tables, 14 regular/strict/neighbor lookups, 14 compiled-padding checks and 10 public compile-or-reuse calls. Its actual gfx1250 GPU run exercised three preserved seed pairs, five Ms (65/112/113/127/128), both allocating and caller-provided output, eager execution and two NaN-poisoned graph replays: 30 public cases, 90 full-output checks, 1,607,270,400 compared elements, zero mismatches at rtol/atol 0.01/0.01. This is tolerance-based correctness, not bit-exact equality. References reused the accepted full-K CPU-FP64-derived BF16 data. No strict GPU result is claimed.The lm_head combined head
4451e763reuses that evidence after a CPU composition review: all tracked files match74a3cafcexcept the already-accepted DSpark E8M0 CSV, and all 167 pinned lm implementation/source files and 33 BF16 tables match the actual CPU/GPU runtime inputs. The lm_head public cases were not rerun on the combined commit; its later targeted shared-path GPU validation is listed below. The E8M0 table is unchanged from3023befb; the new guard is confined to A16W16 lookup.The performance result remains bound to predecessor
a3005ac8/ FlyDSL 0.5.3: baseline 450.207 us versus complete FlyDSL 259.321 us, 42.44% median paired reduction across seven same-process ABBA rounds, about 1,159 TFLOPS. One 2.348 GB weight was reused; this is not a guaranteed cold-cache or model/E2E result. Final candidate correctness does not relabel that timing as a new-head performance measurement.Validation
3023befb: native CPU binding covers 8,917 source files and default E8M0 merging of five inputs into 4,555 keys. The changed rows resolve through the real public lookup and bridge.3023befbalso passes all 25 cases / 50 forms / 100 full-output checks with maximum mismatch fraction 0.99305%. It reuses the unchanged native source/merge/padding evidence; neither dtype batch adds a performance claim.a3005ac8: FP8 ID/name/parser/launch consistency, 9,240 lookup cases, stable prior IDs/fallbacks, BF16 default merging and shape validation; Black 26.10.1, Ruff 0.16.0, syntax and diff checks passed. The3023befbdelta changes only the nine CSV rows; the lm delta changes its BF16 CSV and the narrow A16W16 borrowing guard, whose native CPU/GPU evidence and composition boundary are stated above.Shared implementation validation completed on
4451e763(2026-11-25 09:59 UTC acceptance): 22 targeted generic MXFP8/PTPC/batched cases, both BF16 and FP16 output, passed 66 complete-output comparisons (eager plus two NaN-poisoned graph replays per case). The cases cover the single/two-row generic schedules, public allocating paths, ragged-K BMM and n32k4 scales. Native CPU preparation verified 8,917 source files and the selector's exclusion of opt-in candidates; all 22 actual GPU launch specializations matched that preparation. GPU execution used the unchanged public APIs and prepared cache in RUN_ONLY mode on gfx1250/CU256, FlyDSL 0.5.3 and NUMA0. CPU-FP64 references used exactly representable quarter-step FP8 values and power-of-two scales; all checks had zero mismatches at rtol/atol 0.01/0.01. This is a focused scheduling/layout regression with a dyadic input fixture, not arbitrary-distribution, full-catalog, model or performance coverage. Exact CPU/GPU containers were removed and the preserved interval showed no new matching fault lines.Review readiness: the targeted shared implementation regression is complete, and this PR is ready for review. CI and reviewer assessment remain separate; this does not claim merge approval or full CI success. Independent main-targeted PRs are prepared separately against the actual main dependencies; this dev validation is not main-head validation. Model/E2E, other architectures, and arbitrary M remain unmeasured. CI status is reported separately and is not inferred from these targeted checks.
No new third-party dependency or public API is introduced. Existing
test_gemm_host_dispatch_cache.pykeeps 11 compute-boundary/compatibility cases;test_gemm_a8w8_mxfp8_bpreshuffle.pycarries the opt-in direct/fused and fallback regressions. The targeted shared-path regression above adds correctness evidence without expanding the model, architecture or performance claims.Tracking and performance handoff: https://github.com/wuhuikx/LLM-Booster/issues/710