Skip to content

Added separate limits for saving full checkpoints and model weights#37196

Open
GitGautamHub wants to merge 2 commits into
huggingface:mainfrom
GitGautamHub:feature-separate-checkpoint-limits
Open

Added separate limits for saving full checkpoints and model weights#37196
GitGautamHub wants to merge 2 commits into
huggingface:mainfrom
GitGautamHub:feature-separate-checkpoint-limits

Conversation

@GitGautamHub

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Apr 2, 2025

Copy link
Copy Markdown
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 Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@github-actions github-actions Bot marked this pull request as draft April 2, 2025 05:59
@Rocketknight1

Copy link
Copy Markdown
Member

cc @muellerzr @SunMarc here and to the original issue #37195

@GitGautamHub GitGautamHub marked this pull request as ready for review April 3, 2025 11:45
Aravind-11 added a commit to Aravind-11/transformers that referenced this pull request Oct 24, 2025
@Aravind-11

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Different limits for saving only model weights and saving full checkpoints

3 participants