chore(docs): Add GRPO clipping viz and explanation#5981
Open
zafstojano wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds a visual explanation of the regions where clipping happens in GRPO, which should be much more intuitive rather than the nested analytical form of the objective.
I wrote about this analysis/decomposition of the regions in the RLHF Book. This time, I updated the diagram to actually show all the cases and values, instead of writing it out in lengthy form.
It should also be quite useful to understand the logged parameters related to clipping mentioned on the page below.
Important
I don't have permissions to upload the image to the trl org in order to reference it here.
Before submitting
AI writing disclosure
We welcome the use of AI tools to help with contributions. For transparency and to help us improve our review process, please indicate the level of AI involvement in this PR.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
Note
Low Risk
Documentation-only change with no runtime, API, or training logic impact.
Overview
Extends the clipped surrogate objective section in
grpo_trainer.mdwith a diagram (grpo_clipping.pngon the trl-lib docs dataset) that shows where GRPO clipping applies for positive vs negative advantages.Adds a short intuitive walkthrough: for positive advantage, updates stop (zero gradient) when the policy ratio is already above
1 + ε; for negative advantage, the same happens below1 - ε, so the doc ties the math to over-reinforcement and over-suppression behavior and complements the existingclip_ratio/*logged metrics on the same page.Reviewed by Cursor Bugbot for commit 935aaee. Bugbot is set up for automated code reviews on this repo. Configure here.