Conversation
Owner
Author
What is the LoRA rank so I can test it? |
It's a rank 8 LoRA. Sorry, I think it was because the LR was too low for spectral normalization. I increased it to 1e-3 and the LoRA seems to be learning now. The learning is still weaker than it is without scaled wd, but it does learn. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Background
Empirically, we can bypass the pitfalls of weight decay (WD) tuning by setting a single optimal value (
WD * LR = 0.1).We achieve this by scaling the weight decay by the width of the tensor, which scales linearly with the squared Frobenius norm.
In summary, the scaling rules are:
WD / widthWD / width(Note: In theory, the LoRA-B factor has a higher Frobenius norm, so it should decay more heavily than the A-factor. But standard optimizers like Adam struggle to grow the B-factor so I recommend using spectral scaling with LoRA scaled WD).2 * WD / block_size(The factor of 2 accounts for the skew-symmetric matrix having double the Frobenius norm, and block size is the width of constructed skew-symmetric matrix).This approach simplifies WD tuning, ensures fair comparisons between layers and training methods, and is compatible with all optimizers.
New Option:
scaled_wdThis option implements the scaling rules mentioned above and decouples the LR from the WD. When enabled, users can simply set
WD = 0.1and forget about it.Additional Notes & Results
Centered WD = 0.1, which yielded the best SDXL finetune I currently use. Standard WD for full finetuning can be overly sensitive, as the norms were originally trained with very large batch sizes, often degrading quality in small-to-medium training runs.0.1scaled WD outperformed my hand-tuned WD values on the very first attempt.