Skip to content

chore(docs): Add GRPO clipping viz and explanation#5981

Open
zafstojano wants to merge 1 commit into
huggingface:mainfrom
zafstojano:docs/add-grpo-clipping-viz
Open

chore(docs): Add GRPO clipping viz and explanation#5981
zafstojano wants to merge 1 commit into
huggingface:mainfrom
zafstojano:docs/add-grpo-clipping-viz

Conversation

@zafstojano

@zafstojano zafstojano commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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.

grpo_clipping

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

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline, Pull Request section?
  • Was this discussed/approved via a GitHub issue? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

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.

  • No AI usage: the PR was written entirely by a human.
  • AI-assisted: some parts were suggested or improved by AI, but the PR was written and reviewed by a human.
  • AI-generated: the PR was mostly or fully generated by an AI tool.

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.md with a diagram (grpo_clipping.png on 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 below 1 - ε, so the doc ties the math to over-reinforcement and over-suppression behavior and complements the existing clip_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant