{"record":{"id":"b7f0373669e5fe3a","repo":"sgl-project/sglang","slug":"sana-wm-denoising-requires-initialized-latents","errorCode":null,"errorMessage":"SANA-WM denoising requires initialized latents.","messagePattern":"SANA-WM denoising requires initialized latents\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py","lineNumber":826,"sourceCode":"\n    @staticmethod\n    def _combine_cfg_parallel_noise(\n        noise_pred: torch.Tensor,\n        guidance_scale: float,\n        cfg_rank: int,\n    ) -> torch.Tensor:\n        if cfg_rank == 0:\n            partial = guidance_scale * noise_pred\n        elif cfg_rank == 1:\n            partial = (1.0 - guidance_scale) * noise_pred\n        else:\n            partial = torch.zeros_like(noise_pred)\n        return cfg_model_parallel_all_reduce(partial)\n\n    @torch.no_grad()\n    def forward(self, batch: Req, server_args: ServerArgs) -> Req:\n        if batch.latents is None:\n            raise ValueError(\"SANA-WM denoising requires initialized latents.\")\n        if batch.latents.ndim != 5:\n            raise ValueError(\n                \"SANA-WM denoising expects 5D latents shaped (B, C, T, H, W), \"\n                f\"got {tuple(batch.latents.shape)}.\"\n            )\n\n        device = get_local_torch_device()\n        target_dtype = PRECISION_TO_TYPE.get(\n            getattr(server_args.pipeline_config, \"dit_precision\", \"bf16\"),\n            torch.bfloat16,\n        )\n        scheduler = getattr(\n            batch, \"scheduler\", None\n        ) or get_or_create_request_scheduler(batch, self.scheduler)\n        self._move_scheduler_tensors_to_device(scheduler, device)\n        timesteps = batch.timesteps\n        if timesteps is None:\n            raise ValueError(\"SANA-WM denoising requires prepared timesteps.\")","sourceCodeStart":808,"sourceCodeEnd":844,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py#L808-L844","documentation":"Raised by the SANA-WM denoising stage forward when batch.latents is None — the denoiser was invoked before a prior stage initialized the noise latents.","triggerScenarios":"Running the denoising stage without a preceding latent-init stage having set batch.latents (skipped stage in pipeline order, or first-frame conditioning failed earlier).","commonSituations":"Pipeline misordering (denoise before init); latent init skipped due to a conditional branch; request routed directly to the denoising stage.","solutions":["Ensure the latent-initialization / before-denoising stage runs before the denoiser in the pipeline","Check that _prepare_noise_latents actually assigned batch.latents","Inspect pipeline stage ordering in the config"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"assert batch.latents is not None, 'run the latent-init stage before denoising'","typeGuard":"def ready_to_denoise(batch) -> bool:\n    return getattr(batch, 'latents', None) is not None","tryCatchPattern":null,"preventionTips":["Enforce stage ordering in pipeline construction","Add a smoke test that runs init->denoise end to end"],"tags":["pipeline-order","latents","sana-wm"],"backgroundTag":"missing-prerequisite-state","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}