{"record":{"id":"903bb7491cfb0380","repo":"invoke-ai/InvokeAI","slug":"expected-main-checkpoint-wan-config-got-type-con","errorCode":null,"errorMessage":"Expected Main_Checkpoint_Wan_Config, got {type(config).__name__}.","messagePattern":"Expected Main_Checkpoint_Wan_Config, got (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/wan.py","lineNumber":484,"sourceCode":"\n    This is what CivitAI fine-tunes and ComfyUI-oriented Hugging Face repos ship.\n    Handles the full matrix of community conventions: the optional\n    ``model.diffusion_model.`` key prefix, the native upstream key layout as well\n    as the diffusers one, ComfyUI ``fp8_scaled`` weights (dequantized to the\n    compute dtype at load time), and plain ``float8_e4m3fn`` weights with no\n    scales (cast the same way as any other non-bf16 dtype).\n\n    Like the GGUF loader, one file is one expert; A14B pairing happens at the\n    WanModelLoaderInvocation layer.\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_Checkpoint_Wan_Config):\n            raise TypeError(f\"Expected Main_Checkpoint_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 single-file 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_Checkpoint_Wan_Config) -> AnyModel:\n        import accelerate\n        from diffusers import WanTransformer3DModel\n        from safetensors.torch import load_file\n\n        from invokeai.backend.util.logging import InvokeAILogger\n\n        logger = InvokeAILogger.get_logger(self.__class__.__name__)\n","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/wan.py#L466-L502","documentation":"The Wan single-file (non-GGUF) checkpoint loader asserts it receives Main_Checkpoint_Wan_Config. Any other config type means the registry routed the model to the wrong loader, so a TypeError naming the actual type is raised.","triggerScenarios":"Main_Checkpoint_Wan loader receives a GGUF config, a diffusers-style Wan config, or another checkpoint config subclass — typically from a model record whose format/type fields don't match the loader the registry selected.","commonSituations":"Selecting the wrong model type/format during import; hand-edited model records; registry/config class changes across InvokeAI versions.","solutions":["Re-import or correct the model record so a regular single-file Wan checkpoint uses Main_Checkpoint_Wan_Config.","If the file is GGUF-quantized, register it with Main_GGUF_Wan_Config so the GGUF loader handles it.","Upgrade InvokeAI if routing behavior seems inconsistent with your version's model types."],"exampleFix":"// before\nconfig = Main_GGUF_Wan_Config(...)  # routed to regular checkpoint loader\n\n// after\nconfig = Main_Checkpoint_Wan_Config(...)  # or GGUF loader for quantized files","handlingStrategy":"type-guard","validationCode":"def is_wan_checkpoint(config) -> bool:\n    return type(config).__name__ == 'Main_Checkpoint_Wan_Config'","typeGuard":"from invokeai.backend.model_manager.config import Main_Checkpoint_Wan_Config\n\ndef is_wan_checkpoint_config(config) -> bool:\n    return isinstance(config, Main_Checkpoint_Wan_Config)","tryCatchPattern":"try:\n    model = wan_ckpt_loader.load_model(config, SubModelType.Transformer)\nexcept TypeError as e:\n    if 'Expected Main_Checkpoint_Wan_Config' in str(e):\n        model = wan_gguf_loader.load_model(config, SubModelType.Transformer)\n    else:\n        raise","preventionTips":["Register regular safetensors Wan checkpoints with the checkpoint (non-GGUF) model type.","Let the model manager create model records instead of writing configs by hand.","Re-scan/re-import models after InvokeAI upgrades that change config classes."],"tags":["type-mismatch","checkpoint","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"}