{"record":{"id":"e9b7b034b232a388","repo":"invoke-ai/InvokeAI","slug":"model-does-not-look-like-a-z-image-lora","errorCode":null,"errorMessage":"model does not look like a Z-Image LoRA","messagePattern":"model does not look like a Z-Image LoRA","errorType":"exception","errorClass":"NotAMatchError","httpStatus":null,"severity":"error","filePath":"invokeai/backend/model_manager/configs/lora.py","lineNumber":801,"sourceCode":"\n        # Check for Z-Image transformer layer patterns (dot-notation formats)\n        # Z-Image uses diffusion_model.layers.X structure (unlike Flux which uses double_blocks/single_blocks)\n        has_z_image_keys = state_dict_has_any_keys_starting_with(\n            state_dict,\n            {\n                \"diffusion_model.layers.\",  # Z-Image S3-DiT layer pattern\n                \"diffusion_model.context_refiner.\",\n                \"diffusion_model.noise_refiner.\",\n                \"transformer.layers.\",  # OneTrainer/diffusers prefix variant\n                \"base_model.model.transformer.layers.\",  # PEFT-wrapped variant\n            },\n        )\n\n        # If it looks like a Z-Image LoRA, return ZImage base\n        if has_z_image_keys:\n            return BaseModelType.ZImage\n\n        raise NotAMatchError(\"model does not look like a Z-Image LoRA\")\n\n\nclass LoRA_LyCORIS_QwenImage_Config(LoRA_LyCORIS_Config_Base, Config_Base):\n    \"\"\"Model config for Qwen Image Edit LoRA models in LyCORIS format.\"\"\"\n\n    base: Literal[BaseModelType.QwenImage] = Field(default=BaseModelType.QwenImage)\n\n    @classmethod\n    def _validate_looks_like_lora(cls, mod: ModelOnDisk) -> None:\n        \"\"\"Qwen Image Edit LoRAs have keys like transformer_blocks.X.attn.to_k.lora_down.weight.\"\"\"\n        state_dict = mod.load_state_dict()\n\n        has_qwen_ie_keys = state_dict_has_any_keys_starting_with(\n            state_dict,\n            {\n                \"transformer_blocks.\",\n                \"transformer.transformer_blocks.\",\n                \"lora_unet_transformer_blocks_\",  # Kohya format","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/backend/model_manager/configs/lora.py#L783-L819","documentation":"NotAMatchError raised by LoRA_LyCORIS_ZImage_Config._get_base_or_raise when the state dict passes the LoRA-ness check but contains none of the Z-Image transformer-layer key prefixes (diffusion_model.layers., diffusion_model.context_refiner., diffusion_model.noise_refiner., transformer.layers., base_model.model.transformer.layers.) and is not a Kohya-format Z-Image LoRA. Base-model inference cannot conclude the model targets Z-Image's S3-DiT architecture.","triggerScenarios":"_validate_base -> _get_base_or_raise runs after _validate_looks_like_lora passes; the file is a LoRA but for a different architecture (its keys don't start with any Z-Image prefix), so the Z-Image config refuses to claim it.","commonSituations":"A Flux or Qwen-Image LoRA being probed against the Z-Image config (failed candidate match — usually benign if another config later claims it), a Z-Image LoRA using an unlisted trainer's naming scheme, or a file mislabeled as Z-Image on a model-sharing site.","solutions":["Check whether the model was successfully matched by another config class afterwards — this error frequently occurs during normal multi-config probing and is not fatal.","Verify the download is actually a Z-Image LoRA (mislabeled files on model sites are common); compare keys against Z-Image S3-DiT naming.","Update InvokeAI for broader trainer-format recognition.","Re-export the LoRA with standard Kohya or PEFT Z-Image key naming.","Install with an explicit base override (base=ZImage) to skip detection."],"exampleFix":"// before: relying on auto-detection of a mislabeled file\n# NotAMatchError: model does not look like a Z-Image LoRA\n// after: confirm keys then install with explicit base\nassert any(k.startswith(\"diffusion_model.layers.\") for k in sd)\ninstaller.install(path, config={\"base\": BaseModelType.ZImage})","handlingStrategy":"fallback","validationCode":"sd = load_file(\"model.safetensors\")\nprefixes = (\"diffusion_model.layers.\", \"diffusion_model.context_refiner.\",\n            \"diffusion_model.noise_refiner.\", \"transformer.layers.\",\n            \"base_model.model.transformer.layers.\")\nif not any(k.startswith(prefixes) for k in sd):\n    print(\"No Z-Image S3-DiT keys; this file cannot match LoRA_LyCORIS_ZImage_Config\")","typeGuard":"def has_z_image_base_keys(state_dict: dict) -> bool:\n    prefixes = (\"diffusion_model.layers.\", \"diffusion_model.context_refiner.\",\n                \"diffusion_model.noise_refiner.\", \"transformer.layers.\",\n                \"base_model.model.transformer.layers.\")\n    return any(isinstance(k, str) and k.startswith(prefixes) for k in state_dict)","tryCatchPattern":"try:\n    base = LoRA_LyCORIS_ZImage_Config._get_base_or_raise(mod)\nexcept NotAMatchError:\n    base = None  # let the model-probe service continue matching other config classes","preventionTips":["Treat this as a probe rejection during multi-config scanning; confirm the final match status before reacting.","Verify downloads are genuine Z-Image LoRAs — mislabeled files are the top cause.","Install with explicit base=ZImage override for files you know are Z-Image but use exotic naming.","Keep InvokeAI updated for expanded Z-Image trainer format support."],"tags":["lora","z-image","base-model-detection","invokeai"],"backgroundTag":"unrecognized-model-format","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}