invoke-ai/InvokeAI · error · ValueError

Unexpected submodel requested for LLaVA OneVision model.

Error message

Unexpected submodel requested for LLaVA OneVision model.

What it means

This ValueError is thrown by the LLaVA OneVision loader when _load_model receives a non-None submodel_type. Unlike diffusion models, LLaVA OneVision is loaded as a single monolithic model (LlavaOnevisionForConditionalGeneration) with no tokenizer/text-encoder/VAE submodel split, so any submodel request indicates a routing mistake.

Source

Thrown at invokeai/backend/model_manager/load/model_loaders/llava_onevision.py:22

from transformers import LlavaOnevisionForConditionalGeneration

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.LlavaOnevision, format=ModelFormat.Diffusers)
class LlavaOnevisionModelLoader(ModelLoader):
    """Class for loading LLaVA Onevision VLLM models."""

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

        model_path = Path(config.path)
        model = LlavaOnevisionForConditionalGeneration.from_pretrained(
            model_path, local_files_only=True, torch_dtype=self._torch_dtype
        )
        assert isinstance(model, LlavaOnevisionForConditionalGeneration)
        return model

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Load LLaVA OneVision with submodel_type=None (or via the standard whole-model load API) rather than requesting a submodel.
  2. Remove any submodel-specific calls (tokenizer/text-encoder) for this model — obtain the tokenizer via model.get_tokenizer() or the transformers pipeline instead.
  3. Check that the model key you are loading actually points to the LLaVA OneVision entry and not a diffusion model record.
  4. Update InvokeAI if a newer version splits the model into submodels.

Example fix

// before
enc = loader._load_model(config, SubModelType.TextEncoder)  # raises
// after
model = loader._load_model(config, submodel_type=None)  # single-file model
tokenizer = model.get_tokenizer()  # tokenizer comes from the model itself
Defensive patterns

Strategy: validation

Validate before calling

if submodel_type is not None:
    raise ValueError("LLaVA OneVision has no submodels; load it with submodel_type=None")

Type guard

def is_whole_model_load(st: Optional[SubModelType]) -> bool:
    return st is None

Try / catch

try:
    model = loader._load_model(config, submodel_type)
except ValueError as e:
    if 'Unexpected submodel requested for LLaVA' in str(e):
        model = loader._load_model(config, submodel_type=None)
    else:
        raise

Prevention

When it happens

Trigger: Calling the loader (or ModelManager load) for a LLaVA OneVision model key with submodel_type set to Tokenizer, TextEncoder, Vae, etc.; generic code paths that always pass a SubModelType for every model family.

Common situations: Porting code written for diffusion models (which require submodel_type) to LLaVA OneVision; a UI or pipeline enumerating submodels for a multimodal model; model-manager records created with submodel entries for a single-file model.

Related errors


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