[ROCm] Return Kimi-K3 MLA output directly - #50847
LiuYinfeng01 wants to merge 1 commit into
Conversation
Avoid copying every MLA projection into a caller-owned buffer while preserving the buffered KDA path. Signed-off-by: Liuyinfeng01 <yinfeliu@amd.com>
|
Thanks for the direct-return cleanup. A new fixed-cohort pure-decode trace gives a useful estimate for why the short one-shot serving A/B can look neutral even though the redundant work is deterministic. Profile setup: 8 x MI355X (gfx950), TP8, BF16/MXFP4, non-speculative decode, prefix caching, 63,911-token shared prefix + 4,089-token suffix, full HIP-graph replay, and The trace contains 93 post-attention-projection
So the realistic standalone expectation at these shapes is below 0.2 ms/step, which is small enough to be hidden by run-to-run end-to-end noise. This is a trace-derived removable-cost estimate, not a candidate A/B measurement. The change still removes 24 deterministic copies and should combine with #50592, which removes the other 69 post-projection copies. |
@Fangzhou-Ai Thank you for the detailed analysis and recommendation. I’ll fold the functionality of #50847 into #50592 so that a single PR removes all 93 KDA and MLA post-projection copies. I really appreciate your profiling work and helpful guidance. |
|
Superseded by #50592, which now includes this MLA direct-return change together with the complementary KDA post-projection direct-return path and combined fixed-cohort A/B evidence. |
Summary
Kimi-K3 has 24 MLA layers. For BF16 hidden states of width 7168, this removes 24 copies of
num_tokens * 7168 * 2bytes per model forward. The returned values are unchanged; only tensor ownership changes.This is intentionally separate from #50664, which owns output-gate fusion and explicitly leaves output-buffer ownership out of scope.
Test plan
2 passedinrocm/vllm-dev:gfx950_kimi_k3_20260727.100/100, candidate100/100; zero invalid responses in both arms.git diff --checkand IDE diagnostics passed.The one-shot serving measurement was neutral within noise: median TPOT was 25.53 ms baseline and 25.75 ms candidate. This PR therefore does not claim a measured end-to-end speedup from that short run; its deterministic effect is removal of the redundant MLA output allocation/copy.
Tool assistance
Cursor assisted with implementation, tests, benchmarking, and drafting this description.
Made with Cursor