sgl-project/sglang · error · ValueError
unsupported input for wan_rmsnorm_silu
Error message
unsupported input for wan_rmsnorm_silu
What it means
wan_rmsnorm_silu raises when its support predicate can_use_wan_rmsnorm_silu returns False. The Triton kernel requires: CUDA 5D non-empty x, dtype fp16/bf16/fp32, 0 < channels <= 1024, channels_last_3d contiguous with stride(1)==1, no grad tracking, and gamma/bias CUDA on the same device with matching dtype (or fp32) and numel == channels.
Source
Thrown at python/sglang/kernels/ops/diffusion/norm/wan_rmsnorm_silu_triton.py:159
and x.stride(1) == 1
and _affine_supported(x, gamma)
and (bias is None or _affine_supported(x, bias))
)
def wan_rmsnorm_silu(
x: torch.Tensor,
gamma: torch.Tensor,
bias: torch.Tensor | None = None,
rms_scale: float | None = None,
eps: float = 1e-12,
) -> torch.Tensor:
"""Fused ``SiLU(F.normalize(x, dim=1) * rms_scale * gamma + bias)``.
Guard with :func:`can_use_wan_rmsnorm_silu`.
"""
if not can_use_wan_rmsnorm_silu(x, gamma, bias):
raise ValueError("unsupported input for wan_rmsnorm_silu")
channels = x.shape[1]
gamma = gamma.reshape(channels).contiguous()
has_bias = bias is not None
bias = gamma if bias is None else bias.reshape(channels).contiguous()
if rms_scale is None:
rms_scale = channels**0.5
return _triton_wan_rmsnorm_silu_cuda(
x, gamma, bias, float(rms_scale), eps, has_bias
)
__all__ = ["can_use_wan_rmsnorm_silu", "wan_rmsnorm_silu"]
View on GitHub (pinned to 0132848349)
Solutions
- Call can_use_wan_rmsnorm_silu(x, gamma, bias) and fall back to eager WanRMS_norm+SiLU when False
- Convert x to channels_last_3d (x = x.to(memory_format=torch.channels_last_3d)) and ensure stride(1)==1
- Wrap inference in torch.no_grad()/torch.inference_mode()
- Verify gamma/bias are CUDA, same device, dtype equal to x or fp32, and numel == x.shape[1]
Example fix
# before
y = wan_rmsnorm_silu(x, gamma, bias)
# after
if can_use_wan_rmsnorm_silu(x, gamma, bias):
y = wan_rmsnorm_silu(x, gamma, bias)
else:
y = torch.nn.functional.silu(torch.nn.functional.normalize(x, dim=1) * scale * gamma.reshape(C) + (bias.reshape(C) if bias is not None else 0)) Defensive patterns
Strategy: type-guard
Validate before calling
from sglang.kernels.ops.diffusion.norm.wan_rmsnorm_silu_triton import can_use_wan_rmsnorm_silu
if can_use_wan_rmsnorm_silu(x, gamma, bias):
y = wan_rmsnorm_silu(x, gamma, bias, rms_scale, eps)
else:
y = eager_wan_rms_silu(x, gamma, bias, rms_scale, eps) Type guard
can_use_wan_rmsnorm_silu(x, gamma, bias) # the library's own predicate is the type guard
Try / catch
try:
y = wan_rmsnorm_silu(x, gamma, bias)
except ValueError:
y = eager_wan_rms_silu(x, gamma, bias) # WanRMS_norm + SiLU in eager torch Prevention
- Always guard with can_use_wan_rmsnorm_silu — the docstring mandates it
- Convert VAE activations to channels_last_3d at entry
- Run inference under torch.no_grad()
- Keep channels <= 1024 and gamma/bias fp32-or-matching dtype with numel == C
When it happens
Trigger: Calling wan_rmsnorm_silu with a CPU tensor, non-channels-last 5D input, requires_grad enabled, channels > 1024, empty tensor, or gamma/bias of wrong dtype/size/device. The docstring explicitly says to guard with can_use_wan_rmsnorm_silu first.
Common situations: Running the Wan VAE decoder without channels_last_3d memory format; forgetting torch.no_grad() during inference wrappers; gamma kept on a different GPU in TP setups; channel counts above 1024 in a modified VAE.
Related errors
- unsupported input for Sana fused bias-SiLU
- num_token_non_padded must be a single-element tensor, got sh
- num_token_non_padded must be an integer tensor, got {num_tok
- v_cache must be provided
- q can only be None when only_qv=True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/2bcec2ae86c8389e.
Report an issue: GitHub.