feat: decouple IS correction level from GSPO policy ratio#2269
Open
bo-ke wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Open
feat: decouple IS correction level from GSPO policy ratio#2269bo-ke wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
bo-ke wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Conversation
Add `is_correction_level` config field to `ClippedPGLossConfig` that controls IS correction weight computation independently of the PPO ratio (which is still controlled by `sequence_level_importance_ratios`). Currently `sequence_level_importance_ratios=True` bundles two behaviors: 1. GSPO policy ratio: exp(mean(log(π_curr/π_prev))) — stable 2. IS correction: exp(sum(prev - gen)) — collapses for long sequences For long sequences (~9k+ tokens), even a small per-token logprob mismatch between training and inference backends accumulates via exp(sum) to near-zero IS weights, effectively reducing the learning rate by 10-50x with high variance across steps. The new `is_correction_level` field supports: - "sequence": exp(sum) — current behavior - "sequence_mean": exp(mean) — geometric mean, numerically stable - "token": per-token exp(prev - gen) When unset (None), behavior is derived from `sequence_level_importance_ratios` for full backward compatibility. Signed-off-by: kebo01 <kebo01@baidu.com>
9931c9e to
c7b1b01
Compare
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?
Decouple IS correction granularity from the GSPO policy ratio so they can be
configured independently.
Currently
sequence_level_importance_ratios=Truebundles two behaviors into asingle flag:
exp(mean(log(π_curr/π_prev)))— numerically stableexp(sum(prev - gen))— collapses for longsequences
For long sequences (~9k+ tokens), even a small per-token logprob mismatch between
training and inference backends (e.g., ~2% with vLLM + Megatron) accumulates via
exp(sum)to near-zero IS weights, effectively reducing the learning rate by10–50x with high variance across steps.
This PR adds a new
is_correction_levelconfig field toClippedPGLossConfigthat controls IS correction weight computation independently of the PPO ratio
(which remains controlled by
sequence_level_importance_ratios).Supported values:
"sequence"—exp(sum(prev - gen)), one weight per sequence (currentbehavior)
"sequence_mean"—exp(mean(prev - gen)), geometric mean, numerically stablefor long sequences
"token"—exp(prev - gen)per token, token-level correctionWhen unset (
None), behavior is derived fromsequence_level_importance_ratiosfor full backward compatibility.
Issues
None — discovered during GRPO training with Qwen3.5-35B-A3B (MoE, ~9k avg
response tokens) where
sampling_importance_ratioshowed mean ~0.4, std ~0.27,with some steps collapsing to 0.02.
Usage
Before your PR is "Ready for review"
Pre checks:
/NVIDIA-NeMo/RL/blob/main/docs/testing.md for how to run tests
/NVIDIA-NeMo/RL/blob/main/docs/documentation.md for how to write, build and test
the docs.
Additional Information
that exp(mean) produces IS weights closer to 1.0 than exp(sum) and that the loss
value matches hand-calculated expectations