{"record":{"id":"71a860f618419cae","repo":"sgl-project/sglang","slug":"activation-function-act-fn-name-r-is-not-support-71a860","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/srt/layers/activation.py","lineNumber":478,"sourceCode":"    \"gelu\": nn.GELU(),\n    \"gelu_pytorch_tanh\": nn.GELU(approximate=\"tanh\"),\n    \"gelu_new\": NewGELU(),\n    \"relu2\": ReLU2(),\n    \"xielu\": XIELU(),\n}\n\n\ndef get_act_fn(\n    act_fn_name: str,\n    quant_config: Optional[QuantizationConfig] = None,\n    intermediate_size: Optional[int] = None,\n    input_is_parallel: bool = True,\n    params_dtype: Optional[torch.dtype] = None,\n) -> 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    act_fn = _ACTIVATION_REGISTRY[act_fn_name]\n    if quant_config is not None and act_fn_name in quant_config.get_scaled_act_names():\n        if intermediate_size is None:\n            raise ValueError(\n                \"intermediate_size must be specified for scaled \"\n                \"activation functions.\"\n            )\n        return ScaledActivation(\n            act_fn, intermediate_size, input_is_parallel, params_dtype\n        )\n    return act_fn\n\n\ndef get_cross_encoder_activation_function(config: PretrainedConfig):\n    if (\n        hasattr(config, \"sbert_ce_default_activation_function\")\n        and config.sbert_ce_default_activation_function is not None","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/activation.py#L460-L496","documentation":"get_act_fn resolves activation functions by lowercased name from the _ACTIVATION_REGISTRY; an unknown name raises ValueError. Supported names are whatever the registry contains (gelu, gelu_tanh, silu, relu, sigmoid, swiglu-style names, etc.).","triggerScenarios":"Calling get_act_fn('geglu') / 'quick_gelu' / 'silu_fp8' or any string not present in _ACTIVATION_REGISTRY; typo or a name from another framework (vLLM vs SGLang naming differences, e.g. 'gelu_new' vs 'gelu').","commonSituations":"Model config's hidden_act uses a name SGLang's registry doesn't map (newer model arch, HF-only activation name); porting a model implementation that hardcodes a different activation string.","solutions":["Check _ACTIVATION_REGISTRY keys (from sglang.srt.layers.activation) for the exact supported names and use the closest match (e.g. 'gelu_new' -> 'gelu')","Update SGLang to a version that registers your activation","Add the activation to the registry with an implementation and upstream it"],"exampleFix":"# before\nact = get_act_fn('quick_gelu')\n# after\nfrom sglang.srt.layers.activation import _ACTIVATION_REGISTRY\nname = 'quick_gelu' if 'quick_gelu' in _ACTIVATION_REGISTRY else 'gelu'\nact = get_act_fn(name)","handlingStrategy":"type-guard","validationCode":"from sglang.srt.layers.activation import _ACTIVATION_REGISTRY\nname = hidden_act.lower()\nif name not in _ACTIVATION_REGISTRY:\n    name = {'gelu_new': 'gelu', 'quick_gelu': 'gelu'}.get(name, 'silu')\nact = get_act_fn(name)","typeGuard":"def is_supported_act(name: str) -> bool:\n    return name.lower() in _ACTIVATION_REGISTRY","tryCatchPattern":"try:\n    act = get_act_fn(hidden_act)\nexcept ValueError:\n    act = get_act_fn('silu')  # safe fallback for registry misses","preventionTips":["Check _ACTIVATION_REGISTRY keys when porting new models","Normalize HF hidden_act names to SGLang's registry names in the model loader"],"tags":["activation","config","valueerror","model-loading"],"backgroundTag":"unsupported-activation-function","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}