{"record":{"id":"5149083d31e3235f","repo":"invoke-ai/InvokeAI","slug":"state-dict-does-not-look-like-a-qwen2-5-vl-qwen2-v","errorCode":null,"errorMessage":"state dict does not look like a Qwen2.5-VL/Qwen2-VL checkpoint","messagePattern":"state dict does not look like a Qwen2\\.5-VL/Qwen2-VL checkpoint","errorType":"validation","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/qwen_vl_encoder.py","lineNumber":152,"sourceCode":"    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_file(mod)\n\n        raise_for_override_fields(cls, override_fields)\n\n        # Only safetensors checkpoints are supported as single-file Qwen VL encoders.\n        # Reject other extensions cheaply before attempting to read keys.\n        if mod.path.suffix != \".safetensors\":\n            raise NotAMatchError(f\"expected a .safetensors file, got {mod.path.suffix or '(no suffix)'}\")\n\n        # Read only the key index — a 7GB fp8 encoder weighs ~7GB on disk, but we\n        # only need the key names to classify it, not the tensor data.\n        try:\n            keys = _read_safetensors_keys(mod.path)\n        except Exception as e:\n            raise NotAMatchError(f\"could not read safetensors header: {e}\") from e\n\n        if not _has_qwen_vl_keys(keys):\n            raise NotAMatchError(\"state dict does not look like a Qwen2.5-VL/Qwen2-VL checkpoint\")\n\n        return cls(**override_fields)\n","sourceCodeStart":134,"sourceCodeEnd":155,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/qwen_vl_encoder.py#L134-L155","documentation":"`NotAMatchError` raised when the safetensors header reads fine but `_has_qwen_vl_keys(keys)` finds none of the expected Qwen2.5-VL/Qwen2-VL key patterns. The file is a valid safetensors checkpoint — just not one this config class recognizes, so the prober moves on to other config classes.","triggerScenarios":"Single-file `.safetensors` probing where the state dict belongs to a different architecture (SD UNet, T5, CLIP, LoRA, VAE) or uses key naming the matcher does not cover (e.g. a re-keyed/merged checkpoint).","commonSituations":"Dumping many checkpoints into the auto-import folder and letting the classifier sort them (non-Qwen files legitimately produce this), merged checkpoints with stripped prefixes, quantization formats that rename keys.","solutions":["Confirm the file actually contains Qwen2.5-VL/Qwen2-VL encoder weights; if not, no fix is needed — it is expected to match a different config class","If it IS a Qwen VL encoder, inspect the key names (`safe_open(...).keys()`) and compare against the matcher's patterns; it may use a novel prefix from a conversion tool","Re-export the checkpoint from official weights to restore canonical key names","Ensure you are installing the full encoder, not a LoRA/delta that shares the extension but not the keys"],"exampleFix":"// before: merged checkpoint with keys like \"encoder.layers.0...\"\n// after: re-derive from upstream so keys are \"model.layers...\" (canonical Qwen2-VL naming)","handlingStrategy":"validation","validationCode":"from safetensors import safe_open\nfrom pathlib import Path\n\ndef keys_look_like_qwen_vl(path: Path) -> bool:\n    with safe_open(path, framework=\"pt\") as f:\n        return any(\"visual\" in k or \"model.layers\" in k for k in f.keys())","typeGuard":null,"tryCatchPattern":"try:\n    cfg = QwenVLTextEncoderConfig.from_model_on_disk(mod, override_fields)\nexcept NotAMatchError as e:\n    if \"does not look like a Qwen\" in str(e):\n        print(\"File is valid safetensors but not a Qwen VL encoder — expected for other model types\")\n    raise","preventionTips":["Keep non-Qwen checkpoints out of auto-import folders for this config, or expect them to be skipped","Re-export merged/quantized checkpoints from canonical upstream weights","Inspect keys with safe_open when classification fails unexpectedly"],"tags":["safetensors","qwen-vl","key-mismatch"],"backgroundTag":"model-architecture-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}