- Notifications
You must be signed in to change notification settings - Fork 45
[WIP] Add GSPO-style REC variant #380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @yanxi-chen, 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 introduces a GSPO-style variant for the REC (Reinforcement with Expert Correction) algorithm, enhancing its policy loss function with new clipping and weighting mechanisms. It also refines the default KL and entropy settings for REC and ensures proper loss aggregation for GSPO, making the algorithm more flexible and robust for various reinforcement learning tasks. 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.
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 GSPO-style variant for the REC algorithm, adding new clipping and importance sampling methods. It also updates default configurations and enforces a specific loss aggregation mode for GSPO. The changes are mostly well-contained. I've identified a critical issue that could lead to a runtime error if new configuration options are mismatched, and another high-severity bug related to handling a configuration parameter. I've provided suggestions to fix both. The rest of the changes, including documentation and example updates, appear consistent with the code modifications.
| assert self.weight in [ | ||
| "none", | ||
| "importance_sampling", | ||
| "gspo_importance_sampling", | ||
| "advantage", | ||
| ], f"Invalid weight: {self.weight}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new gspo_importance_sampling weight relies on normalized_seq_ratio, which is only calculated when clip_mode is gspo-one-side. This can lead to an UnboundLocalError if these options are used incorrectly. To prevent this, you should enforce that gspo_importance_sampling can only be used with gspo-one-side by adding an assertion.
assert self.weight in [ "none", "importance_sampling", "gspo_importance_sampling", "advantage", ], f"Invalid weight: {self.weight}" if self.weight == "gspo_importance_sampling": assert ( self.clip_mode == "gspo-one-side" ), "'gspo_importance_sampling' weight must be used with 'gspo-one-side' clip mode."
Description
RECPolicyLossFn: supportclip_mode = "gspo-one-side"andweight = "gspo_importance_sampling"kl_coef = 0explicitly in configsGSPOLossFn, enforceloss_agg_mode = "seq-mean-token-mean", as required by GSPO's rationaleChecklist
Please check the following items before code is ready to be reviewed.