invoke-ai/InvokeAI · error · ValueError

LoRA "{lora_key}" already applied to transformer.

Error message

LoRA "{lora_key}" already applied to transformer.

What it means

The loader refuses to apply the same LoRA twice to the transformer input: if any entry in self.transformer.loras already has lora.key equal to the requested lora_key, a ValueError is raised. Duplicate LoRA application would double its weight/scale and corrupt the model, so it is treated as a graph-construction error rather than a warning.

Source

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

        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."
                )

        output = ZImageLoRALoaderOutput()

        # Attach LoRA layers to the models.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Remove the duplicate LoRA from one of the chained loader nodes (or from the transformer's existing loras list).
  2. If you want a stronger effect, keep a single LoRA node and raise its weight instead of stacking duplicates.
  3. In programmatic graphs, deduplicate by lora.key before appending to transformer.loras.

Example fix

// before
loader2.lora = same_key  # already in loader1.transformer.loras
// after
loader2.lora = different_lora_key  # or remove loader2 from the chain
Defensive patterns

Strategy: validation

Validate before calling

existing = {l.lora.key for l in loader.transformer.loras} if loader.transformer else set()
if loader.lora.key in existing:
    raise ValueError(f"LoRA {loader.lora.key} would be applied twice to the transformer")

Try / catch

try:
    out = z_image_lora_loader.invoke(context)
except ValueError as e:
    if "already applied to transformer" in str(e):
        context.logger.error(f"{e} - remove the duplicate loader node or raise the weight instead.")
    else:
        raise

Prevention

When it happens

Trigger: Calling ZImageLoRALoader where self.lora.key matches one of the LoRA entries already attached to the ZImageTransformerField passed as self.transformer (e.g. chaining two loader nodes with the same LoRA).

Common situations: Wiring multiple Z-Image LoRA loader nodes in series where the same LoRA is selected twice; duplicating nodes in the workflow editor without changing the LoRA; programmatic graph building appending the same LoRA id repeatedly.

Related errors


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