sgl-project/sglang · error · ValueError
Activation function {act_fn_name!r} is not supported.
Error message
Activation function {act_fn_name!r} is not supported. What it means
get_act_fn looks up activation functions by lowercased name in the module's _ACTIVATION_REGISTRY. Unknown names raise ValueError, so any model config whose activation string is not registered (gelu, silu, relu, etc. — whatever the registry contains) fails at layer construction time.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/activation.py:160
"""PyTorch-native implementation equivalent to forward()."""
return x * torch.sigmoid(1.702 * x)
_ACTIVATION_REGISTRY = {
"gelu": nn.GELU,
"gelu_new": NewGELU,
"gelu_pytorch_tanh": lambda: nn.GELU(approximate="tanh"),
"relu": nn.ReLU,
"silu": nn.SiLU,
"quick_gelu": QuickGELU,
}
def get_act_fn(act_fn_name: str) -> nn.Module:
"""Get an activation function by name."""
act_fn_name = act_fn_name.lower()
if act_fn_name not in _ACTIVATION_REGISTRY:
raise ValueError(f"Activation function {act_fn_name!r} is not supported.")
return _ACTIVATION_REGISTRY[act_fn_name]()
View on GitHub (pinned to 0132848349)
Solutions
- Inspect _ACTIVATION_REGISTRY in the same module to see supported names and use one of them.
- Add the missing name/alias to the registry (e.g. map 'swish' → the silu module) at module scope.
- Fix the model config's hidden_act/activation string to a canonical name.
Example fix
# before
act = get_act_fn('swish') # ValueError
# after
# register alias near the registry definition
_ACTIVATION_REGISTRY['swish'] = _ACTIVATION_REGISTRY['silu']
act = get_act_fn('swish') Defensive patterns
Strategy: validation
Validate before calling
from sglang.multimodal_gen.runtime.layers.activation import _ACTIVATION_REGISTRY
name = cfg.hidden_act.lower()
if name not in _ACTIVATION_REGISTRY:
raise SystemExit(f"unsupported activation {name}; supported: {sorted(_ACTIVATION_REGISTRY)}") Type guard
def is_supported_act(name: str) -> bool:
from ...activation import _ACTIVATION_REGISTRY
return name.lower() in _ACTIVATION_REGISTRY Prevention
- Register aliases (swish→silu, gelu_new→tanh-gelu) at app startup.
- Validate model configs against the registry before building layers.
When it happens
Trigger: Calling get_act_fn('swish') or any name not present in _ACTIVATION_REGISTRY — usually because a new model config uses an activation alias (e.g. 'gelu_new', 'quick_gelu', 'silu2') that this build hasn't registered.
Common situations: Adding support for a new architecture whose config uses an unregistered activation string; typo in config; aliases not normalized (case is handled via .lower(), but underscores/aliases are not).
Related errors
- Unsupported activation: {hidden_act}. Only silu is supported
- scalar_type_id {scalar_type_id} doesn't exists.
- Helion KDA decode requires power-of-two key and value head d
- `A_log` must have {HV} elements (got {A_log.numel()}).
- `dt_bias` must have {HV * K} elements (got {dt_bias.numel()}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7970324c73fcf199.
Report an issue: GitHub.