Fix: leaf_level offloading breaks after delete_adapters#12639
Fix: leaf_level offloading breaks after delete_adapters#12639sayakpaul merged 9 commits intohuggingface:mainfrom
Conversation
|
thanks for the PR! @adi776borate |
|
@adi776borate thanks for your PR! Could you also add a test for this in https://github.com/huggingface/diffusers/blob/main/tests/lora/utils.py? @yiyixuxu we have a test for Line 2341 in 7a001c3 I ran it with ====================== 16 passed, 1 skipped, 860 deselected, 2 warnings in 60.04s (0:01:00) ======================So, @adi776borate maybe we could start by adding a similar test case as Line 2341 in 7a001c3 enable_sequential_cpu_offload() (can happen in a separate PR).
|
|
@sayakpaul I've added a regression test @yiyixuxu I also verified locally that Ready for the review. |
|
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. |
tests/lora/utils.py
Outdated
| pipe.load_lora_weights(tmpdirname, adapter_name="default") | ||
| pipe(**inputs, generator=torch.manual_seed(0)) | ||
| # Delete the adapter | ||
| pipe.delete_adapters("default") |
There was a problem hiding this comment.
We can make this test tighter by also adding some assertions:
diff --git a/tests/lora/utils.py b/tests/lora/utils.py
index efe68dd3c..7e19aac29 100644
--- a/tests/lora/utils.py
+++ b/tests/lora/utils.py
@@ -2403,7 +2403,9 @@ class PeftLoraLoaderMixinTests:
)
pipe.load_lora_weights(tmpdirname, adapter_name="default")
- pipe(**inputs, generator=torch.manual_seed(0))
+ out_lora = pipe(**inputs, generator=torch.manual_seed(0))[0]
+
# Delete the adapter
pipe.delete_adapters("default")
- pipe(**inputs, generator=torch.manual_seed(0))
\ No newline at end of file
+ out_no_lora = pipe(**inputs, generator=torch.manual_seed(0))[0]
+ self.assertFalse(np.allclose(out_lora, out_no_lora, atol=1e-3, rtol=1e-3))
\ No newline at end of file
There was a problem hiding this comment.
Thanks for the suggestion! I have made the changes.
|
@yiyixuxu I'm getting familiar with testing and resolving CI errors. |
|
I have ran the tests and they are passing as well. Thanks for your work! |
Sorry for being busy recently and not seeing this earlier—this solved my problem perfectly. Thank you! @adi776borate |
|
Failing tests are unrelated. |
|
Thanks for your contributions, @adi776borate! |
Thank you @sayakpaul and @yiyixuxu! I really appreciate the guidance. It's been a great experience, and I'm excited to have my first PR merged into 🧨. |
What does this PR do?
Fixes #12396
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu
@sayakpaul
Anyone in the community is free to review the PR once the tests have passed.