{"record":{"id":"7970324c73fcf199","repo":"sgl-project/sglang","slug":"activation-function-act-fn-name-r-is-not-support","errorCode":null,"errorMessage":"Activation function {act_fn_name!r} is not supported.","messagePattern":"Activation function (.+?) is not supported\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/activation.py","lineNumber":160,"sourceCode":"        \"\"\"PyTorch-native implementation equivalent to forward().\"\"\"\n        return x * torch.sigmoid(1.702 * x)\n\n\n_ACTIVATION_REGISTRY = {\n    \"gelu\": nn.GELU,\n    \"gelu_new\": NewGELU,\n    \"gelu_pytorch_tanh\": lambda: nn.GELU(approximate=\"tanh\"),\n    \"relu\": nn.ReLU,\n    \"silu\": nn.SiLU,\n    \"quick_gelu\": QuickGELU,\n}\n\n\ndef get_act_fn(act_fn_name: str) -> nn.Module:\n    \"\"\"Get an activation function by name.\"\"\"\n    act_fn_name = act_fn_name.lower()\n    if act_fn_name not in _ACTIVATION_REGISTRY:\n        raise ValueError(f\"Activation function {act_fn_name!r} is not supported.\")\n\n    return _ACTIVATION_REGISTRY[act_fn_name]()\n","sourceCodeStart":142,"sourceCodeEnd":163,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/activation.py#L142-L163","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"# before\nact = get_act_fn('swish')  # ValueError\n# after\n# register alias near the registry definition\n_ACTIVATION_REGISTRY['swish'] = _ACTIVATION_REGISTRY['silu']\nact = get_act_fn('swish')","handlingStrategy":"validation","validationCode":"from sglang.multimodal_gen.runtime.layers.activation import _ACTIVATION_REGISTRY\nname = cfg.hidden_act.lower()\nif name not in _ACTIVATION_REGISTRY:\n    raise SystemExit(f\"unsupported activation {name}; supported: {sorted(_ACTIVATION_REGISTRY)}\")","typeGuard":"def is_supported_act(name: str) -> bool:\n    from ...activation import _ACTIVATION_REGISTRY\n    return name.lower() in _ACTIVATION_REGISTRY","tryCatchPattern":null,"preventionTips":["Register aliases (swish→silu, gelu_new→tanh-gelu) at app startup.","Validate model configs against the registry before building layers."],"tags":["activation","registry","lookup-failed","model-config"],"backgroundTag":"unsupported-activation-function","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}