Skip to content

Fix GRPO data prep actor checkpoint resume#1523

Merged
hamishivi merged 5 commits intoallenai:mainfrom
MohdElgaar:fix/checkpoint-resume-data-prep
Apr 8, 2026
Merged

Fix GRPO data prep actor checkpoint resume#1523
hamishivi merged 5 commits intoallenai:mainfrom
MohdElgaar:fix/checkpoint-resume-data-prep

Conversation

@MohdElgaar
Copy link
Copy Markdown
Contributor

Summary

  • restore checkpoint client_state that is loaded during from_pretrained()
  • save _last_consumed_step so resumed runs continue from the next unseen learner step
  • start the data prep actor only after checkpoint state has been restored, and remove the outdated global_0/state.pt reload path

The resume path was broken, so data_prep_actor_state was never restored on resume. The dataloaders were starting from the beginning and replayed already-seen data after a checkpoint restore.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the GRPO data preparation actor's checkpoint resume mechanism. Previously, resuming training from a checkpoint would fail to properly restore the data preparation actor's state, leading to the re-processing of already seen data. The changes ensure that the data preparation actor's state, including the last consumed step, is correctly loaded and the actor is started in a consistent state, allowing training to seamlessly continue from where it left off without redundant data processing.

Highlights

  • Robust Checkpoint Restoration: Implemented robust checkpoint restoration for the data preparation actor, ensuring client_state is correctly loaded during from_pretrained().
  • Preventing Data Re-processing: Introduced saving and restoring of _last_consumed_step to guarantee that resumed runs continue processing from the next unconsumed learner step, preventing data re-processing.
  • Refactored Actor Lifecycle: Refactored the data preparation actor's lifecycle to ensure it starts only after its state has been fully restored from a checkpoint.
  • Streamlined Resume Process: Removed the deprecated and ineffective global_0/state.pt checkpoint reload path, streamlining the resume process.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • open_instruct/data_loader.py
    • Modified __init__ to use set_state and start methods for initial state handling.
    • Added a new start method to manage the ThreadPoolExecutor and _prep_future for the data preparation loop.
    • Ensured the data preparation loop is started if not already running when data is requested in get_data.
    • Updated get_state to include _last_consumed_step in the saved state.
    • Enhanced set_state to prevent state updates after the preparation loop has begun and to correctly derive training_step from _last_consumed_step.
  • open_instruct/grpo_fast.py
    • Added a new helper function _build_data_prep_actor_resume_state to construct the data preparation actor's resume state from the main checkpoint, including fallback logic for last_consumed_step.
    • Modified from_pretrained return type to include the full checkpoint_state.
    • Updated load method to store the checkpoint_state after loading.
    • Refactored create_model_and_optimizer to remove data_prep_actor_state as an input, return the checkpoint_state, and explicitly handle the restoration and starting of the data preparation actor using the new _build_data_prep_actor_resume_state function.
    • Adjusted main function to remove the manual loading of global_0/state.pt and to correctly pass and receive the checkpoint_state from create_model_and_optimizer.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 a critical fix for the checkpoint resume functionality of the GRPO data preparation actor. The changes correctly defer the start of the data preparation actor until after its state has been restored from a checkpoint, which resolves the issue of replaying already-seen data on resume. The refactoring of checkpoint loading logic into create_model_and_optimizer and PolicyTrainerRayProcess centralizes state management and improves code organization. While the overall approach is sound, I've identified a critical off-by-one error in the calculation of the resume training step that needs to be addressed.

Comment thread open_instruct/grpo_fast.py Outdated
MohdElgaar and others added 3 commits March 11, 2026 19:30
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@hamishivi hamishivi enabled auto-merge April 8, 2026 18:28
@hamishivi hamishivi added this pull request to the merge queue Apr 8, 2026
Merged via the queue into allenai:main with commit c5fada0 Apr 8, 2026
7 checks passed
davidheineman pushed a commit that referenced this pull request Apr 10, 2026
* Fix GRPO data prep actor checkpoint resume

* Fix off-by-one error

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Add changelog entry for PR #1523 and apply style fixes

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Hamish Ivison <hamishivi@gmail.com>
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.

2 participants