-
Couldn't load subscription status.
- Fork 6.4k
[LoRA training] update metadata use for lora alpha + README #11723
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
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c0e299a
lora alpha
linoytsaban d9bbc99
Apply style fixes
github-actions[bot] 757fa48
Merge branch 'main' into metadata
sayakpaul 137db40
Update examples/advanced_diffusion_training/README_flux.md
linoytsaban 422e4e4
Merge branch 'main' into metadata
linoytsaban 4399fbd
fix readme format
linoytsaban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,6 +170,23 @@ accelerate launch train_dreambooth_lora_flux.py \ | |
| --push_to_hub | ||
| ``` | ||
|
|
||
| ### LoRA Rank and Alpha | ||
| Two key LoRA hyperparameters are LoRA rank and LoRA alpha. | ||
| - `--rank`: Defines the dimension of the trainable LoRA matrices. A higher rank means more expressiveness and capacity to learn (and more parameters). | ||
| - `--lora_alpha`: A scaling factor for the LoRA's output. The LoRA update is scaled by lora_alpha / lora_rank. | ||
| - lora_alpha vs. rank: | ||
| This ratio dictates the LoRA's effective strength: | ||
| lora_alpha == rank: Scaling factor is 1. The LoRA is applied with its learned strength. (e.g., alpha=16, rank=16) | ||
| lora_alpha < rank: Scaling factor < 1. Reduces the LoRA's impact. Useful for subtle changes or to prevent overpowering the base model. (e.g., alpha=8, rank=16) | ||
| lora_alpha > rank: Scaling factor > 1. Amplifies the LoRA's impact. Allows a lower rank LoRA to have a stronger effect. (e.g., alpha=32, rank=16) | ||
|
|
||
| [!TIP] | ||
|
||
| A common starting point is to set `lora_alpha` equal to `rank`. | ||
| Some also set `lora_alpha` to be twice the `rank` (e.g., lora_alpha=32 for lora_rank=16) | ||
| to give the LoRA updates more influence without increasing parameter count. | ||
| If you find your LoRA is "overcooking" or learning too aggressively, consider setting `lora_alpha` to half of `rank` | ||
| (e.g., lora_alpha=8 for rank=16). Experimentation is often key to finding the optimal balance for your use case. | ||
|
|
||
| ### Target Modules | ||
| When LoRA was first adapted from language models to diffusion models, it was applied to the cross-attention layers in the Unet that relate the image representations with the prompts that describe them. | ||
| More recently, SOTA text-to-image diffusion models replaced the Unet with a diffusion Transformer(DiT). With this change, we may also want to explore | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.