Remove dead _last_input_before_norm write in NormalizationBridge#1528
Merged
Conversation
Written on every forward but never read anywhere in the repo since TransformerLensOrg#1129; pins one [batch, seq, d_model] activation (and, when requires_grad, its upstream autograd graph) per norm module between forwards. Noted in TransformerLensOrg#1526.
Contributor
Author
Collaborator
|
Looks good, thanks @Hetens! |
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.
Description
Dead-code cleanup split out of #1526 per maintainer request there (the bug fix itself is #1527, based on
main).NormalizationBridge.forwardwroteself._last_input_before_norm = hidden_stateson every call, but nothing in the repo has read that attribute since the #1129 cleanup. The write pins one[batch, seq, d_model]activation per norm module between forwards, and when the input hasrequires_grad=Trueit also keeps the upstream autograd graph alive, which is real memory overhead for anyone training through the bridge.One-line deletion; a repo-wide grep confirms no remaining references. Note for merge ordering: #1527 touches the surrounding lines on
main, so whichever lands second may need a trivial rebase whenmainsyncs intodev. Happy to handle that.The second observation from #1526 (the
layer_norm_foldingconfig flag is never setTrueanywhere, so its branch inforwardappears unreachable) is deliberately NOT touched here: removing a public config field or its branch is a design decision I'd rather leave to maintainers.Type of change
Checklist:
Notes on the checklist:
tests/unit/model_bridge/generalized_components/passes locally (161 passed).Drafted with the assistance of Claude (Anthropic's AI assistant), working under my direction.