{"record":{"id":"04c778282797bfcf","repo":"invoke-ai/InvokeAI","slug":"state-dict-looks-like-gguf-quantized-04c778","errorCode":null,"errorMessage":"state dict looks like GGUF quantized","messagePattern":"state dict looks like GGUF quantized","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/qwen3_encoder.py","lineNumber":257,"sourceCode":"        # post-attention / post-feedforward norms a Qwen3 encoder never has; they must be classified as\n        # Gemma2Encoder (otherwise a Gemma GGUF matches both configs and can be re-identified wrongly).\n        if _has_gemma2_keys(state_dict):\n            raise NotAMatchError(\n                \"state dict looks like a Gemma-2 encoder (has post_attention_norm/post_ffw_norm keys), \"\n                \"not a Qwen3 encoder\"\n            )\n        # Reject Qwen2.5-VL / Qwen2-VL encoders: they carry a visual tower and must be\n        # classified as QwenVLEncoder (text-only Qwen3 encoders never have one).\n        if _has_qwen_vl_visual_tower(state_dict):\n            raise NotAMatchError(\n                \"state dict bundles a Qwen-VL visual tower; this is a Qwen-VL encoder, not a text-only Qwen3 encoder\"\n            )\n\n    @classmethod\n    def _validate_does_not_look_like_gguf_quantized(cls, mod: ModelOnDisk) -> None:\n        has_ggml = _has_ggml_tensors(mod.load_state_dict())\n        if has_ggml:\n            raise NotAMatchError(\"state dict looks like GGUF quantized\")\n\n\n# Transformers architectures the unquantized Qwen3 encoder config accepts.\n_QWEN3_ENCODER_ARCHITECTURES = {\n    \"Qwen2VLForConditionalGeneration\",\n    \"Qwen2ForCausalLM\",\n    \"Qwen3ForCausalLM\",\n}\n\n# Architectures the SDNQ Qwen encoder loaders can actually instantiate. Both the standalone\n# Qwen3EncoderSDNQLoader and the FLUX.2 / Z-Image pipeline loaders reconstruct a text-only\n# Qwen3Config + Qwen3ForCausalLM from the state dict, so they can only load a Qwen3 model: a Qwen2\n# state dict lacks Qwen3-specific parameters (q/k normalization), and a Qwen-VL state dict also\n# carries visual-tower weights. Accepting those classes during identification produces folders the\n# loader's strict incomplete-load guard would reject, so the SDNQ paths must narrow to this set.\n_SDNQ_LOADABLE_QWEN_ARCHITECTURES = {\"Qwen3ForCausalLM\"}\n\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/qwen3_encoder.py#L239-L275","documentation":"NotAMatchError raised by Qwen3Encoder._validate_does_not_look_like_gguf_quantized (qwen3_encoder.py:257). The state dict contains GGML/quantized tensor formats (ggml-prefixed or quantized block tensors), so the unquantized Qwen3 encoder config rejects it — GGUF-quantized models must be handled by the GGUF-specific configs/loaders.","triggerScenarios":"from_model_on_disk identification where _has_ggml_tensors(mod.load_state_dict()) is true — i.e. the folder's weights are GGUF-quantized (e.g. Q8_0/Q4_K tensors) but the unquantized Qwen3Encoder config is probing it.","commonSituations":"Installing a GGUF-quantized Qwen3 encoder while expecting the plain (unquantized) Qwen3Encoder loader to handle it; mixed formats inside one model directory; a download that fetched the GGUF variant instead of safetensors.","solutions":["Use the GGUF-quantized Qwen3 encoder config/loader (e.g. Qwen3Encoder GGUF config) or install the model specifying the GGUF format explicitly.","Download the unquantized safetensors version of the model if you want the plain Qwen3Encoder path.","If the folder mixes formats, keep GGUF files in their own directory and rescan.","Verify tensor names with gguf-dump/safetensors inspector to confirm which variant the file actually is."],"exampleFix":"// before\nmodel/qwen3-encoder/  // contains qwen3-encoder-Q8_0.gguf, scanned as unquantized Qwen3Encoder\n// after\ninstall qwen3-encoder-Q8_0.gguf as GGUF-quantized encoder, or download the safetensors (unquantized) revision","handlingStrategy":"validation","validationCode":"def is_gguf_quantized(path) -> bool:\n    return any(f.suffix == '.gguf' for f in path.rglob('*'))","typeGuard":"def has_ggml_tensors(state_dict: dict) -> bool:\n    QUANT_DTYPES = {'Q4_K', 'Q5_K', 'Q6_K', 'Q8_0', 'Q4_0'}\n    return any(t.dtype in QUANT_DTYPES or 'ggml' in str(t.dtype).lower() for t in state_dict.values())","tryCatchPattern":"try:\n    register_model(path, model_type='Qwen3Encoder')  # unquantized\nexcept NotAMatchError:\n    register_model(path, model_type='Qwen3Encoder', format='GGUF')  # quantized loader","preventionTips":["Decide quantized vs unquantized before install and pick the matching config.","Keep .gguf files out of directories scanned as unquantized safetensors models.","Check tensor dtypes (packed integer/quant types) with safetensors/gguf tools."],"tags":["gguf","quantization","model-identification","state-dict"],"backgroundTag":"gguf-quantized-model-mismatch","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}