invoke-ai/InvokeAI · warning · NotAMatchError

state dict bundles a Qwen-VL visual tower; this is a Qwen-VL

Error message

state dict bundles a Qwen-VL visual tower; this is a Qwen-VL encoder, not a text-only Qwen3 encoder

What it means

NotAMatchError raised by Qwen3Encoder._validate_looks_like_qwen3_model (qwen3_encoder.py:249). The state dict includes a Qwen-VL visual tower, meaning it is a multimodal Qwen2-VL / Qwen2.5-VL encoder, not a text-only Qwen3 encoder. The config raises so QwenVLEncoder claims the model; text-only Qwen3 encoders never bundle visual weights.

Source

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

        state_dict = mod.load_state_dict()
        if not _has_qwen3_keys(state_dict):
            raise NotAMatchError("state dict does not look like a Qwen3 model")
        # Reject T5 encoders: they share the token_embd.weight key with Qwen3 GGUFs but use the ``enc.``
        # block prefix, and must be classified as T5Encoder (Qwen3 encoders never have ``enc.blk.*`` keys).
        if _has_t5_encoder_keys(state_dict):
            raise NotAMatchError("state dict looks like a T5 encoder (has 'enc.blk.*' keys), not a Qwen3 encoder")
        # Reject Gemma-2/3 encoders: their GGUFs also carry token_embd.weight + blk.* keys but use
        # 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_does_not_look_like_gguf_quantized(cls, mod: ModelOnDisk) -> None:
        has_ggml = _has_ggml_tensors(mod.load_state_dict())
        if has_ggml:
            raise NotAMatchError("state dict looks like GGUF quantized")


# Transformers architectures the unquantized Qwen3 encoder config accepts.
_QWEN3_ENCODER_ARCHITECTURES = {
    "Qwen2VLForConditionalGeneration",
    "Qwen2ForCausalLM",
    "Qwen3ForCausalLM",
}

# Architectures the SDNQ Qwen encoder loaders can actually instantiate. Both the standalone

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Use a text-only Qwen3 (or Qwen2) text encoder checkpoint instead of the VL variant if your pipeline needs a Qwen3Encoder.
  2. Let identification continue so QwenVLEncoder matches, if you actually want the VL model.
  3. Extract only the text encoder weights into a text_encoder/ subfolder if you only need the text side of the VL model.
  4. Check the HuggingFace repo name: 'Qwen2.5-VL*'/'Qwen2-VL*' is multimodal; 'Qwen3-*' text encoders have no visual tower.

Example fix

// before
repo = 'Qwen/Qwen2.5-VL-7B-Instruct'  // has visual tower
// after
repo = 'Qwen/Qwen3-4B' (text-only encoder weights in text_encoder/)
Defensive patterns

Strategy: validation

Validate before calling

import json
def is_qwen_vl_checkpoint(path) -> bool:
    cfg = json.loads((path / 'config.json').read_text())
    return cfg.get('architectures', [''])[0].endswith('ForConditionalGeneration') and 'VL' in cfg.get('model_type', '')

Type guard

def has_visual_tower(state_dict: dict) -> bool:
    return any(k.startswith('visual.') or 'visual_tower' in k or k.startswith('model.visual') for k in state_dict)  # if True, it is Qwen-VL, not text-only Qwen3

Try / catch

try:
    register_model(path, model_type='Qwen3Encoder')
except NotAMatchError:
    register_model(path, model_type='QwenVLEncoder')  # or use a text-only Qwen3 checkpoint

Prevention

When it happens

Trigger: from_model_on_disk identification of a Qwen2.5-VL/Qwen2-VL model whose state dict contains visual-tower tensors (detected by _has_qwen_vl_visual_tower) while the Qwen3Encoder config probes it.

Common situations: Downloading a full Qwen2.5-VL checkpoint and pointing InvokeAI's scanner at it expecting a Qwen3 text encoder; confusion between Qwen2-VL and Qwen3 model repos on HuggingFace; using a VL model where a text-only encoder is required by a pipeline (e.g. Z-Image).

Related errors


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