{"record":{"id":"85f22bfbac714521","repo":"sgl-project/sglang","slug":"ltx-2-sp-time-sharding-for-packed-token-latents-cu","errorCode":null,"errorMessage":"LTX-2 SP time-sharding for packed token latents currently requires {self.patch_size_t=}. (Expected 1)","messagePattern":"LTX-2 SP time-sharding for packed token latents currently requires (.+?)\\. \\(Expected 1\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py","lineNumber":331,"sourceCode":"            self.patch_size,\n        )\n        latents = latents.permute(0, 2, 4, 6, 1, 3, 5, 7).flatten(4, 7).flatten(1, 3)\n        # Deliberately left non-contiguous: both flattens are views, so this\n        # keeps the permuted strides. Normalising here would change which GEMM\n        # kernel runs and move bf16 output. The fp8 path makes its own copy.\n        return latents\n\n    def _infer_video_latent_frames_and_tokens_per_frame(\n        self, batch, seq_len: int\n    ) -> tuple[int, int]:\n        \"\"\"Infer latent-frame count and tokens-per-frame for packed token latents [B, S, D].\n\n        Notes:\n        - This assumes `patch_size_t == 1` (no temporal patching).\n        - Tokens are ordered as (frame, height, width) after packing.\n        \"\"\"\n        if int(self.patch_size_t) != 1:\n            raise ValueError(\n                \"LTX-2 SP time-sharding for packed token latents currently requires \"\n                f\"{self.patch_size_t=}. (Expected 1)\"\n            )\n        if int(seq_len) <= 0:\n            raise ValueError(f\"Expected {seq_len=} > 0 for packed token latents.\")\n        if int(self.vae_scale_factor) <= 0:\n            raise ValueError(f\"Invalid {self.vae_scale_factor=}. Must be > 0.\")\n        if int(self.patch_size) <= 0:\n            raise ValueError(f\"Invalid {self.patch_size=}. Must be > 0.\")\n\n        latent_height = int(batch.height) // int(self.vae_scale_factor)\n        latent_width = int(batch.width) // int(self.vae_scale_factor)\n        if latent_height <= 0 or latent_width <= 0:\n            raise ValueError(\n                \"Invalid latent H/W computed from batch.height/width: \"\n                f\"{batch.height=} {batch.width=} {self.vae_scale_factor=}\"\n            )\n        if (latent_height % int(self.patch_size)) != 0 or (","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py#L313-L349","documentation":"LTX-2 sequence-parallel time-sharding of packed token latents assumes no temporal patching (patch_size_t == 1) so frames map 1:1 onto latent tokens. If the pipeline config has patch_size_t != 1, the frame/token arithmetic would be wrong, so it refuses.","triggerScenarios":"Enabling SP latent sharding (shard_latents_for_sp) on a video request while the transformer's patch_size_t is set to a value other than 1 (e.g. 2 from a patched VAE/transformer config).","commonSituations":"Loading a model revision whose transformer config uses temporal patching; manually overriding patch_size_t in the pipeline config; mixing a patched VAE with the SP path.","solutions":["Set patch_size_t = 1 in the pipeline/transformer config when using SP time-sharding","Disable sequence parallelism (use TP) for models with temporal patching","Upgrade/downgrade to a model revision whose config matches the SP assumption (patch_size_t=1)"],"exampleFix":"# before\npipeline_config.patch_size_t = 2  # temporal patching + SP -> raises\n\n# after\npipeline_config.patch_size_t = 1\n# or run without --sp-size","handlingStrategy":"validation","validationCode":"if using_sp():\n    assert int(pipeline_config.patch_size_t) == 1, \"SP time-sharding requires patch_size_t=1\"","typeGuard":null,"tryCatchPattern":"except ValueError as e:\n    if \"patch_size_t\" in str(e):\n        run_without_sp()  # fall back to TP or single GPU","preventionTips":["Pin model revisions with patch_size_t=1 for SP deployments","Smoke-test SP sharding after any config/model override"],"tags":["sglang","ltx-2","sequence-parallelism","patch-size","video","latent-sharding"],"backgroundTag":"parallelism-unsupported-config","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}