{"record":{"id":"ca09dde3a86425ee","repo":"sgl-project/sglang","slug":"dynamic-batch-seeds-must-be-a-list-with-one-seed-p","errorCode":null,"errorMessage":"dynamic_batch_seeds must be a list with one seed per prompt","messagePattern":"dynamic_batch_seeds must be a list with one seed per prompt","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py","lineNumber":89,"sourceCode":"        \"\"\"Generate deterministic per-output seeds.\n\n        Batched requests pass one base seed per prompt through `extra`; each\n        prompt expands to `num_outputs_per_prompt` consecutive seeds.\n        \"\"\"\n        seed = batch.seed\n        num_videos_per_prompt = batch.num_outputs_per_prompt\n\n        assert seed is not None\n\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            ]","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py#L71-L107","documentation":"_generate_seeds validates the optional dynamic_batch_seeds argument: when provided it must be a Python list whose length exactly equals the number of prompts in the request. Anything else (scalar, tuple, numpy array, wrong-length list) is rejected because per-prompt seed streams must map one-to-one onto prompts.","triggerScenarios":"Passing dynamic_batch_seeds as an int, a single-element list for a multi-prompt request, a tensor/array instead of a list, or a list built for a different prompt count than the current call.","commonSituations":"Porting code that used a single seed; batching multiple prompts but reusing a one-element seed list; passing numpy arrays or tensors from a data loader instead of plain lists; off-by-one when concatenating prompt batches.","solutions":["Pass a plain Python list of ints with exactly len(prompts) entries, e.g. dynamic_batch_seeds=[42, 43] for two prompts","If you only have one seed, omit dynamic_batch_seeds and use the regular seed argument","Convert tensors/arrays via [int(s) for s in seeds] before calling"],"exampleFix":"// before\nresult = pipe(prompts=[\"a\", \"b\"], dynamic_batch_seeds=[42])\n\n// after\nresult = pipe(prompts=[\"a\", \"b\"], dynamic_batch_seeds=[42, 43])","handlingStrategy":"validation","validationCode":"if dynamic_batch_seeds is not None:\n    assert isinstance(dynamic_batch_seeds, list) and len(dynamic_batch_seeds) == len(prompts), \\\n        \"dynamic_batch_seeds must have one entry per prompt\"","typeGuard":"def valid_dynamic_seeds(s, prompt_count: int) -> bool:\n    return isinstance(s, list) and len(s) == prompt_count","tryCatchPattern":null,"preventionTips":["Convert tensors/arrays to plain int lists before calling","Build the seed list with a list comprehension over prompts"],"tags":["seed","batch-validation","input-validation"],"backgroundTag":"argument-length-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}