invoke-ai/InvokeAI · error · ValueError

Unexpected submodel requested for TextLLM model.

Error message

Unexpected submodel requested for TextLLM model.

What it means

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.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/text_llm.py:23

from transformers import AutoModelForCausalLM

from invokeai.backend.model_manager.configs.factory import AnyModelConfig
from invokeai.backend.model_manager.load.load_default import ModelLoader
from invokeai.backend.model_manager.load.model_loader_registry import ModelLoaderRegistry
from invokeai.backend.model_manager.taxonomy import AnyModel, BaseModelType, ModelFormat, ModelType, SubModelType


@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.TextLLM, format=ModelFormat.Diffusers)
class TextLLMModelLoader(ModelLoader):
    """Class for loading text causal language models (Llama, Phi, Qwen, Mistral, etc.)."""

    def _load_model(
        self,
        config: AnyModelConfig,
        submodel_type: Optional[SubModelType] = None,
    ) -> AnyModel:
        if submodel_type is not None:
            raise ValueError("Unexpected submodel requested for TextLLM model.")

        # Use float32 for CPU-only models since CPU fp16 is emulated and slow.
        dtype = self._torch_dtype
        if getattr(config, "cpu_only", False) is True:
            dtype = torch.float32

        model_path = Path(config.path)
        model = AutoModelForCausalLM.from_pretrained(model_path, local_files_only=True, torch_dtype=dtype)
        return model

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass submodel_type=None when loading TextLLM models.
  2. Fix dispatch code to only send submodel requests to main-pipeline loaders.
  3. Verify the model type via the model-manager record before choosing loader arguments.

Example fix

// before
model = loader.load_model(config, submodel_type=SubModelType.Tokenizer)
// after
model = loader.load_model(config, submodel_type=None)
Defensive patterns

Strategy: validation

Validate before calling

if model_type is ModelType.TextLLM and submodel_type is not None:
    submodel_type = None

Type guard

def is_submodel_capable(model_type: ModelType) -> bool:
    return model_type in {ModelType.Main, ModelType.ONNX}

Try / catch

try:
    model = loader.load_model(config, submodel_type=None)
except ValueError as e:
    logger.error("TextLLM load failed: %s", e)
    raise

Prevention

When it happens

Trigger: Calling load_model on a TextLLM model config with submodel_type set to any value instead of None.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/6827eb7590b23cbb. Report an issue: GitHub.