[Kernel] Add JIT rotary_embedding_kernel (#17934)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Xiaoyu Zhang <35585791+BBuf@users.noreply.github.com>
Co-authored-by: root <root@zhikuan-A10x2.ea134>
This commit is contained in:
pansicheng
2026-02-13 12:41:25 +08:00
committed by GitHub
parent 32e0286829
commit 7d4ae057ec
5 changed files with 897 additions and 1 deletions

View File

@@ -128,8 +128,10 @@ class RotaryEmbedding(MultiPlatformOp):
and not (_is_npu)
and not (_is_musa)
):
# rotary_embedding from sglang.jit_kernel.pos_enc and vllm._custom_ops has the same implementation.
# TODO: Test on different devices and remove this conditional.
if _is_cuda or _is_hip:
from sgl_kernel import rotary_embedding
from sglang.jit_kernel.pos_enc import rotary_embedding
else:
from vllm._custom_ops import rotary_embedding
@@ -404,6 +406,7 @@ class RotaryEmbedding(MultiPlatformOp):
fused_set_kv_buffer_arg is None
), "fused_set_kv_buffer_arg is not supported for xpu implementation"
positions = torch.add(positions, offsets) if offsets is not None else positions
return torch.ops.sgl_kernel.rotary_embedding(
positions,
query,