[Feature] Add elementwise_affine argument to LigerRMSNorm#989
Merged
Tcc0403 merged 2 commits intolinkedin:mainfrom Dec 24, 2025
Merged
[Feature] Add elementwise_affine argument to LigerRMSNorm#989Tcc0403 merged 2 commits intolinkedin:mainfrom
Tcc0403 merged 2 commits intolinkedin:mainfrom
Conversation
Tcc0403
reviewed
Dec 24, 2025
3 tasks
Tcc0403
pushed a commit
that referenced
this pull request
Dec 25, 2025
…atched models (#990) ## Summary Fixes an AttributeError encountered in `LigerRMSNorm.extra_repr` when models are patched `in-place` (e.g., using `apply_liger_kernel_to_model`). In my previous PR (#989 ), I added `elementwise_affine` to `extra_repr` to improve layer visibility. However, when layers are replaced via monkey patching, the `LigerRMSNorm` constructor is typically skipped, leaving the instance without the `elementwise_affine` attribute. ## Testing Done I verified the fix locally. The issue is reproducible via `test/transformers/test_monkey_patch.py`. After applying this fix, `test/transformers/test_monkey_patch.py` passes successfully. - Hardware Type: NVIDIA A100-SXM4-80GB - [x] run `make test` to ensure correctness - [x] run `make checkstyle` to ensure code style - [x] run `make test-convergence` to ensure convergence
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.
Summary
This PR adds the
elementwise_affineargument toLigerRMSNormto align its API withtorch.nn.RMSNorm. This allows users to instantiate the normalization layer without learnable parameters.Details
elementwise_affine(defaulting toTrue) to the__init__method ofLigerRMSNorm.elementwise_affineis set toFalse,self.weightis registered asNone, preventing the allocation of unnecessary parameters.extra_reprto include theelementwise_affinestatus in the printed model structure.LigerRMSNormForGemma) that rely on positional arguments duringsuper().__init__calls.Testing Done
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence