Skip to content

[FlyDSL] split-K epilogue optimization in gfx950 a16w16 + Kimi-K3 router/in_proj tune - #6494

Merged
nsusanto merged 2 commits into
mainfrom
k3-fly-splitk-protocol
Oct 15, 2026
Merged

nsusanto merged 2 commits into
mainfrom
k3-fly-splitk-protocol

Conversation

@nsusanto

@nsusanto nsusanto commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The Kimi-K3 router GEMM ran on hipBLASLt at 11.3 us (M=56); FlyDSL split-K, the fastest kernel for it, only reached 10.8. The FlyDSL GEMM loop is fine and the loss is in the split-K protocol. This PR fixes the protocol and retunes the
Kimi-K3 router and KDA in_proj rows.

Includes the fp32-output staging fix of #6005.

Technical Details

gemm_a16w16_gfx950_utils.py / gemm_a16w16_gfx950.py (both kernel variants), split-K path only:

  1. The owner workgroup zero-filled C and waited (vmcnt(0) + barrier) before its first A/B load, so it started
    1-2k cycles late and finished last. The zero-fill now goes out behind the priming loads and completes with the
    first stage.
  2. Every workgroup ended with a device-scope semaphore RMW with return, a wait, and a reset by the last arriver.
    Replaced by one int64 ticket RMW per workgroup at kernel start (latency hidden under the K loop). Semaphore
    buffers are keyed by split_k and never reset, so a tile's word advances by split_k per launch and
    ticket // split_k is the launch index; the owner tags the signal with it, the other splits spin for that tag.
  3. The atomics added 4 contiguous dwords per lane: one wave-level atomic touched 16 cache lines with 4 lanes each,
    four read-modify-write passes per line. Lanes now walk consecutive elements (one fp32 or one bf16/fp16 pair), so
    each atomic instruction covers whole 64 B lines.
  4. Kernel name suffix _ksd -> _kst4 (FlyDSL's disk cache ignores kernel bodies).

kimik3_bf16_tuned_gemm.csv: 7 fp32 router rows (N=896, M 56-144) replaced; in_proj bf16 rows (N=6288) M 64-128
replaced, M=56 added. No duplicate keys against the other merged bf16 tables.

Server command (c14):

SAFETENSORS_FAST_GPU=1 VLLM_ENGINE_READY_TIMEOUT_S=7200 VLLM_EXECUTE_MODEL_TIMEOUT_SECONDS=1200 VLLM_ROCM_AITER_MLA_ASM_PADDING=asm VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=INT4 VLLM_ROCM_USE_AITER=1 VLLM_USE_BREAKABLE_CUDAGRAPH=0 VLLM_USE_DIRECT_DCP_KV_GATHER=0 VLLM_USE_DIRECT_DCP_Q_GATHER=0 
vllm serve /data/Kimi-K3 --served-model-name moonshotai/Kimi-K3 --host 0.0.0.0 --port 8002 --trust-remote-code --moe-backend auto --tensor-parallel-size 8 --load-format fastsafetensors --gpu-memory-utilization 0.9 --language-model-only --max-num-seqs 28 --enable-auto-tool-choice --tool-call-parser kimi_k3 --reasoning-parser kimi_k3 --max-model-len 1048576 --enable-prefix-caching --kv-cache-dtype fp8 --max-num-batched-tokens 8192 --attention-config \{\"mla_prefill_backend\":\"ROCM_AITER_FA\"\} --compilation-config \{\"mode\":3\,\"cudagraph_mode\":\"FULL\"\,\"max_cudagraph_capture_size\":112\,\"custom_ops\":\[\"+fused_rms_norm_gated\"\]\,\"cudagraph_capture_sizes\":\[2\,3\,4\,5\,6\,7\,8\,9\,10\,11\,12\,13\,14\,15\,16\,17\,18\,19\,20\,21\,22\,23\,24\,25\,26\,27\,28\,29\,30\,31\,32\,33\,34\,35\,36\,37\,38\,39\,40\,41\,42\,43\,44\,45\,46\,47\,48\,49\,50\,51\,52\,53\,54\,55\,56\,57\,58\,59\,60\,61\,62\,63\,64\,65\,66\,67\,68\,69\,70\,71\,72\,73\,74\,75\,76\,77\,78\,79\,80\,81\,82\,83\,84\,85\,86\,87\,88\,89\,90\,91\,92\,93\,94\,95\,96\,97\,98\,99\,100\,101\,102\,103\,104\,105\,106\,107\,108\,109\,110\,111\,112\]\} --speculative-config \{\"model\":\"Inferact/Kimi-K3-DSpark\"\,\"num_speculative_tokens\":3\,\"method\":\"dspark\"\,\"attention_backend\":\"ROCM_AITER_MLA\"\,\"kv_cache_dtype\":\"fp8\"\,\"draft_sample_method\":\"probabilistic\"\,\"rejection_sample_method\":\"block\"\} --kv-transfer-config \{\"kv_connector\":\"SimpleCPUOffloadConnector\"\,\"kv_role\":\"kv_both\"\,\"kv_connector_extra_config\":\{\"cpu_bytes_to_use_per_rank\":224875000000\,\"lazy_offload\":false\}\} 

Bench:

vllm bench serve --backend openai-chat --model moonshotai/Kimi-K3 --tokenizer /data/Kimi-K3 --trust-remote-code \
  --host localhost --port 8002 --endpoint /v1/chat/completions --dataset-name random --random-input-len 1024 \
  --random-output-len 1024 --random-range-ratio 0 --request-rate=inf --random-prefix-len 0 --num-prompts <10 x conc> \
  --max-concurrency <conc> --ignore-eos --seed 43 --percentile-metrics ttft,tpot,itl,e2el

Test Result

New rows vs the previous rows re-timed on the new kernel (us):

shape M previous row new row
router fp32 56 / 64 / 80 / 96 / 112 / 128 / 144 8.84 / 10.52 / 11.48 / 11.20 / 11.54 / 14.44 / 14.26 8.12 / 8.16 / 8.84 / 9.48 / 10.14 / 10.28 / 11.48
in_proj bf16 56 / 64 / 80 / 96 / 112 / 128 - / 25.22 / 27.50 / 29.16 / 30.66 / 32.14 22.06 / 21.98 / 24.62 / 26.22 / 27.82 / 28.92

Serving traces

GEMM c14 (M=56) c70 (M=70)
MoE router gate, N=896 K=7168, fp32 out 11.39 -> 8.02 us 9.82 + 4.97 (PostGSU) -> 8.30 us
KDA in_proj, N=6288 K=7168 25.33 -> 24.70 27.78 -> 24.02
latent-MoE routed_expert_down_proj, N=3584 K=7168 16.95 -> 14.73 18.26 -> 17.57
shared experts gate_up_proj, N=1536 K=7168 10.69 -> 8.58 11.53 -> 10.43
MLA fused_qkv_a_proj, N=2112 K=7168 13.30 -> 11.17 13.89 -> 11.85

Bench:

conc run tok/s mean TPOT (ms) P99 TPOT mean TTFT (ms)
14 base 674.69 19.56 25.46 340.96
14 PR 711.87 (+5.5%) 18.71 (-4.3%) 23.99 349.80
70 base 1706.55 39.93 41.36 1145.33
70 PR 1775.88 (+4.1%) 38.34 (-4.0%) 39.40 1128.77

gsm8k

  lm_eval \
    --model local-completions \
    --model_args "model=moonshotai/Kimi-K3,base_url=http://localhost:8002/v1/completions,tokenizer=/data/Kimi-K3,num_concurrent=14,max_retries=3,tokenized_r
  equests=False,trust_remote_code=True" \
    --tasks gsm8k --num_fewshot 5 --seed 42 \
    --output_path <out_dir> --log_samples

Base:
|gsm8k| 3|flexible-extract| 5|exact_match|↑ |0.953 |± |0.0058|
| | |strict-match | 5|exact_match|↑ |0.953 |± |0.0058|
spec decode over gsm8k: acceptance 76.04% acceptance length 3.281 (accepted 96054 / draft tokens 126321, 42107 drafts)
PR:
|gsm8k| 3|flexible-extract| 5|exact_match|↑ |0.9500|± | 0.006|
| | |strict-match | 5|exact_match|↑ |0.9507|± | 0.006|
spec decode over gsm8k: acceptance 78.68% acceptance length 3.360 (accepted 96537 / draft tokens 122700, 40900 drafts)

GPQA Diamond

lm_eval --model local-chat-completions \
  --model_args model=moonshotai/Kimi-K3,base_url=http://localhost:8002/v1/chat/completions,num_concurrent=14,max_length=40960,tokenizer=/data/moonshotai/Kimi-K3,tokenizer_backend=huggingface,trust_remote_code=True \
  --apply_chat_template --tasks gpqa_diamond_cot_zeroshot --gen_kwargs '{"max_gen_toks":32768}' --seed 42

Base:
|gpqa_diamond_cot_zeroshot| 2.2|flexible-extract| 0|exact_match|↑ |0.8737|± |0.0237|
| | |strict-match | 0|exact_match|↑ |0.0000|± |0.0000|
PR:
|gpqa_diamond_cot_zeroshot| 2.2|flexible-extract| 0|exact_match|↑ |0.8788|± |0.0233|
| | |strict-match | 0|exact_match|↑ |0.0000|± |0.0000|

AIME25

lm_eval --model local-chat-completions \
  --model_args model=moonshotai/Kimi-K3,base_url=http://localhost:8002/v1/chat/completions,num_concurrent=7,max_length=72000,seed=<0..3>,tokenizer=/data/moonshotai/Kimi-K3,tokenizer_backend=huggingface,trust_remote_code=True \
  --apply_chat_template --tasks aime25 --seed <0..3> \
  --gen_kwargs '{"do_sample":true,"temperature":0.6,"top_p":0.95,"max_gen_toks":65536}'
AIME25 seed 0 seed 1 seed 2 seed 3 avg@4
base 0.8667 0.9000 0.7000 0.8000 0.8167
PR 0.7667 0.9667 0.8667 0.8000 0.8500

Submission Checklist

@nsusanto
nsusanto requested a review from a team October 13, 2026 16:50
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 6494 --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.

@github-actions github-actions Bot changed the title [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj retune [HIP] [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj retune Oct 13, 2026

@vgokhale vgokhale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but let's wait for a review from @coderfeli

@nsusanto nsusanto changed the title [HIP] [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj retune [HIP] [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj tune Oct 13, 2026
@nsusanto nsusanto changed the title [HIP] [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj tune [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj tune Oct 13, 2026
@nsusanto nsusanto changed the title [FlyDSL] Cheaper split-K epilogue in gfx950 a16w16 + Kimi-K3 router/in_proj tune [FlyDSL] split-K epilogue optimization in gfx950 a16w16 + Kimi-K3 router/in_proj tune Oct 13, 2026
@zufayu
zufayu requested a review from yadaish October 14, 2026 01:27
@k50112113
k50112113 self-requested a review October 14, 2026 14:22
@vgokhale

Copy link
Copy Markdown
Contributor

Can you increase rtol/atol to 1e-4 just to confirm the accuracy is intact? There does appear to be a small drop in gsm8k

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants