{"record":{"id":"2cbcbe38a4471b86","repo":"sgl-project/sglang","slug":"invalid-latent-h-w-computed-from-batch-height-widt","errorCode":null,"errorMessage":"Invalid latent H/W computed from batch.height/width: {batch.height=} {batch.width=} {self.vae_scale_factor=}","messagePattern":"Invalid latent H/W computed from batch\\.height/width: (.+?) (.+?) (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py","lineNumber":345,"sourceCode":"        - 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 (\n            latent_width % int(self.patch_size)\n        ) != 0:\n            raise ValueError(\n                \"Invalid spatial patching for packed token latents. Expected latent H/W \"\n                \"to be divisible by patch_size, got \"\n                f\"{latent_height=} {latent_width=} {self.patch_size=}.\"\n            )\n\n        post_patch_h = latent_height // int(self.patch_size)\n        post_patch_w = latent_width // int(self.patch_size)\n        tokens_per_frame = int(post_patch_h) * int(post_patch_w)\n        if tokens_per_frame <= 0:\n            raise ValueError(\n                f\"Invalid tokens_per_frame={tokens_per_frame} from \"","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py#L327-L363","documentation":"After dividing batch height/width by vae_scale_factor, the LTX-2 config checks that the resulting latent dimensions are positive. A zero or negative latent_height/latent_width means the request's resolution is smaller than one VAE latent cell. The error message includes batch.height, batch.width, and vae_scale_factor for diagnosis.","triggerScenarios":"Calling shard_latents_for_sp with a batch where height or width is smaller than vae_scale_factor (e.g. height=4 with vae_scale_factor=8 yields latent_height=0), or with non-positive height/width.","commonSituations":"Passing thumbnails or tiny test resolutions (e.g. 64x64 with a scale factor larger than the resolution), unit tests with dummy dimensions, or resolution/aspect-ratio math bugs upstream that produce tiny dims.","solutions":["Increase the request resolution so height and width are at least vae_scale_factor (ideally a multiple of vae_scale_factor * patch_size)","Check upstream code that computes batch.height/batch.width for truncation or unit confusion (pixels vs latent units)","Verify vae_scale_factor is not accidentally set too large for the intended resolution"],"exampleFix":"# before\nbatch = VideoBatch(height=64, width=64)  # with vae_scale_factor=32 -> latent 2x2 (ok) but height=24 -> 0\n\n# after\nbatch = VideoBatch(height=768, width=1280)  # latent 96x160 with vae_scale_factor=8","handlingStrategy":"validation","validationCode":"lh = batch.height // config.vae_scale_factor; lw = batch.width // config.vae_scale_factor\nassert lh > 0 and lw > 0, (batch.height, batch.width, config.vae_scale_factor)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce a minimum resolution of vae_scale_factor (ideally its multiple) at request intake","Reject or quantize non-positive/tiny dimensions before the pipeline sees them"],"tags":["ltx-2","video-generation","resolution-validation","sequence-parallelism"],"backgroundTag":"invalid-input-dimensions","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}