sgl-project/sglang · error · ValueError
Unsupported dims: {self.dims}
Error message
Unsupported dims: {self.dims} What it means
LatentUpsampler.forward only supports 3D (video: b c f h w) and modified-4D/5D rearrange paths keyed by self.dims and upscale_factors; any other dims value falls through to this ValueError. The module is built for a fixed spatial/temporal upsampling geometry.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/upsampler/latent_upsampler.py:92
p1=self.upscale_factors[0],
p2=self.upscale_factors[1],
p3=self.upscale_factors[2],
)
elif self.dims == 2:
return rearrange(
x,
"b (c p1 p2) h w -> b c (h p1) (w p2)",
p1=self.upscale_factors[0],
p2=self.upscale_factors[1],
)
elif self.dims == 1:
return rearrange(
x,
"b (c p1) f h w -> b c (f p1) h w",
p1=self.upscale_factors[0],
)
else:
raise ValueError(f"Unsupported dims: {self.dims}")
class ResBlock(torch.nn.Module):
"""Residual block with two conv layers, group norm, and SiLU activation."""
def __init__(
self, channels: int, mid_channels: Optional[int] = None, dims: int = 3
):
super().__init__()
if mid_channels is None:
mid_channels = channels
conv = torch.nn.Conv2d if dims == 2 else torch.nn.Conv3d
self.conv1 = conv(channels, mid_channels, kernel_size=3, padding=1)
self.norm1 = torch.nn.GroupNorm(32, mid_channels)
self.conv2 = conv(mid_channels, channels, kernel_size=3, padding=1)
self.norm2 = torch.nn.GroupNorm(32, channels)
self.activation = torch.nn.SiLU()
View on GitHub (pinned to 0132848349)
Solutions
- Set dims to the supported value matching your data (5 for video latents b c f h w)
- For plain 2D image latent upsampling use a different module (e.g. a VAE decoder-side upsampler or interpolate)
- Verify tensor shape before forward: x.ndim should equal self.dims + 2
Example fix
// before ups = LatentUpsampler(..., dims=2) y = ups(x) # x: b c h w // after ups = LatentUpsampler(..., dims=5) y = ups(x) # x: b c f h w video latents
Defensive patterns
Strategy: type-guard
Validate before calling
assert x.ndim == ups.dims + 2 or (x.ndim == ups.dims and ups.dims in (3, 4)), f"unexpected rank {x.ndim} for dims={ups.dims}" Type guard
def is_supported_upsampler_input(x: torch.Tensor, ups) -> bool:
return x.ndim in (ups.dims, ups.dims + 1, ups.dims + 2) and ups.dims in (3, 5) Try / catch
try:
y = ups(x)
except ValueError as e:
if "Unsupported dims" in str(e):
raise ValueError(f"feed {ups.dims + 2}-D latents to LatentUpsampler") from e
raise Prevention
- Check tensor rank against module dims before forward
- Use the video latent upsampler only for video latents; pick another path for 2D images
When it happens
Trigger: Instantiating LatentUpsampler with dims not equal to the supported values (e.g. dims=2 for plain 2D image latents) and calling forward(), or feeding tensors whose rank does not match the configured path.
Common situations: Reusing the video latent upsampler for 2D image latents, changing dims in config, or passing incorrectly rearranged tensors from a different pipeline stage.
Related errors
- Z-Image text embeddings must have shape [seq, dim] or [batch
- Z-Image caption tensor must have rank 2 or 3
- f"Expected camera embedding shape [B, C, F, H, W], got {tupl
- f"Input shape {tuple(x.shape)} must be divisible by patch_si
- Expected [F, H, W, C] uint8 video, got shape={tuple(video_ui
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/df3689e1eb484daa.
Report an issue: GitHub.