feat: add Dr.GRPO loss normalization - #51
Open
0z5a 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.
Summary
dr_grpoloss variantbatch_size * group_size * max_completion_lengthbudgetrollout_max_tokenswhen it is not set explicitlygrpoobjective and KL regularizer behavior unchangedWhy
Dr.GRPO identifies two normalization choices that can bias R1-Zero-style training: reward scaling by the within-group standard deviation and response-dependent policy-loss normalization. This change exposes both corrections as one explicit objective variant while preserving the current default exactly.
For a paper-faithful no-KL recipe, use
loss_variant="dr_grpo", a fixedmax_completion_length, andkl_coef=0. Offline GRPO requires the fixed completion budget explicitly; online GRPO defaults it torollout_max_tokens.Primary reference: Understanding R1-Zero-Like Training: A Critical Perspective.
L20 microbenchmark
Exact commit:
ffa8520de2c6ac0494702e5eb6d7c9bb33d30536NVIDIA L20, FP32 formula path,
B=256,G=8, response tensor length512, fixed budget1024, 1,048,576 response slots and 785,863 valid tokens. Twenty alternating samples, 200 iterations per sample, CUDA-event timing after warmup.Dr.GRPO was 35.53% faster in this isolated formula microbenchmark because it removes the reward-std and dynamic token-count reductions. This is not an end-to-end training throughput claim; model forward/backward still dominate real training.
Validation
python -m pytest -q: 658 passed on NVIDIA L20 GPU5Compatibility
The default remains
loss_variant="grpo"; existing configs and loss numerics are unchanged.