{"record":{"id":"62ff0c09aa6b2ccb","repo":"invoke-ai/InvokeAI","slug":"a-submodel-type-must-be-provided-when-loading-wan","errorCode":null,"errorMessage":"A submodel type must be provided when loading Wan main pipelines.","messagePattern":"A submodel type must be provided when loading Wan main pipelines\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/wan.py","lineNumber":67,"sourceCode":"    \"\"\"Loader for Wan 2.2 diffusers-format models (T2V-A14B and TI2V-5B).\n\n    Forces bfloat16 for the transformer and VAE — fp16 is unstable on Wan VAE\n    (same issue affects the Flux VAE). Resolves the appropriate Hugging Face\n    class for each submodel via the parent loader's ``get_hf_load_class``.\n    \"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if isinstance(config, Checkpoint_Config_Base):\n            # Defensive: the registry keys on format, so single-file configs are\n            # routed to WanGGUFCheckpointModel / WanCheckpointModel, not here.\n            raise TypeError(f\"{type(config).__name__} is a single-file config; it does not belong to this loader.\")\n\n        if submodel_type is None:\n            raise Exception(\"A submodel type must be provided when loading Wan main pipelines.\")\n\n        if submodel_type is SubModelType.VAE:\n            from invokeai.backend.wan.rocm_causal_conv3d import patch_wan_causal_conv3d_for_rocm\n\n            patch_wan_causal_conv3d_for_rocm()\n\n        model_path = Path(config.path)\n        load_class = self.get_hf_load_class(model_path, submodel_type)\n        repo_variant = config.repo_variant if isinstance(config, Diffusers_Config_Base) else None\n        variant = repo_variant.value if repo_variant else None\n        model_path = model_path / submodel_type.value\n\n        def _load_with_variant_fallback(dtype_kwarg: dict[str, torch.dtype]) -> AnyModel:\n            # Some Wan repos ship without a fp16 variant suffix on every submodel.\n            # If the requested variant isn't on disk, fall back to the default weights.\n            try:\n                return load_class.from_pretrained(\n                    model_path,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/wan.py#L49-L85","documentation":"Wan main pipelines are composite models; this loader needs to know which component (transformer, VAE, text encoder) to build, passed via submodel_type. If submodel_type is None, a plain Exception is raised because no component can be selected.","triggerScenarios":"Loading a Wan pipeline config without specifying SubModelType (e.g., calling _load_model with submodel_type=None), typically when the model manager was asked for the whole pipeline in a context that should request a specific submodel.","commonSituations":"Custom automation/scripts that call the loader API directly; older integration code written before Wan main-pipeline loading required submodel selection; copy-pasted loader calls from single-component model types.","solutions":["Pass an explicit submodel_type (SubModelType.Transformer, SubModelType.VAE, SubModelType.TextEncoder) when loading Wan main pipelines.","Use the normal model-manager load path, which iterates submodels and always supplies submodel_type.","If you only need the transformer, register a single-file Wan checkpoint config instead so the checkpoint loaders apply."],"exampleFix":"// before\nmodel = loader.load_model(config, submodel_type=None)\n\n// after\nfrom invokeai.backend.model_manager import SubModelType\nmodel = loader.load_model(config, submodel_type=SubModelType.Transformer)","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager import SubModelType\n\ndef validate_wan_load(config, submodel_type):\n    assert submodel_type is not None, \"Wan main pipelines require an explicit submodel_type\"\n    assert submodel_type in (SubModelType.Transformer, SubModelType.VAE, SubModelType.TextEncoder)","typeGuard":null,"tryCatchPattern":"try:\n    model = loader.load_model(config, submodel_type)\nexcept Exception as e:\n    if 'submodel type must be provided' in str(e):\n        model = loader.load_model(config, submodel_type=SubModelType.Transformer)\n    else:\n        raise","preventionTips":["Never pass submodel_type=None when loading composite (main pipeline) models.","Use the model manager's high-level load API rather than instantiating loaders directly.","Add asserts in automation scripts that submodel_type is set before pipeline loads."],"tags":["missing-argument","model-loading","wan"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}