{"record":{"id":"ed9fb7de70bb7a9b","repo":"invoke-ai/InvokeAI","slug":"not-a-gguf-file-mod-path-name","errorCode":null,"errorMessage":"not a .gguf file: {mod.path.name}","messagePattern":"not a \\.gguf file: (.+?)","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/gemma2_encoder.py","lineNumber":134,"sourceCode":"    tokenizer are read from the GGUF metadata, so no companion config.json / tokenizer files are required.\n    The weights are loaded natively by ``Gemma2EncoderGGUFLoader`` — the large 2D projections stay\n    quantized as ``GGMLTensor`` and are dequantized on demand by the model cache, rather than being fully\n    dequantized into memory at load time. Only Gemma-2-2b (2304-dim) is accepted, matching PiD's fixed\n    caption projection; 9B/27B GGUFs are rejected here as for the directory config.\n    \"\"\"\n\n    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)\n    type: Literal[ModelType.Gemma2Encoder] = Field(default=ModelType.Gemma2Encoder)\n    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)\n    cpu_only: bool | None = Field(default=None, description=\"Whether this model should run on CPU only\")\n\n    @classmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_file(mod)\n        raise_for_override_fields(cls, override_fields)\n\n        if mod.path.suffix.lower() != \".gguf\":\n            raise NotAMatchError(f\"not a .gguf file: {mod.path.name}\")\n\n        architecture, hidden_size = _read_gguf_arch_and_hidden_size(mod.path)\n        if architecture != \"gemma2\":\n            raise NotAMatchError(f\"GGUF architecture '{architecture}' is not 'gemma2'\")\n        if hidden_size != _PID_GEMMA_HIDDEN_SIZE:\n            raise NotAMatchError(\n                f\"Gemma2 GGUF embedding_length {hidden_size} is incompatible with PiD, which requires \"\n                f\"{_PID_GEMMA_HIDDEN_SIZE} (Gemma-2-2b); 9B/27B variants are not supported.\"\n            )\n\n        return cls(**override_fields)\n","sourceCodeStart":116,"sourceCodeEnd":146,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/gemma2_encoder.py#L116-L146","documentation":"NotAMatchError raised by Gemma2Encoder_GGUF_Config.from_model_on_disk when the candidate path is not a file ending in .gguf (case-insensitive). This GGUF config only handles single-file GGUF models; any other file name simply doesn't match, and the model factory tries other config classes.","triggerScenarios":"Model scan or from_model_on_disk dispatching a non-.gguf file (e.g. .safetensors, .bin, .ckpt, .zip) to Gemma2Encoder_GGUF_Config, typically when the user forces the format or the file lives in a folder being scanned as GGUF.","commonSituations":"Pointing InvokeAI at a single safetensors file expecting GGUF support; a GGUF renamed without the extension; scanning a mixed folder where non-GGUF files get probed against this config.","solutions":["Rename the file so it ends in .gguf if it actually is a GGUF (check magic bytes first)","If it is safetensors/bin, let the directory-based Gemma2Encoder config or the appropriate safetensors config classify it instead","Do not force ModelFormat.GGUFQuantized on non-GGUF files when importing"],"exampleFix":"// before\nmv gemma-2-2b-it-Q4_K_M gemma-2-2b-it-Q4_K_M.gguf.check  # wrong: no .gguf suffix\n// after\nmv gemma-2-2b-it-Q4_K_M gemma-2-2b-it-Q4_K_M.gguf","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef is_gguf_path(p: str | Path) -> bool:\n    return Path(p).is_file() and Path(p).suffix.lower() == \".gguf\"","typeGuard":"def is_gguf_file(p: Path) -> bool:\n    return p.suffix.lower() == \".gguf\"","tryCatchPattern":"if not is_gguf_path(path):\n    print(\"Gemma2Encoder_GGUF_Config only accepts .gguf files; use the directory config for safetensors\")\nelse:\n    try:\n        import_model(path)\n    except NotAMatchError as e:\n        handle(e)","preventionTips":["Keep model files with correct extensions; never strip .gguf when renaming","Route safetensors/bin models to the appropriate config class, not the GGUF one","Don't force ModelFormat.GGUFQuantized overrides on non-GGUF files"],"tags":["gguf","file-extension","model-import"],"backgroundTag":"wrong-file-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}