[ROCm][Perf] Fuse Kimi-K3 MLA output gate - #50664
JohnQinAMD wants to merge 1 commit into
Conversation
Add an optional common MLA output-gate callback whose default preserves the existing expression, and install the AITER specialization only from the AMD Kimi-K3 model. Keep output-buffer ownership in its separate optimization. Assisted-by: OpenAI Codex Signed-off-by: Yanyuan Qin <yanyuan.qin@amd.com>
|
Nobody is going to easily review a FULLY vibe coded PR. |
jamesETsmith
left a comment
There was a problem hiding this comment.
Thanks for this @JohnQinAMD, I was about to implement the fusion myself until I saw you'd already done it.
The tests in the PR also only test the mock gate and not the actual code path. I think it would make sense to consturct KimiMLAAttenntion and ensure that your changes are working. I think if you removed output_gate=kimi_k3_mla_output_gate, in vllm/models/kimi_k3/amd/linear.py all your tests would still pass.
| with patch( | ||
| "vllm.models.kimi_k3.amd.ops.mla_gate._get_aiter_mla_gate", | ||
| return_value=(None, lambda *_: False), | ||
| ): |
There was a problem hiding this comment.
If I'm reading it correctly, I don't think the signature of _get_aiter_mla_gate in this patch matches what the function can return (either None or (kimi_k3_mla_gate, supports_kimi_k3_mla_gate))
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
Wire the AITER Kimi-K3 MLA output-gate fusion into the AMD model path while
preserving the generic implementation.
MLAModulesgains an optional output-gate callback. Its default remains theexisting projection, sigmoid, and multiply expression; only the Kimi-K3 AMD
adapter installs the AITER callback. Unsupported AITER installations, devices,
shapes, dtypes, or layouts use the existing expression. NVIDIA dispatch and
generic MLA split policy are unchanged.
Depends on ROCm/aiter#4497.
Test plan
Tested on 8x MI355X (
gfx950) with the public Kimi-K3 image andmoonshotai/Kimi-K3@9f62e4e9. The AITER #4497 kernel head isd2f4c61f; thecommand below pins the vLLM base and PR revisions.
Fetch and verify the vLLM source:
Use complete verified vLLM/AITER trees as overlays on the public image,
including AITER
csrc/andhsa/; do not copy individual files. Verifyimport vllm, vllm._C, aiterbefore testing.Serve both source-isolated arms with identical flags:
After one 8K/128 warmup, run three 8K/1K batch-one trials with seeds 1--3,
temperature zero, and
--ignore-eos. Run fulllm-eval==0.4.12GSM8K on botharms: 1,319 questions, 5-shot, greedy completion, 2,048 generated tokens,
concurrency 128, and seed 42.
Test results
git diff --check, and DCO passed.Endpoint values are medians of three fixed-seed 8K/1K trials after warmup.
Full GSM8K: control 1277/1319, candidate 1273/1319, zero invalid or
transport failures; 8 wins/12 losses (
p=0.5034). This paired run found nostatistically detectable accuracy difference.
Limits
ROCm/aiter#4497 owns the kernel; this PR owns only the generic callback seam and Kimi-K3
AMD adapter. Output-buffer ownership is intentionally outside this change.
Operator tests establish the fused BF16 numerical contract; GSM8K is the
model-quality gate.
Tool assistance
OpenAI Codex assisted with implementation, tests, benchmarking, and drafting
this description.