sgl-project/sglang · error · ValueError

Cannot use multiple prompts with a fixed output_file_name. E

Error message

Cannot use multiple prompts with a fixed output_file_name. Either remove --output-file-name or use a single prompt.

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py:246

    def generate(
        self,
        sampling_params_kwargs: dict | None = None,
        external_trace_header: dict[str, str] | None = None,
    ) -> GenerationResult | list[GenerationResult] | None:
        """Generate image(s)/video(s) based on the given prompt(s).

        Returns a single GenerationResult for a single prompt, a list for
        multiple prompts, or None when every request failed.
        """
        # 1. prepare requests
        prompts = self._resolve_prompts(
            sampling_params_kwargs.get("prompt"),
            sampling_params_kwargs.get("prompt_path"),
        )
        user_output_file_name = sampling_params_kwargs.get("output_file_name")

        if len(prompts) > 1 and user_output_file_name is not None:
            raise ValueError(
                "Cannot use multiple prompts with a fixed output_file_name. "
                "Either remove --output-file-name or use a single prompt."
            )

        sampling_params_orig = SamplingParams.from_user_sampling_params_args(
            self.server_args.model_path,
            server_args=self.server_args,
            **sampling_params_kwargs,
        )

        request_groups: list[list[Req]] = []
        parent_requests: list[tuple[Req, int]] = []
        image_paths_per_prompt = self._resolve_image_paths_per_prompt(
            prompts, sampling_params_orig.image_path
        )

        for i, p in enumerate(prompts):
            sampling_params = _replace_sampling_params_for_prompt(

View on GitHub (pinned to 0132848349)

Solutions

  1. Remove output_file_name / --output-file-name and let the generator auto-name outputs per prompt
  2. Reduce to a single prompt if the fixed filename is required
  3. Set output_file_name=None explicitly when batching programmatically

Example fix

# before
generator.generate(prompt=["p1","p2"], output_file_name="out.png")
# after
generator.generate(prompt=["p1","p2"])  # auto-generated per-prompt filenames
Defensive patterns

Strategy: validation

Validate before calling

def check_batch_args(prompts, output_file_name):
    if len(prompts) > 1:
        assert output_file_name is None, "remove output_file_name when batching prompts"

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/71fd1f0dd94adf83. Report an issue: GitHub.