{"record":{"id":"b336d85e8ff82ae8","repo":"sgl-project/sglang","slug":"seed-list-length-must-match-num-outputs-per-prompt-b336d8","errorCode":null,"errorMessage":"seed list length must match num_outputs_per_prompt ({num_videos_per_prompt}), got {len(seed)}","messagePattern":"seed list length must match num_outputs_per_prompt \\((.+?)\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py","lineNumber":98,"sourceCode":"\n        prompt_count = len(batch.prompt) if isinstance(batch.prompt, list) else 1\n        dynamic_batch_seeds = batch.extra.get(\"dynamic_batch_seeds\")\n\n        if dynamic_batch_seeds is not None:\n            if (\n                not isinstance(dynamic_batch_seeds, list)\n                or len(dynamic_batch_seeds) != prompt_count\n            ):\n                raise ValueError(\n                    \"dynamic_batch_seeds must be a list with one seed per prompt\"\n                )\n            base_seeds = [int(item) for item in dynamic_batch_seeds]\n            seeds = []\n            for base_seed in base_seeds:\n                seeds.extend([base_seed + i for i in range(num_videos_per_prompt)])\n        elif isinstance(seed, list):\n            if len(seed) != num_videos_per_prompt:\n                raise ValueError(\n                    f\"seed list length must match num_outputs_per_prompt \"\n                    f\"({num_videos_per_prompt}), got {len(seed)}\"\n                )\n            seeds = [int(item) for item in seed]\n        else:\n            # Keep per-prompt seed streams deterministic and non-overlapping.\n            base_seeds = [\n                int(seed) + i * num_videos_per_prompt for i in range(prompt_count)\n            ]\n            seeds = []\n            for base_seed in base_seeds:\n                seeds.extend([base_seed + i for i in range(num_videos_per_prompt)])\n        batch.seeds = seeds\n\n        # Create generators based on generator_device parameter\n        # Note: This will overwrite any existing batch.generator\n        generator_device = batch.generator_device\n        if generator_device is None:","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py#L80-L116","documentation":"When the seed argument is passed as a list, its length must equal num_videos_per_prompt (the number of outputs generated per prompt); the stage builds one seed per output. Any other length is rejected to keep the seed-to-output mapping deterministic.","triggerScenarios":"Calling generation with seed=[s1, s2] (or an empty list) while num_videos_per_prompt=1 (the default), or setting num_videos_per_prompt=4 but providing fewer seeds.","commonSituations":"Copying seed lists from multi-output examples into default single-output requests; changing num_outputs/num_videos_per_prompt without adjusting the seed list; confusing per-prompt seeds (dynamic_batch_seeds) with per-output seeds.","solutions":["Either pass a single int seed instead of a list for the common one-output case, or make len(seed) == num_videos_per_prompt","If you want per-prompt seeds with multiple prompts, use dynamic_batch_seeds instead of a seed list"],"exampleFix":"// before\nout = pipe(prompt=\"sunset\", seed=[1, 2], num_videos_per_prompt=1)\n\n// after\nout = pipe(prompt=\"sunset\", seed=[1, 2], num_videos_per_prompt=2)","handlingStrategy":"validation","validationCode":"if isinstance(seed, list):\n    assert len(seed) == num_videos_per_prompt, f\"need {num_videos_per_prompt} seeds, got {len(seed)}\"","typeGuard":"def valid_seed_list(seed, n: int) -> bool:\n    return not isinstance(seed, list) or len(seed) == n","tryCatchPattern":null,"preventionTips":["Prefer a single int seed unless generating multiple outputs per prompt","Use dynamic_batch_seeds for per-prompt variation"],"tags":["seed","input-validation","num-outputs"],"backgroundTag":"argument-length-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}