invoke-ai/InvokeAI · error · ValueError

Unknown lora: {lora_key}!

Error message

Unknown lora: {lora_key}!

What it means

ZImageLoRALoader.invoke verifies that the LoRA key supplied in self.lora.key exists in the model manager (context.models.exists). If it does not, the LoRA record is unknown/uninstalled and a ValueError is raised before any patching occurs. This prevents silently building a transformer/encoder output referencing a missing LoRA.

Source

Thrown at invokeai/app/invocations/z_image_lora_loader.py:61

    weight: float = InputField(default=0.75, description=FieldDescriptions.lora_weight)
    transformer: TransformerField | None = InputField(
        default=None,
        description=FieldDescriptions.transformer,
        input=Input.Connection,
        title="Z-Image Transformer",
    )
    qwen3_encoder: Qwen3EncoderField | None = InputField(
        default=None,
        title="Qwen3 Encoder",
        description=FieldDescriptions.qwen3_encoder,
        input=Input.Connection,
    )

    def invoke(self, context: InvocationContext) -> ZImageLoRALoaderOutput:
        lora_key = self.lora.key

        if not context.models.exists(lora_key):
            raise ValueError(f"Unknown lora: {lora_key}!")

        # Check for existing LoRAs with the same key.
        if self.transformer and any(lora.lora.key == lora_key for lora in self.transformer.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to transformer.')
        if self.qwen3_encoder and any(lora.lora.key == lora_key for lora in self.qwen3_encoder.loras):
            raise ValueError(f'LoRA "{lora_key}" already applied to Qwen3 encoder.')

        # Warn on variant mismatch between LoRA and transformer.
        lora_config = context.models.get_config(lora_key)
        lora_variant = getattr(lora_config, "variant", None)
        if lora_variant and self.transformer is not None:
            transformer_config = context.models.get_config(self.transformer.transformer.key)
            transformer_variant = getattr(transformer_config, "variant", None)
            if transformer_variant and lora_variant != transformer_variant:
                context.logger.warning(
                    f"LoRA variant mismatch: LoRA '{lora_config.name}' is for {lora_variant.value} "
                    f"but transformer is {transformer_variant.value}. This may cause unexpected results."
                )

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Install the LoRA into InvokeAI (scan folder / add model) so its key exists in the model manager.
  2. Re-select the LoRA in the node so the node stores a current, valid ModelIdentifierField key.
  3. Repair/re-scan the models directory in the Model Manager if records are stale.
  4. Update the workflow JSON to reference an existing LoRA key from this installation.

Example fix

// before
lora = ModelIdentifierField(key='8f3a-deleted-lora-key')
// after
lora = ModelIdentifierField(key='current-installed-z-image-lora-key')  # re-pick in UI
Defensive patterns

Strategy: validation

Validate before calling

if not context.models.exists(loader.lora.key):
    installed = [m.name for m in context.models.search_by_attr(attr='type', value=ModelType.LoRA)]
    raise ValueError(f"LoRA {loader.lora.key} not installed. Available: {installed}")

Try / catch

try:
    out = z_image_lora_loader.invoke(context)
except ValueError as e:
    if str(e).startswith("Unknown lora:"):
        context.logger.error(f"{e} - reinstall the LoRA or re-select it in the node.")
    else:
        raise

Prevention

When it happens

Trigger: Invoking the Z-Image LoRA loader with a ModelIdentifierField whose key is absent from the model-record store (deleted, never installed, or stale key from a copied graph or imported workflow).

Common situations: Deleting a LoRA from the Model Manager while a saved workflow still references it; importing shared workflow JSON with keys from another install; key format changed after a InvokeAI model-record migration; typos when constructing fields programmatically.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/aedb6021ba3d6653. Report an issue: GitHub.