{"record":{"id":"4f9c8e0522804898","repo":"sgl-project/sglang","slug":"realesrgan-batch-upscale-did-not-produce-all-frame","errorCode":null,"errorMessage":"RealESRGAN batch upscale did not produce all frames","messagePattern":"RealESRGAN batch upscale did not produce all frames","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py","lineNumber":675,"sourceCode":"        output_frames: list[np.ndarray | None] = [None] * len(frames)\n        groups: dict[tuple[int, ...], list[int]] = {}\n        for idx, frame in enumerate(frames):\n            groups.setdefault(tuple(frame.shape), []).append(idx)\n\n        for shape, indices in groups.items():\n            logger.info(\n                \"RealESRGAN upscale group: frames=%d shape=%s indices=%s\",\n                len(indices),\n                shape,\n                indices,\n            )\n            group_frames = [frames[idx] for idx in indices]\n            group_outputs = model.upscale_batch(group_frames, outscale=outscale)\n            for idx, output in zip(indices, group_outputs):\n                output_frames[idx] = output\n\n        if any(frame is None for frame in output_frames):\n            raise RuntimeError(\"RealESRGAN batch upscale did not produce all frames\")\n\n        total_duration_s = time.perf_counter() - total_start_time\n        logger.info(\n            \"RealESRGAN batch_upscale_frames completed in %.3f seconds for %d frames across %d groups\",\n            total_duration_s,\n            len(frames),\n            len(groups),\n        )\n        return [frame for frame in output_frames if frame is not None]\n\n\n# ---------------------------------------------------------------------------\n# HF download helper\n# ---------------------------------------------------------------------------\n\n\ndef _resolve_model_path(model_path: str) -> str:\n    \"\"\"Return a local .pth file path.","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py#L657-L693","documentation":"RuntimeError raised by upscale_batched after processing resolution-grouped batches: at least one output slot is still None, meaning the underlying upscale_batch returned fewer outputs than input frames — an internal invariant violation, not user input error.","triggerScenarios":"Calling upscale_batched (via batch_upscale_frames) where model.upscale_batch for some group returns an empty or short list; typically a backend/model bug or an unexpected exception path that silently short-circuits a group.","commonSituations":"Custom monkeypatched or subclassed upscaler returning wrong-length lists; edge case with a single-frame group; version mismatch in the upscaler wrapper.","solutions":["Verify with a plain upscale_batch call on the same frames that outputs match input count","Update sglang to pick up fixes to the batching wrapper","File a bug with the frame group that produced the short output"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"out = upscaler.upscale_batch(group)\nassert len(out) == len(group)","typeGuard":null,"tryCatchPattern":"try:\n    frames = upscaler.upscale_batched(frames)\nexcept RuntimeError as e:\n    if \"did not produce all frames\" in str(e):\n        return [upscaler.upscale(f) for f in frames]  # per-frame fallback\n    raise","preventionTips":["Keep sglang updated for batching fixes","Add output-length assertions when wrapping the upscaler"],"tags":["realesrgan","batch","invariant","postprocess"],"backgroundTag":"output-count-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}