{"record":{"id":"15daee481ec6f137","repo":"invoke-ai/InvokeAI","slug":"state-dict-does-not-look-like-a-z-image-model","errorCode":null,"errorMessage":"state dict does not look like a Z-Image model","messagePattern":"state dict does not look like a Z-Image model","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"warning","filePath":"invokeai/backend/model_manager/configs/main.py","lineNumber":1435,"sourceCode":"    @classmethod\n    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        cls._validate_looks_like_z_image_model(mod)\n\n        cls._validate_does_not_look_like_gguf_quantized(mod)\n\n        variant = override_fields.pop(\"variant\", None) or ZImageVariantType.Turbo\n\n        return cls(**override_fields, variant=variant)\n\n    @classmethod\n    def _validate_looks_like_z_image_model(cls, mod: ModelOnDisk) -> None:\n        has_z_image_keys = _has_z_image_keys(mod.load_state_dict())\n        if not has_z_image_keys:\n            raise NotAMatchError(\"state dict does not look like a Z-Image model\")\n\n    @classmethod\n    def _validate_does_not_look_like_gguf_quantized(cls, mod: ModelOnDisk) -> None:\n        has_ggml_tensors = _has_ggml_tensors(mod.load_state_dict())\n        if has_ggml_tensors:\n            raise NotAMatchError(\"state dict looks like GGUF quantized\")\n\n\nclass Main_GGUF_ZImage_Config(Checkpoint_Config_Base, Main_Config_Base, Config_Base):\n    \"\"\"Model config for GGUF-quantized Z-Image transformer models.\"\"\"\n\n    base: Literal[BaseModelType.ZImage] = Field(default=BaseModelType.ZImage)\n    format: Literal[ModelFormat.GGUFQuantized] = Field(default=ModelFormat.GGUFQuantized)\n    variant: ZImageVariantType = Field()\n\n    @classmethod\n    def from_model_on_disk(cls, mod: ModelOnDisk, override_fields: dict[str, Any]) -> Self:\n        raise_if_not_file(mod)","sourceCodeStart":1417,"sourceCodeEnd":1453,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/main.py#L1417-L1453","documentation":"_validate_looks_like_z_image_model loads the model's state dict and checks for Z-Image-specific keys (_has_z_image_keys); if none are found it raises NotAMatchError. This prevents the Z-Image checkpoint config from claiming arbitrary single-file weights that happen to land in the scan path. Identification then falls through to other config classes.","triggerScenarios":"from_model_on_disk -> _validate_looks_like_z_image_model on a checkpoint/safetensors file whose state dict contains no Z-Image transformer keys, during Z-Image main-model identification.","commonSituations":"Importing a renamed/repurposed safetensors file (e.g. a Flux or Qwen checkpoint renamed to z-image), a truncated download that lost most tensors, or an unsupported re-pack of the model that renamed keys.","solutions":["Verify the file is an authentic Z-Image checkpoint from the official release; re-download if truncated.","Check that the checkpoint wasn't key-renamed by a conversion script; re-run the official conversion.","Import the file as the model type it actually is instead of forcing Z-Image classification."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from safetensors import safe_open\n\nZ_IMAGE_KEY_MARKERS = (\"layers.\", \"z_image\", \"transformer.blocks\")\n\ndef looks_like_z_image(path: str) -> bool:\n    with safe_open(path, framework=\"pt\") as f:\n        return any(any(m in k for m in Z_IMAGE_KEY_MARKERS) for k in list(f.keys())[:200])","typeGuard":"def is_z_image_state_dict(state_dict: dict) -> bool:\n    return any(\"z_image\" in k or k.startswith(\"model.diffusion_model.layers\") for k in state_dict.keys())","tryCatchPattern":"try:\n    cfg = Main_Checkpoint_ZImage_Config.from_model_on_disk(mod)\nexcept NotAMatchError:\n    # state dict isn't Z-Image; re-check provenance of the file\n    cfg = None","preventionTips":["Download Z-Image checkpoints only from the official release.","Verify file integrity (size/hash) after download to rule out truncation.","Don't rename foreign checkpoints to z-image names; import them as their real type."],"tags":["model-identification","z-image","state-dict"],"backgroundTag":"unrecognized-model-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}