Comfy-Org/ComfyUI · error · RuntimeError

SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` m

Error message

SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` must be a dict; got {type(seedvr2_tiling).__name__} with value {seedvr2_tiling!r}.

What it means

VideoAutoencoderKLWrapper.decode accepts an optional seedvr2_tiling argument that must be a dict of tiling options (or None, which is treated as {}). Any other type (string, bool, list, number) raises a RuntimeError because the code immediately calls .get() on it. The error message includes the offending type and value for easy diagnosis.

Source

Thrown at comfy/ldm/seedvr/vae.py:1473

        x = self.decode(z)
        return x, z, p

    def _encode_with_raw_latent(self, x):
        if x.ndim == 4:
            x = x.unsqueeze(2)
        self.device = x.device
        p = super().encode(x)
        z = p.squeeze(2)
        return z, p

    def encode(self, x):
        z, _ = self._encode_with_raw_latent(x)
        return z

    def decode(self, z, seedvr2_tiling=None):
        seedvr2_tiling = {} if seedvr2_tiling is None else seedvr2_tiling
        if not isinstance(seedvr2_tiling, dict):
            raise RuntimeError(
                "SeedVR2 VideoAutoencoderKLWrapper.decode: `seedvr2_tiling` must be a dict; "
                f"got {type(seedvr2_tiling).__name__} with value {seedvr2_tiling!r}."
            )

        if z.ndim == 5:
            _, c, _, _, _ = z.shape
            if c != SEEDVR2_LATENT_CHANNELS:
                raise RuntimeError(
                    "SeedVR2 VideoAutoencoderKLWrapper.decode: 5-D latent input must "
                    f"have {SEEDVR2_LATENT_CHANNELS} channels; got shape {tuple(z.shape)}."
                )
            latent = z
        elif z.ndim == 4:
            b, tc, h, w = z.shape
            if tc % SEEDVR2_LATENT_CHANNELS != 0:
                raise RuntimeError(
                    "SeedVR2 VideoAutoencoderKLWrapper.decode: 4-D latent input must "
                    f"use collapsed channel layout (B, {SEEDVR2_LATENT_CHANNELS}*T, H, W); "

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Pass a dict, e.g. decode(z, {"enable_tiling": True}) or omit the argument entirely.
  2. If the value comes from parsed JSON or UI input, coerce/validate it to a dict before the call.
  3. Enable tiling with the documented keys: decode(z, {"enable_tiling": True, ...tile params...}).

Example fix

# before
img = vae.decode(latent, seedvr2_tiling=True)
# after
img = vae.decode(latent, seedvr2_tiling={"enable_tiling": True})
Defensive patterns

Strategy: type-guard

Validate before calling

if seedvr2_tiling is not None and not isinstance(seedvr2_tiling, dict):
    raise TypeError("seedvr2_tiling must be a dict or None")
vae.decode(z, seedvr2_tiling=seedvr2_tiling)

Type guard

def is_tiling_opts(v) -> bool:
    return v is None or isinstance(v, dict)

Try / catch

try:
    out = vae.decode(z, seedvr2_tiling=opts)
except RuntimeError as e:
    if "must be a dict" in str(e):
        opts = {"enable_tiling": bool(opts)} if not isinstance(opts, dict) else opts
        out = vae.decode(z, seedvr2_tiling=opts)
    else:
        raise

Prevention

When it happens

Trigger: Calling decode(z, seedvr2_tiling=True), decode(z, "tiled"), or passing a JSON-parsed value that is not an object.

Common situations: Treating tiling as a boolean flag; deserializing workflow JSON where seedvr2_tiling was saved as a string or list; forwarding an untyped UI combo value straight into decode.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/cfb14508eda99b53. Report an issue: GitHub.