{"record":{"id":"7641f971452e876f","repo":"invoke-ai/InvokeAI","slug":"expected-autoencoderklwan-or-fluxautoencoder-for-a","errorCode":null,"errorMessage":"Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}.","messagePattern":"Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/anima_image_to_latents.py","lineNumber":61,"sourceCode":"\n@invocation(\n    \"anima_i2l\",\n    title=\"Image to Latents - Anima\",\n    tags=[\"image\", \"latents\", \"vae\", \"i2l\", \"anima\"],\n    category=\"image\",\n    version=\"1.0.1\",\n    classification=Classification.Prototype,\n)\nclass AnimaImageToLatentsInvocation(BaseInvocation, WithMetadata, WithBoard):\n    \"\"\"Generates latents from an image using the Anima VAE (supports Wan 2.1 and FLUX VAE).\"\"\"\n\n    image: ImageField = InputField(description=\"The image to encode.\")\n    vae: VAEField = InputField(description=FieldDescriptions.vae, input=Input.Connection)\n\n    @staticmethod\n    def vae_encode(vae_info: LoadedModel, image_tensor: torch.Tensor) -> torch.Tensor:\n        if not isinstance(vae_info.model, (AutoencoderKLWan, FluxAutoEncoder)):\n            raise TypeError(\n                f\"Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE, got {type(vae_info.model).__name__}.\"\n            )\n\n        if isinstance(vae_info.model, AutoencoderKLWan):\n            estimated_working_memory = estimate_vae_working_memory_anima(\n                operation=\"encode\",\n                image_tensor=image_tensor,\n                vae=vae_info.model,\n                tile_size=None,\n            )\n        else:\n            estimated_working_memory = estimate_vae_working_memory_flux(\n                operation=\"encode\",\n                image_tensor=image_tensor,\n                vae=vae_info.model,\n            )\n\n        with vae_info.model_on_device(working_mem_bytes=estimated_working_memory) as (_, vae):","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/anima_image_to_latents.py#L43-L79","documentation":"The Anima VAE encode entry point only supports AutoencoderKLWan or FluxAutoEncoder VAE models. Before doing any work, vae_encode type-checks the loaded model and raises this TypeError if the model manager returned some other VAE class.","triggerScenarios":"Connecting a VAE field whose loaded model is e.g. AutoencoderKL (SD/SDXL VAE) or another unsupported class to the Anima ImageToLatents node's vae input.","commonSituations":"Selecting a mismatched VAE in a workflow (SDXL VAE with an Anima pipeline); a model-manager lookup returning the wrong model due to duplicate keys; workflows copied across pipelines with different model families.","solutions":["Select an Anima-compatible VAE (AutoencoderKLWan or FluxAutoEncoder) in the VAE loader node.","Verify the VAE model's base/architecture matches Anima in the model manager.","Re-import the VAE if the model manager resolved the wrong class for its key."],"exampleFix":"// before\nvae = vae_loader(vae_model=\"sdxl-vae\")\n// after\nvae = vae_loader(vae_model=\"anima-vae\")  # AutoencoderKLWan / FluxAutoEncoder","handlingStrategy":"type-guard","validationCode":"vae_info = context.models.load(vae.vae)\nfrom diffusers import AutoencoderKLWan\nfrom invokeai.backend.flux.model import FluxAutoEncoder\nassert isinstance(vae_info.model, (AutoencoderKLWan, FluxAutoEncoder)), \"incompatible VAE\"","typeGuard":"def is_anima_vae(model) -> bool:\n    from diffusers import AutoencoderKLWan\n    from invokeai.backend.flux.model import FluxAutoEncoder\n    return isinstance(model, (AutoencoderKLWan, FluxAutoEncoder))","tryCatchPattern":"try:\n    latents = img2latents.invoke(context)\nexcept TypeError as e:\n    if \"Anima VAE\" in str(e):\n        raise RuntimeError(\"Attach an Anima-compatible VAE loader\") from e","preventionTips":["Match VAE base model to the pipeline family before wiring workflows","Check the model type column in the model manager UI","Avoid reusing SD/SDXL VAE fields in Anima workflows"],"tags":["vae","type-error","model-loading"],"backgroundTag":"incompatible-model-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}