{"record":{"id":"b0a28892e8eda375","repo":"sgl-project/sglang","slug":"sana-wm-forward-long-requires-timestep","errorCode":null,"errorMessage":"SANA-WM forward_long requires timestep.","messagePattern":"SANA-WM forward_long requires timestep\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py","lineNumber":758,"sourceCode":"        chunk_plucker: Optional[torch.Tensor] = None,\n        *,\n        kv_cache: Optional[list] = None,\n        save_kv_cache: bool = True,\n        start_f: Optional[int] = None,\n        end_f: Optional[int] = None,\n        frame_index: Optional[torch.Tensor] = None,\n        **kwargs,\n    ) -> Tuple[torch.Tensor, list]:\n        \"\"\"Streaming autoregressive forward over a chunk of latent frames.\n\n        RoPE / camera / plücker are windowed to the chunk's GLOBAL frame range\n        ``[start_f, end_f)``; a per-block 10-slot ``kv_cache`` carries recurrent\n        state / concat-windows across chunks. Returns ``(out, new_cache)``.\n        \"\"\"\n        if encoder_hidden_states is None:\n            raise ValueError(\"SANA-WM forward_long requires encoder_hidden_states.\")\n        if timestep is None:\n            raise ValueError(\"SANA-WM forward_long requires timestep.\")\n\n        if kv_cache is None:\n            kv_cache = [[None] * _NUM_STREAM_CACHE_SLOTS for _ in self.blocks]\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        start = 0 if start_f is None else int(start_f)\n        end = start + T if end_f is None else int(end_f)\n\n        x = self.x_embedder(hidden_states.to(dtype=self.x_embedder.proj.weight.dtype))\n\n        # Timestep AdaLN-single: force the framewise (B, 1, T) path so blocks\n        # always apply per-frame modulation.\n        if timestep.dim() == 1:\n            timestep = timestep[:, None, None].expand(-1, 1, T)","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py#L740-L776","documentation":"forward_long requires the diffusion timestep for each chunk; None raises immediately. Chunked streaming still denoises, so a timestep per chunk is mandatory.","triggerScenarios":"Calling forward_long without timestep or with timestep=None while iterating chunks.","commonSituations":"Streaming wrapper that supplies timestep only once, or per-pixel-frame instead of per-chunk; porting from a wrapper where t defaulted.","solutions":["Pass the scheduler timestep tensor for the current denoising step to every forward_long chunk call","Keep the same t across chunks within one denoising step"],"exampleFix":"# before\nout, cache = model.forward_long(h, ehs, start_f=sf, end_f=ef)\n# after\nout, cache = model.forward_long(h, t, encoder_hidden_states=ehs, start_f=sf, end_f=ef)","handlingStrategy":"validation","validationCode":"assert timestep is not None at the top of your chunk loop","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep (t, ehs) as an immutable tuple per denoising step"],"tags":["sana-wm","forward-long","timestep","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}