invoke-ai/InvokeAI · error · NotAMatchError

GGUF architecture '{architecture}' is not 'gemma2'

Error message

GGUF architecture '{architecture}' is not 'gemma2'

What it means

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.

Source

Thrown at invokeai/backend/model_manager/configs/gemma2_encoder.py:138

    caption projection; 9B/27B GGUFs are rejected here as for the directory config.
    """

    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)
    type: Literal[ModelType.Gemma2Encoder] = Field(default=ModelType.Gemma2Encoder)
    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)
    cpu_only: bool | None = Field(default=None, description="Whether this model should run on CPU only")

    @classmethod
    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:
        raise_if_not_file(mod)
        raise_for_override_fields(cls, override_fields)

        if mod.path.suffix.lower() != ".gguf":
            raise NotAMatchError(f"not a .gguf file: {mod.path.name}")

        architecture, hidden_size = _read_gguf_arch_and_hidden_size(mod.path)
        if architecture != "gemma2":
            raise NotAMatchError(f"GGUF architecture '{architecture}' is not 'gemma2'")
        if hidden_size != _PID_GEMMA_HIDDEN_SIZE:
            raise NotAMatchError(
                f"Gemma2 GGUF embedding_length {hidden_size} is incompatible with PiD, which requires "
                f"{_PID_GEMMA_HIDDEN_SIZE} (Gemma-2-2b); 9B/27B variants are not supported."
            )

        return cls(**override_fields)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Download a GGUF whose general.architecture is 'gemma2', e.g. gemma-2-2b-it-Q4_K_M.gguf
  2. Check the architecture first: gguf-dump file.gguf | grep general.architecture
  3. Register non-gemma2 GGUFs as their proper model types rather than as PiD encoders

Example fix

// before (inspect)
general.architecture = llama3
// after
huggingface-cli download bartowski/gemma-2-2b-it-GGUF gemma-2-2b-it-Q4_K_M.gguf  # general.architecture = gemma2
Defensive patterns

Strategy: validation

Validate before calling

def gguf_architecture(path) -> str | None:
    import gguf
    try:
        reader = gguf.GGUFReader(path)
        field = reader.fields.get("general.architecture")
        return str(field.contents()) if field else None
    except Exception:
        return None

Type guard

def is_gemma2_gguf(p: Path) -> bool:
    return gguf_architecture(p) == "gemma2"

Try / catch

try:
    import_model(gguf_path)
except NotAMatchError as e:
    if "is not 'gemma2'" in str(e):
        print("Wrong model family GGUF — download a gemma-2-2b-it quantization")

Prevention

When it happens

Trigger: Importing a .gguf file of any non-Gemma2 model (e.g. a llama3 or qwen2.5 quantization) into the PiD Gemma2 encoder slot.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/d86bf54d5322f59f. Report an issue: GitHub.