unslothai/unsloth · error · ValueError
seeds must be a non-empty list of integers
Error message
seeds must be a non-empty list of integers
What it means
When a seeds parameter is provided it must be a non-empty list of integers. seeds=[] (empty list) is rejected here; None means 'no seeds given' and is valid. Note the element-type check is not strict at this line — values are coerced with int(s) afterwards, and out-of-range values are caught by a separate check — but non-integer-coercible elements will raise on the int() conversion.
Source
Thrown at studio/backend/core/inference/diffusion_batched.py:67
"""The per-image ``(prompt, seed)`` jobs plus the base seed for this call.
- ``prompts`` (list): one image per prompt. With ``seeds`` too, lengths must
match (seed i drives prompt i); without, seeds derive from the base.
- ``seeds`` (list) alone: one image per seed, all with ``prompt``.
- neither: ``batch_size`` images of ``prompt`` with derived seeds
base..base+batch_size-1 (each masked JSON-safe).
``draw_seed`` supplies a fresh random base when the caller sent none (the
engine passes a ``torch.Generator`` draw). Raises ``ValueError`` on empty /
oversized lists, a length mismatch, or an out-of-range seed."""
if prompts is not None:
if not prompts or not all(isinstance(p, str) and p.strip() for p in prompts):
raise ValueError("prompts must be a non-empty list of non-empty strings")
if len(prompts) > MAX_BATCH_IMAGES:
raise ValueError(f"prompts supports at most {MAX_BATCH_IMAGES} entries per call")
if seeds is not None:
if not seeds:
raise ValueError("seeds must be a non-empty list of integers")
if len(seeds) > MAX_BATCH_IMAGES:
raise ValueError(f"seeds supports at most {MAX_BATCH_IMAGES} entries per call")
seeds = [int(s) for s in seeds]
if any(s < 0 or s > SEED_MASK for s in seeds):
raise ValueError("every seed must be between 0 and 2**53 - 1 (JSON-safe)")
if prompts is not None and len(seeds) != len(prompts):
raise ValueError(
f"prompts and seeds must have the same length "
f"(got {len(prompts)} prompts, {len(seeds)} seeds)"
)
if prompts is not None:
count = len(prompts)
elif seeds is not None:
count = len(seeds)
else:
count = max(1, int(batch_size))
View on GitHub (pinned to 203007d190)
Solutions
- Send seeds: null (or omit the field) when you have no seeds to pin, instead of an empty list.
- Or populate the list with at least one integer seed (0 to 2**53-1).
Example fix
# before engine.generate(prompt=p, seeds=[]) # after engine.generate(prompt=p, seeds=None) # or omit seeds entirely
Defensive patterns
Strategy: validation
Validate before calling
def valid_seeds_shape(seeds) -> bool:
return seeds is None or (isinstance(seeds, list) and len(seeds) > 0) Type guard
def is_valid_seed_list(v) -> bool:
return v is None or (isinstance(v, list) and len(v) > 0) Try / catch
try:
out = engine.generate(prompt=p, seeds=seeds)
except ValueError as e:
if "seeds must be a non-empty list" in str(e):
out = engine.generate(prompt=p, seeds=None) # let the engine draw
else:
raise Prevention
- Send null/omit seeds when you have none — never an empty array.
- Guard list-building code: seeds = computed or None.
When it happens
Trigger: Calling generate with seeds=[] — commonly produced by client-side code that builds the seeds list conditionally and ends up empty instead of None.
Common situations: seeds = [compute_seed() for x in items] where items is empty; UI 'lock seed' features sending an empty array when no seeds are locked; JSON payloads with "seeds": [].
Related errors
- seeds supports at most {MAX_BATCH_IMAGES} entries per call
- prompts and seeds must have the same length (got {len(prompt
- A prompts list is supported for plain text-to-image only; th
- prompts must be a non-empty list of non-empty strings
- prompts supports at most {MAX_BATCH_IMAGES} entries per call
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/a65539c9207669cc.
Report an issue: GitHub.