perf(moe): specialize Kimi-K3 B1 gate projection (gfx950) - #6
Open
JohnQinAMD wants to merge 2 commits into
Open
JohnQinAMD wants to merge 2 commits into
JohnQinAMD wants to merge 2 commits into
Conversation
Add a narrow gfx950 FlyDSL projection for the production 1x7168 by 896x7168 BF16 router shape. Preserve the GateLinear BF16 output contract, isolate dispatch behind a named capability predicate, and leave unsupported shapes on their existing paths. Assisted-by: Codex Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Keep the FlyDSL launcher ABI unchanged while making the intentional stream construction explicit to Ruff. Assisted-by: OpenAI Codex Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
This was referenced Jul 31, 2026
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.
[Kimi-K3] Add gfx950 B1 router projection specialization
Summary
This change adds a narrow FlyDSL BF16 router-projection specialization for the
Kimi-K3 TP8 B1 decode shape on gfx950. The upstream branch is based directly
on AITER
origin/main; it does not depend on the separate route-plus-sortoptimization.
The new kernel computes
1x7168 @ 896x7168.Twith one 64-thread workgroup percontiguous expert row. Lanes accumulate in FP32, reduce with a wave DPP tree,
round to BF16 to preserve GateLinear's output contract, and store FP32 logits.
It launches 896 workgroups rather than serializing the 12.85 MB router weight
matrix through one CU.
Dispatch is intentionally isolated:
supports_kimi_k3_b1_gate_projectionis the single named support predicate.kimi_k3_gate_projection_dispatchis the single named dispatch decision.896x7168 contiguous expert-major BF16 weights.
This is projection-only. It chains into the Phase B route-sort mechanism but
does not fuse projection with selection or metadata. That avoids introducing a
margin-dependent local-candidate reduction while production routing margins
remain unavailable.
Performance
Measured on MI355X/gfx950 with CUDA graph capture, 100 operations per graph,
100,000 warmup operations, 21 trials, and two independent Python processes:
The complete-boundary table below was measured with the independent projection
stacked on the separately proposed route-plus-sort optimization:
B1 projection alone improves from
13.6949/13.6825 usto4.2076/4.2236 us. Cross-process complete-boundary deltas are0.194%,0.142%, and0.050%for B1/B8/B16.The existing generic FlyDSL candidates bottomed out at
19.686 uscomplete,and the dedicated small-M candidates bottomed out at
21.842 us; neither metthe
18.5 uscomplete gate. The retained one-expert-per-wave layout also beattwo experts per wave (
17.788 uscomplete) and four experts per wave(
20.484 us).The exact stacked TP8 B1 endpoint was then measured twice on MI355X with 8K
input, 1K output, and no speculative decoding. It reached 50.7012 and
50.5690 decode tok/s (50.6351 mean, 0.261% spread), with 19.7234 and
19.7750 ms mean TPOT. This is 1.143% above the prior 50.0628 tok/s checkpoint.
The endpoint image includes AITER ROCm#4405 as a benchmark dependency; ROCm#4405 is
intentionally not bundled in this isolated AITER PR diff.
Correctness and policy
The frozen 24-case campaign passes:
0relative RMSE).6.103515625e-05.bytes/scales, and zero-token policies remain unchanged and pass.
before GEMM1.
The measured synthetic ordinary top-k margin is
5.7739e-04. Productionrouting margins are unavailable, so margin-dependent production claims remain
provisional. No exact artificial-tie claim is made for engineered
hidden/weight matrices. Projection-route fusion is not part of this change.
Kernel resources
1d04d17f5ed6e274a32e6ec3e2444b8cb4f2f4ca389ef36328bb40b87a96193aValidation
7 passed in 6.74s11 passed in 6.84s24/24 passed3d309473bbb8d7261c9d9bbfd13082d1d6ab42efFiles
aiter/ops/flydsl/kernels/kimi_k3_b1_gate_projection.pyaiter/ops/flydsl/kimi_k3_gate.pyop_tests/flydsl_tests/test_kimi_k3_b1_gate_projection.pyDisclosure
Developed with assistance from OpenAI Codex. The author reviewed the dispatch
contract, reduction order, numerical policy, tests, and endpoint evidence.