Skip to content

[feat][checkpoint] Allow selective state restore on resume - #2010

Open
bvolpato wants to merge 6 commits into
NovaSky-AI:mainfrom
bvolpato:bvolpato/model-only-checkpoint-resume
Open

[feat][checkpoint] Allow selective state restore on resume#2010
bvolpato wants to merge 6 commits into
NovaSky-AI:mainfrom
bvolpato:bvolpato/model-only-checkpoint-resume

Conversation

@bvolpato

@bvolpato bvolpato commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Allow checkpoint weights to seed a new training phase while independently controlling global-step, dataloader, optimizer, and learning-rate scheduler restoration.

Exact resume remains unchanged because every option defaults to true.

Changes

  • Add trainer.resume_load_global_step, trainer.resume_load_dataloader_state, trainer.resume_load_optimizer_states, and trainer.resume_load_lr_scheduler_states.
  • Reset training to step zero when global-step restoration is disabled.
  • Skip stale fully-async UID and epoch state for a new training phase.
  • Preserve logical epoch progress and epoch-end saves in sync and fully-async trainers when global-step restoration skips the dataloader cursor.
  • Bound fully-async producers to the shortened first epoch's remaining groups when the cursor is skipped. Filtered groups return one permit so replacement sampling still works without leaving surplus buffered generation at epoch teardown.
  • Pass optimizer and scheduler restore options to policy and critic checkpoint loading.
  • Document selective-state resume and separate checkpoint output paths.
  • Add focused sync and fully-async regression coverage.

Testing

  • pytest tests/train/test_trainer.py tests/train/test_config.py tests/train/test_fully_async_trainer.py -q (179 passed)
  • Same focused suites on a clean merge with current upstream/main at a6871df (183 passed)
  • pre-commit run --all-files
  • uv lock --check
  • documentation type check and production build (66 pages)
  • git diff --check

Megatron dependency

Merge #2149 before using trainer.resume_load_optimizer_states=false with Megatron. It refreshes optimizer master parameters from the loaded model; without it, the first optimizer step can overwrite checkpoint weights with stale master values. Default full-state resume is unaffected.

@bvolpato
bvolpato force-pushed the bvolpato/model-only-checkpoint-resume branch from 08cf263 to adffbdf Compare August 10, 2026 21:49
@bvolpato bvolpato changed the title [feat][checkpoint] Allow fresh optimizer state on resume [feat][checkpoint] Allow selective state restore on resume Aug 10, 2026
@bvolpato
bvolpato force-pushed the bvolpato/model-only-checkpoint-resume branch from adffbdf to a2b3558 Compare August 13, 2026 01:20
@bvolpato
bvolpato marked this pull request as ready for review August 13, 2026 01:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces four new configuration parameters (resume_load_global_step, resume_load_dataloader_state, resume_load_optimizer_states, and resume_load_lr_scheduler_states) to allow users to selectively disable restoring specific states when resuming from a checkpoint. The trainer logic and documentation have been updated accordingly, and new unit tests have been added. Feedback suggests explicitly checking if self.train_dataloader is initialized before attempting to restore its state to avoid potential AttributeError warnings when no dataloader exists.

Comment thread skyrl/train/trainer.py Outdated
Comment thread skyrl/train/trainer.py
@bvolpato
bvolpato force-pushed the bvolpato/model-only-checkpoint-resume branch from 9b0aeb4 to 93a835b Compare August 14, 2026 04:36
Comment thread skyrl/train/fully_async_trainer.py Outdated
@bvolpato
bvolpato force-pushed the bvolpato/model-only-checkpoint-resume branch from 8e40852 to b2cde16 Compare August 16, 2026 15:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b2cde16. Configure here.

Comment thread skyrl/train/trainer.py
Track whether the dataloader cursor restored successfully.

When global step is kept without that cursor, run only the logical remainder of the first resumed epoch.
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.

1 participant