Skip to content

[Config] [gfx1250] Kimi-K3 latent-MoE BF16 GEMM rows for 256 CUs - #8348

Open
gbyu-amd wants to merge 1 commit into
mainfrom
gyu/kimik3-latent-bf16-gfx1250
Open

gbyu-amd wants to merge 1 commit into
mainfrom
gyu/kimik3-latent-bf16-gfx1250

Conversation

@gbyu-amd

@gbyu-amd gbyu-amd commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add gfx1250 / cu_num=256 rows to kimik3_bf16_tuned_gemm.csv for Kimi-K3's two latent-MoE BF16 GEMMs, routed_expert_down_proj (N 3584, K 7168) and routed_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 tgemm takes 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

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) of tgemm.mm as 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.

Hardware Workload/configuration Before (us) After (us) Change
gfx1250 N 3584 K 7168, M 1 / 8 / 32 / 128 6.6 / 6.7 / 8.0 / 13.2 5.9 / 6.0 / 6.8 / 11.1 0.84–0.90x
gfx1250 N 3584 K 7168, M 256 / 512 18.3 / 27.6 19.0 / 27.5 1.04x / 1.00x
gfx1250 N 3584 K 7168, M 1024 / 2048 94.5 / 100.8 34.8 / 46.3 0.37x / 0.46x
gfx1250 N 3584 K 7168, M 4096 / 8192 / 16384 / 32768 119.1 / 252.9 / 531.7 / 1034.7 83.8 / 181.2 / 390.4 / 752.2 0.70–0.73x
gfx1250 N 7168 K 3584, M 1–16 5.1–5.9 5.0–5.9 ~1.00x (default kernel)
gfx1250 N 7168 K 3584, M 32 / 64 / 128 6.5 / 8.6 / 10.0 6.0 / 8.1 / 10.4 0.92x / 0.94x / 1.04x
gfx1250 N 7168 K 3584, M 256 / 512 / 1024 23.8 / 31.4 / 63.8 16.2 / 20.5 / 27.2 0.43–0.68x
gfx1250 N 7168 K 3584, M 2048 / 4096 / 8192 / 16384 / 32768 73.1 / 149.4 / 295.8 / 601.4 / 1460.8 44.0 / 91.2 / 191.2 / 378.3 / 764.1 0.52–0.65x
gfx1250 both GEMMs x 92 MoE layers, M 120–160 (decode, 32 requests x 5 tokens) 3030 2730 -9.9%
gfx1250 same, M 480–640 (128 requests x 5 tokens) 10696 5000 -53.2%
gfx1250 same, M 8192 / 16384 (prefill) 50479 / 104245 34258 / 70719 -32.1% / -32.2%

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

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

gfx1250 only; the rows are keyed gfx1250, so no other architecture selects them. With this file on main (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 through get_GEMM_A16W16_config to their libtype / kernel; the tuner's err_ratio is 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

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

Tuned-config rows only.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

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

3b6409834

Behavior and intent

On gfx1250 / 256 CUs, Kimi-K3's two latent-MoE BF16 GEMMs through tgemm use 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, and main without #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. tgemm looks 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.

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.
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8348 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@gbyu-amd
gbyu-amd marked this pull request as ready for review November 20, 2026 04:58
@gbyu-amd
gbyu-amd requested a review from a team November 20, 2026 04:58
@aiter-bot

aiter-bot commented Nov 20, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 3b64098347e9 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

On gfx1250 / 256 CUs, Kimi-K3's two latent-MoE BF16 GEMMs through `tgemm` use the tuned kernels instead of the default.

Validation and unverified scope

The tests and timings above, on gfx1250 with `main` + ROCm/aiter#8031. Unverified: end-to-end serving with only these rows changed, other CU counts, and `main` without ROCm/aiter#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. `tgemm` looks 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.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • FAIL — Aiter Test Gate: failed
  • Required CI failed; fix it before requesting human review.

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu
zufayu requested a review from yifehuan November 21, 2026 11:39
zejunchen-zejun added a commit that referenced this pull request Nov 25, 2026
…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]>
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]>
gbyu-amd pushed a commit that referenced this pull request Dec 3, 2026
…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.
gbyu-amd added a commit that referenced this pull request Dec 3, 2026
…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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants