Added separate limits for saving full checkpoints and model weights#37196
Open
GitGautamHub wants to merge 2 commits into
Open
Added separate limits for saving full checkpoints and model weights#37196GitGautamHub wants to merge 2 commits into
GitGautamHub wants to merge 2 commits into
Conversation
Contributor
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
Member
|
cc @muellerzr @SunMarc here and to the original issue #37195 |
Aravind-11
added a commit
to Aravind-11/transformers
that referenced
this pull request
Oct 24, 2025
This was referenced Oct 24, 2025
Closed
Contributor
|
Hi @GitGautamHub , what's the status on this? I can take this up but it looks very complicated since these changes could affect a lot of other files. I don't know if i'm right. Would like your inputs on this. |
Aravind-11
added a commit
to Aravind-11/transformers
that referenced
this pull request
Oct 27, 2025
4 tasks
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.
What does this PR do?
This PR introduces separate limits for saving full checkpoints and model weights in the Trainer class. Currently, save_total_limit applies to both, which can lead to inefficient storage management. This change allows users to:
Retain intermediate model weights for analysis without storing full checkpoints unnecessarily.
Ensure that the latest full checkpoint is available for resuming training.
Fixes Issue
Fixes #37195
Motivation
The current implementation of save_total_limit does not differentiate between full checkpoints and model weights. This can be problematic when users require frequent weight saves but only need a limited number of full checkpoints. Introducing separate limits enhances flexibility and optimizes storage usage.
Changes Made
Updated _rotate_checkpoints() in trainer.py to support independent limits for full checkpoints and model weights.
Introduced save_checkpoint_limit and save_model_weights_limit as configurable parameters.
Updated relevant documentation and method docstrings.
Tests
Due to local environment issues, I was unable to run the tests locally.
The CI/CD pipeline should validate the changes.