{"record":{"id":"6827eb7590b23cbb","repo":"invoke-ai/InvokeAI","slug":"unexpected-submodel-requested-for-textllm-model","errorCode":null,"errorMessage":"Unexpected submodel requested for TextLLM model.","messagePattern":"Unexpected submodel requested for TextLLM model\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/text_llm.py","lineNumber":23,"sourceCode":"from transformers import AutoModelForCausalLM\n\nfrom invokeai.backend.model_manager.configs.factory import AnyModelConfig\nfrom invokeai.backend.model_manager.load.load_default import ModelLoader\nfrom invokeai.backend.model_manager.load.model_loader_registry import ModelLoaderRegistry\nfrom invokeai.backend.model_manager.taxonomy import AnyModel, BaseModelType, ModelFormat, ModelType, SubModelType\n\n\n@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.TextLLM, format=ModelFormat.Diffusers)\nclass TextLLMModelLoader(ModelLoader):\n    \"\"\"Class for loading text causal language models (Llama, Phi, Qwen, Mistral, etc.).\"\"\"\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(\"Unexpected submodel requested for TextLLM model.\")\n\n        # Use float32 for CPU-only models since CPU fp16 is emulated and slow.\n        dtype = self._torch_dtype\n        if getattr(config, \"cpu_only\", False) is True:\n            dtype = torch.float32\n\n        model_path = Path(config.path)\n        model = AutoModelForCausalLM.from_pretrained(model_path, local_files_only=True, torch_dtype=dtype)\n        return model\n","sourceCodeStart":5,"sourceCodeEnd":33,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/text_llm.py#L5-L33","documentation":"TextLLM models are loaded as whole models; the loader does not produce components, so any non-None submodel_type triggers this ValueError. It mirrors the guards in the SigLIP, Spandrel and TI loaders.","triggerScenarios":"Calling load_model on a TextLLM model config with submodel_type set to any value instead of None.","commonSituations":"Pipeline code that uniformly passes a submodel_type; mistaking a TextLLM entry for a main diffusion model in the model manager; generic loader wrappers that default to requesting a TextEncoder.","solutions":["Pass submodel_type=None when loading TextLLM models.","Fix dispatch code to only send submodel requests to main-pipeline loaders.","Verify the model type via the model-manager record before choosing loader arguments."],"exampleFix":"// before\nmodel = loader.load_model(config, submodel_type=SubModelType.Tokenizer)\n// after\nmodel = loader.load_model(config, submodel_type=None)","handlingStrategy":"validation","validationCode":"if model_type is ModelType.TextLLM and submodel_type is not None:\n    submodel_type = None","typeGuard":"def is_submodel_capable(model_type: ModelType) -> bool:\n    return model_type in {ModelType.Main, ModelType.ONNX}","tryCatchPattern":"try:\n    model = loader.load_model(config, submodel_type=None)\nexcept ValueError as e:\n    logger.error(\"TextLLM load failed: %s\", e)\n    raise","preventionTips":["Load LLM entries as whole models only.","Keep dispatcher tables explicit about which model types accept submodels.","Validate model record type before generic load calls."],"tags":["valueerror","submodel","llm","model-loading"],"backgroundTag":"unsupported-submodel-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}