{"record":{"id":"0dae49498259a966","repo":"invoke-ai/InvokeAI","slug":"the-submodel-type-submodel-is-not-available-fo","errorCode":null,"errorMessage":"The \"{submodel_type}\" submodel is not available for this model.","messagePattern":"The \"(.+?)\" submodel is not available for this model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/generic_diffusers.py","lineNumber":63,"sourceCode":"                e\n            ):  # try without the variant, just in case user's preferences changed\n                result = model_class.from_pretrained(model_path, torch_dtype=self._torch_dtype, local_files_only=True)\n            else:\n                raise e\n        result = self._apply_fp8_layerwise_casting(result, config, submodel_type)\n        return result\n\n    # TO DO: Add exception handling\n    def get_hf_load_class(self, model_path: Path, submodel_type: Optional[SubModelType] = None) -> ModelMixin:\n        \"\"\"Given the model path and submodel, returns the diffusers ModelMixin subclass needed to load.\"\"\"\n        result = None\n        if submodel_type:\n            try:\n                config = self._load_diffusers_config(model_path, config_name=\"model_index.json\")\n                module, class_name = config[submodel_type.value]\n                result = self._hf_definition_to_type(module=module, class_name=class_name)\n            except KeyError as e:\n                raise ValueError(f'The \"{submodel_type}\" submodel is not available for this model.') from e\n        else:\n            try:\n                config = self._load_diffusers_config(model_path, config_name=\"config.json\")\n                if class_name := config.get(\"_class_name\"):\n                    result = self._hf_definition_to_type(module=\"diffusers\", class_name=class_name)\n                elif class_name := config.get(\"architectures\"):\n                    result = self._hf_definition_to_type(module=\"transformers\", class_name=class_name[0])\n                else:\n                    raise RuntimeError(\"Unable to decipher Load Class based on given config.json\")\n            except KeyError as e:\n                raise ValueError(\"An expected config.json file is missing from this model.\") from e\n        assert result is not None\n        return result\n\n    # TO DO: Add exception handling\n    def _hf_definition_to_type(self, module: str, class_name: str) -> ModelMixin:  # fix with correct type\n        if module in [\n            \"diffusers\",","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/generic_diffusers.py#L45-L81","documentation":"get_hf_load_class resolves the Python class for a requested submodel by reading the diffusers model_index.json and indexing it with submodel_type.value. If the key is absent from model_index.json (KeyError) — i.e. this pipeline does not contain that submodel — it re-raises as this ValueError.","triggerScenarios":"Requesting e.g. SubModelType.TextEncoder from a diffusers pipeline that has no text_encoder entry (unconditional models, some VAE-only dirs, ControlNet repos), or a model_index.json missing/corrupt entries.","commonSituations":"Loading ControlNet/VAE-only directories as full pipelines; older or hand-assembled diffusers repos lacking standard keys; typos in submodel lookups; models exported without optional components (e.g. safety_checker).","solutions":["Verify model_index.json actually contains the requested submodel key before requesting it","Load only submodels the pipeline provides; get the rest from a different model","Fix or regenerate model_index.json if it is corrupt or incomplete"],"exampleFix":"# before\ncls = loader.get_hf_load_class(path, SubModelType.TextEncoder)  # VAE-only repo\n# after\nif SubModelType.TextEncoder.value in json.loads((path / \"model_index.json\").read_text()):\n    cls = loader.get_hf_load_class(path, SubModelType.TextEncoder)","handlingStrategy":"validation","validationCode":"import json\ndef submodel_available(model_path, submodel_type):\n    mi = json.loads((model_path / \"model_index.json\").read_text())\n    return submodel_type.value in mi","typeGuard":"def has_submodel(model_path, st: SubModelType) -> bool:\n    mi = json.loads((model_path / \"model_index.json\").read_text())\n    return st.value in mi","tryCatchPattern":"try:\n    cls = loader.get_hf_load_class(model_path, submodel_type)\nexcept ValueError as e:\n    if \"submodel is not available for this model\" in str(e):\n        print(f\"{submodel_type} absent from this pipeline; load it from another model\")\n    else:\n        raise","preventionTips":["Read model_index.json before requesting submodels","Do not assume ControlNet/VAE-only repos contain text encoders or schedulers","Validate exported diffusers directories include all required components"],"tags":["diffusers","model-loader","submodel-type","missing-component"],"backgroundTag":"missing-model-component","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}