sgl-project/sglang · error · ValueError
SANA-WM forward requires timestep.
Error message
SANA-WM forward requires timestep.
What it means
SANA-WM's forward requires the diffusion timestep; timestep is mandatory and None raises immediately since the model always operates on noised latents.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py:622
if not torch.is_grad_enabled():
self._plucker_emb_cache = (key, chunk_plucker, plucker_emb)
return plucker_emb
def forward(
self,
hidden_states: torch.Tensor,
encoder_hidden_states: Optional[torch.Tensor] = None,
timestep: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
camera_conditions: Optional[torch.Tensor] = None,
chunk_plucker: Optional[torch.Tensor] = None,
guidance: Optional[torch.Tensor] = None, # kept for compat
**kwargs,
) -> torch.Tensor:
if encoder_hidden_states is None:
raise ValueError("SANA-WM forward requires encoder_hidden_states.")
if timestep is None:
raise ValueError("SANA-WM forward requires timestep.")
B, C, T_raw, H_raw, W_raw = hidden_states.shape
p_t, p_h, p_w = self.patch_size
T = T_raw // p_t
H = H_raw // p_h
W = W_raw // p_w
chunk_size = kwargs.get("chunk_size", self.chunk_size)
chunk_split_strategy = kwargs.get(
"chunk_split_strategy", self.chunk_split_strategy
)
chunk_index = kwargs.get("chunk_index", None)
# Patch embed: (B, C, T, H, W) -> (B, T*H*W, D)
x = self.x_embedder(hidden_states.to(dtype=self.x_embedder.proj.weight.dtype))
# Timestep AdaLN-single. SANA-WM's LTX sampler passes per-frame
# timesteps shaped (B, 1, T) so the clean first-frame condition can stay
# at timestep 0 while remaining latent frames denoise. Keep the scalarView on GitHub (pinned to 0132848349)
Solutions
- Pass the scheduler's current timestep tensor (shape (B,) or broadcastable) to forward
- Verify your sampler loop forwards t each step
Example fix
# before out = model(h, encoder_hidden_states=ehs) # after out = model(h, timestep=t, encoder_hidden_states=ehs)
Defensive patterns
Strategy: validation
Validate before calling
assert timestep is not None and timestep.numel() == B
Type guard
def valid_timestep(t) -> bool: return isinstance(t, torch.Tensor) and t.numel() >= 1
Prevention
- Forward the scheduler timestep in every sampling step explicitly
When it happens
Trigger: Calling forward without timestep, or with timestep=None; e.g. running a single clean pass or a wrapper that only supplies hidden_states and text embeddings.
Common situations: Adapters from other DiT APIs where timestep is optional (e.g. some inference wrappers default t=0); forgetting to pass scheduler timesteps in a sampling loop.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- SANA-WM forward_long requires timestep.
- SANA-WM forward requires encoder_hidden_states.
- SANA-WM forward_long requires encoder_hidden_states.
- Either chunk_index or chunk_size must be provided.
- num_frames/height/width are required when hidden_states is p
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6d6923fdd706d065.
Report an issue: GitHub.