[XPU] Wire up SYCL apply_rotary_emb kernel in ApplyRotaryEmb (#55721)

Signed-off-by: Michal Ganczarenko <michal.ganczarenko@intel.com>
Signed-off-by: Michał Ganczarenko <michal.ganczarenko@intel.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Michał Ganczarenko
2026-09-22 20:43:24 -07:00
committed by GitHub
co-authored by Claude
parent 94f4170df3
commit 73c59d365b
3 changed files with 78 additions and 0 deletions
+25
View File
@@ -6,6 +6,7 @@ from typing import TYPE_CHECKING
import torch
from vllm_xpu_kernels.flash_attn_interface import flash_attn_varlen_func
from vllm_xpu_kernels.rotary import apply_rotary_emb
from vllm.compilation.breakable_cudagraph import eager_break_during_capture
from vllm.logger import init_logger
@@ -249,6 +250,24 @@ def _xpu_ops_deepseek_scaling_rope_fake(
return query, key
def _xpu_apply_rotary_emb_impl(
x: torch.Tensor,
cos: torch.Tensor,
sin: torch.Tensor,
is_neox_style: bool,
) -> torch.Tensor:
return apply_rotary_emb(x, cos, sin, is_neox_style)
def _xpu_apply_rotary_emb_fake(
x: torch.Tensor,
cos: torch.Tensor,
sin: torch.Tensor,
is_neox_style: bool,
) -> torch.Tensor:
return torch.empty_like(x)
def _xpu_fp8_bmm_impl(
a: torch.Tensor,
b: torch.Tensor,
@@ -1257,6 +1276,12 @@ class xpu_ops:
dispatch_key=current_platform.dispatch_key,
)
direct_register_custom_op(
op_name="xpu_apply_rotary_emb",
op_func=_xpu_apply_rotary_emb_impl,
fake_impl=_xpu_apply_rotary_emb_fake,
)
direct_register_custom_op(
op_name="xpu_mxfp8_quantize",
op_func=_xpu_mxfp8_quantize_impl,
@@ -237,6 +237,18 @@ class ApplyRotaryEmb(CustomOp):
output = self._post_process(output, origin_shape, origin_dtype)
return output
def forward_xpu(
self,
x: torch.Tensor,
cos: torch.Tensor,
sin: torch.Tensor,
) -> torch.Tensor:
import vllm._xpu_ops # noqa: F401 registers torch.ops.vllm.xpu_apply_rotary_emb
x, cos, sin, origin_shape, origin_dtype = self._pre_process(x, cos, sin)
output = torch.ops.vllm.xpu_apply_rotary_emb(x, cos, sin, self.is_neox_style)
return self._post_process(output, origin_shape, origin_dtype)
def forward_hip(
self,
x: torch.Tensor,