Merged
Conversation
| attn_module.k_proj = attn_module.k_proj.regular_linear_layer | ||
| attn_module.v_proj = attn_module.v_proj.regular_linear_layer | ||
| attn_module.out_proj = attn_module.out_proj.regular_linear_layer | ||
| attn_module.q_proj.lora_linear_layer = None |
Contributor
Author
There was a problem hiding this comment.
If we remove the whole patched layer when unloading LoRAs we cannot unfuse it anymore. Let's just set the LoRA linear layer to None.
| self.w_up = self.w_up.to(device=device, dtype=dtype) | ||
| self.w_down = self.w_down.to(device, dtype=dtype) | ||
| unfused_weight = fused_weight - torch.bmm(self.w_up[None, :], self.w_down[None, :])[0] | ||
| w_up = self.w_up.to(device=device).float() |
Contributor
Author
There was a problem hiding this comment.
Improve precision to fp32
| self.w_up = self.w_up.to(device=device, dtype=dtype) | ||
| self.w_down = self.w_down.to(device, dtype=dtype) | ||
| unfused_weight = fused_weight - torch.bmm(self.w_up[None, :], self.w_down[None, :])[0] | ||
| w_up = self.w_up.to(device=device).float() |
Contributor
Author
There was a problem hiding this comment.
Improve precision
|
The documentation is not available anymore as the PR was closed or merged. |
…users into fix_unfuse_lora
sayakpaul
reviewed
Aug 30, 2023
Comment on lines
+90
to
+96
| def state_dict(self, *args, destination=None, prefix="", keep_vars=False): | ||
| if self.lora_linear_layer is None: | ||
| return self.regular_linear_layer.state_dict( | ||
| *args, destination=destination, prefix=prefix, keep_vars=keep_vars | ||
| ) | ||
|
|
||
| return super().state_dict(*args, destination=destination, prefix=prefix, keep_vars=keep_vars) |
sayakpaul
reviewed
Aug 30, 2023
Member
|
Thanks a lot. |
yoonseokjin
pushed a commit
to yoonseokjin/diffusers
that referenced
this pull request
Dec 25, 2023
* Fix Unfuse Lora * add tests * Fix more * Fix more * Fix all * make style * make style
AmericanPresidentJimmyCarter
pushed a commit
to AmericanPresidentJimmyCarter/diffusers
that referenced
this pull request
Apr 26, 2024
* Fix Unfuse Lora * add tests * Fix more * Fix more * Fix all * make style * make style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes the unfusing issue as discovered by @apolinario here