Skip to content

perf(runtime): avoid Kimi MLA projection layout copies - #950

Open
Max191 wants to merge 1 commit into
lightseekorg:mainfrom
Max191-agents:agents/avoid-kimi-mla-layout-copies
Open

perf(runtime): avoid Kimi MLA projection layout copies#950
Max191 wants to merge 1 commit into
lightseekorg:mainfrom
Max191-agents:agents/avoid-kimi-mla-layout-copies

Conversation

@Max191

@Max191 Max191 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Runs the MLA query and value projections directly from their supported transposed activation layouts into the caller-provided strided outputs. This removes the activation materialization and final copy. This also removes an amd-specific specialization that proves to not be necessary based on benchmark performance.

Performance evidence

On 4 MI350X GPUs (attn-tp4 moe-tp4), five baseline Kimi 2.5 runs were compared with three candidate runs. Each run served eight successful requests at concurrency eight with exactly 8,192 input and 8,192 output tokens. EAGLE3 used one draft step and verify width two.

Median TTFT moved from 4405.845 to 4302.860 ms (+2.337%), TPOT from 27.375 to 26.454 ms (+3.364%), E2EL from 228633.556 to 220785.828 ms (+3.432%), and output throughput from 280.960 to 291.261 tok/s (+3.666%). Candidate TPOT ranged from 26.420 to 26.511 ms and output throughput from 290.374 to 291.265 tok/s; the corresponding baseline ranges were 27.249 to 27.430 ms and 280.569 to 281.944 tok/s.

Every run completed 8/8 requests. Generated text, per-request response-event vectors, the 33,016-event total, and the 98.473467% acceptance proxy matched the baseline exactly.

Run the MLA query and value projections directly from their supported
transposed activation layouts into the caller-provided strided outputs. This
uses torch.bmm's out parameter to remove the activation materialization,
temporary result, and final copy while preserving the projection contract.

Performance evidence

On physical MI350X GPUs 4-7, five upstream/main runs at b28e18d were
compared with three candidate runs. Each run served eight successful requests
at concurrency eight with exactly 8,192 input and 8,192 output tokens, graph
capture including the 8,192-token prefill graph, profiler disabled, greedy
sampling, seed 20260724, and zero client warmups. EAGLE3 used one draft step
and verify width two. The target and draft revisions were
42c6da365fdd32ae482ee7eb8bdc563da31c3404 and
27f31052f73704614af4abe6a65e766663959f29.

Median TTFT moved from 4405.845 to 4302.860 ms (+2.337%), TPOT from
27.375 to 26.454 ms (+3.364%), E2EL from 228633.556 to 220785.828 ms
(+3.432%), and output throughput from 280.960 to 291.261 tok/s (+3.666%).
Candidate TPOT ranged from 26.420 to 26.511 ms and output throughput from
290.374 to 291.265 tok/s; the corresponding baseline ranges were 27.249 to
27.430 ms and 280.569 to 281.944 tok/s.

Every run completed 8/8 requests. Generated text, per-request response-event
vectors, the 33,016-event total, and the 98.473467% acceptance proxy matched
the baseline exactly. Pre-commit and diff checks passed.

Signed-off-by: Max Dawkins <max.dawkins@gmail.com>
@Max191
Max191 requested a review from a team as a code owner August 5, 2026 15:50
@raikonenfnu
raikonenfnu requested a review from qedawkins August 6, 2026 06:59
@torchspec-bot

Copy link
Copy Markdown
Collaborator

Hi @Max191 please fix the conflicts thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants