{"record":{"id":"008d2a012c6ff000","repo":"invoke-ai/InvokeAI","slug":"only-gemma2encoder-gguf-config-models-are-supporte","errorCode":null,"errorMessage":"Only Gemma2Encoder_GGUF_Config models are supported here.","messagePattern":"Only Gemma2Encoder_GGUF_Config models are supported here\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/load/model_loaders/gemma2_encoder.py","lineNumber":132,"sourceCode":"\n@ModelLoaderRegistry.register(base=BaseModelType.Any, type=ModelType.Gemma2Encoder, format=ModelFormat.GGUFQuantized)\nclass Gemma2EncoderGGUFLoader(ModelLoader):\n    \"\"\"Loads a single-file GGUF Gemma-2-2b encoder and exposes its decoder + tokenizer.\n\n    Unlike a naive `from_pretrained(gguf_file=...)` (which dequantizes every weight into RAM/VRAM at load,\n    giving no memory saving over the unquantized model), this keeps the large 2D projection weights as\n    InvokeAI ``GGMLTensor`` — the model cache's custom linear handling dequantizes them on demand. Only the\n    embedding and the RMSNorm weights are materialized eagerly. The tokenizer is still read from the GGUF\n    metadata. Mirrors the Qwen3 GGUF encoder loader in ``z_image.py``.\n    \"\"\"\n\n    def _load_model(\n        self,\n        config: AnyModelConfig,\n        submodel_type: Optional[SubModelType] = None,\n    ) -> AnyModel:\n        if not isinstance(config, Gemma2Encoder_GGUF_Config):\n            raise ValueError(\"Only Gemma2Encoder_GGUF_Config models are supported here.\")\n\n        gguf_path = Path(config.path)\n\n        match submodel_type:\n            case SubModelType.Tokenizer:\n                # The tokenizer is parsed from the GGUF metadata; no model tensors are loaded here.\n                return AutoTokenizer.from_pretrained(gguf_path.parent, gguf_file=gguf_path.name, local_files_only=True)\n            case SubModelType.TextEncoder:\n                compute_dtype = TorchDevice.choose_bfloat16_safe_dtype(TorchDevice.choose_torch_device())\n                return load_gemma2_model_from_gguf(gguf_path, compute_dtype)\n\n        raise ValueError(\n            f\"Unsupported submodel type for Gemma2 encoder: {submodel_type!r}. Expected Tokenizer or TextEncoder.\"\n        )\n\n\ndef load_gemma2_model_from_gguf(gguf_path: Path, compute_dtype: \"torch.dtype\") -> AnyModel:\n    \"\"\"Build a Gemma2Model from a single-file llama.cpp GGUF, keeping the 2D projection weights quantized.","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/load/model_loaders/gemma2_encoder.py#L114-L150","documentation":"Gemma2EncoderGGUFLoader._load_model requires the config to be exactly Gemma2Encoder_GGUF_Config; any other config class reaching this loader raises this ValueError. It is the GGUF-side analogue of the non-GGUF loader's type check.","triggerScenarios":"A model stored with format GGUFQuantized but a config object of another class (e.g. Gemma2Encoder_Gemma2Encoder_Config or a generic Diffusers config) dispatched to the GGUF loader; direct calls to _load_model with a mismatched config; corrupt or hand-edited model records.","commonSituations":"Models converted in-place between safetensors and GGUF without updating their stored config/format; manual DB/models.yaml edits; tests passing synthetic configs to the loader.","solutions":["Re-register/re-convert the model so its config class is Gemma2Encoder_GGUF_Config with format GGUFQuantized","Point the model record at the loader matching its actual format (Gemma2Encoder format for the HF-style loader)","Fix any code constructing configs that mislabels GGUF models"],"exampleFix":"# before\nconfig = Gemma2Encoder_Gemma2Encoder_Config(path=x.gguf, format=ModelFormat.GGUFQuantized)\n# after\nconfig = Gemma2Encoder_GGUF_Config(path=x.gguf, format=ModelFormat.GGUFQuantized)","handlingStrategy":"type-guard","validationCode":"from invokeai.backend.model_manager.config import Gemma2Encoder_GGUF_Config\ndef can_load_with_gemma2_gguf_loader(config):\n    return isinstance(config, Gemma2Encoder_GGUF_Config)","typeGuard":"def is_gemma2_gguf_config(config) -> bool:\n    return isinstance(config, Gemma2Encoder_GGUF_Config)","tryCatchPattern":"try:\n    model = gguf_loader._load_model(config, submodel_type)\nexcept ValueError as e:\n    if \"Only Gemma2Encoder_GGUF_Config\" in str(e):\n        print(f\"Config {type(config).__name__} is not a GGUF Gemma2 config; fix the model record\")\n    else:\n        raise","preventionTips":["Keep format=GGUFQuantized only on records with Gemma2Encoder_GGUF_Config","Re-convert models instead of editing config classes manually","Verify config class after model conversion between safetensors and GGUF"],"tags":["model-loader","config-mismatch","gemma2","gguf"],"backgroundTag":"unsupported-model-config","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}