-
Notifications
You must be signed in to change notification settings - Fork 6k
Support to load Kohya-ss style LoRA file format (without restrictions) #3756
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
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
This reverts commit f174f75.
cc @sayakpaul could you take a look here? :-) |
I think that would be better as it will allow us to reduce redundant work. Let's make sure to revisit after #3778 is dealt with. Cc: @williamberman |
Hey @takuma104, thank you for this PR -- I think it is amazing. For the last week or so, I have been trying to get CivitAILoRAs up and running with diffusers but it always produced super weird (and sometimes irrelevant) results such as this: But using this PR and not changing anything else (same prompt, same seed, same configuration), I can get super precise and good looking pictures from this random model (https://civitai.com/models/24380/minty-doges-doge-style-lora) Seeing this PR is still in draft stage, I wonder whether there is a more official way of loading these sort of LoRAs or whether this PR will get landed soon. |
I want to add I have also used this PR locally and it appears to work well. |
One issue. When I use this PR I'm getting this error intermittently. Only happens on this PR when loading loras. Occurs about 1/5 times.
|
@takuma104 hey! Since #3778 has been merged now, let's pick this one up :-) |
There will always be some amount of limitation in loading non-diffusers LoRAs as there are way too many formats to cater to. So, we're doing our bests to provide a unified support. |
Hey @sayakpaul / @takuma104, in case you folks might not have the availability / time, I would be more than happy to assist on reviving this PR (either preparing a new PR that takes this + rebases with the changes of #3778 OR submitting a PR to the @takuma104's repo) with your permission. We have been using this branch for a couple of weeks and it has been working flawlessly so I assume not much needs to change in regards to the actual logic. |
More than happy to collaborate and ship this. Let's start with a new PR superseeding this. Let's make sure to have Takuma as a co-author of the commits. Works? |
Heavily based on huggingface#3756 by @takuma104 Co-Authored-By: Takuma Mori <[email protected]>
Heavily based on huggingface#3756 by @takuma104 Co-Authored-By: Takuma Mori <[email protected]>
Definitely! Will try to get a working version (compatible with the new unloading logic and the refactored layout) and then I can submit a PR which we can iterate on it! |
Let's go then! Thanks so much! @takuma104 I hope this is alright :) |
Heavily based on huggingface#3756 by @takuma104 Co-Authored-By: Takuma Mori <[email protected]> Co-Authored-By: Sayak Paul <[email protected]>
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Hello, has the pull request that will ultimately replace this one been submitted? Additionally, Does anyone plan to update this content in the Lora training script? |
What's the PR for?
Discussed in #3064 (comment), PR #3437. In the PR #3437, we implemented the loading of Kohya-ss style LoRA, but this was only support for the Attention part, which had already been implemented in Diffusers. Kohya-ss style LoRA is not only extended to Attention, but also to
ClipMLP
,Transformer2DModel
'sproj_in
,proj_out
, and so on. This PR will support these remaining issues.Modification:
modes/lora.py
. I've moved theLoRALinearLayer
here. Fornn.Conv2d
andnn.Linear
that add LoRA to, I've addedConv2dWithLoRA
andLinearWithLoRA
respectively.nn.Linear
inFeedForward
andGEGLU
classes toLinearWithLoRA
.proj_in
,.proj_out
inTransformer2DModel
class toConv2dWithLoRA
LoRALinearLayer
as a monkey-patch tomlp
intext_encoder
Impact:
In the
Transformer2DModel
andFeedForward
classes, some of thenn.Linear
andnn.Conv2d
have been replaced with their subclass. We need to thoroughly confirm that this does not cause any issues in normal use without LoRA. Currently, unit tests that check for class name matching are not passing as follows.Generation Comparison:
LoRA file: Light and Shadow These results should be reproduced by this script.
Todo: