-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[LoRA] Remove the use of depcrecated loRA functionalities such as LoRAAttnProcessor
#6369
Conversation
@@ -311,71 +355,12 @@ def test_stable_diffusion_xformers_attn_processors(self): | |||
image = sd_pipe(**inputs).images | |||
assert image.shape == (1, 64, 64, 3) | |||
|
|||
@unittest.skipIf(not torch.cuda.is_available(), reason="xformers requires cuda") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need to keep this test because it uses attention processors. Objections?
assert image.shape == (1, 64, 64, 3) | ||
|
||
@unittest.skipIf(not torch.cuda.is_available() or not is_xformers_available(), reason="xformers requires cuda") | ||
def test_stable_diffusion_set_xformers_attn_processors(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
lora_attn_procs = create_lora_layers(sd_pipe.unet) | ||
sd_pipe.unet.set_attn_processor(lora_attn_procs) | ||
sd_pipe = sd_pipe.to(torch_device) | ||
sd_pipe.unet.load_attn_procs(lora_components["unet_lora_params"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still works on regular state dicts as expected.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@@ -1480,120 +1502,6 @@ def test_lora_processors(self): | |||
# sample 2 and sample 3 should be different | |||
assert (sample2 - sample3).abs().max() > 1e-4 | |||
|
|||
def test_lora_save_load(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. No need to test for attention processors I think.
@@ -1087,7 +1129,7 @@ def test_lora_fuse_nan(self): | |||
# corrupt one LoRA weight with `inf` values | |||
with torch.no_grad(): | |||
sd_pipe.unet.mid_block.attentions[0].transformer_blocks[0].attn1.to_q.lora_layer.down.weight += float( | |||
"inf" | |||
"NaN" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why we do this is the following:
import torch
a = torch.tensor([float("inf")])
print(torch.isnan(a).any().item())
Prints False, whereas replacing the "inf" with "NaN" prints True.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me, but even adding an "inf" value should yield NaNs for the forward pass
…RAAttnProcessor` (huggingface#6369) * start deprecating loraattn. * fix * wrap into unet_lora_state_dict * utilize text_encoder_lora_params * utilize text_encoder_attn_modules * debug * debug * remove print * don't use text encoder for test_stable_diffusion_lora * load the procs. * set_default_attn_processor * fix: set_default_attn_processor call. * fix: lora_components[unet_lora_params] * checking for 3d. * 3d. * more fixes. * debug * debug * debug * debug * more debug * more debug * more debug * more debug * more debug * more debug * hack. * remove comments and prep for a PR. * appropriate set_lora_weights() * fix * fix: test_unload_lora_sd * fix: test_unload_lora_sd * use dfault attebtion processors. * debu * debug nan * debug nan * debug nan * use NaN instead of inf * remove comments. * fix: test_text_encoder_lora_state_dict_unchanged * attention processor default * default attention processors. * default * style
What does this PR do?
More concrete problem that this PR solves: https://github.com/huggingface/diffusers/actions/runs/7339182559/job/19982940578.
In summary, we remove: