sgl-project/sglang · error · ValueError
Invalid {self.vae_scale_factor=}. Must be > 0.
Error message
Invalid {self.vae_scale_factor=}. Must be > 0. What it means
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.
Source
Thrown at python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py:338
def _infer_video_latent_frames_and_tokens_per_frame(
self, batch, seq_len: int
) -> tuple[int, int]:
"""Infer latent-frame count and tokens-per-frame for packed token latents [B, S, D].
Notes:
- This assumes `patch_size_t == 1` (no temporal patching).
- Tokens are ordered as (frame, height, width) after packing.
"""
if int(self.patch_size_t) != 1:
raise ValueError(
"LTX-2 SP time-sharding for packed token latents currently requires "
f"{self.patch_size_t=}. (Expected 1)"
)
if int(seq_len) <= 0:
raise ValueError(f"Expected {seq_len=} > 0 for packed token latents.")
if int(self.vae_scale_factor) <= 0:
raise ValueError(f"Invalid {self.vae_scale_factor=}. Must be > 0.")
if int(self.patch_size) <= 0:
raise ValueError(f"Invalid {self.patch_size=}. Must be > 0.")
latent_height = int(batch.height) // int(self.vae_scale_factor)
latent_width = int(batch.width) // int(self.vae_scale_factor)
if latent_height <= 0 or latent_width <= 0:
raise ValueError(
"Invalid latent H/W computed from batch.height/width: "
f"{batch.height=} {batch.width=} {self.vae_scale_factor=}"
)
if (latent_height % int(self.patch_size)) != 0 or (
latent_width % int(self.patch_size)
) != 0:
raise ValueError(
"Invalid spatial patching for packed token latents. Expected latent H/W "
"to be divisible by patch_size, got "
f"{latent_height=} {latent_width=} {self.patch_size=}."
)View on GitHub (pinned to 0132848349)
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
Example fix
// before
config = LTX2PipelineConfig.from_dict({"vae_scale_factor": 0, ...})
batch = ...
config.shard_latents_for_sp(batch) # ValueError
// after
config = LTX2PipelineConfig.from_dict({"vae_scale_factor": 8, ...})
batch = ...
config.shard_latents_for_sp(batch) Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(config.vae_scale_factor, int) and config.vae_scale_factor > 0, config.vae_scale_factor
Prevention
- Validate vae_scale_factor and patch fields at config construction, not at sharding time
- Log the resolved config values once at startup
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Invalid {self.patch_size=}. Must be > 0.
- Invalid latent H/W computed from batch.height/width: {batch.
- Invalid tokens_per_frame={tokens_per_frame} from {latent_hei
- LTX-2 token latents seq_len={seq_len} is not divisible by to
- LTX-2 SP time-sharding for packed token latents currently re
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/24c4cf613b1f8afa.
Report an issue: GitHub.