Skip to content

📢 Improve GRPO trainer error message for invalid num_generations #3199

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

Merged
merged 3 commits into from
Apr 5, 2025

Conversation

AliBakly
Copy link
Contributor

@AliBakly AliBakly commented Mar 31, 2025

This PR fixes a confusing error message when users try to use num_generations=1 with the GRPO trainer.

Current Message:
ValueError: The global train batch size (1 x 4) must be evenly divisible by the number of generations per prompt (1). Given the current train batch size, the valid values for the number of generations are: [2, 4].
This is mathematically incorrect since 1 is a valid divisor of any number, and confused me in the beginning. The real issue is that GRPO requires at least 2 generations to function properly.

Changes
Just raise a ValueError if num_generations<2 with a more informative message.

Copy link
Member

@qgallouedec qgallouedec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@qgallouedec qgallouedec changed the title Improve GRPO trainer error message for invalid num_generations 📢 Improve GRPO trainer error message for invalid num_generations Apr 1, 2025
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Change-Id: Ia34c4f5b0c55ea62149849612a3b3c18cc291d68
@AliBakly AliBakly force-pushed the fix-grpo-error-message branch from b38b233 to 53672f3 Compare April 2, 2025 12:24
@qgallouedec qgallouedec merged commit 5a0cebc into huggingface:main Apr 5, 2025
6 of 9 checks passed
yxliu-TAMU pushed a commit to mincheolseong/ECEN743-GRPO-Project-Proposal that referenced this pull request Apr 20, 2025
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.

3 participants