[ROCm] Skip fresh Kimi-K3 KDA state copies - #50855
Draft
LiuYinfeng01 wants to merge 2 commits into
Draft
LiuYinfeng01 wants to merge 2 commits into
LiuYinfeng01 wants to merge 2 commits into
Conversation
LiuYinfeng01
force-pushed
the
perf/rocm-k3-kda-fresh-state
branch
from
August 3, 2026 11:02
8c160f6 to
2f619fe
Compare
Use host metadata to detect all-fresh prefill batches and let chunk KDA initialize from zero without materializing dense recurrent states. Signed-off-by: Liuyinfeng01 <yinfeliu@amd.com>
LiuYinfeng01
force-pushed
the
perf/rocm-k3-kda-fresh-state
branch
from
August 3, 2026 11:03
2f619fe to
e048ea5
Compare
Let chunk KDA target indexed recurrent-cache rows so all-fresh prefills avoid materializing and scattering dense final states. Signed-off-by: Liuyinfeng01 <yinfeliu@amd.com>
LiuYinfeng01
force-pushed
the
perf/rocm-k3-kda-fresh-state
branch
from
August 3, 2026 11:11
7341710 to
54e90fe
Compare
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Detect all-fresh Kimi-K3 prefill batches from existing CPU metadata, then let chunk KDA start from zero and write final recurrent states directly to indexed cache rows. This skips dense gather, zero-fill, final-state allocation, and scatter while retaining the existing path for mixed, resumed, padded, and non-ROCm batches.
Kimi-K3 has 69 KDA layers. On TP8, one recurrent state is 0.75 MiB per request per layer. At batch 128, the old path materialized a 96 MiB zero initial-state tensor and a 96 MiB final-state tensor per layer before scattering the latter into cache rows.
Test Plan
python -m pytest -q tests/models/kimi_k3/test_kda_metadata.pypython -m pytest -q tests/models/kimi_k3/test_kda.py -k test_chunk_kda_none_matches_zero_initial_staterocm/vllm-dev:gfx950_kimi_k3_20260727with [GFX950] Relocate MLA Gluon kernel and unify decode dispatch ROCm/aiter#4450Test Result
18 passed, covering fresh, resumed, and zero-length-padded batches.D=128: output and final state match explicit-zero initialization; non-contiguous indexed cache rows match; untouched sentinel rows remain unchanged.100/100, candidate99/100, with zero invalid responses. The direct-store kernel is separately numerically matched to the candidate path.git diff --checkpassed. The fixed image does not include Ruff.Tool assistance
Cursor assisted with implementation, tests, benchmarking, and drafting this description.