sgl-project/sglang · critical · RuntimeError

SANA-WM first-frame conditioning failed; refusing to continu

Error message

SANA-WM first-frame conditioning failed; refusing to continue with pure-noise latents because that produces misleading low-quality output.

What it means

SANA-WM splices the condition image into the initial noise latents for first-frame conditioning. If _splice_first_frame raises for any reason (decode failure, resolution mismatch, device/dtype issue), forward aborts rather than continuing with pure noise, which would silently produce garbage video.

Source

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

        latent_shape = self.pipeline_config.prepare_latent_shape(
            batch, batch_size, num_frames
        )
        # latent_shape: (B, 128, T_latent, H_sp, W_sp)
        latents = self._prepare_noise_latents(latent_shape, dtype, device, generator)
        log_sana_wm_tensor_stats("latents.initial_noise", latents)

        batch.raw_latent_shape = latent_shape

        condition_image = getattr(batch, "condition_image", None)
        if condition_image is not None:
            try:
                latents = self._splice_first_frame(
                    latents, condition_image, dtype, device, batch=batch
                )
                self.log_info("First-frame spliced into noise latents.")
            except Exception as e:
                raise RuntimeError(
                    "SANA-WM first-frame conditioning failed; refusing to "
                    "continue with pure-noise latents because that produces "
                    "misleading low-quality output."
                ) from e
        else:
            raise ValueError(
                "SANA-WM is a TI2V world model and requires condition_image "
                "for first-frame conditioning. Provide --image-path, "
                "--condition-image, or the equivalent API image input."
            )

        batch.latents = latents

        # The released SANA-WM checkpoint is camera-conditioned. Official
        # inference requires a camera trajectory or action DSL. If the SGLang
        # request omits one, use a static identity trajectory so the UCPE path
        # remains active instead of silently dropping all camera conditioning.
        try:

View on GitHub (pinned to 0132848349)

Solutions

  1. Inspect the chained __cause__ exception to find the real failure.
  2. Ensure the condition image is a valid tensor/PIL image sized to the requested video height/width.
  3. Reduce batch/resolution if the cause is OOM.
  4. Fix or re-encode the image, then retry the request.
Defensive patterns

Strategy: try-catch

Validate before calling

if condition_image is None or not condition_image.isfinite().all():
    raise ValueError('bad condition image')

Try / catch

try:
    out = stage.forward(...)
except RuntimeError as e:
    if 'first-frame conditioning failed' in str(e):
        cause = e.__cause__  # real failure: resize/OOM/decode
        handle(cause)
    else:
        raise

Prevention

When it happens

Trigger: Any exception inside _splice_first_frame — corrupt/unsupported condition image, mismatched height/width vs generation config, VAE encode failure, OOM — wrapped into this RuntimeError with the original exception chained.

Common situations: Condition image resolution not matching the requested video height/width, malformed image paths, or CUDA OOM during the splice encode.

Related errors


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