{"record":{"id":"c9201f985134e228","repo":"sgl-project/sglang","slug":"expected-request-count-outputs-got-output-coun","errorCode":null,"errorMessage":"Expected {request_count} outputs, got {output_count} from scheduler","messagePattern":"Expected (.+?) outputs, got (.+?) from scheduler","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py","lineNumber":550,"sourceCode":"        else:\n            size = (req.height, req.width, req.num_frames)\n        return dict(\n            prompt=req.prompt,\n            size=size,\n            generation_time=generation_time,\n            peak_memory_mb=output_batch.peak_memory_mb,\n            metrics=metrics.to_dict() if metrics else {},\n            action=output_batch.action_pred,\n            trajectory_latents=output_batch.trajectory_latents,\n            trajectory_timesteps=output_batch.trajectory_timesteps,\n            rollout_trajectory_data=output_batch.rollout_trajectory_data,\n            trajectory_decoded=output_batch.trajectory_decoded,\n        )\n\n    @staticmethod\n    def _validate_output_count(output_count: int, request_count: int) -> None:\n        if output_count != request_count:\n            raise RuntimeError(\n                f\"Expected {request_count} outputs, got {output_count} from scheduler\"\n            )\n\n    def _send_to_scheduler_and_wait_for_response(self, batch: list[Req]) -> OutputBatch:\n        \"\"\"\n        Sends a request to the scheduler and waits for a response.\n        \"\"\"\n        return sync_scheduler_client.forward(batch)\n\n    # LoRA\n    def _send_lora_request(self, req: Any, success_msg: str, failure_msg: str):\n        response = sync_scheduler_client.forward(req)\n        if response.error is None:\n            logger.info(success_msg)\n            return response\n        else:\n            error_msg = response.error\n            raise RuntimeError(f\"{failure_msg}: {error_msg}\")","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py#L532-L568","documentation":"DiffusionGenerator._validate_output_count checks that the number of results returned by the scheduler equals the number of requests sent. A mismatch means the scheduler dropped, duplicated, or mis-batched outputs — an internal consistency failure, not a user-input problem.","triggerScenarios":"generate() with N prompts where output_batch.output (or output_file_paths) has length != N; typically after a scheduler bug, a mixed output mode, or a partial failure where some requests produced files and others produced tensors.","commonSituations":"Scheduler version skew after a partial upgrade; a request in the batch aborted so its output is missing; mixing output modes (some requests writing files, some returning latents) so one list is shorter.","solutions":["Retry the call once — transient scheduler hiccups can cause one-off mismatches","Update/align sglang versions between client and scheduler processes","Check scheduler logs for aborted or failed individual requests within the batch","If reproducible, reduce the batch to isolate which prompt triggers the mismatch and report it with logs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        return generator.generate(prompt=prompts)\n    except RuntimeError as e:\n        if \"from scheduler\" not in str(e) or attempt == 1:\n            raise\n        logger.warning(\"output count mismatch, retrying: %s\", e)","preventionTips":["Pin matching client/scheduler sglang versions","Avoid mixed output modes (files vs tensors) within one batch","Batch smaller groups so mismatches are easier to bisect"],"tags":["scheduler","consistency-check","batch-generation","diffusion"],"backgroundTag":"response-count-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}