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
9 changes: 8 additions & 1 deletion python/sglang/srt/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
)
from sglang.srt.configs.nemotron_h import NemotronHConfig, NemotronHPuzzleConfig
from sglang.srt.configs.olmo3 import Olmo3Config
from sglang.srt.configs.qwen3_5 import Qwen3_5Config, Qwen3_5MoeConfig
from sglang.srt.configs.qwen3_5 import (
Qwen3_5Config,
Qwen3_5MoeConfig,
Qwen3_5MoeTextConfig,
Qwen3_5TextConfig,
)
from sglang.srt.configs.qwen3_asr import Qwen3ASRConfig
from sglang.srt.configs.qwen3_next import Qwen3NextConfig
from sglang.srt.configs.step3_vl import (
Expand Down Expand Up @@ -64,6 +69,8 @@
"Qwen3NextConfig",
"Qwen3_5Config",
"Qwen3_5MoeConfig",
"Qwen3_5TextConfig",
"Qwen3_5MoeTextConfig",
"InternS2PreviewConfig",
"DotsVLMConfig",
"DotsOCRConfig",
Expand Down
31 changes: 18 additions & 13 deletions python/sglang/srt/layers/layernorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ def forward_hip(
residual: Optional[torch.Tensor] = None,
post_residual_addition: Optional[torch.Tensor] = None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
if _use_aiter:
return self.forward_aiter(x, residual, post_residual_addition)

# Fallback to native implementation if vllm is not available
if not _has_vllm_rms_norm:
return self.forward_native(x, residual, post_residual_addition)
Expand All @@ -480,14 +483,10 @@ def forward_hip(
# NOTE: Remove this if aiter kernel supports discontinuous input
x = x.contiguous()
if residual is not None:
out = torch.empty_like(x)
residual_out = torch.empty_like(x)
if post_residual_addition is not None:
residual = residual + post_residual_addition
fused_add_rms_norm(
out, x, residual_out, residual, self.weight.data, self.variance_epsilon
)
return out, residual_out
fused_add_rms_norm(x, residual, self.weight.data, self.variance_epsilon)
Comment thread
sammysun0711 marked this conversation as resolved.
return x, residual
out = torch.empty_like(x)
rms_norm(out, x, self.weight.data, self.variance_epsilon)
return out
Expand Down Expand Up @@ -788,6 +787,16 @@ def forward_hip(
residual: Optional[torch.Tensor] = None,
post_residual_addition: Optional[torch.Tensor] = None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
if x.numel() == 0:
if residual is not None:
if post_residual_addition is not None:
residual = residual + post_residual_addition
return x, residual
return x

if is_batch_invariant_mode_enabled():
return self.forward_native(x, residual, post_residual_addition)

if not _has_vllm_rms_norm:
return self.forward_native(x, residual, post_residual_addition)

Expand All @@ -807,18 +816,14 @@ def forward_hip(
return rms_norm(x, w, self.variance_epsilon)
else:
# vllm API: rms_norm(out, input, weight, eps) -> None (in-place)
# fused_add_rms_norm(out, input, residual_out, residual, weight, eps)
# fused_add_rms_norm(input, residual, weight, eps) -> None
if not x.is_contiguous():
x = x.contiguous()
if residual is not None:
out = torch.empty_like(x)
residual_out = torch.empty_like(x)
if post_residual_addition is not None:
residual = residual + post_residual_addition
fused_add_rms_norm(
out, x, residual_out, residual, w, self.variance_epsilon
)
return out, residual_out
fused_add_rms_norm(x, residual, w, self.variance_epsilon)
return x, residual
out = torch.empty_like(x)
rms_norm(out, x, w, self.variance_epsilon)
return out
Expand Down
Loading
Loading