{"record":{"id":"be64ecfa248816e8","repo":"invoke-ai/InvokeAI","slug":"only-tokenizer-and-textencoder-submodels-are-suppo-be64ec","errorCode":null,"errorMessage":"Only Tokenizer and TextEncoder submodels are supported. Received: {submodel_type.value if submodel_type else 'None'}","messagePattern":"Only Tokenizer and TextEncoder submodels are supported\\. Received: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/mistral_encoder.py","lineNumber":884,"sourceCode":"                # 30-layer cow distillation was trained against the post-layer-29\n                # state *without* the final norm — swap it for Identity to match\n                # ComfyUI's reference implementation. ``Mistral3ForConditionalGeneration``\n                # nests the LM under ``.language_model``; handle both layouts.\n                inner = getattr(model, \"language_model\", None) or model\n                logger = InvokeAILogger.get_logger(\"MistralEncoderDiffusersLoader\")\n                _strip_final_norm_for_cow(inner, config.variant, logger)\n                _warn_if_40_layer_mistral(config.variant, logger)\n                # The BFL `text_encoder` checkpoint maps to `Mistral3Model`, which ships a\n                # `vision_tower` + `multi_modal_projector` (~0.8GB of real weights). The\n                # invocation only ever runs `.language_model`, so drop the vision path to\n                # keep it out of the RAM cache and every cache->VRAM transfer. The\n                # checkpoint/GGUF loaders already build a bare `MistralModel`.\n                for unused in (\"vision_tower\", \"multi_modal_projector\"):\n                    if getattr(model, unused, None) is not None:\n                        setattr(model, unused, None)\n                return model\n\n        raise ValueError(\n            \"Only Tokenizer and TextEncoder submodels are supported. \"\n            f\"Received: {submodel_type.value if submodel_type else 'None'}\"\n        )\n\n\n@ModelLoaderRegistry.register(\n    base=BaseModelType.Any,\n    type=ModelType.MistralEncoder,\n    format=ModelFormat.Checkpoint,\n)\nclass MistralEncoderCheckpointLoader(ModelLoader):\n    \"\"\"Load a Mistral encoder from a single safetensors file (text-only).\"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:","sourceCodeStart":866,"sourceCodeEnd":902,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/mistral_encoder.py#L866-L902","documentation":"MistralEncoderDiffusersLoader only knows how to build the Tokenizer and TextEncoder submodels; the Mistral encoder model has no VAE/UNet/etc. When _load_model is called with any other SubModelType (or None) the match statement falls through and a ValueError is raised naming the offending submodel type. This mirrors the loader's registry scope — only encoder-related submodels make sense for a text-encoder model.","triggerScenarios":"Requesting submodels like SubModelType.Vae, SubModelType.UNet, SubModelType.Scheduler, SubModelType.CLIP*, or passing submodel_type=None when loading a MistralEncoder model through this Diffusers loader.","commonSituations":"Generic pipeline-loading code that iterates all submodel types for a model record without checking which submodels the model type actually exposes; copy-pasted loader code from main SD pipelines applied to the Mistral encoder; custom code calling _load_model without a submodel_type.","solutions":["Only request SubModelType.Tokenizer or SubModelType.TextEncoder for MistralEncoder models; resolve VAE/denoiser etc. from the parent pipeline model instead.","Pass submodel_type explicitly — do not rely on the default None value.","If a pipeline builder iterates submodels, filter the loop to submodels relevant to ModelType.MistralEncoder.","Upgrade InvokeAI if you believe a valid submodel is missing — the supported set is defined by the match statement in this loader."],"exampleFix":"// before\nmodel = loader._load_model(cfg, SubModelType.Vae)  # ValueError: Received: vae\n// after\nif submodel_type in (SubModelType.Tokenizer, SubModelType.TextEncoder):\n    model = loader._load_model(cfg, submodel_type)","handlingStrategy":"validation","validationCode":"VALID = {SubModelType.Tokenizer, SubModelType.TextEncoder}\nif submodel_type not in VALID:\n    raise ValueError(f\"Mistral encoder supports only {VALID}, got {submodel_type}\")\nmodel = loader._load_model(cfg, submodel_type)","typeGuard":null,"tryCatchPattern":"try:\n    model = loader._load_model(cfg, submodel_type)\nexcept ValueError as e:\n    if \"Only Tokenizer and TextEncoder submodels\" in str(e):\n        logging.warning(\"skipping unsupported submodel %s for MistralEncoder\", submodel_type)\n    else:\n        raise","preventionTips":["Restrict submodel loops for MistralEncoder models to Tokenizer/TextEncoder.","Always pass submodel_type explicitly; never rely on the None default.","Check ModelType before reusing generic pipeline submodel-resolution code."],"tags":["python","model-loading","submodel","invokeai"],"backgroundTag":"unsupported-submodel-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}