Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions python/sglang/srt/layers/rotary_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@
import torch.nn as nn

from sglang.srt.custom_op import CustomOp
from sglang.srt.utils import cpu_has_amx_support, is_cpu, is_cuda, is_hip, is_npu
from sglang.srt.utils import (
cpu_has_amx_support,
get_bool_env_var,
is_cpu,
is_cuda,
is_hip,
is_npu,
)

_is_cuda = is_cuda()
_is_hip = is_hip()
_use_aiter = get_bool_env_var("SGLANG_USE_AITER") and _is_hip
_is_npu = is_npu()
_is_cpu_amx_available = cpu_has_amx_support()
_is_cpu = is_cpu()

if _is_cuda:
from sgl_kernel import apply_rope_with_cos_sin_cache_inplace
if _use_aiter:
from aiter.rotary_embedding import get_rope as aiter_get_rope


def _rotate_neox(x: torch.Tensor) -> torch.Tensor:
Expand Down Expand Up @@ -1388,7 +1398,8 @@ def get_rope_wrapper(
device: Optional[str] = None,
):
if device != "cpu":
return get_rope(
wrapper = aiter_get_rope if _use_aiter else get_rope
return wrapper(
head_size,
rotary_dim,
max_position,
Expand Down
2 changes: 0 additions & 2 deletions python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@
decode_attention_fwd_grouped_rope,
)

if _use_aiter:
from aiter.rotary_embedding import get_rope

logger = logging.getLogger(__name__)

Expand Down
Loading