sgl-project/sglang · error · ValueError
SANA-WM forward requires encoder_hidden_states.
Error message
SANA-WM forward requires encoder_hidden_states.
What it means
SANA-WM's forward requires text conditioning; encoder_hidden_states is a mandatory argument and passing None raises immediately. The model has no unconditional path, unlike diffusers models that default to dropout/CFG-free branches.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py:620
)
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-frameView on GitHub (pinned to 0132848349)
Solutions
- Pass encoder_hidden_states (text embeddings, shape (B, N, D)) to forward
- If you truly want unconditional, pass zero/empty embeddings matching the text encoder's output shape
- Check the exact kwarg name in the signature before calling
Example fix
# before out = model(h, timestep=t) # after out = model(h, timestep=t, encoder_hidden_states=ehs)
Defensive patterns
Strategy: validation
Validate before calling
if encoder_hidden_states is None:
raise TypeError('encoder_hidden_states required') from None Type guard
def has_ehs(ehs: torch.Tensor | None) -> bool: return isinstance(ehs, torch.Tensor) and ehs.ndim == 3
Prevention
- Make encoder_hidden_states positional in your wrapper so omission is a TypeError, not a deep ValueError
When it happens
Trigger: Calling forward(hidden_states, timestep) without encoder_hidden_states, or passing it as None explicitly / under a wrong kwarg name (e.g. 'context' or 'encoder_hidden_state').
Common situations: Porting code from diffusers SanaPipeline where encoder_hidden_states defaulted; calling with **kwargs dict that lacks the key; wrapper code that drops None fields.
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 requires timestep.
- SANA-WM forward_long requires encoder_hidden_states.
- SANA-WM forward_long requires timestep.
- 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/ca4a869e1dcd9ce6.
Report an issue: GitHub.