{"record":{"id":"c55dd2d08b9626ab","repo":"invoke-ai/InvokeAI","slug":"a-submodel-type-must-be-provided-when-loading-main-c55dd2","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/qwen_image.py","lineNumber":145,"sourceCode":"        model_config[\"zero_cond_t\"] = True\n\n    return model_config\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.QwenImage, type=ModelType.Main, format=ModelFormat.Diffusers)\nclass QwenImageDiffusersModel(GenericDiffusersLoader):\n    \"\"\"Class to load Qwen Image Edit 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            raise NotImplementedError(\"CheckpointConfigBase is not implemented for Qwen Image Edit models.\")\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\n        # We force bfloat16 for Qwen Image Edit models.\n        # Use `dtype` (newer) with fallback to `torch_dtype` (older diffusers).\n        dtype_kwarg = {\"dtype\": torch.bfloat16}\n        try:\n            result: AnyModel = load_class.from_pretrained(\n                model_path,\n                **dtype_kwarg,\n                variant=variant,\n                local_files_only=True,\n            )\n        except TypeError:","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/qwen_image.py#L127-L163","documentation":"The Qwen Image main-pipeline model loader requires a submodel_type (e.g. transformer, vae, tokenizer) whenever the model is a main/diffusers pipeline so it can pick the correct subfolder and HF load class. If _load_model is invoked with submodel_type=None for a main pipeline (non-checkpoint config path), it raises this bare Exception. It signals a dispatch bug or a model registered as a pipeline without a submodel context.","triggerScenarios":"Calling QwenImageDiffusersModelLoader._load_model(config, None) where config is NOT Checkpoint_Config_Base (the earlier isinstance raises NotImplementedError first for checkpoint configs), i.e. loading a Qwen Image main pipeline without specifying which submodel to load.","commonSituations":"Directly invoking the loader outside the normal ModelManager pipeline; a registry entry pointing a pipeline at this loader without submodel resolution; custom code that iterates loader APIs and forgets the submodel argument.","solutions":["Pass the SubModelType you intend to load (e.g. SubModelType.Transformer) as the second argument to _load_model.","Load models through the ModelManager/model manager service so submodel_type is resolved automatically from the pipeline.","If the model is actually a single-file checkpoint, ensure its config is CheckpointConfigBase and use the single-file loader instead of the diffusers main loader."],"exampleFix":"// before\nmodel = loader._load_model(config, None)\n// after\nfrom invokeai.backend.model_manager import SubModelType\nmodel = loader._load_model(config, SubModelType.Transformer)","handlingStrategy":"validation","validationCode":"from invokeai.backend.model_manager import SubModelType\nif submodel_type is None:\n    raise ValueError(\"Provide a SubModelType (e.g. SubModelType.Transformer) when loading a Qwen Image main pipeline.\")\nloader._load_model(config, submodel_type)","typeGuard":"def has_submodel(sub: SubModelType | None) -> bool:\n    return sub is not None","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, SubModelType.Transformer)\n    else:\n        raise","preventionTips":["Always load models via ModelManager so submodel_type is resolved automatically","Never call _load_model directly with None for main pipelines","Assert submodel_type is not None before loader calls in scripts"],"tags":["model-loader","invokeai","submodel-type","pipeline"],"backgroundTag":"missing-required-argument","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}