FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Qwen-Image LoRAs in lora_A/lora_B format lose their .alpha and load at the wrong strength · Issue #14938 · huggingface/diffusers · GitHub

Repository navigation

Qwen-Image LoRAs in lora_A/lora_B format lose their .alpha and load at the wrong strength #14938

Description

Describe the bug

When a Qwen-Image LoRA's keys are already named lora_A/lora_B, _convert_non_diffusers_qwen_lora_to_diffusers discards each module's .alpha instead of applying it. A LoRA trained with alpha ≠ rank therefore loads at the wrong strength. The lora_down/lora_up path and the Z-Image converter already fold alpha / rank into the weights.

For example, e-n-v-y/Qwen-Image-2.1-Fix-v2.0 is rank 32 with alpha 83 and 96, so it loads at roughly a third of its intended strength. ai-toolkit and ComfyUI LoRAs commonly use this layout. It affects Qwen-Image (20B) and Qwen-Image-2.1 alike.

Reproduction

import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
from diffusers import QwenImage21Pipeline

repo, weight = "e-n-v-y/Qwen-Image-2.1-Fix-v2.0", "qwen2.1-detail-fix-2.0.safetensors"
raw = load_file(hf_hub_download(repo, weight))
sd = QwenImage21Pipeline.lora_state_dict(repo, weight_name=weight)

print(sum(k.endswith(".alpha") for k in raw), "alpha keys in the file,",
      sum(k.endswith(".alpha") for k in sd), "after conversion")
a = next(k for k in raw if k.endswith("lora_A.weight") and k.replace("lora_A.weight", "alpha") in raw)
converted = "transformer." + a.replace("diffusion_model.", "")
print("unscaled:", torch.equal(sd[converted].float(), raw[a].float()))

Logs

30 alpha keys in the file, 0 after conversion
unscaled: True
# first module: alpha 83, rank 32 -> should load at 2.59x what it does

System Info

diffusers main at 8b33bfc, Python 3.14, torch 2.14.1, peft 0.21.2.

Who can help?

@sayakpaul

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL