sgl-project/sglang · error · ValueError
dynamic_batch_seeds must be a list with one seed per prompt
Error message
dynamic_batch_seeds must be a list with one seed per prompt
What it means
_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.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py:89
"""Generate deterministic per-output seeds.
Batched requests pass one base seed per prompt through `extra`; each
prompt expands to `num_outputs_per_prompt` consecutive seeds.
"""
seed = batch.seed
num_videos_per_prompt = batch.num_outputs_per_prompt
assert seed is not None
prompt_count = len(batch.prompt) if isinstance(batch.prompt, list) else 1
dynamic_batch_seeds = batch.extra.get("dynamic_batch_seeds")
if dynamic_batch_seeds is not None:
if (
not isinstance(dynamic_batch_seeds, list)
or len(dynamic_batch_seeds) != prompt_count
):
raise ValueError(
"dynamic_batch_seeds must be a list with one seed per prompt"
)
base_seeds = [int(item) for item in dynamic_batch_seeds]
seeds = []
for base_seed in base_seeds:
seeds.extend([base_seed + i for i in range(num_videos_per_prompt)])
elif isinstance(seed, list):
if len(seed) != num_videos_per_prompt:
raise ValueError(
f"seed list length must match num_outputs_per_prompt "
f"({num_videos_per_prompt}), got {len(seed)}"
)
seeds = [int(item) for item in seed]
else:
# Keep per-prompt seed streams deterministic and non-overlapping.
base_seeds = [
int(seed) + i * num_videos_per_prompt for i in range(prompt_count)
]View on GitHub (pinned to 0132848349)
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
Example fix
// before result = pipe(prompts=["a", "b"], dynamic_batch_seeds=[42]) // after result = pipe(prompts=["a", "b"], dynamic_batch_seeds=[42, 43])
Defensive patterns
Strategy: validation
Validate before calling
if dynamic_batch_seeds is not None:
assert isinstance(dynamic_batch_seeds, list) and len(dynamic_batch_seeds) == len(prompts), \
"dynamic_batch_seeds must have one entry per prompt" Type guard
def valid_dynamic_seeds(s, prompt_count: int) -> bool:
return isinstance(s, list) and len(s) == prompt_count Prevention
- Convert tensors/arrays to plain int lists before calling
- Build the seed list with a list comprehension over prompts
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- seed list length must match num_outputs_per_prompt ({num_vid
- unsupported input for causal Conv3D cat/pad CUDA
- unsupported input for usp_merge_heads CUDA
- unsupported input for modulate_scale_shift CUDA
- unsupported input for LTX2 QKNorm split-RoPE CUDA
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/ca09dde3a86425ee.
Report an issue: GitHub.