sgl-project/sglang · error · ValueError
LTX-2 SP time-sharding for packed token latents currently re
Error message
LTX-2 SP time-sharding for packed token latents currently requires {self.patch_size_t=}. (Expected 1) What it means
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.
Source
Thrown at python/sglang/multimodal_gen/configs/pipeline_configs/ltx_2.py:331
self.patch_size,
)
latents = latents.permute(0, 2, 4, 6, 1, 3, 5, 7).flatten(4, 7).flatten(1, 3)
# Deliberately left non-contiguous: both flattens are views, so this
# keeps the permuted strides. Normalising here would change which GEMM
# kernel runs and move bf16 output. The fp8 path makes its own copy.
return latents
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 (View on GitHub (pinned to 0132848349)
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)
Example fix
# before pipeline_config.patch_size_t = 2 # temporal patching + SP -> raises # after pipeline_config.patch_size_t = 1 # or run without --sp-size
Defensive patterns
Strategy: validation
Validate before calling
if using_sp():
assert int(pipeline_config.patch_size_t) == 1, "SP time-sharding requires patch_size_t=1" Try / catch
except ValueError as e:
if "patch_size_t" in str(e):
run_without_sp() # fall back to TP or single GPU Prevention
- Pin model revisions with patch_size_t=1 for SP deployments
- Smoke-test SP sharding after any config/model override
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Expected {seq_len=} > 0 for packed token latents.
- Krea-2 sequence parallelism does not support ragged/padded m
- padding_side must be 'left' or 'right', got {padding_side}
- Unsupported text encoder output: expected `hidden_states`.
- num_inference_steps must be positive, got {steps}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/85f22bfbac714521.
Report an issue: GitHub.