Repository navigation
Conversation
Kimi-K3 routed_expert_down_proj (N 3584, K 7168) and routed_expert_up_proj (N 7168, K 3584) at M = 1..32768 (powers of two), gemm_a16w16_tune.py --libtype all on gfx1250 / 256 CUs. Depends on #8031.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
NOT READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
…M rows for every M bucket up to 1024 Rows for the router (896x7168), latent down (3584x7168) and latent up (7168x3584) GEMMs of Kimi-K3's latent MoE on gfx1250 / 256 CUs: one row for every decode M bucket up to 1024 (16-aligned to 256, 32-aligned to 1024), so no decode M falls through to a power-of-two row. Each bucket was picked inside a decode-step proxy (92 layers x the three GEMMs, per-layer weights, CUDA graph) at every multiple of 5 in the bucket, since DP8EP8 decode with DSpark k=4 gives M = 5 x requests per rank. Step proxy, every multiple of 5 from M 100 to 960: -4.6% on average, worst +0.6%; c256 -11.4%, c512 -7.0%, c1024 -9.2%. The latent rows at M 1/2/4/8 and 2048-32768 are #8348's, with the _i0_ptdm / _i1_ptdm names written as _ptdm / _ptdmi. The TDM rows need #8031's kernel. Co-Authored-By: Claude Opus 5.5 <[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]>
…4098) (cherry picked from commit b34b6b8) Rebase onto main 12-03: kimik3_bf16_tuned_gemm.csv conflicted with main's gfx950 row updates (#8317 / #8245 / #8915). Replayed by row key: the 32 gfx1250 rows this commit adds are inserted; its 15 gfx950 edits were number formatting only (a CSV round-trip) and are left as main has them. Same rows as the PR head 3b64098.
…does (_ptdm / _ptdmi) The rebase onto main 12-03 dropped k3-455-dev's pre-merge copy of #8031 (b445370, PR head 520f0bb) for main's merged deca29e. The two spell a TDM HGEMM's wave schedule differently: the PR head wrote it as a name token, `..._gm{g}_i0_ptdm_gfx1250` / `..._gm{g}_i1_ptdm_gfx1250`, while main's final version folds it into the policy, `..._gm{g}_ptdm_gfx1250` (plain) / `..._gm{g}_ptdmi_gfx1250` (interleaved), and its _HGEMM_KERNEL_RE has no `_i` token. Main converted its own CSV rows; the K3 rows tuned on the PR head kept the old spelling, so get_flydsl_hgemm_kernel_params() returns None for them and every lookup logs "not recognized by the current catalog; falling back to next candidate" and runs the default Triton gemm_a16w16 (C1203 on e17: 1332 warnings per D tray, all during graph capture). Rows affected, all gfx1250 bf16 -> bf16: - kimik3_bf16_tuned_gemm.csv, 256 rows from #9096: LM / DSpark draft head, N 163840, K 7168, M 1-256; - kimik3_bf16_tuned_gemm.csv, 20 rows from #8348: latent-MoE routed_expert_down_proj (N 3584, K 7168) and routed_expert_up_proj (N 7168, K 3584), M 1-32768; - op_tests/k3_latent_bf16_tuned_rows.csv, the same 20 latent rows. Rename only: `_i0_ptdm_` -> `_ptdm_`, `_i1_ptdm_` -> `_ptdmi_`; no other byte changes. Every renamed name parses with this tree's get_flydsl_hgemm_kernel_params() (TDM validator included) to the same tile / stages / waves / split-K / group_m / interleave the old parser read from the old name, and no file in the tree keeps `_i[01]_ptdm`. The TDM kernel builder is unchanged between the two trees apart from the cache-policy constant's name and the AOT factory wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Add gfx1250 /
cu_num=256rows tokimik3_bf16_tuned_gemm.csvfor Kimi-K3's two latent-MoE BF16 GEMMs,routed_expert_down_proj(N 3584, K 7168) androuted_expert_up_proj(N 7168, K 3584), at M = 1, 2, 4, ..., 32768. Depends on #8031: merge it first.Motivation
The file has gfx950 rows for these two shapes but none for gfx1250, so on gfx1250 every call through
tgemmtakes the untuned default. The default is far from the best kernel above M = 512: for N 3584 K 7168 it takes 91–95 us from M = 560 to 1024, where the tuned row takes 33–35 us.Changes
aiter/configs/model_configs/kimik3_bf16_tuned_gemm.csv: +32 rows (gfx1250,cu_num=256), one appended block, no existing row changed. 2 shapes x 16 Ms (powers of two, 1–32768); M values in between reach these rows through the padded-M lookup.python3 csrc/gemm_a16w16/gemm_a16w16_tune.py --libtype all --mp 4, all candidates at each M, on gfx1250 withmain(ce334d015) + [FlyDSL] [gfx1250] TDM HGEMM: FP32 cluster split-K, and DSV4.1 BF16 rows where TDM measures faster #8031.mainhas not changed the BF16 GEMM path since then (checked up toa485545d3)...._i0_ptdm_gfx1250/..._i1_ptdm_gfx1250) come from [FlyDSL] [gfx1250] TDM HGEMM: FP32 cluster split-K, and DSV4.1 BF16 rows where TDM measures faster #8031's TDM kernel, so these rows only resolve with it.Performance (if applicable)
gfx1250 (256 CUs), one GPU. Pure kernel time from
torch.profiler(the sum of every kernel a call launches, launch gaps excluded) oftgemm.mmas a model calls it. Cold weights: one CUDA graph runs the GEMM on 42 weight copies (>= 2 GiB) in turn, so each call reads its weight from HBM. Before = the same tree without these rows (the default config). Mean of two runs, the second on swapped GPUs.Two rows are 4% slower than the default with cold weights and faster with warm weights (one weight copy re-read): N 3584 K 7168 M 256 (19.0 vs 18.3 us cold, 15.2 vs 16.5 us warm) and N 7168 K 3584 M 128 (10.4 vs 10.0 cold, 6.9 vs 10.5 warm). They are kept as the tuner picked them.
Testing
gfx1250 only; the rows are keyed
gfx1250, so no other architecture selects them. With this file onmain(ce334d015) + #8031:python3 -m pytest op_tests/tuning_tests/test_csv_validation.py op_tests/tuning_tests/test_config_shape_collision.py op_tests/tuning_tests/test_a16w16_tuned_config_lookup.py-> 74 passed (4951 subtests). All 32 rows resolve throughget_GEMM_A16W16_configto their libtype / kernel; the tuner'serr_ratiois 0.0 for every row, and in the benchmark above the output's max relative error against an FP32 reference is <= 3.8e-3 at every M (the same as the default's).Documentation
Tuned-config rows only.
Dependencies
Requires #8031 (the FlyDSL BF16 TDM kernels these rows name). Merge after it.
Breaking Changes
None. Only new gfx1250 / 256-CU keys; existing rows are unchanged.
PR Self-Review
Reviewed revision
3b6409834Behavior and intent
On gfx1250 / 256 CUs, Kimi-K3's two latent-MoE BF16 GEMMs through
tgemmuse the tuned kernels instead of the default.Validation and unverified scope
The tests and timings above, on gfx1250 with
main+ #8031. Unverified: end-to-end serving with only these rows changed, other CU counts, andmainwithout #8031 (the FlyDSL rows do not resolve there).PR-specific question
The rows are consumed only by
(gfx1250, cu_num=256, M, N, K, bias=False, bf16, bf16, scaleAB=False, bpreshuffle=False)for N x K = 3584 x 7168 and 7168 x 3584.tgemmlooks M up exactly, then at the two padded-M granularities; the second rounds up to a power of two, so every M <= 32768 now reaches one of these rows.Changed op tests
None.