Repository navigation
[ROCm][Perf] Sparse MLA: build pure-decode indptr on the host and skip the NoPE q copy - #61504
amd-dlimpus wants to merge 2 commits into
Conversation
…p the NoPE q copy On pure decode without speculative decoding, seq_lens_cpu_upper_bound is exact, so paged_kv_indptr is cumsum(min(seq_len, topk)) computed on the host and uploaded with one pinned non-blocking copy. This replaces the sparse seqlen kernel, cumsum, and fill launches. req_id_per_token is 0..n-1 and is only rewritten when the decode batch grows. NoPE models already get a token-major query from the MQA bmm, so the copy into q_concat_buffer is skipped when the layout and dtype match. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Limpus, David <dlimpus@amd.com>
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Limpus, David <dlimpus@amd.com>
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
Two small per-step cuts on the ROCm AITER sparse MLA decode path. Split out of the draft #59739. Independent of the MXFP4 KV cache work (#60321).
num_prefills == 0,max_query_len == 1) with no speculative decoding,seq_lens_cpu_upper_boundis exact. Sopaged_kv_indptr = cumsum(min(seq_len, topk))is computed on the host into a pinned buffer and uploaded with one non-blocking copy. This replaces thegenerate_sparse_seqlen_tritonlaunch, the device cumsum, and the tail fill. Atorch.Eventguards reuse of the pinned buffer.req_id_per_tokenis0..n-1on pure decode, so it is only rewritten when the decode batch grows past what the buffer already holds. Mixed and prefill batches, and any run with a speculative config, keep the existing device path unchanged.qk_rope_head_dim == 0, the MQA bmm output is already the token-major query.forwarduses it directly instead of copying it intoq_concat_buffer, provided it is contiguous and the dtype matches.Test Plan
tests/v1/attention/test_rocm_sparse_host_decode_indptr.py(new): checks that the hostcumsum(min(seq_len, topk))matchesgenerate_sparse_seqlen_tritonfor topk 2048 and 64.tests/kernels/attention/test_rocm_aiter_mla_sparse_metadata_sync.py:test_pure_decode_builds_indptr_on_the_hostasserts the device seqlen kernel is not launched, and checks the resultingpaged_kv_indptrandreq_id_per_token.test_rocm_aiter_mla_sink.py,test_rocm_aiter_mla_sparse_index_remap.py,test_mla_short_prefill_indexer.py,test_rocm_aiter_mla_sparse.py,test_rocm_aiter_triton_sparse_mla.py.Test Result
metadata_synccases where theobject.__new__fixture lacked the new attributes.[tokens, heads, 512]copy. Decode benchmark numbers will be added before marking this ready.