Skip to content

[ROCm] Skip fresh Kimi-K3 KDA state copies - #50855

Draft
LiuYinfeng01 wants to merge 2 commits into
vllm-project:mainfrom
LiuYinfeng01:perf/rocm-k3-kda-fresh-state
Draft

LiuYinfeng01 wants to merge 2 commits into
vllm-project:mainfrom
LiuYinfeng01:perf/rocm-k3-kda-fresh-state

Conversation

@LiuYinfeng01

@LiuYinfeng01 LiuYinfeng01 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

Test Result

  • Metadata: 18 passed, covering fresh, resumed, and zero-length-padded batches.
  • Kernel at Kimi head dimension D=128: output and final state match explicit-zero initialization; non-contiguous indexed cache rows match; untouched sentinel rows remain unchanged.
  • TP8 server boot and all-fresh serving smoke passed.
  • ISL 8192 / OSL 512 / concurrency 4 / 8 requests: zero failures. Median TTFT was 1649.10 ms baseline and 1658.77 ms candidate, neutral within this small sample.
  • GSM8K subset before the direct-store follow-up, 100 questions / 5-shot / greedy / seed 42: baseline 100/100, candidate 99/100, with zero invalid responses. The direct-store kernel is separately numerically matched to the candidate path.
  • Python syntax and git diff --check passed. The fixed image does not include Ruff.

Tool assistance

Cursor assisted with implementation, tests, benchmarking, and drafting this description.

@mergify mergify Bot added kimi k3 rocm Related to AMD ROCm labels Aug 3, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Aug 3, 2026
@LiuYinfeng01
LiuYinfeng01 force-pushed the perf/rocm-k3-kda-fresh-state branch from 8c160f6 to 2f619fe Compare August 3, 2026 11:02
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
LiuYinfeng01 force-pushed the perf/rocm-k3-kda-fresh-state branch from 2f619fe to e048ea5 Compare August 3, 2026 11:03
@LiuYinfeng01 LiuYinfeng01 changed the title [ROCm] Skip fresh Kimi-K3 KDA state gathers [ROCm] Skip fresh Kimi-K3 KDA state copies Aug 3, 2026
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>
@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LiuYinfeng01.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant