Repository navigation
[gfx1250] Route the missing Kimi-K3 fused BF16 GEMM to Triton - #4552
Merged
Merged
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Kimi-K3 bf16 tuned GEMM routing table to ensure two previously-missing gfx1250 GEMM shapes (N=2112, K=7168 and N=12440, K=7168) route to the Triton backend instead of falling back to torch/hipBLASLt.
Changes:
- Add gfx1250 CSV entries for (M ∈ {1..16384}, N=2112, K=7168) routed to
libtype=triton. - Add gfx1250 CSV entries for (M ∈ {1..16384}, N=12440, K=7168) routed to
libtype=triton.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zejunchen-zejun
pushed a commit
that referenced
this pull request
Aug 4, 2026
All 24 a16w16 shapes Kimi-K3 hits on gfx1250 tp4 were running the untuned
default tile (BLOCK 32/64/64, NUM_BUFFERS 5, num_warps 2, bandwidth_bound).
Tune them over M = 1, 2, 4 ... 32768, which is the range concurrency and input
length actually reach.
Tuned on the kernel this branch ships, i.e. with the three preceding fixes
applied. That matters more than it sounds: an earlier revision of this PR
carried configs ranked against the pre-fix kernel and reported 3.59x over the
default tile. That kernel was not really waiting on its TDM ring, so tiles that
skipped a wait ranked as fast, and the number could not be carried forward.
Re-timed on the shipped kernel, every point in its own process with the three
config sources alternating inside it and the min taken over three rounds:
source total over 384 points
untuned default tile 440752us
configs ranked pre-fix 165392us 2.66x vs default
these configs 143433us 3.07x vs default
The pre-fix set still works -- it is 2.66x over the default -- but it lost
ground once the wait it had been ranked against became real. Re-tuning recovers
13.3% of that. 3.07x is the honest replacement for the earlier 3.59x.
Selection is deliberately conservative, because a tile holds one speed for a
process's lifetime and draws a different one in the next:
* six independent tuner runs, one sample each, ranked on the median across
runs rather than on any single run;
* ranked on median + spread/2, not the median alone -- a few tiles are
bimodal and their median can win while their slow mode is worse than the
default;
* a candidate must beat the default at *every* M in the bucket, not on
average.
Where nothing cleared that bar the default tile is kept: 18 of the 384 points,
in 10 buckets before collapsing. An untuned point costs nothing; a regressed one
costs real time in production. There are no points where the default is faster
than what is shipped here.
Every emitted config was then screened for correctness on the shipped kernel --
not on a patched copy -- at the largest M its bucket governs, with one operand
all ones so the expected result is an exact 1-D fp32 sum: no reference GEMM, and
no dependence on hipBLASLt, which was itself off by 5.3e-02 on one of these
shapes. Both operand roles are covered by running the pass twice with the roles
swapped, which matters here because the bug fixed in the preceding commit is a
two-stream wait and a single-pattern screen would exercise one stream.
240/240 bucket entries pass, 3 trials each.
Two of the 24, N=2112 K=7168 and N=12440 K=7168 (the fused KDA in_proj GEMM),
reach the triton path only once they have a routing row in
kimik3_bf16_tuned_gemm.csv. Those rows are #4552; this commit is configs only.
Co-Authored-By: Claude Opus 5 <[email protected]>
get_GEMM_A16W16_config falls back to torch when the shape has no row, and two of the shapes Kimi-K3 hits on gfx1250 tp4 have none: N=12440 K=7168 (the fused KDA in_proj, what ATOM's _fuse_in_proj builds by concatenating in_proj + b_proj + f_a_proj) and N=2112 K=7168. The CSV is tuned for the unfused 12/24/128 x 7168 shapes, so the fused N is a miss rather than a deliberate torch routing. It is the only untuned bf16 shape in the run: hipBLASLt picks Cijk_..._MT32x16x32_MI16x16x1 at 5.3ms/layer for M=2048, and 69 KDA layers make that 367ms of a 1060ms prefill. The row set is drawn from measurement rather than extended to the ends of the ladder. Each point runs in its own process, triton and F.linear alternate inside it, min over three rounds, and triton runs the config _get_triton_config loads -- no explicit override -- so this measures what the row will actually get once the tuned configs of #4537 are installed. A row is kept only where triton wins by more than 2%: an unrouted shape costs nothing, a mis-routed one costs real time. N=2112 K=7168 N=12440 K=7168 M blas triton M blas triton 1 60.80 79.05 0.77x 1 65.25 77.41 0.84x 2 59.70 78.75 0.76x 2 66.91 76.52 0.87x 4 59.97 77.31 0.78x 4 67.60 78.31 0.86x 8 60.06 79.03 0.76x 8 68.87 74.76 0.92x 16 61.35 77.21 0.79x 16 70.61 75.20 0.94x 32 62.24 78.90 0.79x 32 79.12 79.77 0.99x 64 64.35 78.41 0.82x 64 99.29 81.38 1.22x 128 65.42 81.10 0.81x 128 350.13 85.01 4.12x 256 71.56 81.21 0.88x 256 648.46 86.24 7.52x 512 224.67 81.43 2.76x 512 1307.23 150.59 8.68x 1024 409.96 85.93 4.77x 1024 2467.74 211.16 11.69x 2048 609.94 84.62 7.21x 2048 5121.83 395.77 12.94x 4096 969.13 194.53 4.98x 4096 10146.32 748.60 13.55x 8192 1683.93 322.25 5.23x 8192 21037.98 1451.01 14.50x 16384 4350.58 657.50 6.62x 16384 40454.79 2751.31 14.70x So 15 rows: N=2112 from M=512, N=12440 from M=64. The 15 points below those crossovers keep going to hipBLASLt, which is the faster backend there. An earlier revision of this branch routed N=12440 across the whole ladder; the small-M half of that was extrapolated from a microbench on the untuned triton path and is retracted here. End to end, dummy weights (--load_dummy xavier), tp4, --max-num-seqs 8 --max-num-batched-tokens 2048, A/B by prepending an extra CSV through AITER_CONFIG_GEMM_BF16=<default>:<model_configs/*>:<extra.csv> -- editing the regenerated merge under /tmp/aiter_configs/*.csv does nothing, the colon list is the only way to A/B this cleanly: torch/hipBLASLt triton TTFT 810ms 611ms -24.7% prefill 2526 tok/s 3352 tok/s TPOT 41.9ms 39.9ms output 130.7 tok/s 142.4 tok/s That run carried routing rows for N=12440 at M >= 48 only, so it covers the large-M side of this change and not the N=2112 rows, which rest on the table above. Tuned configs for both shapes are in #4537. Neither PR blocks the other: the JSONs there sit unused for these two shapes until these rows exist, and these rows without #4537 route to the default tile, which is the configuration the -24.7% above was measured in. Tested on gfx1250, 256 CU, SPX, 4 GPUs. Co-Authored-By: Claude Opus 5 <[email protected]>
zejunchen-zejun
force-pushed
the
xiaobing/gfx1250-k3-bf16-gemm-routing
branch
from
August 4, 2026 11:20
820bbe7 to
e85a275
Compare
Keep N=2112 on its existing global route to avoid duplicate merge keys, and include the requested small-M N=12440 entries. Co-authored-by: Cursor <[email protected]>
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.
This PR is routing only: 15 rows in
aiter/configs/model_configs/kimik3_bf16_tuned_gemm.csv, no code.What is missing today
get_GEMM_A16W16_configlooks the shape up in the model CSV and returnslibtype=\"torch\"when there is no row. The fused Kimi-K3 shape below has no row on gfx1250 tp4, so it goes toF.linearand hipBLASLt:in_projGEMMN=12440 = 4*3072 + 24 + 128is what ATOM's_fuse_in_projbuilds by concatenatingin_proj + b_proj + f_a_proj. The CSV is tuned for the unfused12/24/128 x 7168shapes, so the fused N is simply a miss — not a deliberate torch routing.It is the only untuned bf16 shape in the whole run, and it is expensive. hipBLASLt picks
Cijk_..._MT32x16x32_MI16x16x1: 5.3 ms/layer at M=2048, and 69 KDA layers make that 367 ms = 34.6% of a 1060 ms prefill.Routing scope
Route
N=12440, K=7168for the full model M ladder:1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384.N=2112, K=7168is intentionally not added here because it is already globally routed bydsv3_bf16_tuned_gemm.csv; adding it again creates duplicate merge keys.Tuned Triton configs are provided separately by #4537.