Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for diffusers 0.15.1, GEGLU order different with lora dict order. #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lora_diffusion/lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,14 @@ def monkeypatch_or_replace_lora_extended(
target_replace_module,
search_class=[nn.Linear, LoraInjectedLinear, nn.Conv2d, LoraInjectedConv2d],
):
temp_proj = []

if (_child_module.__class__ == nn.Linear) or (
_child_module.__class__ == LoraInjectedLinear
):
if len(loras[0].shape) != 2:
if len(loras) == 0 and name == 'proj':
pass
elif len(loras[0].shape) != 2:
continue

_source = (
Expand Down Expand Up @@ -783,8 +786,17 @@ def monkeypatch_or_replace_lora_extended(
# switch the module
_module._modules[name] = _tmp

up_weight = loras.pop(0)
down_weight = loras.pop(0)
if name == 'proj':
up_weight = temp_proj.pop(0)
down_weight = temp_proj.pop(0)
else:
up_weight = loras.pop(0)
down_weight = loras.pop(0)
if up_weight.shape[0] not in weight.shape or down_weight.shape[1] not in weight.shape:
temp_proj.append(up_weight)
temp_proj.append(down_weight)
up_weight = loras.pop(0)
down_weight = loras.pop(0)

_module._modules[name].lora_up.weight = nn.Parameter(
up_weight.type(weight.dtype)
Expand Down