{"record":{"id":"f57fdc2dc85788cb","repo":"sgl-project/sglang","slug":"sana-wm-forward-long-requires-encoder-hidden-state","errorCode":null,"errorMessage":"SANA-WM forward_long requires encoder_hidden_states.","messagePattern":"SANA-WM forward_long requires encoder_hidden_states\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py","lineNumber":756,"sourceCode":"        encoder_attention_mask: Optional[torch.Tensor] = None,\n        camera_conditions: Optional[torch.Tensor] = None,\n        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.","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py#L738-L774","documentation":"forward_long (SANA-WM's chunked/streaming long-video forward) requires text conditioning just like forward. Passing encoder_hidden_states=None raises immediately; there is no unconditional path.","triggerScenarios":"Calling forward_long(hidden_states, timestep, start_f, end_f, ...) without encoder_hidden_states, or with a kwargs dict missing the key.","commonSituations":"Building a streaming generation loop and forgetting the text embeddings in the chunk-call signature; reusing a wrapper written for forward with different kwarg names.","solutions":["Pass encoder_hidden_states on every forward_long chunk call (same embeddings for all chunks of one generation)","If unconditional generation is intended, pass zeros matching the expected embedding shape"],"exampleFix":"# before\nout, cache = model.forward_long(h, t, start_f=0, end_f=16, kv_cache=cache)\n# after\nout, cache = model.forward_long(h, t, encoder_hidden_states=ehs, start_f=0, end_f=16, kv_cache=cache)","handlingStrategy":"validation","validationCode":"assert encoder_hidden_states is not None before each forward_long chunk call","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass identical ehs to every chunk; centralize the chunk call in one function"],"tags":["sana-wm","forward-long","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}