{"record":{"id":"6d6923fdd706d065","repo":"sgl-project/sglang","slug":"sana-wm-forward-requires-timestep","errorCode":null,"errorMessage":"SANA-WM forward requires timestep.","messagePattern":"SANA-WM forward requires timestep\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py","lineNumber":622,"sourceCode":"        if not torch.is_grad_enabled():\n            self._plucker_emb_cache = (key, chunk_plucker, plucker_emb)\n        return plucker_emb\n\n    def forward(\n        self,\n        hidden_states: torch.Tensor,\n        encoder_hidden_states: Optional[torch.Tensor] = None,\n        timestep: Optional[torch.Tensor] = None,\n        encoder_attention_mask: Optional[torch.Tensor] = None,\n        camera_conditions: Optional[torch.Tensor] = None,\n        chunk_plucker: Optional[torch.Tensor] = None,\n        guidance: Optional[torch.Tensor] = None,  # kept for compat\n        **kwargs,\n    ) -> torch.Tensor:\n        if encoder_hidden_states is None:\n            raise ValueError(\"SANA-WM forward requires encoder_hidden_states.\")\n        if timestep is None:\n            raise ValueError(\"SANA-WM forward requires timestep.\")\n\n        B, C, T_raw, H_raw, W_raw = hidden_states.shape\n        p_t, p_h, p_w = self.patch_size\n        T = T_raw // p_t\n        H = H_raw // p_h\n        W = W_raw // p_w\n        chunk_size = kwargs.get(\"chunk_size\", self.chunk_size)\n        chunk_split_strategy = kwargs.get(\n            \"chunk_split_strategy\", self.chunk_split_strategy\n        )\n        chunk_index = kwargs.get(\"chunk_index\", None)\n\n        # Patch embed: (B, C, T, H, W) -> (B, T*H*W, D)\n        x = self.x_embedder(hidden_states.to(dtype=self.x_embedder.proj.weight.dtype))\n\n        # Timestep AdaLN-single. SANA-WM's LTX sampler passes per-frame\n        # timesteps shaped (B, 1, T) so the clean first-frame condition can stay\n        # at timestep 0 while remaining latent frames denoise. Keep the scalar","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py#L604-L640","documentation":"SANA-WM's forward requires the diffusion timestep; timestep is mandatory and None raises immediately since the model always operates on noised latents.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the scheduler's current timestep tensor (shape (B,) or broadcastable) to forward","Verify your sampler loop forwards t each step"],"exampleFix":"# before\nout = model(h, encoder_hidden_states=ehs)\n# after\nout = model(h, timestep=t, encoder_hidden_states=ehs)","handlingStrategy":"validation","validationCode":"assert timestep is not None and timestep.numel() == B","typeGuard":"def valid_timestep(t) -> bool: return isinstance(t, torch.Tensor) and t.numel() >= 1","tryCatchPattern":null,"preventionTips":["Forward the scheduler timestep in every sampling step explicitly"],"tags":["sana-wm","missing-argument","timestep"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}