Skip to content

feat(metrics): log mean absolute rollout-policy logprob error - #5271

Merged
yuki-97 merged 3 commits into
NVIDIA-NeMo:mainfrom
christian-muertz:cmrtz/absolute-logprob-error
Nov 24, 2026
Merged

yuki-97 merged 3 commits into
NVIDIA-NeMo:mainfrom
christian-muertz:cmrtz/absolute-logprob-error

Conversation

@christian-muertz

@christian-muertz christian-muertz commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What and why

Add token_abs_logprob_error to 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 with token_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.

@copy-pr-bot

copy-pr-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.TOKENS in metric_normalizations, so rescale_loss_metrics and the Megatron split-API rescale cover it, and every trainer path sums it across microbatches and ranks like token_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_tokens while 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)

@github-actions github-actions Bot added Documentation Improvements or additions to documentation CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 23, 2026
@christian-muertz

Copy link
Copy Markdown
Contributor Author

/ok to test 5ccab16

@christian-muertz

Copy link
Copy Markdown
Contributor Author

/ok to test 30a15f2

@yuki-97
yuki-97 merged commit b0ce1b0 into NVIDIA-NeMo:main Nov 24, 2026
96 of 101 checks passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants