Uh oh!
There was an error while loading. Please reload this page.
Fix Unfuse Lora - #4833
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 |
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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() |
There was a problem hiding this comment.
Improve precision to fp32
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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() |
There was a problem hiding this comment.
Improve precision
The documentation is not available anymore as the PR was closed or merged. |
Uh oh!
There was an error while loading. Please reload this page.
| 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) |
Uh oh!
There was an error while loading. Please reload this page.
sayakpaul
commented
Aug 30, 2023
Thanks a lot. |
* Fix Unfuse Lora * add tests * Fix more * Fix more * Fix all * make style * make style
* Fix Unfuse Lora * add tests * Fix more * Fix more * Fix all * make style * make style
What does this PR do?
This PR fixes the unfusing issue as discovered by @apolinariohere