-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
layernorm_decay_fix #35927
layernorm_decay_fix #35927
Conversation
Agree that all normalization layers should not have weight decay applied to their parameters, so this is a good change, but I'll need a review from @SunMarc @muellerzr for the trainer changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes looks good to me. Can you add an additional test to check if rmsnorm is correctly removed, thanks !
please also fix the CI with |
Thank you for the review comments! I ran
and confirmed it shows I'll add the additional test for RMSNorm right away! |
Thank you for the review comments. I added test code to verify RMSNorm parameters are correctly excluded:
I confirmed that RMSNorm parameters are correctly filtered out to no_decay set. Here are some examples from no_decay: These are the layers that were not filtered out in the previous code. |
Nice ! Could you add a test in the PR with a smaller model like |
there is still an issue with the formatting, the ci is still red |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Sorry for my confusion earlier, and thank you for your patience and clear guidance! I've added a test using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for iterating !
* layernorm_decay_fix * W293 fix * ruff format fix * black format * ruff format * erase last layer * add test_get_parameter_names_rmsnorm * rmsnorm fix
* layernorm_decay_fix * W293 fix * ruff format fix * black format * ruff format * erase last layer * add test_get_parameter_names_rmsnorm * rmsnorm fix
What does this PR do?
This PR improves the weight decay parameter filtering mechanism to properly handle all normalization layers, especially RMSNorm variants.
Background and Motivation
Normalization layers (like LayerNorm and RMSNorm) should not have weight decay applied to their parameters. (See discussion)
The current implementation filters out instances of
nn.LayerNorm
through type checking. However, this approach has limitations:nn.RMSNorm
Simply adding
nn.RMSNorm
toALL_LAYERNORM_LAYERS
would not catch these custom implementations. Therefore, this PR adds name-based filtering alongside the existing type-based filtering.Changes
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
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.