invoke-ai/InvokeAI · error · TypeError

Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE,

Error message

Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}.

What it means

In the Anima latents-to-image invocation, the loaded VAE must be an AutoencoderKLWan or FluxAutoEncoder for decoding; this TypeError is raised immediately after context.models.load if the model is any other class.

Source

Thrown at invokeai/app/invocations/anima_latents_to_image.py:115

        ~1s tiled with the transformer left resident). Tile when the full-decode working
        memory would consume most of the device, otherwise a single-pass decode is
        faster (~0.65s vs ~1.05s at 1024x1024) and exact.
        """
        if device.type == "cuda":
            total_vram = torch.cuda.get_device_properties(device).total_memory
        elif device.type == "xpu":
            total_vram = torch.xpu.get_device_properties(device).total_memory
        else:
            return False
        return full_decode_working_memory > 0.7 * total_vram

    @torch.no_grad()
    def invoke(self, context: InvocationContext) -> ImageOutput:
        latents = context.tensors.load(self.latents.latents_name)

        vae_info = context.models.load(self.vae.vae)
        if not isinstance(vae_info.model, (AutoencoderKLWan, FluxAutoEncoder)):
            raise TypeError(
                f"Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}."
            )

        use_tiling = False
        if isinstance(vae_info.model, AutoencoderKLWan):
            full_decode_working_memory = estimate_vae_working_memory_anima(
                operation="decode",
                image_tensor=latents,
                vae=vae_info.model,
                tile_size=None,
            )
            use_tiling = self._use_tiled_decode(TorchDevice.choose_torch_device(), full_decode_working_memory)
            estimated_working_memory = estimate_vae_working_memory_anima(
                operation="decode",
                image_tensor=latents,
                vae=vae_info.model,
                tile_size=ANIMA_VAE_TILE_SIZE if use_tiling else None,
            )

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use an Anima-compatible VAE (AutoencoderKLWan or FluxAutoEncoder) in the LatentsToImage node.
  2. Verify the VAE record's base model/architecture in the model manager.
  3. Re-scan models or re-import the VAE so it registers under the correct class.

Example fix

// before
latents2img.vae = vae_loader("sd-vae-1.4")
// after
latents2img.vae = vae_loader("anima-vae")
Defensive patterns

Strategy: type-guard

Validate before calling

vae_info = context.models.load(vae_field.vae)
if not is_anima_vae(vae_info.model):
    raise ValueError("Anima latents-to-image requires AutoencoderKLWan/FluxAutoEncoder")

Type guard

def is_anima_vae(model) -> bool:
    from diffusers import AutoencoderKLWan
    from invokeai.backend.flux.model import FluxAutoEncoder
    return isinstance(model, (AutoencoderKLWan, FluxAutoEncoder))

Try / catch

try:
    output = node.invoke(context)
except TypeError as e:
    if "Anima VAE" in str(e):
        raise RuntimeError("Attach the matching Anima VAE for decode") from e

Prevention

When it happens

Trigger: Decoding Anima latents with a vae input whose loaded model is not an Anima-compatible VAE (e.g. an SD/SDXL AutoencoderKL).

Common situations: Selecting the default pipeline VAE for the wrong model family; workflow templates carried over from SDXL; duplicate model keys causing the manager to load the wrong record.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/2f3a3db968339cc2. Report an issue: GitHub.