Repository navigation
[ASM] Add gfx950 Kimi K3 fused MXFP4 prefill producer for 8K+ tokens - #8020
Conversation
Install a PyISA fused producer for Kimi K3 MoE prefill (model 3584, inter 384, 896 experts, top-k 16, SiTUv2, MXFP4 activations and weights). It uses the existing post-reduction mode (flat=3): standard fmoe launcher, Opus sort with 256-row tiles, token-major BF16 partials and the FlyDSL reduction. Select it in the Kimi a4w4 config for the 16384 and 32768 token rows, which serve 8193 to 131071 tokens. The 8192 row stays on FlyDSL.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Summary
This PR adds a fused assembly producer for Kimi K3 MXFP4 MoE prefill on gfx950. The Kimi a4w4 config selects it for the
16384and32768token rows, which serve 8193 to 131071 tokens. With captured Kimi routing, fullfused_moelatency is 8–11% lower than with the tuned FlyDSL path. With random routing it is 6–8% lower from 12K tokens up.The PR changes no Python, C++, FlyDSL or Triton code. It has three changes:
hsa/gfx950/fmoe/situv2/fmoe_bf16_pertokenMXfp4_g1u1_situv2_prefill_1tg_4w_256mx1_128nx1_ps_fp32gate_route.cofmoe_bf16_pertokenMXfp4_g1u1_situv2.csv(flat=3,subGU_m=256,subGU_n=384, one workgroup per CU)kimik3_a4w4_tuned_fmoe.csv(tokens16384and32768). The8192row and all smaller rows stay on FlyDSL.How it works
The producer uses the existing post-reduction ASM mode (
flat=3, added in #5988 for Qwen Q256):(token, topk)slot.The launch uses the standard
fmoe_g1u1launcher and its 448-byte argument layout. The kernel reads no argument slot beyond the ones the launcher fills, and it needs no workspace.For 8193 to 32768 tokens the producer plans its own work order. Each XCD takes a contiguous range of the sorted tiles, so the tiles of one expert run on one XCD and share its weights in L2. Inside the range, the 32 workgroups of the XCD take 32 neighbouring tiles per round. The tile with the most valid rows goes to the workgroup with the least work so far. All workgroups compute the same plan from the sorted route IDs, so the plan needs no shared state.
Shape: model 3584, intermediate 384, 896 experts, top-k 16, MXFP4 activations and weights, BF16 output.
Performance
MI355X (gfx950, 256 CUs), one GPU leased through gpuq for each run. Both arms call the public
fused_moewith a caller-provided output. Each arm is one CUDA graph of 20 calls. The arms are replayed in alternating order, 50 samples per arm, and the table shows medians per call. Latency includes sorting, activation quantization, scale sort, the producer and the reduction. The baseline is main's tuned FlyDSL row. Weights and activations are synthetic. "Captured" rows use Kimi K3 routing captured from vLLM (layers 1 and 2).The µs columns are from PCI 0000:85:00.0; the last column is the same test on 0000:f5:00.0. A third run, with this branch merged into main at
3d3d56db3e, agrees with both within 1 percentage point on every row.At the low end of the
16384row (8193 tokens, random routing) the producer is 1% slower than FlyDSL. At 8192 tokens and below the config does not change.Correctness
Environment: Torch 2.13 (ROCm 7.2), FlyDSL 0.5.0, Triton 3.8.