{"record":{"id":"bc017f1f738faa44","repo":"invoke-ai/InvokeAI","slug":"only-mistralencoder-diffusers-config-models-are-su","errorCode":null,"errorMessage":"Only MistralEncoder_Diffusers_Config models are supported here.","messagePattern":"Only MistralEncoder_Diffusers_Config models are supported here\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/mistral_encoder.py","lineNumber":836,"sourceCode":"@ModelLoaderRegistry.register(\n    base=BaseModelType.Any,\n    type=ModelType.MistralEncoder,\n    format=ModelFormat.MistralEncoder,\n)\nclass MistralEncoderDiffusersLoader(ModelLoader):\n    \"\"\"Load a Mistral text encoder from a HuggingFace folder layout.\n\n    Handles both the full FLUX.2-dev pipeline layout (with sibling ``tokenizer/``)\n    and a standalone download where ``text_encoder/`` files live at the root.\n    \"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, MistralEncoder_Diffusers_Config):\n            raise ValueError(\"Only MistralEncoder_Diffusers_Config models are supported here.\")\n\n        model_path = Path(config.path)\n        text_encoder_path = model_path / \"text_encoder\"\n\n        # Standalone download: text_encoder files at the root.\n        if not text_encoder_path.exists() and (model_path / \"config.json\").exists():\n            text_encoder_path = model_path\n\n        target_device = TorchDevice.choose_torch_device()\n        model_dtype = TorchDevice.choose_bfloat16_safe_dtype(target_device)\n\n        match submodel_type:\n            case SubModelType.Tokenizer:\n                logger = InvokeAILogger.get_logger(\"MistralEncoderProcessor\")\n                # Let the multi-strategy loader own the full ladder: embedded Tekken,\n                # sibling tokenizer/, root-level processor files, then the HF fallback.\n                return _load_tokenizer_for_model(model_path, logger)\n            case SubModelType.TextEncoder:","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/mistral_encoder.py#L818-L854","documentation":"MistralEncoderDiffusersLoader._load_model asserts that the config record it was handed is a MistralEncoder_Diffusers_Config before touching config.path. This loader is registered for ModelType.MistralEncoder with format MistralEncoder, so the registry should only route Diffusers-style Mistral encoder records here; a ValueError is raised when some other config subclass (e.g. checkpoint or GGUF config) is passed programmatically or the registry dispatch is bypassed. It is an internal invariant/argument-validation error, not a data-corruption issue.","triggerScenarios":"Calling MistralEncoderDiffusersLoader._load_model directly with a config that is not MistralEncoder_Diffusers_Config (e.g. a MistralEncoder_Checkpoint_Config or MistralEncoder_GGUF_Config record), or custom code that constructs/injects model configs whose 'type/format' fields resolve to this loader while the config class differs.","commonSituations":"Custom scripts or plugins that build model config records by hand and load them outside the normal ModelManager install/load flow; a merged or edited models.yaml/DB row whose config class no longer matches its declared format; testing the loader with a mocked AnyModelConfig.","solutions":["Pass a config record created for a Diffusers-format Mistral encoder (MistralEncoder_Diffusers_Config, i.e. a folder layout with text_encoder/ or root config.json), not a single-file checkpoint or GGUF.","If loading a single .safetensors checkpoint or GGUF file, let the model manager route to MistralEncoderCheckpointLoader / MistralEncoderGGUFLoader instead of calling this loader.","Check how the config record was created/imported — re-scan or re-import the model so InvokeAI derives the correct config class from the actual file layout.","If you must call the loader directly, wrap the call in isinstance(config, MistralEncoder_Diffusers_Config) before invoking."],"exampleFix":"// before\nloader = MistralEncoderDiffusersLoader(...)\nmodel = loader._load_model(checkpoint_cfg, SubModelType.TextEncoder)  # ValueError\n// after\nfrom invokeai.backend.model_manager.configs.mistral import MistralEncoder_Diffusers_Config\nassert isinstance(cfg, MistralEncoder_Diffusers_Config), \"use the checkpoint/GGUF loader for this file\"\nmodel = loader._load_model(cfg, SubModelType.TextEncoder)","handlingStrategy":"type-guard","validationCode":"from invokeai.backend.model_manager.configs.factory import AnyModelConfig\nfrom invokeai.backend.model_manager.configs.mistral import MistralEncoder_Diffusers_Config\n\ndef can_load_with_diffusers_loader(cfg: AnyModelConfig) -> bool:\n    return isinstance(cfg, MistralEncoder_Diffusers_Config)","typeGuard":"def is_mistral_diffusers_config(cfg: AnyModelConfig) -> TypeGuard[MistralEncoder_Diffusers_Config]:\n    return isinstance(cfg, MistralEncoder_Diffusers_Config)","tryCatchPattern":"try:\n    model = loader._load_model(cfg, SubModelType.TextEncoder)\nexcept ValueError as e:\n    if \"Only MistralEncoder_Diffusers_Config\" in str(e):\n        model = pick_loader_for_config(cfg)._load_model(cfg, SubModelType.TextEncoder)\n    else:\n        raise","preventionTips":["Never call model loaders directly; go through the ModelManager so the registry dispatches by type/format.","When constructing configs programmatically, use the factory/scan helpers so the config class matches the file layout.","Add an isinstance assert before custom loader calls."],"tags":["python","model-loading","config-validation","invokeai"],"backgroundTag":"unsupported-model-config-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}