{"record":{"id":"0099ec35b5510c50","repo":"sgl-project/sglang","slug":"expected-len-reqs-grouped-outputs-got-len-out","errorCode":null,"errorMessage":"Expected {len(reqs)} grouped outputs, got {len(output_batch.output)}","messagePattern":"Expected (.+?) grouped outputs, got (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/managers/gpu_worker.py","lineNumber":823,"sourceCode":"            output_compression=req.output_compression,\n            enable_frame_interpolation=req.enable_frame_interpolation,\n            frame_interpolation_exp=req.frame_interpolation_exp,\n            frame_interpolation_scale=req.frame_interpolation_scale,\n            frame_interpolation_model_path=req.frame_interpolation_model_path,\n            enable_upscaling=req.enable_upscaling,\n            upscaling_model_path=req.upscaling_model_path,\n            upscaling_scale=req.upscaling_scale,\n        )\n\n    def _save_group_output_paths(\n        self,\n        reqs: list[Req],\n        output_batch: OutputBatch,\n    ) -> None:\n        if not self.is_output_rank or output_batch.output is None:\n            return\n        if len(output_batch.output) != len(reqs):\n            raise RuntimeError(\n                f\"Expected {len(reqs)} grouped outputs, got {len(output_batch.output)}\"\n            )\n\n        first_req = reqs[0]\n        output_batch.output_file_paths = save_outputs(\n            output_batch.output,\n            first_req.data_type,\n            first_req.fps,\n            True,\n            lambda idx: reqs[idx].output_file_path(1, 0),\n            audio=output_batch.audio,\n            audio_sample_rate=output_batch.audio_sample_rate,\n            output_compression=first_req.output_compression,\n            enable_frame_interpolation=first_req.enable_frame_interpolation,\n            frame_interpolation_exp=first_req.frame_interpolation_exp,\n            frame_interpolation_scale=first_req.frame_interpolation_scale,\n            frame_interpolation_model_path=first_req.frame_interpolation_model_path,\n            enable_upscaling=first_req.enable_upscaling,","sourceCodeStart":805,"sourceCodeEnd":841,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/gpu_worker.py#L805-L841","documentation":"Before saving grouped outputs, the worker asserts that the OutputBatch's output list length equals the number of requests in the batch; a mismatch means the pipeline silently lost or duplicated outputs, so saving would misattribute files and the run aborts.","triggerScenarios":"_execute_forward_batch reaching _save_group_output_paths with len(output_batch.output) != len(reqs) on the output rank (e.g. 3 requests but only 2 generated outputs).","commonSituations":"Same root causes as the StopIteration wrapper: a pipeline stage dropping items, or output filtering (e.g. empty results removed) applied before this check; reproducible with specific grouped request mixes.","solutions":["Inspect logs for the preceding pipeline exception or drop point; this check is the symptom, not the cause","Reduce the batch size or disable grouping to isolate the request that gets dropped","Check for version mismatch between the pipeline implementation and gpu_worker after upgrading sglang","File an issue with the exact request batch that reproduces the count mismatch"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    worker._execute_forward_batch(batch)\nexcept RuntimeError as e:\n    if \"grouped outputs\" in str(e):\n        log_and_alert(\"output/req count mismatch\", batch_ids=batch.ids)\n        raise","preventionTips":["Monitor output-count assertions as a canary metric","Avoid custom pipeline stages that filter outputs before saving"],"tags":["runtime","pipeline","inference","assertion","multimodal"],"backgroundTag":"pipeline-output-count-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}