feat(rl): add REINFORCE advantage estimator#2083
Open
EazyReal wants to merge 1 commit into
Open
Conversation
0a6ea75 to
8f1c408
Compare
8f1c408 to
ea4859d
Compare
Contributor
Author
|
@zhuzilin could you review this one? This adds the missing REINFORCE estimator as a narrow advantage path, keeping the estimator interface aligned with the existing GRPO/RLOO style instead of adding a separate training special case. |
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 changed
Adds a
reinforceoption to--advantage-estimator. It reuses the GRPO group-normalized advantages and applies the plain additive surrogate-A * log pi_theta(newcompute_reinforce_lossinslime/utils/ppo_utils.py) — no importance-sampling ratio, no clipping; gradient flows only throughlog_probs, andclipfracis identically zero.Wiring:
compute_advantages_and_returns(slime/backends/megatron_utils/loss.py):reinforcerouted through the existing GRPO returns path (get_grpo_returns).policy_loss_function(slime/backends/megatron_utils/loss.py): dispatches tocompute_reinforce_lossforreinforce.slime/ray/rollout.py):reinforceadded to the mean-centering and optional std-normalization sets, identical to GRPO.--advantage-estimatorchoices/help (slime/utils/arguments.py).Why
REINFORCE with a group baseline is a useful low-overhead estimator: same group normalization as GRPO but without the PPO clip/IS machinery. It is the on-policy base that off-policy importance-sampling corrections can layer on top of.
Validation
CPU unit test
tests/test_reinforce.py(registered in thecpu-unittestmatrix), run withpytest tests/test_reinforce.py:compute_reinforce_lossmatches the closed form-A * log_probsand returns all-zeroclipfrac.d/d log_probs = -A(gradient flows only throughlog_probs).End-to-end: with the dispatch wired into
compute_advantages_and_returns,--advantage-estimator reinforceruns through the GRPO returns + group-normalization path and no longer raisesNotImplementedError.