{"record":{"id":"517e00824d9d0630","repo":"unslothai/unsloth","slug":"seeds-supports-at-most-max-batch-images-entries","errorCode":null,"errorMessage":"seeds supports at most {MAX_BATCH_IMAGES} entries per call","messagePattern":"seeds supports at most (.+?) entries per call","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/diffusion_batched.py","lineNumber":69,"sourceCode":"    - ``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\n    if seeds is not None:\n        job_seeds = seeds","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion_batched.py#L51-L87","documentation":"The seeds list is capped at MAX_BATCH_IMAGES = 32 entries per call, symmetrically with the prompts cap, so one request cannot schedule an unbounded batch. Longer seed lists must be split across calls.","triggerScenarios":"Calling generate with seeds containing 33+ entries (len(seeds) > 32), typically alongside a single prompt to render variations of it.","commonSituations":"Seed-sweep scripts enumerating hundreds of seeds to cherry-pick a good render; grid-search tools generating 8x8=64 seeds in one call.","solutions":["Chunk seeds into groups of at most 32 and make one call per chunk.","Reduce the sweep size, or use batch_size (for derived sequential seeds) which is bounded the same way."],"exampleFix":"# before\nengine.generate(prompt=p, seeds=list(range(1000, 1100)))\n# after\nfor i in range(1000, 1100, 32):\n    engine.generate(prompt=p, seeds=list(range(i, min(i+32, 1100))))","handlingStrategy":"validation","validationCode":"def valid_seed_count(seeds) -> bool:\n    return seeds is None or len(seeds) <= 32","typeGuard":null,"tryCatchPattern":"try:\n    out = engine.generate(prompt=p, seeds=seeds)\nexcept ValueError as e:\n    if \"seeds supports at most\" in str(e):\n        out = [engine.generate(prompt=p, seeds=c) for c in chunked(seeds, 32)]\n    else:\n        raise","preventionTips":["Chunk seed sweeps into batches of 32.","Prefer batch_size with derived seeds for sequential runs."],"tags":["diffusion","batching","seeds","limits","validation"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}