{"record":{"id":"d86bf54d5322f59f","repo":"invoke-ai/InvokeAI","slug":"gguf-architecture-architecture-is-not-gemma2","errorCode":null,"errorMessage":"GGUF architecture '{architecture}' is not 'gemma2'","messagePattern":"GGUF architecture '(.+?)' is not 'gemma2'","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/gemma2_encoder.py","lineNumber":138,"sourceCode":"    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":120,"sourceCodeEnd":146,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/gemma2_encoder.py#L120-L146","documentation":"NotAMatchError raised by Gemma2Encoder_GGUF_Config.from_model_on_disk when the GGUF's general.architecture metadata is present but not 'gemma2'. The file is a valid GGUF of some other architecture (llama, qwen2, phi3, etc.) and therefore cannot be the Gemma-2-2b text encoder PiD requires.","triggerScenarios":"Importing a .gguf file of any non-Gemma2 model (e.g. a llama3 or qwen2.5 quantization) into the PiD Gemma2 encoder slot.","commonSituations":"Grabbing the wrong GGUF from a quantization collection; confusing gemma-2 GGUFs with Gemma-1 (architecture 'gemma') or Gemma-3 files; auto-scanned downloads folder mixing many model families.","solutions":["Download a GGUF whose general.architecture is 'gemma2', e.g. gemma-2-2b-it-Q4_K_M.gguf","Check the architecture first: gguf-dump file.gguf | grep general.architecture","Register non-gemma2 GGUFs as their proper model types rather than as PiD encoders"],"exampleFix":"// before (inspect)\ngeneral.architecture = llama3\n// after\nhuggingface-cli download bartowski/gemma-2-2b-it-GGUF gemma-2-2b-it-Q4_K_M.gguf  # general.architecture = gemma2","handlingStrategy":"validation","validationCode":"def gguf_architecture(path) -> str | None:\n    import gguf\n    try:\n        reader = gguf.GGUFReader(path)\n        field = reader.fields.get(\"general.architecture\")\n        return str(field.contents()) if field else None\n    except Exception:\n        return None","typeGuard":"def is_gemma2_gguf(p: Path) -> bool:\n    return gguf_architecture(p) == \"gemma2\"","tryCatchPattern":"try:\n    import_model(gguf_path)\nexcept NotAMatchError as e:\n    if \"is not 'gemma2'\" in str(e):\n        print(\"Wrong model family GGUF — download a gemma-2-2b-it quantization\")","preventionTips":["Verify general.architecture == 'gemma2' with gguf-dump before importing","Keep PiD-encoder GGUFs in a separate folder from other model families to avoid mixups","Note gemma (Gemma-1) and gemma3 GGUFs do not count — only gemma2"],"tags":["gguf","architecture-mismatch","model-import"],"backgroundTag":"model-architecture-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}