sgl-project/sglang · error · ValueError
Multi-output conditioning requires at least one prompt.
Error message
Multi-output conditioning requires at least one prompt.
What it means
Thrown by ConditionExpansion.from_batch when the computed prompt_batch_size is <= 0, i.e. batch.prompt is an empty list, so there is nothing to expand even though multi-output conditioning was requested.
Source
Thrown at python/sglang/multimodal_gen/runtime/utils/condition_expansion.py:30
prompt_batch_size: int
sample_batch_size: int
@classmethod
def from_batch(cls, batch):
num_outputs = int(batch.num_outputs_per_prompt or 1)
if num_outputs <= 1:
return None
if isinstance(batch.prompt, list):
prompt_batch_size = len(batch.prompt)
elif batch.prompt is not None:
prompt_batch_size = 1
else:
raise ValueError(
"Multi-output conditioning requires prompt text so the prompt "
"batch size is unambiguous."
)
if prompt_batch_size <= 0:
raise ValueError("Multi-output conditioning requires at least one prompt.")
return cls(prompt_batch_size, prompt_batch_size * num_outputs)
def _expand_tensor(self, value: torch.Tensor, name: str) -> torch.Tensor:
current_batch_size = value.shape[0]
if current_batch_size == self.sample_batch_size:
return value
if current_batch_size != self.prompt_batch_size:
raise ValueError(
f"{name} has batch dim {current_batch_size} (shape "
f"{tuple(value.shape)}); expected {self.prompt_batch_size} "
f"(per-prompt) or {self.sample_batch_size} (per-sample)."
)
repeats = self.sample_batch_size // self.prompt_batch_size
return value.repeat_interleave(repeats, dim=0)
def _expand_tensors(self, value, name: str):
"""Expand a tensor or each tensor in a list, preserving its container."""
if value is None:View on GitHub (pinned to 0132848349)
Solutions
- Ensure the batch contains at least one prompt before calling expansion
- Guard upstream: skip processing when the batch is empty
- Fix the upstream filter/slicing that produced an empty prompt list
Example fix
# before batch.prompt = [] # after batch.prompt = ["prompt text"]
Defensive patterns
Strategy: validation
Validate before calling
if isinstance(batch.prompt, list):
assert len(batch.prompt) > 0, "empty prompt list" Type guard
def has_prompts(batch) -> bool:
return batch.prompt is not None and (not isinstance(batch.prompt, list) or len(batch.prompt) > 0) Prevention
- Skip empty batches early in the processing loop
- Assert non-empty prompt lists in test fixtures
When it happens
Trigger: batch.prompt == [] with num_outputs > 1 passed into expand_conditioning_to_sample_batch.
Common situations: Empty batch constructed by mistake (filtered to zero items upstream); test fixture with an empty prompt list.
Related errors
- Multi-output conditioning requires prompt text so the prompt
- kv-canary: RealKvSource.read_bytes must be a positive multip
- top_p must be scalar or have one value per row, got {top_ps.
- top_p values must be in (0, 1]
- top_k must be scalar or have one value per row, got {top_ks.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/8bd5a8a08f4df954.
Report an issue: GitHub.