sgl-project/sglang · critical · RuntimeError
Expected {request_count} outputs, got {output_count} from sc
Error message
Expected {request_count} outputs, got {output_count} from scheduler What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py:550
else:
size = (req.height, req.width, req.num_frames)
return dict(
prompt=req.prompt,
size=size,
generation_time=generation_time,
peak_memory_mb=output_batch.peak_memory_mb,
metrics=metrics.to_dict() if metrics else {},
action=output_batch.action_pred,
trajectory_latents=output_batch.trajectory_latents,
trajectory_timesteps=output_batch.trajectory_timesteps,
rollout_trajectory_data=output_batch.rollout_trajectory_data,
trajectory_decoded=output_batch.trajectory_decoded,
)
@staticmethod
def _validate_output_count(output_count: int, request_count: int) -> None:
if output_count != request_count:
raise RuntimeError(
f"Expected {request_count} outputs, got {output_count} from scheduler"
)
def _send_to_scheduler_and_wait_for_response(self, batch: list[Req]) -> OutputBatch:
"""
Sends a request to the scheduler and waits for a response.
"""
return sync_scheduler_client.forward(batch)
# LoRA
def _send_lora_request(self, req: Any, success_msg: str, failure_msg: str):
response = sync_scheduler_client.forward(req)
if response.error is None:
logger.info(success_msg)
return response
else:
error_msg = response.error
raise RuntimeError(f"{failure_msg}: {error_msg}")View on GitHub (pinned to 0132848349)
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
Defensive patterns
Strategy: retry
Try / catch
for attempt in range(2):
try:
return generator.generate(prompt=prompts)
except RuntimeError as e:
if "from scheduler" not in str(e) or attempt == 1:
raise
logger.warning("output count mismatch, retrying: %s", e) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {output_batch.error}
- action policy returned no output
- Subclasses of BaseScheduler must define '{attr}' property
- denoising_strength must be positive
- Must pass a value for `mu` when `use_dynamic_shifting` is Tr
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/c9201f985134e228.
Report an issue: GitHub.