refactor(char-causal-lm): drop redundant gradient checkpointing overrides - #13
Closed
AmitMY wants to merge 1 commit into
Closed
Conversation
…ides Both overrides only forwarded to self.model, which is what PreTrainedModel already does: its own implementation walks submodules and reaches the wrapped model on its own. Verified against the four tests added in #10 rather than assumed. With the overrides deleted, enable/disable/kwargs and the backward pass all still pass on transformers 4.57.6 and 5.14.1: 245 passed on both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Closing (auto-closed when #10's base branch was deleted, and that is the right outcome): keeping the explicit The measurement stands — The four tests from #10 are merged and remain valuable either way: they pin delegation behaviour that was previously untested, so a future transformers change that breaks it fails loudly instead of silently disabling checkpointing mid-training. |
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.
Audit item #7, part two. Stacked on #10 — based on that branch so its four new tests run against this deletion. Merge #10 first; GitHub will retarget this to
mainautomatically.Both only forwarded to
self.model— which is exactly whatPreTrainedModelalready does. Its own implementation walks submodules and reaches the wrapped model without help.Verified, not assumed
This is why #10 came first. With the overrides deleted, all four of those tests still pass on both CI transformers versions:
enablereaches wrapped modeldisablereaches wrapped modelgradient_checkpointing_kwargsform245 passed on both.
ruffclean.If you would rather keep the explicit delegation as documentation of intent, that is a fair call — closing this costs nothing, and #10's tests are worth having either way.
🤖 Generated with Claude Code
Note
Low Risk
Small deletion of pass-through methods; behavior is covered by existing gradient-checkpointing tests on the stacked PR.
Overview
Removes
gradient_checkpointing_enableandgradient_checkpointing_disablefromCharacterCausalLMWrapperbecause they only delegated to the innerself.model.PreTrainedModelalready enables and disables gradient checkpointing across submodules, and the wrapper still setssupports_gradient_checkpointing = True, so training behavior is unchanged. Companion tests on the stacked branch cover both transformers versions.Reviewed by Cursor Bugbot for commit 389f7b1. Bugbot is set up for automated code reviews on this repo. Configure here.