invoke-ai/InvokeAI · error · NotAMatchError

state dict does not look like GGUF quantized

Error message

state dict does not look like GGUF quantized

What it means

Qwen3Encoder_GGUF_Config._validate_looks_like_gguf_quantized raises NotAMatchError when the loaded state dict contains no GGML tensors, meaning the file is not GGUF-quantized. The config is exclusively for GGUF-quantized Qwen3 encoder files, so identification bails out for safetensors/binaries or other quantization formats. This typically means the wrong config was probed or the wrong file was downloaded.

Source

Thrown at invokeai/backend/model_manager/configs/qwen3_encoder.py:451

        # post-attention / post-feedforward norms a Qwen3 encoder never has; they must be classified as
        # Gemma2Encoder (otherwise a Gemma GGUF matches both configs and can be re-identified wrongly).
        if _has_gemma2_keys(state_dict):
            raise NotAMatchError(
                "state dict looks like a Gemma-2 encoder (has post_attention_norm/post_ffw_norm keys), "
                "not a Qwen3 encoder"
            )
        # Reject Qwen2.5-VL / Qwen2-VL encoders: they carry a visual tower and must be
        # classified as QwenVLEncoder (text-only Qwen3 encoders never have one).
        if _has_qwen_vl_visual_tower(state_dict):
            raise NotAMatchError(
                "state dict bundles a Qwen-VL visual tower; this is a Qwen-VL encoder, not a text-only Qwen3 encoder"
            )

    @classmethod
    def _validate_looks_like_gguf_quantized(cls, mod: ModelOnDisk) -> None:
        has_ggml = _has_ggml_tensors(mod.load_state_dict())
        if not has_ggml:
            raise NotAMatchError("state dict does not look like GGUF quantized")


class Qwen3Encoder_SDNQ_Config(Checkpoint_Config_Base, Config_Base):
    """Configuration for SDNQ-quantized Qwen3 Encoder models (single file)."""

    base: Literal[BaseModelType.Any] = Field(default=BaseModelType.Any)
    type: Literal[ModelType.Qwen3Encoder] = Field(default=ModelType.Qwen3Encoder)
    format: Literal[ModelFormat.SDNQQuantized] = Field(default=ModelFormat.SDNQQuantized)
    cpu_only: bool | None = Field(default=None, description="Whether this model should run on CPU only")
    variant: Qwen3VariantType = Field(description="Qwen3 model size variant (4B or 8B)")

    @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)

        cls._validate_looks_like_qwen3_model(mod)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Download the actual GGUF-quantized variant of the Qwen3 encoder (e.g. Q4_K_M / Q8_0 from the model repo's GGUF files).
  2. If the file is safetensors/SDNQ, let it be identified by Qwen3Encoder_Checkpoint_Config or Qwen3Encoder_SDNQ_Config instead of the GGUF config.
  3. Verify the file format (magic bytes 'GGUF') — do not merely rename non-GGUF files to .gguf.

Example fix

// before: renamed safetensors
cp model.safetensors model.gguf  # NotAMatchError: no GGML tensors

// after: download real GGUF
huggingface-cli download repo Qwen3-4B-Encoder-Q8_0.gguf
Defensive patterns

Strategy: validation

Validate before calling

def is_gguf_file(path) -> bool:
    with open(path, 'rb') as f:
        return f.read(4) == b'GGUF'

if not is_gguf_file(mod.path):
    raise ValueError(f'{mod.path} is not a GGUF file')

Type guard

def has_ggml_tensors(state_dict: dict) -> bool:
    return any(getattr(t, 'tensor_type', None) is not None and 'ggml' in str(type(t)).lower() for t in state_dict.values())

Try / catch

try:
    config = Qwen3Encoder_GGUF_Config.from_model_on_disk(mod)
except NotAMatchError:
    config = Qwen3Encoder_SDNQ_Config.from_model_on_disk(mod)  # non-GGUF formats

Prevention

When it happens

Trigger: from_model_on_disk probing a non-GGUF Qwen3 file (safetensors, SDNQ, .bin) against Qwen3Encoder_GGUF_Config; _has_ggml_tensors(load_state_dict()) returns False.

Common situations: Renaming a safetensors file with a .gguf extension; downloading the unquantized (FP16) model while expecting a GGUF; the model manager probing every installed file against all candidate configs.

Related errors


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