{"record":{"id":"bdf3d891bb35af89","repo":"invoke-ai/InvokeAI","slug":"there-are-no-submodels-in-a-lora-model","errorCode":null,"errorMessage":"There are no submodels in a LoRA model.","messagePattern":"There are no submodels in a LoRA model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/lora.py","lineNumber":99,"sourceCode":"\n    # We cheat a little bit to get access to the model base\n    def __init__(\n        self,\n        app_config: InvokeAIAppConfig,\n        logger: Logger,\n        ram_cache: ModelCache,\n    ):\n        \"\"\"Initialize the loader.\"\"\"\n        super().__init__(app_config, logger, ram_cache)\n        self._model_base: Optional[BaseModelType] = None\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if submodel_type is not None:\n            raise ValueError(\"There are no submodels in a LoRA model.\")\n        model_path = Path(config.path)\n        assert self._model_base is not None\n\n        # Load the state dict from the model file.\n        if model_path.suffix == \".safetensors\":\n            state_dict = load_file(model_path.absolute().as_posix(), device=\"cpu\")\n        else:\n            state_dict = torch.load(model_path, map_location=\"cpu\")\n\n        # Strip 'bundle_emb' keys - these are unused and currently cause downstream errors.\n        # To revisit later to determine if they're needed/useful.\n        state_dict = {k: v for k, v in state_dict.items() if not k.startswith(\"bundle_emb\")}\n\n        # Normalize PEFT named-adapter keys (e.g. `lora_A.default.weight` → `lora_A.weight`)\n        # so the downstream format detectors and converters see canonical PEFT keys.\n        state_dict = normalize_peft_adapter_names(state_dict)\n\n        # At the time of writing, we support the OMI standard for base models Flux and SDXL","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/lora.py#L81-L117","documentation":"This ValueError is raised by the LoRA loader when _load_model is called with a non-None submodel_type. LoRAs are single weight files with no submodel structure (no tokenizer, VAE, etc.), so the API contract is to load them whole; requesting a submodel of a LoRA is always a caller mistake.","triggerScenarios":"Calling ModelManager/load with a LoRA model key and any SubModelType (e.g. Tokenizer, TextEncoder, Vae); generic loops that pass a submodel_type for every model regardless of family.","commonSituations":"Writing pipeline-assembly code that treats LoRAs like base models; UI code enumerating submodels of a checkpoint and accidentally including attached LoRA entries; loading a LoRA key obtained from a config that lists it as if it had submodels.","solutions":["Load the LoRA with submodel_type=None and apply it via its ModelKey through the LoRA patching/apply API instead.","Do not request submodels for LoRA models; merge/patch behavior is handled at inference time (e.g. via the lora Patcher classes).","Verify the model key being loaded is the LoRA record, not the base checkpoint that has submodels.","Update InvokeAI if following an outdated tutorial that predates the current LoRA loading API."],"exampleFix":"// before\nlora = loader._load_model(lora_config, SubModelType.TextEncoder)  # raises\n// after\nlora_model = loader._load_model(lora_config, submodel_type=None)  # LoRAs load whole\n# then apply at inference, e.g. with LoRAPatcher using the lora model key","handlingStrategy":"validation","validationCode":"if submodel_type is not None:\n    raise ValueError(\"LoRA models have no submodels; pass submodel_type=None\")","typeGuard":"def is_lora(config: AnyModelConfig) -> bool:\n    return getattr(config, 'format', None) in (ModelFormat.Lora, ModelFormat.LyCORIS)\n\n# for LoRA configs, always load with submodel_type=None","tryCatchPattern":"try:\n    model = loader._load_model(config, submodel_type)\nexcept ValueError as e:\n    if 'no submodels in a LoRA' in str(e):\n        model = loader._load_model(config, submodel_type=None)\n    else:\n        raise","preventionTips":["Load LoRAs whole (submodel_type=None) and apply them at inference via the LoRA patcher.","Never treat LoRA entries as base models when enumerating submodels.","Use ModelManager.load_model with the LoRA's ModelKey instead of calling the loader directly.","Validate model type before writing generic submodel loops."],"tags":["python","valueerror","model-loader","invokeai","lora","submodel"],"backgroundTag":"unsupported-submodel-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}