{"record":{"id":"d505f6a4fb6bfbb6","repo":"sgl-project/sglang","slug":"latents-must-be-provided","errorCode":null,"errorMessage":"Latents must be provided","messagePattern":"Latents must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/hunyuan3d/shape.py","lineNumber":328,"sourceCode":"        assert scheduler is not None\n        cache_dit_num_inference_steps = batch.extra.get(\n            \"cache_dit_num_inference_steps\", batch.num_inference_steps\n        )\n        freshly_loaded = load_transformer_if_needed(self, server_args)\n        if freshly_loaded:\n            self._maybe_enable_cache_dit(cache_dit_num_inference_steps, batch)\n            self._maybe_torch_compile(self.transformer)\n            register_loaded_transformer(self, server_args, pipeline)\n        else:\n            self._maybe_enable_cache_dit(cache_dit_num_inference_steps, batch)\n\n        timesteps = batch.timesteps\n        if timesteps is None:\n            raise ValueError(\"Timesteps must be provided\")\n\n        latents = batch.latents\n        if latents is None:\n            raise ValueError(\"Latents must be provided\")\n\n        cond = batch.prompt_embeds[0] if batch.prompt_embeds else None\n        if cond is None:\n            raise ValueError(\"Conditioning (prompt_embeds) must be provided\")\n\n        if batch.raw_latent_shape is None:\n            batch.raw_latent_shape = latents.shape\n\n        guidance = batch.extra.get(\"shape_guidance\")\n        num_inference_steps = batch.num_inference_steps\n        num_warmup_steps = len(timesteps) - num_inference_steps * scheduler.order\n\n        extra_step_kwargs = self.prepare_extra_func_kwargs(\n            scheduler.step,\n            {\"generator\": batch.generator, \"eta\": batch.eta},\n        )\n\n        target_dtype = next(self.transformer.parameters()).dtype","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/hunyuan3d/shape.py#L310-L346","documentation":"The Hunyuan3D denoising loop requires initial latents on the batch, normally produced by the _prepare_latents step or an equivalent upstream stage. batch.latents is None means no initial noise tensor was generated or passed in, so denoising cannot start.","triggerScenarios":"Invoking the denoising-loop stage directly without a preceding latent-preparation stage; manual batch construction omitting latents; latent-prep stage skipped because of a condition (e.g. disabled random init) or a failed generator.","commonSituations":"Reordered/partial pipelines in tests; refactor decoupling latent prep from the loop; providing latents under a different attribute name (e.g. latents_1 instead of latents).","solutions":["Run the latent-preparation stage (or _prepare_latents) before the denoising loop so batch.latents is populated","If building batches manually, generate latents with the expected shape (batch_size, *latent_shape) and assign to batch.latents","Verify pipeline stage ordering and that no stage was conditionally skipped"],"exampleFix":"# before\nbatch.latents = None\n\n# after\nfrom diffusers.utils.torch_utils import randn_tensor\nbatch.latents = randn_tensor((1, *stage.latent_shape), generator=gen,\n                             device=dev, dtype=dt)","handlingStrategy":"validation","validationCode":"if batch.latents is None:\n    from diffusers.utils.torch_utils import randn_tensor\n    batch.latents = randn_tensor((1, *stage.latent_shape),\n                                 generator=gen, device=dev, dtype=dt)","typeGuard":"def has_latents(batch) -> bool:\n    return getattr(batch, \"latents\", None) is not None","tryCatchPattern":null,"preventionTips":["Run latent-prep stage before the denoise stage","Smoke-test custom pipelines end-to-end with a single request"],"tags":["hunyuan3d","pipeline-order","missing-state","latents"],"backgroundTag":"pipeline-stage-ordering-error","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}