{"record":{"id":"9086bdc648c9df41","repo":"invoke-ai/InvokeAI","slug":"state-dict-does-not-look-like-gguf-quantized","errorCode":null,"errorMessage":"state dict does not look like GGUF quantized","messagePattern":"state dict does not look like GGUF quantized","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/main.py","lineNumber":859,"sourceCode":"        if variant is None:\n            # TODO(psyche): Should we have a graceful fallback here? Previously we fell back to the \"normal\" variant,\n            # but this variant is no longer used for FLUX models. If we get here, but the model is definitely a FLUX\n            # model, we should figure out a good fallback value.\n            raise NotAMatchError(\"unable to determine model variant from state dict\")\n\n        return variant\n\n    @classmethod\n    def _validate_looks_like_main_model(cls, mod: ModelOnDisk) -> None:\n        has_main_model_keys = _has_main_keys(mod.load_state_dict())\n        if not has_main_model_keys:\n            raise NotAMatchError(\"state dict does not look like a main model\")\n\n    @classmethod\n    def _validate_looks_like_gguf_quantized(cls, mod: ModelOnDisk) -> None:\n        has_ggml_tensors = _has_ggml_tensors(mod.load_state_dict())\n        if not has_ggml_tensors:\n            raise NotAMatchError(\"state dict does not look like GGUF quantized\")\n\n    @classmethod\n    def _validate_is_not_flux2(cls, mod: ModelOnDisk) -> None:\n        \"\"\"Validate that this is NOT a FLUX.2 model.\"\"\"\n        state_dict = mod.load_state_dict()\n        if _is_flux2_model(state_dict):\n            raise NotAMatchError(\"model is a FLUX.2 model, not FLUX.1\")\n\n\nclass Main_GGUF_Flux2_Config(Checkpoint_Config_Base, Main_Config_Base, Config_Base):\n    \"\"\"Model config for GGUF-quantized FLUX.2 checkpoint models (e.g. Klein).\"\"\"\n\n    base: Literal[BaseModelType.Flux2] = Field(default=BaseModelType.Flux2)\n    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)\n\n    variant: Flux2VariantType = Field()\n\n    @classmethod","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/main.py#L841-L877","documentation":"Main_GGUF_FLUX_Config._validate_looks_like_gguf_quantized checks whether the loaded state dict contains any GGMLTensor instances (_has_ggml_tensors). If every tensor is a regular torch.Tensor, the file is not a GGUF quantization and NotAMatchError is raised. The config only accepts quantized GGUF files; unquantized checkpoints belong to other config classes.","triggerScenarios":"from_model_on_disk on a plain (non-GGUF) safetensors FLUX checkpoint, or a GGUF file loaded by a runtime lacking GGML tensor support (gguf/quantization dependency missing so tensors decode as plain tensors), or fake/mislabeled .gguf files.","commonSituations":"Downloading the fp16 FLUX checkpoint renamed with a .gguf extension; older InvokeAI installs without the GGUF loader dependency; community files that are actually re-packaged safetensors.","solutions":["Ensure the file is a genuine GGUF quantization from a trusted release; re-download and check the hash.","Install/repair the GGUF support dependencies (e.g. the gguf package) so GGMLTensor instances are produced on load.","If the model is fp16/fp8 safetensors, import it as a regular checkpoint model instead.","Update InvokeAI if the GGUF format variant is newer than the loader supports."],"exampleFix":"// before: mislabeled file\nmv flux1-dev.safetensors flux1-dev.gguf   # still plain tensors -> NotAMatchError\n// after: use the real quantized release\n# download flux1-dev-Q4_K_S.gguf and import it","handlingStrategy":"validation","validationCode":"import struct\n\ndef is_gguf_file(path):\n    with open(path, \"rb\") as f:\n        return f.read(4) == b\"GGUF\"\n\nif not is_gguf_file(\"model.gguf\"):\n    print(\"renamed safetensors, not GGUF - import as a regular checkpoint\")","typeGuard":"def is_gguf_quantized_state_dict(sd: dict) -> bool:\n    from invokeai.backend.quantization.gguf import GGMLTensor\n    return any(isinstance(v, GGMLTensor) for v in sd.values())","tryCatchPattern":"try:\n    cfg = Main_GGUF_FLUX_Config.from_model_on_disk(mod)\nexcept NotAMatchError:\n    cfg = Main_Checkpoint_FLUX_Config.from_model_on_disk(mod)  # plain checkpoint path","preventionTips":["Download GGUF files from official quantized releases; check the GGUF magic bytes.","Never rename .safetensors to .gguf (or vice versa).","Keep the gguf quantization dependency installed and current.","Verify file sizes: GGUF quantized builds are much smaller than fp16."],"tags":["gguf","quantization","state-dict"],"backgroundTag":"model-not-matching-config","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}