{"record":{"id":"8bd5a8a08f4df954","repo":"sgl-project/sglang","slug":"multi-output-conditioning-requires-at-least-one-pr","errorCode":null,"errorMessage":"Multi-output conditioning requires at least one prompt.","messagePattern":"Multi-output conditioning requires at least one prompt\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/utils/condition_expansion.py","lineNumber":30,"sourceCode":"    prompt_batch_size: int\n    sample_batch_size: int\n\n    @classmethod\n    def from_batch(cls, batch):\n        num_outputs = int(batch.num_outputs_per_prompt or 1)\n        if num_outputs <= 1:\n            return None\n        if isinstance(batch.prompt, list):\n            prompt_batch_size = len(batch.prompt)\n        elif batch.prompt is not None:\n            prompt_batch_size = 1\n        else:\n            raise ValueError(\n                \"Multi-output conditioning requires prompt text so the prompt \"\n                \"batch size is unambiguous.\"\n            )\n        if prompt_batch_size <= 0:\n            raise ValueError(\"Multi-output conditioning requires at least one prompt.\")\n        return cls(prompt_batch_size, prompt_batch_size * num_outputs)\n\n    def _expand_tensor(self, value: torch.Tensor, name: str) -> torch.Tensor:\n        current_batch_size = value.shape[0]\n        if current_batch_size == self.sample_batch_size:\n            return value\n        if current_batch_size != self.prompt_batch_size:\n            raise ValueError(\n                f\"{name} has batch dim {current_batch_size} (shape \"\n                f\"{tuple(value.shape)}); expected {self.prompt_batch_size} \"\n                f\"(per-prompt) or {self.sample_batch_size} (per-sample).\"\n            )\n        repeats = self.sample_batch_size // self.prompt_batch_size\n        return value.repeat_interleave(repeats, dim=0)\n\n    def _expand_tensors(self, value, name: str):\n        \"\"\"Expand a tensor or each tensor in a list, preserving its container.\"\"\"\n        if value is None:","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/utils/condition_expansion.py#L12-L48","documentation":"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.","triggerScenarios":"batch.prompt == [] with num_outputs > 1 passed into expand_conditioning_to_sample_batch.","commonSituations":"Empty batch constructed by mistake (filtered to zero items upstream); test fixture with an empty prompt list.","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"],"exampleFix":"# before\nbatch.prompt = []\n# after\nbatch.prompt = [\"prompt text\"]","handlingStrategy":"validation","validationCode":"if isinstance(batch.prompt, list):\n    assert len(batch.prompt) > 0, \"empty prompt list\"","typeGuard":"def has_prompts(batch) -> bool:\n    return batch.prompt is not None and (not isinstance(batch.prompt, list) or len(batch.prompt) > 0)","tryCatchPattern":null,"preventionTips":["Skip empty batches early in the processing loop","Assert non-empty prompt lists in test fixtures"],"tags":["batching","sampling","validation","empty-input"],"backgroundTag":"empty-batch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}