{"record":{"id":"26d18680306f7b33","repo":"invoke-ai/InvokeAI","slug":"expected-modelpatchraw-for-lora-lora-lora-key-26d186","errorCode":null,"errorMessage":"Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type(lora_info.model).__name__}.","messagePattern":"Expected ModelPatchRaw for LoRA '(.+?)', got (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/krea2_denoise.py","lineNumber":588,"sourceCode":"            # Conditional/unconditional passes are sequential, but the larger combined sequence and extra\n            # transient buffers warrant a modest bump.\n            estimated = int(estimated * 1.1)\n        estimated += regional_attention_mask_bytes\n        if num_loras > 0:\n            estimated += int(0.5 * num_loras * GB)\n        return estimated\n\n    def _build_step_callback(self, context: InvocationContext) -> Callable[[PipelineIntermediateState], None]:\n        def step_callback(state: PipelineIntermediateState) -> None:\n            context.util.sd_step_callback(state, BaseModelType.Krea2)\n\n        return step_callback\n\n    def _lora_iterator(self, context: InvocationContext) -> Iterator[PatchSpec]:\n        for lora in self.transformer.loras:\n            lora_info = context.models.load(lora.lora)\n            if not isinstance(lora_info.model, ModelPatchRaw):\n                raise TypeError(\n                    f\"Expected ModelPatchRaw for LoRA '{lora.lora.key}', got {type(lora_info.model).__name__}.\"\n                )\n            yield (lora_info.model, lora.weight, lora_info.model_in_ram())\n","sourceCodeStart":570,"sourceCodeEnd":592,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/krea2_denoise.py#L570-L592","documentation":"LoRAs applied to the Krea-2 transformer must be loaded as ModelPatchRaw patch objects. `_lora_iterator` loads each LoRA model from the model manager and raises a TypeError if the loaded model instance is not a ModelPatchRaw, indicating the model record resolved to an unexpected type (wrong model type/format for a LoRA slot).","triggerScenarios":"A transformer.loras entry whose ModelField key points to a model record that loads as a regular transformer/VAE/main model instead of a LoRA patch — e.g. a stale model key after re-install, or a non-Krea-2 LoRA converted/registered with the wrong model type.","commonSituations":"Model manager records migrated from an older InvokeAI version with changed model types; users pointing the LoRA field at a checkpoint rather than a LoRA; corrupted model-install records where the LoRA was imported without patch conversion.","solutions":["Re-select the LoRA in the workflow so the ModelField key points to the correct LoRA model record.","Re-import/re-convert the LoRA so the model manager registers it as a patch (ModelPatchRaw) rather than another model type.","Check the model's recorded type/format in the model manager UI and fix or delete stale records before retrying."],"exampleFix":"// before: key resolves to a full checkpoint model\nlora_field = ModelField(key=\"<checkpoint-model-key>\")\n// after: key of a registered Krea-2 LoRA patch\nlora_field = ModelField(key=\"<krea2-lora-model-key>\")","handlingStrategy":"type-guard","validationCode":"lora_info = context.models.load(lora.lora)\nif not isinstance(lora_info.model, ModelPatchRaw):\n    raise TypeError(f\"Model {lora.lora.key} is {type(lora_info.model).__name__}, not a LoRA patch; re-import as LoRA.\")","typeGuard":"def is_lora_patch(lora_info) -> bool:\n    return isinstance(lora_info.model, ModelPatchRaw)","tryCatchPattern":"try:\n    out = invoke_krea2_denoise(transformer=..., loras=loras)\nexcept TypeError as e:\n    if \"Expected ModelPatchRaw\" in str(e):\n        loras = [reselect_valid_lora(l) for l in loras]\n        out = invoke_krea2_denoise(transformer=..., loras=loras)\n    else:\n        raise","preventionTips":["Verify each LoRA's model type in the model manager before adding it to the graph.","Re-import LoRAs after InvokeAI version migrations and delete stale records.","Never point LoRA ModelFields at full checkpoints or VAE models."],"tags":["invokeai","krea2","lora","type-error"],"backgroundTag":"wrong-model-type","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}