Repository navigation
feat(metrics): log mean absolute rollout-policy logprob error - #5271
Merged
yuki-97 merged 3 commits intoNov 24, 2026
Merged
Conversation
Signed-off-by: Christian Muertz <[email protected]>
yuki-97
reviewed
Nov 17, 2026
yuki-97
left a comment
Contributor
There was a problem hiding this comment.
This PR adds token_abs_logprob_error, the token-normalized mean absolute difference between generation logprobs and previous-policy logprobs, and reports it in both full and minimal metrics. It is a good companion to token_mult_prob_error: the mean absolute difference grows linearly with the mismatch, so it shows the typical training–generation gap without a few outlier tokens dominating it.
Scope: the new mismatch metric in ClippedPGLossFn, its normalization registration and the updated tests, at 52b00cc
Checked:
- Masking — previous and generation logprobs are zeroed outside the mask before the metric is computed, so masked or filtered tokens cannot turn it into NaN; it uses the same mask and global token count as
token_mult_prob_error. (loss_functions.py:846-848) - Reductions — it is registered as
MetricNormalizer.TOKENSinmetric_normalizations, sorescale_loss_metricsand the Megatron split-API rescale cover it, and every trainer path sums it across microbatches and ranks liketoken_mult_prob_error. (loss_functions.py:558,megatron_policy_worker.py:2550) - Tests — the golden checks pop the new key the same way as
policy_support_excluded_tokenswhile still asserting loss and gradients, and the host-transfer count of 7 is correct. (test_clipped_pg_loss_goldens.py:166-168,test_loss_functions.py:3299) - Loss and gradients — unchanged; the metric is computed under
torch.no_grad()outside the compiled objective. (loss_functions.py:1154)
nit
- docs entry for the new metric in the GRPO guide
Generated by Claude Code (#4999 version)
Signed-off-by: Christian Muertz <[email protected]>
Contributor
Author
|
/ok to test 5ccab16 |
Signed-off-by: Christian Muertz <[email protected]>
Contributor
Author
|
/ok to test 30a15f2 |
yuki-97
approved these changes
Nov 24, 2026
fujial-code
added a commit
that referenced
this pull request
Nov 24, 2026
Picks up #5271 and #5272; no conflicts. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: fujial <[email protected]>
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 and why
Add
token_abs_logprob_errorto the full and minimal GRPO/PPO training metrics. It reports the mean absolute difference between generation and previous-policy logprobs, in nats per valid token. It shares the token mask and global normalization withtoken_mult_prob_error; its linear scale makes typical differences easier to interpret.Convergence / perf / functionality proof
The numerical metric test covers the masked token mean. The golden tests continue to check the loss and gradients. A focused CPU check of the production metric and global normalization passed, as did Ruff lint, formatting, syntax and diff checks.
Needs upstream changes
None.