- 
                Notifications
    
You must be signed in to change notification settings  - Fork 41
 
[Feature]Add tis fall back for ppo_policy_loss #334
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 @garyzhang99, 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 crucial feature to address training instability in Proximal Policy Optimization (PPO) algorithms, particularly when dealing with discrepancies in probability calculations between different model components like VLLM and transformer. By implementing a pre-clipping mechanism for the importance sampling ratio, the feature prevents extremely large or small ratios from causing large negative gradients and subsequent training issues such as repetition in generated text. This configurable truncation provides a robust way to stabilize PPO training, especially in scenarios where minor computational errors can have significant impacts. 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 'Truncate Large IS' feature to the PPO policy loss function, aimed at improving training stability. The implementation of the feature itself is sound, adding the necessary configuration and logic for clamping the importance sampling ratio. However, a critical issue is that the unit test for this new feature is incomplete, with the core assertions commented out. This means the correctness of the feature is not being verified. I have also provided a couple of suggestions to improve code robustness and clarity in the implementation. The incomplete test must be addressed before this PR can be merged.
| 
           /unittest-module-algorithm  | 
    
          Summary
 Tests
 Github Test Reporter by CTRF 💚  | 
    
| 
           /unittest-module-algorithm  | 
    
          Summary
 Tests
 Github Test Reporter by CTRF 💚  | 
    
Description
The Truncate Large IS feature addresses training instability issues in PPO caused by computation errors between VLLM (used for
old_logprob) and transformer (used forlogprob) calculations.Problem Statement
When probabilities are very small, even minor computation errors between VLLM and transformer can lead to extremely large importance sampling ratios. This is particularly problematic when:
old_logprobandlogprobare small (representing low probabilities)In the standard PPO implementation with one-sided clipping (multiply advantage first, then clip and take max), this can cause:
Solution
The Truncate Large IS feature adds a pre-clipping step that truncates the importance sampling ratio to a configurable range before it's used in loss computation. This is similar to CISPO's approach to handling importance sampling ratios.
Configuration
Parameters
truncate_large_is(bool, default:False): Enable/disable the truncate large IS featuretruncate_is_range_low(float, default:0.0): Lower bound for IS ratio truncationtruncate_is_range_high(float, default:2.0): Upper bound for IS ratio truncationUsage in YAML Config
Recommended Settings
For general use with potential VLLM/transformer computation errors:
Implementation Details
The truncation is applied as follows:
This ensures that extremely large (or small) ratios are bounded before they interact with the advantage values.
When to Use
Consider enabling this feature when:
Checklist
Please check the following items before code is ready to be reviewed.