Skip to content

Commit 9887ba0

Browse files
akii96xaguilar-amd
authored andcommitted
Fix stale is_sparse_impl reference and trim comment bloat
Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com> Signed-off-by: Aakif Nawaz <aakif.nawaz@amd.com>
1 parent 3c93c04 commit 9887ba0

3 files changed

Lines changed: 4 additions & 27 deletions

File tree

vllm/model_executor/layers/attention/mla_attention.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,7 @@ def __init__(
557557
kv_b_proj._cpu_skip_gemm_dispatch = True
558558
self.use_direct_call = not current_platform.opaque_attention_op()
559559

560-
# the fused sparse-MLA Q-prep kernel folds the main RoPE into
561-
# the decode kernel, so it needs the rotary embedding's cos/sin cache.
562-
# Without a rotary embedding there is no RoPE to fold, so disable the
563-
# fused path to keep the wrapper / KV-write / decode branches consistent.
560+
# Disable fused Q-prep path when no rotary_emb is available.
564561
self.rotary_emb = rotary_emb
565562
self._fused_rope_cos_sin: tuple[torch.Tensor, torch.Tensor] | None = None
566563
if getattr(self.impl, "use_fused_qk_rope_cache", False) and rotary_emb is None:
@@ -978,14 +975,11 @@ def forward_impl(
978975
mqa_ql_nope = mqa_ql_nope.transpose(0, 1)
979976

980977
use_fused_qk_rope_cache = (
981-
is_sparse_impl
978+
self.impl.is_sparse
982979
and getattr(self.impl, "use_fused_qk_rope_cache", False)
983980
and self.rotary_emb is not None
984981
)
985982
if use_fused_qk_rope_cache:
986-
# fold RoPE + Q-concat + KV-concat + KV-cache-write
987-
# into one kernel. positions is threaded in as a real argument
988-
# (survives torch.compile / CUDA graph replay).
989983
if positions is None:
990984
raise RuntimeError(
991985
"Fused MLA Q-prep is enabled but `positions` was not "

vllm/model_executor/layers/mla.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ def __init__(
127127
rotary_emb=self.rotary_emb,
128128
)
129129

130-
# when the decode impl fuses RoPE into its Q-prep kernel
131-
# (fused_qk_rope_concat_and_cache_mla), defer the main RoPE here and
132-
# pass positions down to the impl as a forward() argument.
133130
self._defer_rope_to_fused_kernel = self.rotary_emb is not None and getattr(
134131
self.mla_attn.impl, "use_fused_qk_rope_cache", False
135132
)

vllm/v1/attention/backends/mla/rocm_aiter_mla_sparse.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,6 @@ def __init__(
709709
(q_concat_shape, vllm_config.model_config.dtype),
710710
)
711711

712-
# fold decode RoPE + Q-concat + KV-concat + KV-cache-write into
713-
# a single aiter kernel (fused_qk_rope_concat_and_cache_mla).
714712
self.use_fused_qk_rope_cache = (
715713
rocm_aiter_ops.is_fused_mla_qkprep_enabled()
716714
and self.kv_cache_dtype.startswith("fp8")
@@ -727,8 +725,6 @@ def do_kv_cache_update(
727725
k_scale: torch.Tensor,
728726
) -> None:
729727
if self.use_fused_qk_rope_cache:
730-
# The KV-cache write (concat + RoPE + fp8 quant) is folded into
731-
# fused_qk_rope_concat_and_cache_mla
732728
return
733729
super().do_kv_cache_update(
734730
kv_c_normed, k_pe, kv_cache, slot_mapping, kv_cache_dtype, k_scale
@@ -748,20 +744,10 @@ def fused_qk_rope_concat_and_cache(
748744
sin_cache: torch.Tensor,
749745
is_neox: bool,
750746
) -> torch.Tensor:
751-
"""Fused decode Q-prep.
752-
753-
Applies RoPE to ``q_pe``/``k_pe``, concatenates ``ql_nope`` with the
754-
RoPE'd ``q_pe`` into ``q_out``, and writes the concatenated,
755-
fp8-quantized latent+rope KV row into ``kv_cache``. The fused path only
756-
runs with an fp8 KV cache, so ``q_out`` is produced directly in fp8
757-
(quantized by the kernel with ``q_scale``).
758-
"""
747+
"""Fused RoPE + Q-concat + KV-concat + fp8 KV-cache write."""
759748
num_tokens, num_q_heads = ql_nope.shape[:2]
760-
# The aiter kernel builds the nope half of q_out (and the KV latent) by
761-
# copying ql_nope and REQUIRES it to be contiguous: a strided ql_nope
762-
# silently yields wrong q_out values. Force contiguity here.
749+
# aiter kernel requires contiguous ql_nope
763750
ql_nope = ql_nope.contiguous()
764-
# Emit q_out directly in fp8 when the KV cache is fp8
765751
q_out_dtype = (
766752
current_platform.fp8_dtype()
767753
if self.kv_cache_dtype.startswith("fp8")

0 commit comments

Comments
 (0)