{"record":{"id":"71fd1f0dd94adf83","repo":"sgl-project/sglang","slug":"cannot-use-multiple-prompts-with-a-fixed-output-fi","errorCode":null,"errorMessage":"Cannot use multiple prompts with a fixed output_file_name. Either remove --output-file-name or use a single prompt.","messagePattern":"Cannot use multiple prompts with a fixed output_file_name\\. Either remove --output-file-name or use a single prompt\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py","lineNumber":246,"sourceCode":"    def generate(\n        self,\n        sampling_params_kwargs: dict | None = None,\n        external_trace_header: dict[str, str] | None = None,\n    ) -> GenerationResult | list[GenerationResult] | None:\n        \"\"\"Generate image(s)/video(s) based on the given prompt(s).\n\n        Returns a single GenerationResult for a single prompt, a list for\n        multiple prompts, or None when every request failed.\n        \"\"\"\n        # 1. prepare requests\n        prompts = self._resolve_prompts(\n            sampling_params_kwargs.get(\"prompt\"),\n            sampling_params_kwargs.get(\"prompt_path\"),\n        )\n        user_output_file_name = sampling_params_kwargs.get(\"output_file_name\")\n\n        if len(prompts) > 1 and user_output_file_name is not None:\n            raise ValueError(\n                \"Cannot use multiple prompts with a fixed output_file_name. \"\n                \"Either remove --output-file-name or use a single prompt.\"\n            )\n\n        sampling_params_orig = SamplingParams.from_user_sampling_params_args(\n            self.server_args.model_path,\n            server_args=self.server_args,\n            **sampling_params_kwargs,\n        )\n\n        request_groups: list[list[Req]] = []\n        parent_requests: list[tuple[Req, int]] = []\n        image_paths_per_prompt = self._resolve_image_paths_per_prompt(\n            prompts, sampling_params_orig.image_path\n        )\n\n        for i, p in enumerate(prompts):\n            sampling_params = _replace_sampling_params_for_prompt(","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py#L228-L264","documentation":"DiffusionGenerator.generate refuses to run when more than one prompt is combined with an explicit output_file_name. A fixed output filename can only name one artifact; with N prompts the scheduler would produce N outputs that would all collide on the same path, so the guard fails fast.","triggerScenarios":"Calling generate(prompt=[p1,p2], output_file_name='out.png') or launching the server/CLI with --prompt-file containing multiple lines plus --output-file-name.","commonSituations":"Using a prompt file for batch generation while leaving a single-prompt --output-file-name flag in the launch args; migrating a single-prompt script to batch mode without removing the filename argument.","solutions":["Remove output_file_name / --output-file-name and let the generator auto-name outputs per prompt","Reduce to a single prompt if the fixed filename is required","Set output_file_name=None explicitly when batching programmatically"],"exampleFix":"# before\ngenerator.generate(prompt=[\"p1\",\"p2\"], output_file_name=\"out.png\")\n# after\ngenerator.generate(prompt=[\"p1\",\"p2\"])  # auto-generated per-prompt filenames","handlingStrategy":"validation","validationCode":"def check_batch_args(prompts, output_file_name):\n    if len(prompts) > 1:\n        assert output_file_name is None, \"remove output_file_name when batching prompts\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass output_file_name in batch scripts; reserve it for single-prompt runs","Wrap CLI launch configs so --output-file-name is dropped automatically when a prompt file has >1 line"],"tags":["input-validation","file-output","batch-generation"],"backgroundTag":"invalid-argument-combination","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}