{"record":{"id":"e0e200f157fbb49a","repo":"Comfy-Org/ComfyUI","slug":"unsupported-spatial-scale-scale-choose-from-li","errorCode":null,"errorMessage":"Unsupported spatial_scale {scale}. Choose from {list(mapping.keys())}","messagePattern":"Unsupported spatial_scale (.+?)\\. Choose from (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/ldm/lightricks/latent_upsampler.py","lineNumber":11,"sourceCode":"from typing import Optional, Tuple\nimport torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom einops import rearrange\n\n\ndef _rational_for_scale(scale: float) -> Tuple[int, int]:\n    mapping = {0.75: (3, 4), 1.5: (3, 2), 2.0: (2, 1), 4.0: (4, 1)}\n    if float(scale) not in mapping:\n        raise ValueError(\n            f\"Unsupported spatial_scale {scale}. Choose from {list(mapping.keys())}\"\n        )\n    return mapping[float(scale)]\n\n\nclass PixelShuffleND(nn.Module):\n    def __init__(self, dims, upscale_factors=(2, 2, 2)):\n        super().__init__()\n        assert dims in [1, 2, 3], \"dims must be 1, 2, or 3\"\n        self.dims = dims\n        self.upscale_factors = upscale_factors\n\n    def forward(self, x):\n        if self.dims == 3:\n            return rearrange(\n                x,\n                \"b (c p1 p2 p3) d h w -> b c (d p1) (h p2) (w p3)\",\n                p1=self.upscale_factors[0],","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/lightricks/latent_upsampler.py#L1-L29","documentation":"The LTX latent upsampler maps each supported spatial scale to a rational upsample factor (0.75->3/4, 1.5->3/2, 2.0->2, 4.0->4) and only those exact floats are implemented. A scale outside this set has no resampling math, so _rational_for_scale refuses it.","triggerScenarios":"Constructing the upsampler (or an upsample node) with spatial_scale=1.0, 2.5, 3.0, or a scale passed as a string that does not float-compare equal to a key; also 0.75 written as 3/4 arithmetic that yields 0.7499999.","commonSituations":"UI dropdowns allowing arbitrary numeric input, users typing custom scales, or float rounding when the value crosses layers (JSON round-trip).","solutions":["Use one of the supported scales: 0.75, 1.5, 2.0, 4.0","Snap near-miss floats: scale = min(mapping, key=lambda k: abs(k - scale)) before validating","Chain two supported stages if you need e.g. 3x (2x then 1.5x)"],"exampleFix":"# before\nupsampler = LatentUpsampler(spatial_scale=1.0)  # ValueError\n# after\nupsampler = LatentUpsampler(spatial_scale=2.0)","handlingStrategy":"validation","validationCode":"SUPPORTED = {0.75, 1.5, 2.0, 4.0}\nassert float(spatial_scale) in SUPPORTED, spatial_scale","typeGuard":"def is_supported_scale(s: float) -> bool:\n    return float(s) in {0.75, 1.5, 2.0, 4.0}","tryCatchPattern":null,"preventionTips":["Restrict UI inputs to the supported scale set","Snap near-miss floats to the nearest supported key before validating"],"tags":["ltx","latent-upsample","validation","config"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}