fix: aligns GRPOConfig with the upstream trl && update docs#8003
fix: aligns GRPOConfig with the upstream trl && update docs#8003Tohrusky wants to merge 2 commits intomodelscope:mainfrom
Conversation
Summary of ChangesHello @Tohrusky, 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 standardizes the configuration logic for Highlights
🧠 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
Activity
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 aligns the GRPOConfig logic with the upstream trl implementation and updates the corresponding documentation. The changes in swift/rlhf_trainers/arguments.py correctly handle the initialization of generation_batch_size and steps_per_generation, making the logic more robust and explicit. The documentation updates in both Chinese and English versions accurately reflect these changes, correcting previous inaccuracies and improving clarity for users. The code is well-structured and the documentation is now more precise. Overall, this is a solid improvement.
PR type
PR information
This PR aligns the GRPOConfig logic in ms-swift with the upstream trl implementation to ensure consistent behavior regarding generation_batch_size.
See:
ms-swift/swift/rlhf_trainers/arguments.py
Line 107 in b52bf59
And trl:
https://github.com/huggingface/trl/blob/main/trl/trainer/grpo_config.py#L843
Docs Updates
Fixed a error in docs/source/Instruction/GRPO/GetStarted/GRPO.md.
Correction: When steps_per_generation is set, the total generation_batch_size should be calculated as: generation_batch_size = per_device_train_batch_size * steps_per_generation * num_processes
Previously, the documentation was misleading regarding how steps_per_generation's default value impacts the generation_batch_size.
Additional Question
The Megatron implementation seems to behave differently with swift:
https://github.com/modelscope/ms-swift/blob/b52bf591fbc1e054908fec064f794536307c3c89/swift/megatron/trainers/grpo_trainer.py#L1071C21-L1071C41
https://swift.readthedocs.io/zh-cn/v3.12/Megatron-SWIFT/GRPO.html#id1
The doc here is a bit confusing regarding
steps_per_generation.Is this difference in logic intentional due to Megatron?
If so, it might be helpful to update the docs to clearly distinguish between the standard behavior and the Megatron behavior to avoid confusion.
Thanks! ❤