{"record":{"id":"bf845c7ff8757584","repo":"sgl-project/sglang","slug":"unsupported-activation-type-act-type","errorCode":null,"errorMessage":"Unsupported activation type: {act_type}","messagePattern":"Unsupported activation type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py","lineNumber":109,"sourceCode":"        self.body.append(self._make_act(act_type, num_feat))\n        # body convs + activations\n        for _ in range(num_conv):\n            self.body.append(nn.Conv2d(num_feat, num_feat, 3, 1, 1))\n            self.body.append(self._make_act(act_type, num_feat))\n        # last conv: maps to out_ch * upscale^2 for pixel shuffle\n        self.body.append(nn.Conv2d(num_feat, num_out_ch * upscale * upscale, 3, 1, 1))\n        self.upsampler = nn.PixelShuffle(upscale)\n\n    @staticmethod\n    def _make_act(act_type: str, num_feat: int) -> nn.Module:\n        if act_type == \"relu\":\n            return nn.ReLU(inplace=True)\n        elif act_type == \"prelu\":\n            return nn.PReLU(num_parameters=num_feat)\n        elif act_type == \"leakyrelu\":\n            return nn.LeakyReLU(negative_slope=0.1, inplace=True)\n        else:\n            raise ValueError(f\"Unsupported activation type: {act_type}\")\n\n    def forward(self, x: torch.Tensor) -> torch.Tensor:\n        out = x\n        for layer in self.body:\n            out = layer(out)\n        out = self.upsampler(out)\n        # residual addition with nearest upsampled input\n        base = F.interpolate(x, scale_factor=self.upscale, mode=\"nearest\")\n        return out + base\n\n\nclass ResidualDenseBlock(nn.Module):\n    \"\"\"Residual Dense Block used in RRDB (RealESRGAN_x4plus).\"\"\"\n\n    def __init__(self, num_feat: int = 64, num_grow_ch: int = 32):\n        super().__init__()\n        self.conv1 = nn.Conv2d(num_feat, num_grow_ch, 3, 1, 1)\n        self.conv2 = nn.Conv2d(num_feat + num_grow_ch, num_grow_ch, 3, 1, 1)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py#L91-L127","documentation":"Raised in realesrgan_upscaler._make_act when the act_type string for an RRDB block activation is not one of the supported values ('relu', 'prelu', 'leakyrelu'). It mirrors Real-ESRGAN's own activation dispatch.","triggerScenarios":"Constructing the RRDB module (via __init__) with act_type set to e.g. 'gelu', 'silu', 'swish', or a case variant like 'ReLU'.","commonSituations":"Porting configs from other upscaler repos whose activation vocabularies differ; typos; new ESRGAN variants using activations not ported here.","solutions":["Use one of 'relu', 'prelu', or 'leakyrelu' (case-sensitive)","Lowercase the value from your config before passing"],"exampleFix":"// before\nRRDB(act_type=\"ReLU\")\n// after\nRRDB(act_type=\"relu\")","handlingStrategy":"validation","validationCode":"assert act_type in {\"relu\", \"prelu\", \"leakyrelu\"}, f\"bad act_type {act_type}\"","typeGuard":"def is_supported_act(a: str) -> bool:\n    return a in {\"relu\", \"prelu\", \"leakyrelu\"}","tryCatchPattern":null,"preventionTips":["Validate config values against the supported set at load time","Lowercase activation names from external configs"],"tags":["realesrgan","activation","config","postprocess"],"backgroundTag":"unsupported-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}