diff --git a/vllm/model_executor/layers/attention/mla_attention.py b/vllm/model_executor/layers/attention/mla_attention.py index b9ce84c2e5..3d6efc3856 100644 --- a/vllm/model_executor/layers/attention/mla_attention.py +++ b/vllm/model_executor/layers/attention/mla_attention.py @@ -989,19 +989,8 @@ class MLAAttention(nn.Module, AttentionLayerBase): x, self.W_V, self.W_V_scale, group_size=128, transpose_bm=True, YQ=out ) else: - # Convert from (B, N * V) to (N, B, V) - out = out.transpose(0, 1) - - # Multiply (N, B, L) x (N, L, V) -> (N, B, V) - torch.bmm(x, self.W_UV, out=out) # Reuse "out" to make it "hot" - - # Convert from (N, B, V) to (B, N * V) - out_new = out.transpose(0, 1).reshape(-1, self.num_heads * self.v_head_dim) - - # Adjust output buffer shape back to the original (B, N * V) - N, B, V = out.shape - out.resize_((B, N * V)) - out.copy_(out_new) # Copy result + # Multiply + Transpose (N, B, L) x (N, L, V)->(N, B, V)->(B, N, V) + torch.bmm(x, self.W_UV, out=out.transpose(0, 1)) def unified_mla_kv_cache_update(