Skip to content

[Lora] fix lora fuse unfuse #5003

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

Merged
merged 3 commits into from
Sep 13, 2023
Merged

[Lora] fix lora fuse unfuse #5003

merged 3 commits into from
Sep 13, 2023

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Sep 12, 2023

Fixes sequentially fusing & unfusing LoRAs.
Fixes: #5000

@apolinario
Copy link
Collaborator

It works!

@apolinario
Copy link
Collaborator

apolinario commented Sep 12, 2023

Found another case where it fails:

pipe.load_lora_weights("Pclanglais/TintinIA")
pipe.fuse_lora()
pipe.unfuse_lora()
pipe.unload_lora_weights()

pipe.load_lora_weights("ProomptEngineer/pe-balloon-diffusion-style")
pipe.fuse_lora()
pipe.unload_lora_weights()
pipe.unfuse_lora()

pipe.load_lora_weights("ostris/crayon_style_lora_sdxl")
pipe.fuse_lora()
pipe.unload_lora_weights()
pipe.unfuse_lora()

The error seems the same but on loaders.py

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-5-545257b7c3f8>](https://localhost:8080/#) in <cell line: 14>()
     12 pipe.fuse_lora()
     13 pipe.unload_lora_weights()
---> 14 pipe.unfuse_lora()

2 frames
[/usr/local/lib/python3.10/dist-packages/diffusers/loaders.py](https://localhost:8080/#) in _unfuse_lora(self)
    127         dtype, device = fused_weight.dtype, fused_weight.device
    128 
--> 129         w_up = self.w_up.to(device=device).float()
    130         w_down = self.w_down.to(device).float()
    131 

AttributeError: 'NoneType' object has no attribute 'to'

@patrickvonplaten
Copy link
Contributor Author

Sweet this seems to be fixed no? I'll add a quick test and then we can merge this I think

@apolinario
Copy link
Collaborator

Yes I added the same fix to loaders.py and I think that made it

@patrickvonplaten
Copy link
Contributor Author

Cool, this one should be good to merge then

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 13, 2023

The documentation is not available anymore as the PR was closed or merged.

@apolinario apolinario merged commit b47f511 into main Sep 13, 2023
@patrickvonplaten patrickvonplaten deleted the fix_lora_fuse_unfuse branch September 13, 2023 09:28
patrickvonplaten added a commit that referenced this pull request Sep 29, 2023
* fix lora fuse unfuse

* add same changes to loaders.py

* add test

---------

Co-authored-by: multimodalart <[email protected]>
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* fix lora fuse unfuse

* add same changes to loaders.py

* add test

---------

Co-authored-by: multimodalart <[email protected]>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* fix lora fuse unfuse

* add same changes to loaders.py

* add test

---------

Co-authored-by: multimodalart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression 🚨 Unfusing LoRAs is broken after the first fuse/unfuse operation
3 participants