sgl-project/sglang · error · ValueError
Either spatial_upsample or temporal_upsample must be True
Error message
Either spatial_upsample or temporal_upsample must be True
What it means
The upsampling stage of the latent upsampler must upscale in at least one dimension: spatial (H×W) or temporal (T). Passing spatial_upsample=False together with temporal_upsample=False leaves the 'else' branch with nothing to build, so __init__ raises.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/upsampler/latent_upsampler.py:233
self.upsampler = SpatialRationalResampler(
mid_channels=mid_channels, scale=self.spatial_scale
)
else:
self.upsampler = torch.nn.Sequential(
torch.nn.Conv2d(
mid_channels, 4 * mid_channels, kernel_size=3, padding=1
),
PixelShuffleND(2),
)
elif temporal_upsample:
self.upsampler = torch.nn.Sequential(
torch.nn.Conv3d(
mid_channels, 2 * mid_channels, kernel_size=3, padding=1
),
PixelShuffleND(1),
)
else:
raise ValueError(
"Either spatial_upsample or temporal_upsample must be True"
)
self.post_upsample_res_blocks = torch.nn.ModuleList(
[ResBlock(mid_channels, dims=dims) for _ in range(num_blocks_per_stage)]
)
self.final_conv = conv(mid_channels, in_channels, kernel_size=3, padding=1)
def forward(self, latent: torch.Tensor) -> torch.Tensor:
b, _, f, _, _ = latent.shape
if self.dims == 2:
x = rearrange(latent, "b c f h w -> (b f) c h w")
x = self.initial_conv(x)
x = apply_group_norm_silu(x, self.initial_norm, self.initial_activation)
for block in self.res_blocks:
x = block(x)View on GitHub (pinned to 0132848349)
Solutions
- Enable at least one of spatial_upsample or temporal_upsample for every stage that instantiates this block
- If the stage truly should not upsample, skip constructing the block entirely instead of passing both False
- Check the stage's target resolution vs input resolution to decide which flag to set
Example fix
# before block = UpsampleBlock(c, spatial_upsample=False, temporal_upsample=False) # after block = UpsampleBlock(c, spatial_upsample=True, temporal_upsample=False)
Defensive patterns
Strategy: validation
Validate before calling
if not (spatial_upsample or temporal_upsample):
raise ValueError("stage config must enable spatial or temporal upsampling")
# before constructing the block Type guard
def is_valid_upsample_cfg(cfg) -> bool:
return bool(cfg.get("spatial_upsample")) or bool(cfg.get("temporal_upsample")) Prevention
- Write a config schema asserting at least one upsampling flag per stage
- Add a unit test iterating all stage configs and asserting this invariant
When it happens
Trigger: Constructing the upsampler block with both flags False, e.g. UpsampleBlock(mid_channels, spatial_upsample=False, temporal_upsample=False) or a config where both are disabled for the final stage.
Common situations: Config generated programmatically that disables all upsampling for a 'no-op' stage; YAML/JSON config where the last stage defaults to False for both keys; editing a config and accidentally turning off the wrong flag.
Related errors
- Unsupported scale {scale}. Choose from {list(mapping.keys())
- Cosmos3 AVAE dec_strides product must equal hop_size: produc
- Invalid threshold_type for topk: {threshold_type}. Choose 'q
- Invalid threshold_type: {threshold_type}. Choose 'query_head
- SGLANG_DIFFUSION_ATTENTION_CONFIG is not set
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/3709a2bf67271c67.
Report an issue: GitHub.