{"record":{"id":"7095b843e81b4798","repo":"invoke-ai/InvokeAI","slug":"a-submodel-type-must-be-provided-when-loading-main-7095b8","errorCode":null,"errorMessage":"A submodel type must be provided when loading main pipelines.","messagePattern":"A submodel type must be provided when loading main pipelines\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py","lineNumber":71,"sourceCode":"@ModelLoaderRegistry.register(base=BaseModelType.StableDiffusion1, type=ModelType.Main, format=ModelFormat.Checkpoint)\n@ModelLoaderRegistry.register(base=BaseModelType.StableDiffusion2, type=ModelType.Main, format=ModelFormat.Checkpoint)\n@ModelLoaderRegistry.register(base=BaseModelType.StableDiffusionXL, type=ModelType.Main, format=ModelFormat.Checkpoint)\n@ModelLoaderRegistry.register(\n    base=BaseModelType.StableDiffusionXLRefiner, type=ModelType.Main, format=ModelFormat.Checkpoint\n)\nclass StableDiffusionDiffusersModel(GenericDiffusersLoader):\n    \"\"\"Class to load main models.\"\"\"\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            return self._load_from_singlefile(config, submodel_type)\n\n        if submodel_type is None:\n            raise Exception(\"A submodel type must be provided when loading main pipelines.\")\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        try:\n            result: AnyModel = load_class.from_pretrained(\n                model_path,\n                torch_dtype=self._torch_dtype,\n                variant=variant,\n                local_files_only=True,\n            )\n        except OSError as e:\n            if variant and \"no file named\" in str(\n                e\n            ):  # try without the variant, just in case user's preferences changed\n                result = load_class.from_pretrained(model_path, torch_dtype=self._torch_dtype, local_files_only=True)","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/stable_diffusion.py#L53-L89","documentation":"Loading a main Stable Diffusion pipeline from a diffusers directory requires knowing which component to build (UNet, VAE, text encoder, tokenizer, scheduler); without a submodel_type the loader cannot proceed, so it raises an Exception. Checkpoint (single-file) configs are exempt because they load via a different path.","triggerScenarios":"Calling the StableDiffusion loader with a diffusers-folder config and submodel_type=None; a caller forgetting to pass the component when loading a main model; code paths that only handle single-file configs.","commonSituations":"Custom automation/scripts that load 'the model' expecting the whole pipeline; refactors that dropped the submodel argument; confusion between Checkpoint and Diffusers config types.","solutions":["Pass the desired SubModelType (e.g. SubModelType.UNet, VAE, TextEncoder, Tokenizer, Scheduler) when loading a main diffusers model.","If you need the whole pipeline, load via the pipeline-level API rather than the component loader.","Confirm the config type: single-file checkpoints don't require submodel_type, diffusers folders do."],"exampleFix":"// before\nmodel = loader.load_model(diffusers_config, submodel_type=None)\n// after\nmodel = loader.load_model(diffusers_config, submodel_type=SubModelType.UNet)","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager.config import Checkpoint_Config_Base\nif not isinstance(config, Checkpoint_Config_Base) and submodel_type is None:\n    raise ValueError(\"submodel_type is required for diffusers main pipelines\")","typeGuard":"def requires_submodel(config) -> bool:\n    return not isinstance(config, Checkpoint_Config_Base)","tryCatchPattern":"try:\n    model = loader.load_model(config, submodel_type=sub)\nexcept Exception as e:\n    if \"submodel type must be provided\" in str(e):\n        logger.error(\"Pass a SubModelType when loading diffusers main pipelines\")\n    raise","preventionTips":["Always specify the component (UNet/VAE/TextEncoder/Tokenizer/Scheduler) for diffusers models.","Branch on config type: checkpoints don't need submodel_type, diffusers folders do.","Use pipeline-level loading when you want the whole model."],"tags":["missing-argument","submodel","stable-diffusion","model-loading"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}