{"record":{"id":"a65539c9207669cc","repo":"unslothai/unsloth","slug":"seeds-must-be-a-non-empty-list-of-integers","errorCode":null,"errorMessage":"seeds must be a non-empty list of integers","messagePattern":"seeds must be a non-empty list of integers","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_batched.py","lineNumber":67,"sourceCode":"    \"\"\"The per-image ``(prompt, seed)`` jobs plus the base seed for this call.\n\n    - ``prompts`` (list): one image per prompt. With ``seeds`` too, lengths must\n      match (seed i drives prompt i); without, seeds derive from the base.\n    - ``seeds`` (list) alone: one image per seed, all with ``prompt``.\n    - neither: ``batch_size`` images of ``prompt`` with derived seeds\n      base..base+batch_size-1 (each masked JSON-safe).\n\n    ``draw_seed`` supplies a fresh random base when the caller sent none (the\n    engine passes a ``torch.Generator`` draw). Raises ``ValueError`` on empty /\n    oversized lists, a length mismatch, or an out-of-range seed.\"\"\"\n    if prompts is not None:\n        if not prompts or not all(isinstance(p, str) and p.strip() for p in prompts):\n            raise ValueError(\"prompts must be a non-empty list of non-empty strings\")\n        if len(prompts) > MAX_BATCH_IMAGES:\n            raise ValueError(f\"prompts supports at most {MAX_BATCH_IMAGES} entries per call\")\n    if seeds is not None:\n        if not seeds:\n            raise ValueError(\"seeds must be a non-empty list of integers\")\n        if len(seeds) > MAX_BATCH_IMAGES:\n            raise ValueError(f\"seeds supports at most {MAX_BATCH_IMAGES} entries per call\")\n        seeds = [int(s) for s in seeds]\n        if any(s < 0 or s > SEED_MASK for s in seeds):\n            raise ValueError(\"every seed must be between 0 and 2**53 - 1 (JSON-safe)\")\n        if prompts is not None and len(seeds) != len(prompts):\n            raise ValueError(\n                f\"prompts and seeds must have the same length \"\n                f\"(got {len(prompts)} prompts, {len(seeds)} seeds)\"\n            )\n\n    if prompts is not None:\n        count = len(prompts)\n    elif seeds is not None:\n        count = len(seeds)\n    else:\n        count = max(1, int(batch_size))\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_batched.py#L49-L85","documentation":"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.","triggerScenarios":"Calling generate with seeds=[] — commonly produced by client-side code that builds the seeds list conditionally and ends up empty instead of None.","commonSituations":"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\": [].","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)."],"exampleFix":"# before\nengine.generate(prompt=p, seeds=[])\n# after\nengine.generate(prompt=p, seeds=None)  # or omit seeds entirely","handlingStrategy":"validation","validationCode":"def valid_seeds_shape(seeds) -> bool:\n    return seeds is None or (isinstance(seeds, list) and len(seeds) > 0)","typeGuard":"def is_valid_seed_list(v) -> bool:\n    return v is None or (isinstance(v, list) and len(v) > 0)","tryCatchPattern":"try:\n    out = engine.generate(prompt=p, seeds=seeds)\nexcept ValueError as e:\n    if \"seeds must be a non-empty list\" in str(e):\n        out = engine.generate(prompt=p, seeds=None)  # let the engine draw\n    else:\n        raise","preventionTips":["Send null/omit seeds when you have none — never an empty array.","Guard list-building code: seeds = computed or None."],"tags":["diffusion","batching","seeds","validation"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}