invoke-ai/InvokeAI · error · TypeError
Expected AutoencoderKLWan for Wan VAE, got {type(vae_info.mo
Error message
Expected AutoencoderKLWan for Wan VAE, got {type(vae_info.model).__name__}. What it means
invoke() loads the VAE via context.models.load and asserts it is a diffusers AutoencoderKLWan instance, because the decode path depends on Wan-specific APIs (config.z_dim, Wan decode semantics). Any other VAE class raises this TypeError with the actual class name.
Source
Thrown at invokeai/app/invocations/wan_latents_to_video.py:107
@torch.no_grad()
def invoke(self, context: InvocationContext) -> VideoOutput:
latents = context.tensors.load(self.latents.latents_name)
_validate_video_latent_batch(latents)
if latents.ndim == 4:
# Promote 4D (single-frame) to 5D so this node can also serve as a
# one-frame "video" encode if someone wires it that way.
latents = latents.unsqueeze(2)
if latents.ndim != 5:
raise ValueError(
f"Wan latents-to-video expects a 5D latent tensor [B, C, T, H, W]; got {tuple(latents.shape)}."
)
if any(size == 0 for size in latents.shape[2:]):
raise ValueError("Wan latents-to-video requires non-empty temporal and spatial dimensions.")
vae_info = context.models.load(self.vae.vae)
if not isinstance(vae_info.model, AutoencoderKLWan):
raise TypeError(f"Expected AutoencoderKLWan for Wan VAE, got {type(vae_info.model).__name__}.")
if latents.shape[1] != vae_info.model.config.z_dim:
raise ValueError(
f"Latent channel mismatch: these latents have {latents.shape[1]} channels but the "
f"selected VAE expects {vae_info.model.config.z_dim}. A14B models need the 16-channel Wan 2.1 VAE; "
"TI2V-5B needs the 48-channel Wan 2.2 VAE."
)
_, _, t_lat, h_lat, w_lat = latents.shape
spatial_scale = getattr(vae_info.model.config, "scale_factor_spatial", None) or 8
temporal_scale = getattr(vae_info.model.config, "scale_factor_temporal", None) or 4
t_pixel = (t_lat - 1) * temporal_scale + 1
h_pixel, w_pixel = h_lat * spatial_scale, w_lat * spatial_scale
optimize_memory = context.config.get().wan_memory_optimization
estimated_working_memory = estimate_vae_working_memory_wan(
operation="decode",
vae=vae_info.model,View on GitHub (pinned to 0b6a024f2f)
Solutions
- Point the node's vae field at a Wan VAE model (AutoencoderKLWan).
- Check the loaded model type in the Model Manager and correct the record if it resolves to the wrong class.
- Create a fresh VAE node referencing the Wan 2.1/2.2 VAE instead of reusing an image-model VAE.
Example fix
// before vae = sdxl_vae # AutoencoderKL video = wan_latents_to_video(latents=latents, vae=vae) # TypeError // after vae = wan_vae # AutoencoderKLWan (Wan 2.1 or 2.2) video = wan_latents_to_video(latents=latents, vae=vae)
Defensive patterns
Strategy: type-guard
Validate before calling
vae_info = context.models.load(vae.vae)
if not isinstance(vae_info.model, AutoencoderKLWan):
raise TypeError(f"Need AutoencoderKLWan, got {type(vae_info.model).__name__}") Type guard
def is_wan_vae(model) -> bool:
return isinstance(model, AutoencoderKLWan) Try / catch
try:
video = node.invoke(context)
except TypeError as e:
if "Expected AutoencoderKLWan" in str(e):
vae = load_wan_vae_for(transformer_variant)
video = replace(node, vae=vae).invoke(context)
else:
raise Prevention
- Verify VAE class in the Model Manager record before wiring.
- Never share VAE nodes across SD/Flux/Wan workflows.
- Use a fresh VAE node per Wan workflow.
- Check model IDs include the 'wan' family.
When it happens
Trigger: Wiring a non-Wan VAE (e.g. SDXL AutoencoderKL, AutoencoderKLWan wrapped differently, Flux VAE) into the vae field of wan_latents_to_video and calling invoke().
Common situations: Reusing a VAE node from an SD/Flux workflow template; a model manager record resolving to the wrong model class; copy-pasting a VAE model ID between workflows.
Related errors
- {type(config).__name__} is a single-file config; it does not
- Expected Main_GGUF_Wan_Config, got {type(config).__name__}.
- Expected Main_Checkpoint_Wan_Config, got {type(config).__nam
- Expected LlavaOnevisionForConditionalGeneration, got {type(m
- Expected AutoencoderKLWan or FluxAutoEncoder for Anima VAE,
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/56c1c6d30fb4890e.
Report an issue: GitHub.