sgl-project/sglang · error · ValueError
SANA-WM refiner decoding expected a sink frame plus refined
Error message
SANA-WM refiner decoding expected a sink frame plus refined frames, got temporal length {frames.shape[2]}. What it means
After the 5D check, decode() requires frames.shape[2] > 1: the decoded clip must contain the sink frame plus at least one refined frame. A temporal length of exactly 1 means only the sink survived (refiner produced nothing) and dropping it would yield an empty video.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/refiner.py:788
self._drop_refiner_sink = True
@torch.no_grad()
def decode(
self,
latents: torch.Tensor,
server_args: ServerArgs,
*,
vae_dtype: torch.dtype,
) -> torch.Tensor:
frames = super().decode(latents, server_args, vae_dtype=vae_dtype)
log_sana_wm_tensor_stats("refiner.decode.frames_with_sink", frames)
if frames.ndim != 5:
raise ValueError(
"SANA-WM refiner decoding expects decoded video shaped "
f"(B, C, T, H, W), got {tuple(frames.shape)}."
)
if frames.shape[2] <= 1:
raise ValueError(
"SANA-WM refiner decoding expected a sink frame plus refined "
f"frames, got temporal length {frames.shape[2]}."
)
if not getattr(self, "_drop_refiner_sink", True):
log_sana_wm_tensor_stats("refiner.decode.frames_output", frames)
return frames
# Match NVlabs `inference_sana_wm.py`: decode with the clean sink anchor,
# then drop the first frame from the returned video.
frames = frames[:, :, 1:].contiguous()
log_sana_wm_tensor_stats("refiner.decode.frames_output", frames)
return frames
View on GitHub (pinned to 0132848349)
Solutions
- Ensure the refined latent contains sink + >=1 frames before decode (see error 2582's constraint)
- Audit any slicing between refine and decode that could drop the refined segment
- Verify the VAE decodes the full temporal extent
Example fix
# before latents = z[:, :, :1] # accidentally kept only the sink frame # after latents = z # sink + refined frames retained
Defensive patterns
Strategy: validation
Validate before calling
assert frames.ndim == 5 and frames.shape[2] > 1, f"decoded clip lacks refined frames: {tuple(frames.shape)}" Type guard
def has_sink_plus_frames(t: torch.Tensor) -> bool:
return t.ndim == 5 and t.shape[2] > 1 Try / catch
null
Prevention
- Never slice latents to the sink frame alone before decode
- Check refined latent frame counts mid-pipeline in debug builds
- Watch sink_size vs frame length in config reviews
When it happens
Trigger: Refining a latent where all non-sink frames were lost/empty; sink_size >= frame count so the refiner emitted only the sink; a VAE that decodes only the first frame.
Common situations: Misconfigured sink_size; an upstream slicing bug trimming refined frames to zero; testing with a minimal 1-frame latent end-to-end.
Related errors
- SANA-WM refiner requires a string prompt or one prompt per b
- Stage-1 latent has {z.shape[2]} frames but sink_size={sink_s
- SANA-WM refiner requires batch.latents from stage 1.
- SANA-WM refiner expects 5D latents shaped (B, C, T, H, W), g
- SANA-WM refiner decoding expects decoded video shaped (B, C,
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/89df9173cc80bfbb.
Report an issue: GitHub.