sgl-project/sglang · error · ValueError
Unsupported RRDBNet conv_first input channels: {in_channels}
Error message
Unsupported RRDBNet conv_first input channels: {in_channels} What it means
Raised in realesrgan_upscaler._build_net_from_state_dict when inferring scale from the RRDBNet checkpoint's conv_first weight shape: 3→scale 4, 12→scale 2, 48→scale 1. Any other input-channel count means the checkpoint is not a standard RRDBNet real-ESRGAN model.
Source
Thrown at python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py:226
# ---------------------------------------------------------------------------
# Architecture auto-detection
# ---------------------------------------------------------------------------
def _build_net_from_state_dict(state_dict: dict) -> nn.Module:
"""Detect architecture from checkpoint keys and return an unloaded network."""
if "conv_first.weight" in state_dict:
# RRDBNet (e.g., RealESRGAN_x4plus)
num_feat = state_dict["conv_first.weight"].shape[0]
in_channels = state_dict["conv_first.weight"].shape[1]
if in_channels == 3:
scale = 4
elif in_channels == 12:
scale = 2
elif in_channels == 48:
scale = 1
else:
raise ValueError(
f"Unsupported RRDBNet conv_first input channels: {in_channels}"
)
num_block = sum(
1
for k in state_dict
if k.startswith("body.") and k.endswith(".rdb1.conv1.weight")
)
num_grow_ch = state_dict["body.0.rdb1.conv1.weight"].shape[0]
logger.info(
"Detected RRDBNet: num_feat=%d, num_block=%d, num_grow_ch=%d, scale=%d",
num_feat,
num_block,
num_grow_ch,
scale,
)
return RRDBNet(
num_in_ch=3,
num_out_ch=3,View on GitHub (pinned to 0132848349)
Solutions
- Use a standard Real-ESRGAN RRDBNet or SRVGGNetCompact checkpoint (e.g. RealESRGAN_x4plus)
- Point model_path at a local .pth or 'repo_id:filename' for a supported model
Example fix
// before upscaler = RealESRGANUpscaler(model_path="some_srgan.pth") // after upscaler = RealESRGANUpscaler(model_path="ai-forever/RealESRGAN_x4:RealESRGAN_x4.pth")
Defensive patterns
Strategy: try-catch
Validate before calling
sd = torch.load(pth, map_location="cpu", weights_only=True)
ch = sd.get("conv_first.weight").shape[1]
assert ch in (3, 12, 48), f"unsupported RRDB channels {ch}" Try / catch
try:
upscaler.upscale(frame)
except RuntimeError as e:
if "not compatible" in str(e) or "conv_first" in str(e):
raise ValueError("Use a standard Real-ESRGAN checkpoint") from e
raise Prevention
- Smoke-test new checkpoints standalone with torch.load before wiring them in
- Stick to published Real-ESRGAN x4plus/x2plus/animevideo checkpoints
When it happens
Trigger: Loading a .pth whose 'conv_first.weight' has an unexpected first dimension (e.g. 1, 6, or 64 channels), typically a different super-resolution architecture or a non-image model.
Common situations: Pointing model_path at a vanilla ESRGAN/SRGAN/Real-ESRGAN anime-video variant with different channel layout, or at an unrelated PyTorch file.
Related errors
- Real-ESRGAN weight file '{resolved_path}' is not compatible
- Failed to load Real-ESRGAN checkpoint from '{resolved_path}'
- Unsupported activation type: {act_type}
- All frames in a batch must have the same resolution
- RealESRGAN batch upscale did not produce all frames
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/e955c0d49ec0fd1c.
Report an issue: GitHub.