[advoptm] Decoupled, Dimension-Scaled Weight Decay #1557
Draft
Koratahiu wants to merge 94 commits into
Draft
Conversation
Collaborator
|
is this the PR you wanted to add no-weight-decay-for-bias? or is this one ready? |
Contributor
Author
Yeah, I already added it. |
Collaborator
|
put back to "Ready" then please |
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 Weight Decay
This 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.Includes: #1344