Skip to content

[Enhance] Add LoRA rank args in train_text_to_image_lora #3866

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

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

okotaku
Copy link
Contributor

@okotaku okotaku commented Jun 25, 2023

What does this PR do?

・Add LoRA rank and network_alpha args in train_text_to_image_lora.py

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 25, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me! @sayakpaul wdyt?

@sayakpaul
Copy link
Member

Thanks for the PR! Could you help me understand why the addition of network_alpha is necessary? IIUC it's only needed for loading the A1111 CivitAI LoRA checkpoints. Cc: @takuma104 as well.

@okotaku
Copy link
Contributor Author

okotaku commented Jun 29, 2023

@sayakpaul Yes. network_alpha has the same meaning as the diffusers' alpha. However, I have noticed that some repositories use network_alpha during training, and I'm not sure of the exact reasons behind this.

For example,

python3 sd-scripts/train_network.py \
  --network_module lycoris.kohya \
  --network_dim "DIM_FOR_LINEAR" --network_alpha "ALPHA_FOR_LINEAR"\
  --network_args "conv_dim=DIM_FOR_CONV" "conv_alpha=ALPHA_FOR_CONV" \
  "dropout=DROPOUT_RATE" "algo=locon" \

https://github.com/KohakuBlueleaf/LyCORIS

--network_alpha: Specifies the alpha value for stable learning and preventing underflow. The default is 1. Specifying the same value as network_dim results in the same behavior as previous versions.

https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md

@sayakpaul
Copy link
Member

Thanks for providing the explanation! I guess we can safely ignore that when training using diffusers. WDYT?

@okotaku
Copy link
Contributor Author

okotaku commented Jun 29, 2023

@sayakpaul Sounds good. I fixed.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gracias 🙏

@sayakpaul sayakpaul merged commit cdf2ae8 into huggingface:main Jun 29, 2023
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…#3866)

* add rank args in lora finetune

* del network_alpha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants