{"record":{"id":"ba987a31cb18487c","repo":"sgl-project/sglang","slug":"sp-dmd-renoise-requires-packed-video-batch-raw-la","errorCode":null,"errorMessage":"SP DMD renoise requires packed video `batch.raw_latent_shape`.","messagePattern":"SP DMD renoise requires packed video `batch\\.raw_latent_shape`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/denoising.py","lineNumber":207,"sourceCode":"            sigma_t = sigma_t.reshape(-1, *[1] * (original.ndim - 1))\n        elif sigma_t.ndim == 2:\n            sigma_t = sigma_t.reshape(*sigma_t.shape, *[1] * (original.ndim - 2))\n        return (1.0 - sigma_t) * original + sigma_t * noise\n\n    def _sample_sp_consistent_noise(\n        self,\n        local_reference: torch.Tensor,\n        batch: Req,\n        server_args: ServerArgs,\n        *,\n        shard_video: bool,\n        shard_audio: bool,\n    ) -> torch.Tensor:\n        \"\"\"Sample renoise on the global latent layout, then shard for SP.\"\"\"\n        if shard_video:\n            raw_shape = batch.raw_latent_shape\n            if not (isinstance(raw_shape, tuple) and len(raw_shape) == 3):\n                raise ValueError(\n                    \"SP DMD renoise requires packed video `batch.raw_latent_shape`.\"\n                )\n            full_reference = torch.empty(\n                tuple(raw_shape),\n                device=local_reference.device,\n                dtype=local_reference.dtype,\n            )\n            full_noise = self._randn_like_with_batch_generators(full_reference, batch)\n            sharded_noise, _ = server_args.pipeline_config.shard_latents_for_sp(\n                batch, full_noise\n            )\n            return sharded_noise\n\n        if shard_audio:\n            orig_audio_len = batch.sp_audio_orig_num_frames\n            if orig_audio_len <= 0:\n                raise ValueError(\n                    \"SP DMD renoise requires `batch.sp_audio_orig_num_frames`.\"","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/denoising.py#L189-L225","documentation":"In JoyEcho's SP (sequence-parallel) DMD renoise path, when video latents are sharded the sampler reconstructs noise on the full (unsharded) layout using batch.raw_latent_shape. It requires a 3-tuple (frames, height/latent, width/latent) packed video shape; anything else means the batch metadata is missing or malformed.","triggerScenarios":"Running DMD denoising with shard_video=True but batch.raw_latent_shape unset, None, a list, or not length 3 (e.g. a 4-D tensor shape was stored instead of the packed 3-D latent shape).","commonSituations":"Building Req batches manually without the SP metadata; a pipeline change that stopped populating raw_latent_shape when sequence parallelism is enabled; enabling shard_video on a video path that never packed latents.","solutions":["Ensure the upstream stage sets batch.raw_latent_shape to the packed 3-tuple (C*T? no: frames, h_lat, w_lat) of the full unsharded video latent","Disable sharding (shard_video=False) if running single-GPU","Upgrade/align the stage that constructs the batch so SP metadata is populated"],"exampleFix":"# before\nbatch.raw_latent_shape = None  # or tuple(latents.shape)  # 4-D\n# after\nbatch.raw_latent_shape = (num_latent_frames, h_lat, w_lat)  # packed 3-tuple","handlingStrategy":"type-guard","validationCode":"if shard_video and not (isinstance(getattr(batch, 'raw_latent_shape', None), tuple) and len(batch.raw_latent_shape) == 3):\n    raise/shard_video = False  # or populate the field upstream","typeGuard":"def has_packed_video_shape(b) -> bool:\n    s = getattr(b, 'raw_latent_shape', None)\n    return isinstance(s, tuple) and len(s) == 3","tryCatchPattern":null,"preventionTips":["Always set raw_latent_shape when building batches for SP runs","Add an integration test that exercises the SP path end to end"],"tags":["joyecho","sequence-parallel","dmd","latent-shape","validation"],"backgroundTag":"missing-batch-metadata-for-parallelism","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}