feat(nn): add configurable norm_layer to Mlp#1702
Open
Thabhelo wants to merge 2 commits into
Open
Conversation
Add a norm_layer parameter supporting LayerNorm, TE-aware norms, and custom factories while keeping use_batchnorm backward compatible. Closes NVIDIA#1451 Signed-off-by: Thabhelo <50872400+Thabhelo@users.noreply.github.com>
Contributor
Greptile SummaryThis PR adds a
Important Files Changed
Reviews (1): Last reviewed commit: "feat(nn): add configurable norm_layer to..." | Re-trigger Greptile |
Split layernorm (PyTorch LayerNorm) from te_layernorm (requires TE and CUDA), store norm_layer on the module, and extend tests accordingly. Signed-off-by: Thabhelo <50872400+Thabhelo@users.noreply.github.com>
Author
|
Okay cool, I have addressed the feedback in the latest push:
Added tests for the TE string path and the stored attribute, too. |
Author
|
Greptile feedback from the first review is addressed in 8896888. Replies are on the inline threads. docs come from the updated Mlp docstrings via Sphinx automodule. |
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.
PhysicsNeMo Pull Request
Description
Adds a
norm_layerparameter tophysicsnemo.nn.Mlpso normalization type is configurable instead of being limited toBatchNorm1dviause_batchnorm.Supported options:
norm_layer="batchnorm","layernorm", or"te_layernorm"norm_layer=nn.LayerNormorget_layer_norm_class()for TE-aware LayerNormnorm_layer(out_features)use_batchnorm=Trueremains backward compatible and is mutually exclusive withnorm_layer.Closes #1451
Checklist
physicsnemo.nnlayer change, notphysicsnemo.models.)Notes
norm_layeris documented in theMlpclass docstring and doctest examples; Sphinx exposes it viadocs/api/nn/layers/fully_connected_mlp.rstautomodule.Dependencies
None.
Test plan
pytest test/nn/module/test_mlp_layers.py -vpytest --doctest-modules physicsnemo/nn/module/mlp_layers.py