[XPU][bugfix] fix rope for llama4 and deepseek (#25145)

Signed-off-by: Yan Ma <yan.ma@intel.com>
This commit is contained in:
Yan Ma
2025-10-30 09:43:13 +08:00
committed by GitHub
parent 48eb8eba58
commit b798e39f93
4 changed files with 22 additions and 32 deletions
@@ -14,7 +14,7 @@ from .rocm_aiter_rope_ops import (
@CustomOp.register("rotary_embedding")
class RotaryEmbedding(CustomOp):
class RotaryEmbeddingBase(CustomOp):
"""Original rotary positional embedding."""
def __init__(
@@ -86,6 +86,21 @@ class RotaryEmbedding(CustomOp):
):
self.cos_sin_cache = self.cos_sin_cache.to(query.device, dtype=query.dtype)
class RotaryEmbedding(RotaryEmbeddingBase):
def __init__(
self,
head_size: int,
rotary_dim: int,
max_position_embeddings: int,
base: float,
is_neox_style: bool,
dtype: torch.dtype,
) -> None:
super().__init__(
head_size, rotary_dim, max_position_embeddings, base, is_neox_style, dtype
)
def forward_native(
self,
positions: torch.Tensor,