Repository navigation
Conversation
Hybrid attention+mamba models can expose non-contiguous KV cache views via as_strided_. The shuffled cache writer assumed a contiguous layout and could corrupt shuffle=1 decode inputs, so compute shuffled write offsets from the actual cache view strides. This fixes for example Qwen3.5 for shuffle=1 for low batch sizes. Signed-off-by: tuukkjs <tuukka.sarvi@amd.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the reshape_and_cache_shuffle_kernel in the ROCm Aiter Flash Attention backend to use explicit tensor strides for offset calculations. By passing kc_stride and vc_stride parameters directly to the kernel, the implementation replaces manual offset arithmetic, improving the robustness of the cache indexing logic. I have no feedback to provide as there were no review comments.
Signed-off-by: tuukkjs <tuukka.sarvi@amd.com> Signed-off-by: Tuukka Sarvi <tuukka.sarvi@amd.com>
|
@tuukkjs From your description, this PR requires a new aiter version v0.1.12, am I right? |
No, this fix will apply with the current aiter version as well. Aiter v0.1.12 will just change the routing of |
|
To clarify the situation further, in my understanding, there are three separate (though somewhat related) issues here:
Solving each of the above brings some value own its own irrespective of what is done to others (with the exception of 3 and 2 as solving 3 would void the need for 2). |
do you have the commit to the necessary upgrade? And we just landed the aiter v0.1.12 upgrade, could you help me to find out if it contains the fix? Thanks a lot. |
The aiter commit is b4885d2. It is included in aiter v0.1.12. It seems vllm is still using aiter v0.1.10.post3? |
Yes. We have to revert to |
|
I ran the results with b4885d2 aiter commit applied on top of aiter v0.1.10.post3 which showed that then all batch sizes give correct results.
I also ran lm_eval with aiter v0.1.12. Batch size 4 gave score about 0.2 and batch size 512 gave score near 0. This makes me think there is something wrong with that tag (or at least was few days ago). |
|
@tjtanaa should we merge this? As far as I understand, without aiter upgrade, this fixes low batch cases. After aiter upgrade (see previous message) also high batch cases are fixed. As far as I understand this affects only ROCM_AITER_FA backend with shuffle (so there should be no regressions elsewhere in my understanding). |
|
This pull request has merge conflicts that must be resolved before it can be |
Co-authored-by: Cursor <cursoragent@cursor.com>
…ffle-hybrid-kv-strides
|
I think that hybrid attention is good now. Could you please test the most recent vLLM release and see if the issue you are trying to resolve with this PR has already been resolved? |
|
Yes, it is now working on main already, so this PR can be closed it seems to me. However, I think there might be a stale TODO now in code. This PR proposes to remove it: #44178. Image: Qwen3.5 hybrid lm eval
|
Hybrid attention+mamba models can expose non-contiguous KV cache views via
as_strided_. The shuffled cache writer assumed a contiguous layout and could corrupt shuffle=1 decode inputs, so compute shuffled write offsets from the actual cache view strides.Follow-up to #32914. After the fix, we get correct results for Qwen 3.5 for the
paged_attention_rocmpath with shuffle=1, i.e., for low batch sizes. At batch_size=512 the issue persists becausepaged_attention_commonroutes to the ASM paged-attention kernel (pa_fwd_asm), which only supportshead_dim == 128. Qwen 3.5 useshead_dim=256. A fix in aiter (ROCm/aiter@b4885d2) restricts the ASM kernel tohead_dim == 128and falls back topaged_attention_rocmfor other head sizes. Once vLLM upgrades aiter to v0.1.12 or later, shuffle=1 should work correctly for Qwen 3.5 at all batch sizes.Adding
head_dim != 128support to the ASM kernel is out of scope of this PR.AI assistance was used for this PR.
Test Plan
Test with Qwen 3.5 (hybrid model) and Qwen 3 (attention-only model).
Test Result
lm_eval (gsm8k, 5-shot) — Qwen3.5-397B (hybrid) MI355X
The fix results in correct results for
paged_attention_rocmpath of shuffle=1, i.e., for low batch sizes. At batch_size=512 the issue persists because asm-kernel only supportshead_dim == 128.lm_eval (gsm8k, 5-shot) — Qwen3-235B (attention-only) MI355X
The standard attention-only model works correctly at both batch sizes with the fix applied, confirming no regression for standard attention-only models.
Summary