[Refactor] refactor loaders.py to make it cleaner and leaner. - #5771
Conversation
loaders.py to make it cleaner and leaner.
| @@ -0,0 +1,201 @@ | |||
| # Copyright 2023 The HuggingFace Team. All rights reserved. | |||
There was a problem hiding this comment.
Can we remove this file and put everything in the corresponding classes? I think most things here should go into lora.py
There was a problem hiding this comment.
Just kept it because of AttnProcLayers as it is used by custom diffusion.
| set_adapter_layers, | ||
| set_weights_and_activate_adapters, | ||
| ) | ||
| from .utils import PatchedLoraProjection, text_encoder_attn_modules, text_encoder_mlp_modules |
There was a problem hiding this comment.
Let's define all these classes directly here. The classes are only used in lora.py anyways no?
There was a problem hiding this comment.
text_encoder_lora_state_dict() is used by some training scripts. I moved it to lora.py as well and made necessary changes. Is that too aggressive?
|
Very cool refactor - let's make sure we don't braek
Once all these slow tests run correctly we can merge this IMO |
loaders.py to make it cleaner and leaner.loaders.py to make it cleaner and leaner.
|
The documentation is not available anymore as the PR was closed or merged. |
|
@patrickvonplaten I have run all the tests you asked for, and they pass :=) I'd appreciate it very much if you could go through the PR one more time rigorously and let me know your feedback. |
|
Added two functions to |
|
Thanks! Will merge once the CI is green then! |
…ingface#5771) * refactor loaders.py to make it cleaner and leaner. * refactor loaders init * inits. * textual inversion to the init. * inits. * remove certain modules from the main init. * AttnProcsLayers * fix imports * avoid circular import. * fix circular import pt 2. * address PR comments * imports * fix: imports. * remove from main init for avoiding circular deps. * remove spurious deps. * fix-copies. * fix imports. * more debug * more debug * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…ingface#5771) * refactor loaders.py to make it cleaner and leaner. * refactor loaders init * inits. * textual inversion to the init. * inits. * remove certain modules from the main init. * AttnProcsLayers * fix imports * avoid circular import. * fix circular import pt 2. * address PR comments * imports * fix: imports. * remove from main init for avoiding circular deps. * remove spurious deps. * fix-copies. * fix imports. * more debug * more debug * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
What does this PR do?
Fixes: #5669
I had to move some import statements to not cause circular dependencies.