{"record":{"id":"24c4cf613b1f8afa","repo":"sgl-project/sglang","slug":"invalid-self-vae-scale-factor-must-be-0","errorCode":null,"errorMessage":"Invalid {self.vae_scale_factor=}. Must be > 0.","messagePattern":"Invalid (.+?)\\. Must be > 0\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py","lineNumber":338,"sourceCode":"\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 (\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            )","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py#L320-L356","documentation":"LTX-2 pipeline config validates that vae_scale_factor is a positive integer before computing latent spatial dims for sequence-parallel (SP) time-sharding of packed token latents. The latent height/width are derived as batch.height // vae_scale_factor, so a zero or negative scale factor would produce garbage dimensions. This ValueError fires when the configured VAE scale factor is <= 0.","triggerScenarios":"Calling shard_latents_for_sp (which calls _infer_video_latent_frames_and_tokens_per_frame) with a pipeline config whose vae_scale_factor was set to 0 or a negative number, typically from a malformed config file or override.","commonSituations":"Custom LTX-2 pipeline configs edited by hand, configs generated from a checkpoint missing the VAE metadata (defaulting to 0), or programmatic overrides that accidentally assign 0.","solutions":["Check the config source and set vae_scale_factor to the model's correct value (LTX-2 typically uses 8 for spatial VAE downsampling)","If loading from a checkpoint/config dict, verify the key exists and is parsed as a positive int before constructing the pipeline config","Add a validation step at config construction time so the error surfaces earlier with more context"],"exampleFix":"// before\nconfig = LTX2PipelineConfig.from_dict({\"vae_scale_factor\": 0, ...})\nbatch = ...\nconfig.shard_latents_for_sp(batch)  # ValueError\n\n// after\nconfig = LTX2PipelineConfig.from_dict({\"vae_scale_factor\": 8, ...})\nbatch = ...\nconfig.shard_latents_for_sp(batch)","handlingStrategy":"validation","validationCode":"assert isinstance(config.vae_scale_factor, int) and config.vae_scale_factor > 0, config.vae_scale_factor","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate vae_scale_factor and patch fields at config construction, not at sharding time","Log the resolved config values once at startup"],"tags":["ltx-2","video-generation","config-validation","sequence-parallelism"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}