{"record":{"id":"89df9173cc80bfbb","repo":"sgl-project/sglang","slug":"sana-wm-refiner-decoding-expected-a-sink-frame-plu","errorCode":null,"errorMessage":"SANA-WM refiner decoding expected a sink frame plus refined frames, got temporal length {frames.shape[2]}.","messagePattern":"SANA-WM refiner decoding expected a sink frame plus refined frames, got temporal length (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/refiner.py","lineNumber":788,"sourceCode":"            self._drop_refiner_sink = True\n\n    @torch.no_grad()\n    def decode(\n        self,\n        latents: torch.Tensor,\n        server_args: ServerArgs,\n        *,\n        vae_dtype: torch.dtype,\n    ) -> torch.Tensor:\n        frames = super().decode(latents, server_args, vae_dtype=vae_dtype)\n        log_sana_wm_tensor_stats(\"refiner.decode.frames_with_sink\", frames)\n        if frames.ndim != 5:\n            raise ValueError(\n                \"SANA-WM refiner decoding expects decoded video shaped \"\n                f\"(B, C, T, H, W), got {tuple(frames.shape)}.\"\n            )\n        if frames.shape[2] <= 1:\n            raise ValueError(\n                \"SANA-WM refiner decoding expected a sink frame plus refined \"\n                f\"frames, got temporal length {frames.shape[2]}.\"\n            )\n        if not getattr(self, \"_drop_refiner_sink\", True):\n            log_sana_wm_tensor_stats(\"refiner.decode.frames_output\", frames)\n            return frames\n        # Match NVlabs `inference_sana_wm.py`: decode with the clean sink anchor,\n        # then drop the first frame from the returned video.\n        frames = frames[:, :, 1:].contiguous()\n        log_sana_wm_tensor_stats(\"refiner.decode.frames_output\", frames)\n        return frames\n","sourceCodeStart":770,"sourceCodeEnd":800,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/refiner.py#L770-L800","documentation":"After the 5D check, decode() requires frames.shape[2] > 1: the decoded clip must contain the sink frame plus at least one refined frame. A temporal length of exactly 1 means only the sink survived (refiner produced nothing) and dropping it would yield an empty video.","triggerScenarios":"Refining a latent where all non-sink frames were lost/empty; sink_size >= frame count so the refiner emitted only the sink; a VAE that decodes only the first frame.","commonSituations":"Misconfigured sink_size; an upstream slicing bug trimming refined frames to zero; testing with a minimal 1-frame latent end-to-end.","solutions":["Ensure the refined latent contains sink + >=1 frames before decode (see error 2582's constraint)","Audit any slicing between refine and decode that could drop the refined segment","Verify the VAE decodes the full temporal extent"],"exampleFix":"# before\nlatents = z[:, :, :1]  # accidentally kept only the sink frame\n# after\nlatents = z  # sink + refined frames retained","handlingStrategy":"validation","validationCode":"assert frames.ndim == 5 and frames.shape[2] > 1, f\"decoded clip lacks refined frames: {tuple(frames.shape)}\"","typeGuard":"def has_sink_plus_frames(t: torch.Tensor) -> bool:\n    return t.ndim == 5 and t.shape[2] > 1","tryCatchPattern":"null","preventionTips":["Never slice latents to the sink frame alone before decode","Check refined latent frame counts mid-pipeline in debug builds","Watch sink_size vs frame length in config reviews"],"tags":["sana-wm","refiner","decode","temporal-length","valueerror"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}