Skip to content

Commit 5e0a9b0

Browse files
ispobockzhyncs
andauthored
Apply deepseek cuda rope (#5385)
Co-authored-by: Yineng Zhang <[email protected]>
1 parent bdde237 commit 5e0a9b0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

python/sglang/srt/layers/rotary_embedding.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,18 @@ def _compute_cos_sin_cache(self) -> torch.Tensor:
645645
cache = torch.cat((cos, sin), dim=-1)
646646
return cache
647647

648-
def forward(
648+
def forward_hip(self, *args, **kwargs):
649+
return self.forward_native(*args, **kwargs)
650+
651+
def forward(self, *args, **kwargs):
652+
if torch._dynamo.is_compiling:
653+
return self.forward_native(*args, **kwargs)
654+
if _is_cuda_available:
655+
return self.forward_cuda(*args, **kwargs)
656+
else:
657+
return self.forward_native(*args, **kwargs)
658+
659+
def forward_native(
649660
self,
650661
positions: torch.Tensor,
651662
query: torch.Tensor,

0 commit comments

Comments
 (0)