Uh oh!
There was an error while loading. Please reload this page.
[LoRA] Remove the use of depcrecated loRA functionalities such as LoRAAttnProcessor - #6369
Conversation
| 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.
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): |
| 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.
It still works on regular state dicts as expected.
HuggingFaceDocBuilderDev
commented
Dec 28, 2023
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. |
| # 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.
Same. No need to test for attention processors I think.
| 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.
The reason why we do this is the following:
importtorcha=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.
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: