Skip to content

Fix: Exclude module handling in LoRA weight loading #11911

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

Open
wants to merge 1 commit into
base: main
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
6 changes: 5 additions & 1 deletion src/diffusers/utils/peft_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ def _derive_exclude_modules(model_state_dict, peft_state_dict, adapter_name=None
all_modules.add(module_name)

target_modules_set = {name.split(".lora")[0] for name in peft_state_dict.keys()}
exclude_modules = list(all_modules - target_modules_set)
exclude_modules_set = set(all_modules - target_modules_set)
exclude_modules = []
for module_name in exclude_modules_set:
if all(module_name not in target_module_name for target_module_name in target_modules_set):
exclude_modules.append(module_name)

return exclude_modules