sgl-project/sglang · error · ValueError

SANA-WM seed list must not be empty.

Error message

SANA-WM seed list must not be empty.

What it means

Raised by _generator_from_seed when the seed argument is a list/tuple of length 0 — per-sample seeds were requested but the list is empty.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:1201

                    )
                    for sample_generator in generator
                ],
                dim=0,
            )
        return randn_tensor(shape, generator=generator, device=device, dtype=dtype)

    @staticmethod
    def _generator_from_seed(
        seed: int | list[int] | tuple[int, ...] | None,
        *,
        batch_size: int,
        device: torch.device,
    ) -> torch.Generator | list[torch.Generator]:
        if seed is None:
            seed = 0
        if isinstance(seed, (list, tuple)):
            if not seed:
                raise ValueError("SANA-WM seed list must not be empty.")
            if len(seed) == 1:
                seed = seed[0]
            elif len(seed) == batch_size:
                return [
                    torch.Generator(device=device).manual_seed(int(sample_seed))
                    for sample_seed in seed
                ]
            else:
                raise ValueError(
                    "SANA-WM seed list length must be 1 or match latent batch "
                    f"size; got {len(seed)} seeds for batch {batch_size}."
                )
        return torch.Generator(device=device).manual_seed(int(seed))

    @staticmethod
    def _canonical_condition_image_tensor(image: torch.Tensor) -> torch.Tensor:
        """Return image as NCHW RGB float tensor without changing its value range."""
        image = image.float()

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass seed=None (defaults to 0) or a single int for a shared generator
  2. Filter empty seed lists to None: seed = seed or None
  3. Build seed lists only when you have at least one seed

Example fix

# before
seed = [r.seed for r in requests if r.seed]  # may be []
# after
seed = [r.seed for r in requests if r.seed] or None
Defensive patterns

Strategy: validation

Validate before calling

seed = seed if (seed is None or not isinstance(seed, (list, tuple)) or len(seed) > 0) else None

Type guard

def seed_ok(s) -> bool:
    return s is None or not isinstance(s, (list, tuple)) or len(s) >= 1

Prevention

When it happens

Trigger: Passing seed=[] to the latent-init forward (or _generator_from_seed directly), e.g. seeds collected from an empty batch or filtered to nothing.

Common situations: seed list built from user requests that are all unseeded; JSON config with "seed": [] ; upstream default producing an empty list instead of None.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/a105f0ad3b7df246. Report an issue: GitHub.