invoke-ai/InvokeAI · error · ValueError

LoRA "{lora_key}" already applied to Qwen3 encoder.

Error message

LoRA "{lora_key}" already applied to Qwen3 encoder.

What it means

Same duplicate-key rule as the transformer, applied to the Qwen3 text encoder: if the requested LoRA key is already present in self.qwen3_encoder.loras, a ValueError is raised. Applying the same LoRA twice to the text encoder would double-count its contribution to prompt embeddings.

Source

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

    )
    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.
        if self.transformer is not None:
            output.transformer = self.transformer.model_copy(deep=True)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Remove the duplicate entry from the Qwen3 encoder's loras list or drop the redundant loader node.
  2. Use one loader node per unique LoRA, feeding both transformer and encoder outputs.
  3. Deduplicate by key in scripts that assemble encoder LoRA lists.

Example fix

// before
encoder_loras = [lora_a, lora_a]  # duplicate key
// after
encoder_loras = [lora_a]
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try:
    out = z_image_lora_loader.invoke(context)
except ValueError as e:
    if "already applied to Qwen3 encoder" in str(e):
        context.logger.error(f"{e} - drop the redundant encoder LoRA entry.")
    else:
        raise

Prevention

When it happens

Trigger: Invoking ZImageLoRALoader where self.lora.key equals an entry already in the ZImageQwen3EncoderField's loras list passed as self.qwen3_encoder.

Common situations: A single LoRA that patches both transformer and encoder applied twice to the encoder input via chained loader nodes; duplicated nodes in the editor; generated graphs appending encoder LoRAs without deduplication.

Related errors


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