[ROCm][PERF] Enable AITER PA gluon decode for MiniMax-M3 MTP and dense layers - #52849
[ROCm][PERF] Enable AITER PA gluon decode for MiniMax-M3 MTP and dense layers#52849ukannika wants to merge 5 commits into
Conversation
Signed-off-by: ukannika <uma.kannikanti@amd.com>
Signed-off-by: ykamiset <yaminipreethi.kamisetty@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. 🚀 |
|
minor q @ukannika can you include your env vars for AITER, shuffle KV cache, etc. in the repro command above? |
Rohan138
left a comment
There was a problem hiding this comment.
LGTM but cc @tjtanaa for the ROCM_AITER_FA changes/ @jhu960213 for the kv cache layout
Signed-off-by: ykamiset <yaminipreethi.kamisetty@amd.com>
|
hey @ukannika Can you check pre-commit locally really quick? I know it's not running here, but I think there may be some errors |
checking now. thank you for reviewing. |
Sorry for that. we missed to push some code change. Fixed now. Thank you |
| raise ValueError("Block size must be a multiple of 16.") | ||
|
|
||
| if rocm_aiter_ops.is_shuffle_kv_cache_enabled(): | ||
| return (num_blocks, 2, block_size, num_kv_heads, head_size) |
There was a problem hiding this comment.
Should we update this?
get_kv_cache_shape is used by gpu runner to determine how the kvcache is packed in the kvcache buffers/pool/management system. It is not referring to the kvcache shape expect by the kernels.
The KVCACHE is reshaped on the fly in the attention forward pass from (num_blocks, num_kv_heads, block_size, 2 * head_size) to (num_blocks, 2, block_size, num_kv_heads, head_size) every time.
num_blocks, block_size, num_kv_heads, _ = key_cache.shape
x = 16 // key_cache.element_size()
new_key_cache = key_cache.reshape(
num_blocks, num_kv_heads, head_size // x, block_size, x
)
new_value_cache = value_cache.reshape(
num_blocks, num_kv_heads, block_size // x, head_size, x
)
However, the kvcache stored in the kvcache management system is still (num_blocks, num_kv_heads, block_size, 2 * head_size)
There was a problem hiding this comment.
@tjtanaa we see an issue if we don't define the shape and stride order when the shuffle layout is enabled: the pool is then labeled (num_blocks, num_kv_heads, block_size, 2*head_size), where each tokens K is immediately followed by its own V, head_size elements apart. The cache write kernel still writes each blocks K in the shuffle layout because of shuffle layout flag enabled, which assumes K and V are kept apart. Looking into how is it working with shuffle layout enabled for asm pa kernel before this change.
There was a problem hiding this comment.
@tjtanaa Enabled the shuffle layout flag and tested the Llama2 70B model using the asm_pa code path. I am seeing an accuracy issue, and the current state of this file is broken due to the layout changes introduced in this PR #44455. AITER assembly paged-attention kernels require independently contiguous K and V storage. This PR addresses the accuracy issue as well.
Here's the command to reproduce accuracy issue
export VLLM_ROCM_USE_AITER=1
export VLLM_ROCM_SHUFFLE_KV_CACHE_LAYOUT=1
vllm serve /model/llama2-70b-chat-hf/fp4_quantized_gptq \
--dtype bfloat16 \
--quantization quark \
--tensor-parallel-size 1 \
--max-model-len 2048 \
--gpu-memory-utilization 0.94 \
--attention-backend ROCM_AITER_FA \
--kv-cache-dtype fp8 \
--block-size 16 \
--max-num-batched-tokens 32768 \
--max-num-seqs 6400 \
--enable-chunked-prefill \
--async-scheduling \
--host 0.0.0.0 \
--port 8000
curl -s http://127.0.0.1:8000/v1/completions -H "Content-Type: application/json" -d '{
"model": "/model/llama2-70b-chat-hf/fp4_quantized_gptq",
"prompt": "The capital of France is",
"max_tokens": 32,
"temperature": 0
}'```
|
This pull request has merge conflicts that must be resolved before it can be |
Purpose
The gluon paged-attention decode kernel handles multi-token query lengths, so
EAGLE3 speculative decoding no longer has to fall back to native vllm unified_attention.
Test Plan
Server cmd to run EAGLE3 speculative decoding
Test Result
MiniMax-M3 with EAGLE3 3-token speculative decoding sees a significant uplift at long context: the AITER gluon paged-attention kernel replaces the unified_attention fallback and is substantially faster for longer contexts.
Accuracy score: