{"record":{"id":"4e9effa36cf2d44d","repo":"invoke-ai/InvokeAI","slug":"expected-main-gguf-wan-config-got-type-config","errorCode":null,"errorMessage":"Expected Main_GGUF_Wan_Config, got {type(config).__name__}.","messagePattern":"Expected Main_GGUF_Wan_Config, got (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/wan.py","lineNumber":407,"sourceCode":"\n    The community typically distributes Wan A14B as two files (one per expert\n    — high-noise + low-noise). Each file is loaded independently here; the\n    pairing happens at the WanModelLoaderInvocation layer. TI2V-5B ships as a\n    single file.\n\n    Mirrors the QwenImage GGUF loader pattern: ``gguf_sd_loader`` -> strip the\n    ComfyUI ``model.diffusion_model.`` / ``diffusion_model.`` prefix if present\n    -> auto-detect arch from state-dict shapes -> ``init_empty_weights`` +\n    ``load_state_dict(strict=False, assign=True)``.\n    \"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, Main_GGUF_Wan_Config):\n            raise TypeError(f\"Expected Main_GGUF_Wan_Config, got {type(config).__name__}.\")\n\n        if submodel_type != SubModelType.Transformer:\n            raise ValueError(\n                \"Only the Transformer submodel is available from a GGUF Wan checkpoint. \"\n                \"Pair with a standalone Wan VAE and Wan T5 encoder for the other components.\"\n            )\n\n        return self._load_from_singlefile(config)\n\n    def _load_from_singlefile(self, config: Main_GGUF_Wan_Config) -> AnyModel:\n        import accelerate\n        from diffusers import WanTransformer3DModel\n\n        from invokeai.backend.util.logging import InvokeAILogger\n\n        model_path = Path(config.path)\n        target_device = TorchDevice.choose_torch_device()\n        compute_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/wan.py#L389-L425","documentation":"The Wan GGUF single-file loader asserts its input config type: only Main_GGUF_Wan_Config is valid here. Any other config (including the non-GGUF Main_Checkpoint_Wan_Config) indicates the registry dispatched the model to the wrong loader, so a TypeError naming the actual config type is raised.","triggerScenarios":"A Wan GGUF loader receives a non-GGUF config — e.g., a normal checkpoint or diffusers Wan config was registered with a GGUF format, or the registry's format→loader mapping is out of sync after an upgrade.","commonSituations":"Model imported choosing the wrong format (GGUF vs regular checkpoint); editing model records by hand; mixing InvokeAI versions where config class names changed.","solutions":["Re-import the model selecting the correct format: GGUF quantized Wan → GGUF config; regular safetensors → checkpoint config.","If the file is not GGUF-quantized, let it load through Main_Checkpoint_Wan_Config's loader instead.","Upgrade InvokeAI if the registry routing appears inconsistent for your model type."],"exampleFix":"// before\nconfig = Main_Checkpoint_Wan_Config(...)  # routed to GGUF loader\n\n// after\nconfig = Main_GGUF_Wan_Config(...)  # or use checkpoint loader for non-GGUF file","handlingStrategy":"type-guard","validationCode":"def is_gguf_wan(config) -> bool:\n    return type(config).__name__ == 'Main_GGUF_Wan_Config'","typeGuard":"from invokeai.backend.model_manager.config import Main_GGUF_Wan_Config\n\ndef is_gguf_wan_config(config) -> bool:\n    return isinstance(config, Main_GGUF_Wan_Config)","tryCatchPattern":"try:\n    model = wan_gguf_loader.load_model(config, SubModelType.Transformer)\nexcept TypeError as e:\n    if 'Expected Main_GGUF_Wan_Config' in str(e):\n        model = wan_checkpoint_loader.load_model(config, SubModelType.Transformer)\n    else:\n        raise","preventionTips":["Select the GGUF model type only for .gguf-quantized Wan files.","Use InvokeAI's import UI rather than constructing configs manually.","Don't hand-edit model record format fields."],"tags":["type-mismatch","gguf","wan","model-loading"],"backgroundTag":"wrong-loader-for-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}