{"record":{"id":"9314f7d62829641f","repo":"invoke-ai/InvokeAI","slug":"could-not-determine-wan-variant-from-state-dict","errorCode":null,"errorMessage":"could not determine Wan variant from state dict","messagePattern":"could not determine Wan variant from state dict","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/main.py","lineNumber":2227,"sourceCode":"        unsupported_reason = _find_unsupported_wan_variant_marker(sd)\n        if unsupported_reason is not None:\n            raise NotAMatchError(unsupported_reason)\n        gguf_name = mod.metadata().get(\"general.name\", \"\")\n        normalized_identity = \"\".join(\n            character for character in f\"{mod.path.stem} {gguf_name}\".lower() if character.isalnum()\n        )\n        if \"wan21\" in normalized_identity:\n            raise NotAMatchError(\"Wan 2.1 GGUF models are not supported by the Wan 2.2 loader\")\n        # A misnamed Wan 2.1 GGUF slips past the name check above; the architectural\n        # markers don't care what the file is called.\n        wan_2_1_reason = _find_wan_2_1_marker(sd)\n        if wan_2_1_reason is not None:\n            raise NotAMatchError(f\"Wan 2.1 GGUF models are not supported by the Wan 2.2 loader: {wan_2_1_reason}\")\n\n        explicit_variant = override_fields.pop(\"variant\", None)\n        variant = explicit_variant or _detect_wan_variant_from_state_dict(sd)\n        if variant is None:\n            raise NotAMatchError(\"could not determine Wan variant from state dict\")\n        if variant in (WanVariantType.T2V_A14B, WanVariantType.I2V_A14B) and \"wan22\" not in normalized_identity:\n            raise NotAMatchError(\"Wan A14B GGUF filename or metadata must identify the model as Wan 2.2\")\n\n        expert = _resolve_wan_expert(mod, override_fields, variant)\n\n        return cls(**override_fields, variant=variant, expert=expert)\n\n\nclass Main_Checkpoint_Wan_Config(Checkpoint_Config_Base, Main_Config_Base, Config_Base):\n    \"\"\"Model config for single-file Wan 2.2 transformer checkpoints (safetensors).\n\n    This is the format the community ships on CivitAI and in ComfyUI-oriented\n    Hugging Face repos: one ``.safetensors`` per transformer, in either the native\n    upstream key layout or the diffusers one, optionally under a\n    ``model.diffusion_model.`` prefix, and optionally ComfyUI ``fp8_scaled``\n    quantized. The loader normalises all of those.\n\n    As with GGUF, A14B's MoE arrives as two files (one per expert); ``expert``","sourceCodeStart":2209,"sourceCodeEnd":2245,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/main.py#L2209-L2245","documentation":"Raised when neither an explicit 'variant' override nor _detect_wan_variant_from_state_dict can classify the Wan GGUF's architecture into a known WanVariantType (T2V_A14B, I2V_A14B, TI2V_5B). The file passed all Wan sanity checks but its tensor shapes don't map to any supported variant.","triggerScenarios":"Importing an experimental or truncated Wan GGUF whose transformer dimensions are ambiguous; a heavily modified/distilled Wan build with nonstandard hidden sizes; a file corrupted mid-download so shape-bearing tensors are missing.","commonSituations":"Preview/beta Wan releases not matching any published config; incomplete HF downloads (download interrupted); custom merges.","solutions":["Re-download the GGUF to rule out truncation, then re-run model scan","Pass an explicit variant at import time (override the 'variant' field with T2V_A14B, I2V_A14B, or TI2V_5B) if you know the architecture","Verify against the publisher's repo that the file is one of the supported variants; otherwise wait for InvokeAI support"],"exampleFix":"// before\n# import with no variant hint for an ambiguous wan gguf\n// after\n# POST a model record with an explicit variant override, or confirm the file\n# matches a known release like Wan2.2-TI2V-5B-Q8_0.gguf","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager.model_on_disk import ModelOnDisk\nfrom invokeai.backend.model_manager.configs.main import _detect_wan_variant_from_state_dict\n\nvariant = _detect_wan_variant_from_state_dict(ModelOnDisk(path).load_state_dict())\nif variant is None:\n    print(f'{path.name}: no known Wan variant detected — re-download or supply a variant override')","typeGuard":null,"tryCatchPattern":"try:\n    import_model(path)\nexcept NotAMatchError as e:\n    if 'could not determine Wan variant' in str(e):\n        import_model(path, variant='ti2v_5b')  # pass the known variant explicitly\n    else:\n        raise","preventionTips":["Re-verify file integrity (size/hash) after downloads; truncated GGUFs lose shape info","Only import published Wan variants (T2V-A14B, I2V-A14B, TI2V-5B)","Supply a variant override for custom merges whose shapes are ambiguous"],"tags":["model-manager","gguf","wan","variant-detection"],"backgroundTag":"model-variant-detection-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}