sgl-project/sglang · error · ValueError

Unsupported activation type: {act_type}

Error message

Unsupported activation type: {act_type}

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py:109

        self.body.append(self._make_act(act_type, num_feat))
        # body convs + activations
        for _ in range(num_conv):
            self.body.append(nn.Conv2d(num_feat, num_feat, 3, 1, 1))
            self.body.append(self._make_act(act_type, num_feat))
        # last conv: maps to out_ch * upscale^2 for pixel shuffle
        self.body.append(nn.Conv2d(num_feat, num_out_ch * upscale * upscale, 3, 1, 1))
        self.upsampler = nn.PixelShuffle(upscale)

    @staticmethod
    def _make_act(act_type: str, num_feat: int) -> nn.Module:
        if act_type == "relu":
            return nn.ReLU(inplace=True)
        elif act_type == "prelu":
            return nn.PReLU(num_parameters=num_feat)
        elif act_type == "leakyrelu":
            return nn.LeakyReLU(negative_slope=0.1, inplace=True)
        else:
            raise ValueError(f"Unsupported activation type: {act_type}")

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        out = x
        for layer in self.body:
            out = layer(out)
        out = self.upsampler(out)
        # residual addition with nearest upsampled input
        base = F.interpolate(x, scale_factor=self.upscale, mode="nearest")
        return out + base


class ResidualDenseBlock(nn.Module):
    """Residual Dense Block used in RRDB (RealESRGAN_x4plus)."""

    def __init__(self, num_feat: int = 64, num_grow_ch: int = 32):
        super().__init__()
        self.conv1 = nn.Conv2d(num_feat, num_grow_ch, 3, 1, 1)
        self.conv2 = nn.Conv2d(num_feat + num_grow_ch, num_grow_ch, 3, 1, 1)

View on GitHub (pinned to 0132848349)

Solutions

  1. Use one of 'relu', 'prelu', or 'leakyrelu' (case-sensitive)
  2. Lowercase the value from your config before passing

Example fix

// before
RRDB(act_type="ReLU")
// after
RRDB(act_type="relu")
Defensive patterns

Strategy: validation

Validate before calling

assert act_type in {"relu", "prelu", "leakyrelu"}, f"bad act_type {act_type}"

Type guard

def is_supported_act(a: str) -> bool:
    return a in {"relu", "prelu", "leakyrelu"}

Prevention

When it happens

Trigger: Constructing the RRDB module (via __init__) with act_type set to e.g. 'gelu', 'silu', 'swish', or a case variant like 'ReLU'.

Common situations: Porting configs from other upscaler repos whose activation vocabularies differ; typos; new ESRGAN variants using activations not ported here.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/bf845c7ff8757584. Report an issue: GitHub.