sgl-project/sglang · critical · ValueError
Modality {modality} is not supported. Supported modalities a
Error message
Modality {modality} is not supported. Supported modalities are `video` and `audio`. What it means
LTX-2's coordinate/rope preparator only knows how to build positional grids for 'video' (spatiotemporal) and 'audio' (1D time) inputs. Passing any other modality string at init fails because scale factors and grid construction are modality-specific.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py:424
self.base_num_frames = int(base_num_frames)
self.num_attention_heads = int(num_attention_heads)
self.base_height = int(base_height)
self.base_width = int(base_width)
self.sampling_rate = int(sampling_rate)
self.hop_length = int(hop_length)
self.audio_latents_per_second = (
float(self.sampling_rate) / float(self.hop_length) / float(scale_factors[0])
)
self.scale_factors = tuple(int(x) for x in scale_factors)
self.theta = float(theta)
self.causal_offset = int(causal_offset)
self.modality = modality
if self.modality not in ["video", "audio"]:
raise ValueError(
f"Modality {modality} is not supported. Supported modalities are `video` and `audio`."
)
self.double_precision = bool(double_precision)
def prepare_video_coords(
self,
batch_size: int,
num_frames: int,
height: int,
width: int,
device: torch.device,
fps: float = 24.0,
*,
start_frame: int = 0,
) -> torch.Tensor:
grid_f = torch.arange(
start=int(start_frame),
end=int(num_frames) + int(start_frame),View on GitHub (pinned to 0132848349)
Solutions
- Use modality='video' for images (single-frame video grid)
- Or use modality='audio' for audio streams
- Extend prepare_*_coords with a new branch if you genuinely need a new modality (code change)
Example fix
// before coords_mod = LTX2Coords(..., modality="image") // after coords_mod = LTX2Coords(..., modality="video") # single frame for images
Defensive patterns
Strategy: validation
Validate before calling
assert modality in ('video', 'audio'), f'modality {modality!r} unsupported; use "video" with 1 frame for images' Type guard
def is_supported_modality(v: str) -> bool:\n return v in ('video', 'audio') Prevention
- Remember images = single-frame video in LTX-2
- Validate modality strings in the config loader
- Document supported enum values in wrappers
When it happens
Trigger: Constructing the module with modality='image', 'text', or an arbitrary string.
Common situations: Adapting the class for image-only generation and passing 'image'; config reuse across modalities; typo. Note: single-frame video (num_frames=1) is the supported way to do images here.
Related errors
- {rope_type=} not supported. Choose between 'interleaved' and
- Unknown activation function: {act_fn}
- Hidden size {self.hidden_size} must be divisible by num_atte
- Unsupported qk_norm: {qk_norm}
- LingBotWorld requires cross_attn_norm=True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b3d8ef6a3bc3f73e.
Report an issue: GitHub.