{"record":{"id":"3709a2bf67271c67","repo":"sgl-project/sglang","slug":"either-spatial-upsample-or-temporal-upsample-must","errorCode":null,"errorMessage":"Either spatial_upsample or temporal_upsample must be True","messagePattern":"Either spatial_upsample or temporal_upsample must be True","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/upsampler/latent_upsampler.py","lineNumber":233,"sourceCode":"                self.upsampler = SpatialRationalResampler(\n                    mid_channels=mid_channels, scale=self.spatial_scale\n                )\n            else:\n                self.upsampler = torch.nn.Sequential(\n                    torch.nn.Conv2d(\n                        mid_channels, 4 * mid_channels, kernel_size=3, padding=1\n                    ),\n                    PixelShuffleND(2),\n                )\n        elif temporal_upsample:\n            self.upsampler = torch.nn.Sequential(\n                torch.nn.Conv3d(\n                    mid_channels, 2 * mid_channels, kernel_size=3, padding=1\n                ),\n                PixelShuffleND(1),\n            )\n        else:\n            raise ValueError(\n                \"Either spatial_upsample or temporal_upsample must be True\"\n            )\n\n        self.post_upsample_res_blocks = torch.nn.ModuleList(\n            [ResBlock(mid_channels, dims=dims) for _ in range(num_blocks_per_stage)]\n        )\n\n        self.final_conv = conv(mid_channels, in_channels, kernel_size=3, padding=1)\n\n    def forward(self, latent: torch.Tensor) -> torch.Tensor:\n        b, _, f, _, _ = latent.shape\n\n        if self.dims == 2:\n            x = rearrange(latent, \"b c f h w -> (b f) c h w\")\n            x = self.initial_conv(x)\n            x = apply_group_norm_silu(x, self.initial_norm, self.initial_activation)\n            for block in self.res_blocks:\n                x = block(x)","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/upsampler/latent_upsampler.py#L215-L251","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nblock = UpsampleBlock(c, spatial_upsample=False, temporal_upsample=False)\n# after\nblock = UpsampleBlock(c, spatial_upsample=True, temporal_upsample=False)","handlingStrategy":"validation","validationCode":"if not (spatial_upsample or temporal_upsample):\n    raise ValueError(\"stage config must enable spatial or temporal upsampling\")\n# before constructing the block","typeGuard":"def is_valid_upsample_cfg(cfg) -> bool:\n    return bool(cfg.get(\"spatial_upsample\")) or bool(cfg.get(\"temporal_upsample\"))","tryCatchPattern":null,"preventionTips":["Write a config schema asserting at least one upsampling flag per stage","Add a unit test iterating all stage configs and asserting this invariant"],"tags":["upsampler","config","init","value-error"],"backgroundTag":"invalid-constructor-arguments","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}