{"record":{"id":"240525d5c46b2e8e","repo":"invoke-ai/InvokeAI","slug":"could-not-determine-wan-variant-from-model-config","errorCode":null,"errorMessage":"Could not determine Wan variant from model {config.name!r}: variant is {variant!r}.","messagePattern":"Could not determine Wan variant from model (.+?): variant is (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/wan_denoise.py","lineNumber":83,"sourceCode":"\n\ndef _get_wan_transformer_working_mem_bytes(device: torch.device, *, enabled: bool) -> int | None:\n    \"\"\"Reserve all but 2 GiB of VRAM so partial-load Wan weights target about 2 GiB resident.\"\"\"\n    if not enabled or device.type != \"cuda\":\n        return None\n\n    total_vram = torch.cuda.get_device_properties(device).total_memory\n    if total_vram <= WAN_MAX_RESIDENT_TRANSFORMER_BYTES:\n        return None\n    return total_vram - WAN_MAX_RESIDENT_TRANSFORMER_BYTES\n\n\ndef _resolve_variant(context: InvocationContext, transformer_field: WanTransformerField) -> WanVariantType:\n    \"\"\"Look up the Wan variant from the main model config that produced this transformer.\"\"\"\n    config = context.models.get_config(transformer_field.transformer)\n    variant = getattr(config, \"variant\", None)\n    if not isinstance(variant, WanVariantType):\n        raise ValueError(f\"Could not determine Wan variant from model {config.name!r}: variant is {variant!r}.\")\n    return variant\n\n\ndef _validate_spatial_dimensions(variant: WanVariantType, width: int, height: int) -> None:\n    if variant == WanVariantType.TI2V_5B and (width % 32 or height % 32):\n        raise ValueError(\n            f\"TI2V-5B requires width and height to be multiples of 32 (got {width}x{height}). \"\n            \"Wan 2.2-VAE 16x spatial * transformer patch_size 2 = pixel dims must divide by 32.\"\n        )\n\n\ndef _validate_ref_condition_shape(\n    condition: torch.Tensor,\n    *,\n    channels: int,\n    frames: int,\n    height: int,\n    width: int,","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/wan_denoise.py#L65-L101","documentation":"_resolve_variant reads the 'variant' attribute from the main model config behind the WanTransformerField and requires it to be a valid WanVariantType member. If the attribute is missing, None, or an unrecognized string, the Wan variant (14B vs TI2V-5B etc.) cannot be determined and the denoise invocation aborts.","triggerScenarios":"Attaching a transformer whose model config has no 'variant' field (older/foreign model installs), a hand-edited models.yaml with variant: null, a model converted/imported before the variant field existed, or pointing the transformer field at a non-Wan model.","commonSituations":"Upgrading Invoke and running old model records lacking the variant key, models installed from third-party repos with incomplete config, manually copied model directories without proper registration.","solutions":["Re-convert/re-install the Wan model so its config includes a valid variant","Set variant explicitly in the model config (e.g. '14b' or 'ti2v-5b') and restart","Remove the model and re-import it via the Model Manager so defaults are applied","Verify the transformer field points at an actual Wan model, not another architecture"],"exampleFix":"// before\n# models.yaml\nmy-wan-model:\n  variant:   # missing/None\n// after\nmy-wan-model:\n  variant: ti2v-5b","handlingStrategy":"validation","validationCode":"config = context.models.get_config(transformer_field.transformer)\nvariant = getattr(config, 'variant', None)\nif variant not in ('14b', 'ti2v-5b'):  # valid WanVariantType values\n    # re-register / fix the model config before invoking","typeGuard":"def has_wan_variant(config) -> bool:\n    from invokeai.backend.model_manager.taxonomy import WanVariantType\n    return isinstance(getattr(config, 'variant', None), WanVariantType)","tryCatchPattern":"try:\n    result = denoise.invoke(context)\nexcept ValueError as e:\n    if \"Could not determine Wan variant\" in str(e):\n        # re-install the model so its config gains a valid variant, then retry\n        model_manager.reinstall(model_key)\n        result = denoise.invoke(context)\n    else:\n        raise","preventionTips":["After upgrading Invoke, re-import or re-convert older Wan models","Never hand-edit variant fields in models.yaml; use the Model Manager","Confirm the transformer field points at a Wan model, not another family","Validate model configs after third-party installs"],"tags":["model-config","wan","configuration"],"backgroundTag":"invalid-model-config","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}