diff --git a/vllm/patches/deepseek_v4_attention.py b/vllm/patches/deepseek_v4_attention.py index db461b45..8286a288 100644 --- a/vllm/patches/deepseek_v4_attention.py +++ b/vllm/patches/deepseek_v4_attention.py @@ -583,9 +583,9 @@ def _apply_inv_rope_bf16( rope = o_f32[..., nope_dim:] y_even = rope[..., 0::2] y_odd = rope[..., 1::2] - # Inverse: sin → -sin + # Inverse: sin → -sin (swap signs on the cross terms) rope_out = torch.stack( - (y_even * cos - y_odd * sin, y_odd * cos + y_even * sin), + (y_even * cos + y_odd * sin, y_odd * cos - y_even * sin), dim=-1, ).flatten(-2) o_f32 = o_f32.clone()