feat: add grpo trainer and simplify gsm8k grpo example#552
feat: add grpo trainer and simplify gsm8k grpo example#552garrett4wade merged 5 commits intomainfrom
Conversation
Summary of ChangesHello @dhh1995, 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 significantly refactors the training infrastructure by introducing a dedicated Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a GRPOTrainer to encapsulate the training logic for GRPO, which is a great step towards simplifying the training examples. The new gsm8k_grpo_trainer.py example demonstrates this simplification effectively. The overall structure of the GRPOTrainer is well-designed, with clear separation of concerns for model creation, data loading, and the training loop.
My review includes a few suggestions:
- A high-severity fix to prevent a crash when no validation dataset is provided.
- A medium-severity improvement for more robust handling of environment variables.
- A medium-severity style suggestion to follow PEP 8 import conventions in the example script.
Overall, this is a solid contribution that improves the usability and structure of the training code.
garrett4wade
left a comment
There was a problem hiding this comment.
Please respect gemini's comments as well. Overall LGTM.
* refact: lift trainer out of grpo gsm8k example * add megatron backend support for rl trainer * fix based on reviews * move trainer into experimental
Description
As per #542 , wrap training scripts into trainers.
This PR extracts the common parts in the training examples into a trainer that supports both FSDP and Megatron backends into a GRPOTrainer. It also provides a much simpler example script that uses the trainer.
Type of Change
work as expected)
Checklist
jb build docs/gemini review)Breaking Change Details (if applicable):
Additional Context
Need help? Check the Contributing Guide or ask in
GitHub Discussions!