feat(Kimi-K3): run each MoE layer's post-attention work as one gfx950 launch in single-request decode #3613
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3613"
general
weight: 0.35
Yu-Zhewen
Summary
This PR adds the "MoE layer tail": a persistent gfx950 Gluon kernel for Kimi-K3 and Kimi-K3.1. It serves decode steps that hold one request, including speculative verify steps. In such a step, it runs each MoE layer's work after the attention core as one launch per rank:
The kernel is a persistent launch of 256 workgroups. Its stages hand data to each other through tagged words in an uncached scratch buffer. The ranks exchange partial sums through an uncached peer buffer that every rank maps with HIP IPC. Each rank adds the 8 parts in rank order, so every rank computes the same sums.
How the model uses it:
kimi_k3family (opsmoe_tail,moe_tail_prepareandmoe_tail_pack). Its API istokenspeed_kernel.ops.model.kimi_k3, and that module's README describes it.ops/gemm/gluon.pynow accepts Kimi-K3.1's 3808-row decode projection, so the attention input projection can also produce the next layer's AttnRes block partials.Numerics: the tail quantizes the routed experts' activations to MXFP4 (A4W4), where the regular decode MoE uses FP8 (A8W4). A step that the tail serves therefore does not give the same values as the regular path. A request's decode numerics depend on whether other requests share its steps. GSM8K accuracy is unchanged within noise (below).
Limits:
TOKENSPEED_KERNEL_OVERRIDE_KIMI_K3_MOE_TAIL=none.--kvstore-ratio, by about 2.1× at ratio 8. Set--kvstore-sizeto keep the previous host-tier size, for example 107 GB per rank at ratio 8.Benchmarks and accuracy
Kimi-K3.1 on 8x MI355X (gfx950), TP8, one request in flight, DSpark speculative decoding (7 draft steps, 8 rows per verify step), greedy sampling. Serving numbers compare the base with this PR; decode and GSM8K were measured on one build of this PR, prefill and AgentX on another. Those builds' tail code compiles to the same instructions as this branch.
Decode verify step, median client step gap:
| Workload | Regular path | Tail | Change |
|---|---|---|---|
| 50k-token prompts, real acceptance (base vs this PR, 4 interleaved starts) | 14.66 ms | 13.89 ms | −5.2% (95% CI −5.3% to −5.1%) |
| 200k-token prompts, AgentX flags (one build, tail off vs on) | 15.24 ms | 14.40 ms | −5.5% (95% CI −5.7% to −5.3%) |
With the 50k-token prompts, accepted tokens per step were 3.6% lower (95% CI −7.0% to −0.5%), and the per-request output rate showed no gain.
InferenceX AgentX, concurrency 1, 30 minutes per build, synthetic acceptance 4.16 (not quality evidence), one run per build, means:
| Metric | Base | This PR | Change |
|---|---|---|---|
| Output throughput per GPU | 16.36 tokens per second | 16.74 tokens per second | +2.4% |
| Time per output token | 3.67 ms | 3.47 ms | −5.5% |
| Time to first token | 1.65 s | 1.57 s | −5.0% |
| End-to-end latency | 6.69 s | 6.41 s | −4.2% |
Prefill, time to first token with 1 output token, mean of 20 requests per arm (2 interleaved starts each):
| Input tokens | Base | This PR | Change |
|---|---|---|---|
| 2,048 | 230.5 ms | 233.9 ms | +1.5% |
| 16,384 | 819.7 ms | 823.4 ms | +0.4% |
GSM8K, first 256 test questions, greedy, up to 2,048 output tokens, real acceptance:
| Metric | Base | This PR | Change |
|---|---|---|---|
| Accuracy | 243 of 256 (94.9%) | 242 of 256 (94.5%) | −0.4 points (95% CI −2.4 to +1.6) |
| Decode output rate per request, mean | 404.5 tokens per second | 419.9 tokens per second | +3.8% (95% CI +1.8% to +5.8%) |
Tests on this branch:
test_kernel_api_selection.py, on one GPU: 499 passed, 122 skipped, 0 failed.n16without it.