{"record":{"id":"5cb5ead3c4f8a63f","repo":"sgl-project/sglang","slug":"real-esrgan-weight-file-resolved-path-is-not-c","errorCode":null,"errorMessage":"Real-ESRGAN weight file '{resolved_path}' is not compatible with the supported architectures (SRVGGNetCompact / RRDBNet). Please ensure you are using a valid Real-ESRGAN checkpoint. Original error: {e}","messagePattern":"Real-ESRGAN weight file '(.+?)' is not compatible with the supported architectures \\(SRVGGNetCompact / RRDBNet\\)\\. Please ensure you are using a valid Real-ESRGAN checkpoint\\. Original error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py","lineNumber":608,"sourceCode":"            )\n        except Exception as e:\n            raise RuntimeError(\n                f\"Failed to load Real-ESRGAN checkpoint from '{resolved_path}'. \"\n                f\"The file may be corrupted or not a valid PyTorch checkpoint. \"\n                f\"Original error: {e}\"\n            ) from e\n\n        # Some checkpoints wrap weights under a 'params' or 'params_ema' key\n        if \"params_ema\" in state_dict:\n            state_dict = state_dict[\"params_ema\"]\n        elif \"params\" in state_dict:\n            state_dict = state_dict[\"params\"]\n\n        try:\n            net = _build_net_from_state_dict(state_dict)\n            net.load_state_dict(state_dict, strict=True)\n        except (RuntimeError, KeyError) as e:\n            raise RuntimeError(\n                f\"Real-ESRGAN weight file '{resolved_path}' is not compatible \"\n                f\"with the supported architectures (SRVGGNetCompact / RRDBNet). \"\n                f\"Please ensure you are using a valid Real-ESRGAN checkpoint. \"\n                f\"Original error: {e}\"\n            ) from e\n        net.eval()\n\n        device = current_platform.get_local_torch_device()\n        if self._half_precision:\n            net = net.half()\n        net = net.to(device)\n\n        # Detect the model's native scale from network architecture\n        native_scale = 4  # sensible default\n        if hasattr(net, \"upscale\"):\n            native_scale = net.upscale\n        elif hasattr(net, \"scale\"):\n            native_scale = net.scale","sourceCodeStart":590,"sourceCodeEnd":626,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py#L590-L626","documentation":"RuntimeError raised when the loaded state_dict cannot be built into or loaded into SRVGGNetCompact/RRDBNet — _build_net_from_state_dict or strict load_state_dict raised RuntimeError/KeyError. The file is a valid torch checkpoint but not a supported Real-ESRGAN architecture.","triggerScenarios":"Loading weights for RealESRGAN-anime, a custom RRDB variant with different num_block/num_feat, or a non-Real-ESRGAN super-resolution model; strict=True load failing on extra/missing keys.","commonSituations":"Wrong checkpoint variant chosen for the model class; partially exported state_dicts; checkpoints from newer Real-ESRGAN versions with extra keys.","solutions":["Use a checkpoint for the supported architectures (SRVGGNetCompact 'realesr-animevideo' or RRDBNet 'x4plus/x2plus')","Check the state_dict keys with torch.load and compare against expected layout","Provide the exact file via 'repo_id:filename' syntax"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"sd = torch.load(pth, map_location=\"cpu\", weights_only=True)\nassert any(k.startswith(\"body.\") for k in sd) or k in sd for k in (), \"\"","typeGuard":null,"tryCatchPattern":"try:\n    upscaler.upscale(img)\nexcept RuntimeError as e:\n    if \"not compatible\" in str(e):\n        raise ValueError(f\"bad checkpoint: {e}\") from e\n    raise","preventionTips":["Pin checkpoint versions in configs","Test each new checkpoint with a one-off upscale before production use"],"tags":["realesrgan","checkpoint","architecture","postprocess"],"backgroundTag":"incompatible-checkpoint","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}