Skip to content

fix(grpo): correct sequence importance ratio metric - #3753

Merged
yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
CarlosGomes98:cgomes/fix-sequence-is-ratio-metric
Aug 23, 2026
Merged

fix(grpo): correct sequence importance ratio metric#3753
yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
CarlosGomes98:cgomes/fix-sequence-is-ratio-metric

Conversation

@CarlosGomes98

Copy link
Copy Markdown
Contributor

What does this PR do ?

Fixes an issue in the metric computation of importance ratio

The issue seems to be that the importance weights are reshaped to [B, 1] in order to be applied to all the tokens in each sequence, but are left that way when they are then reused together with the sample mask. That broadcasts to [B, B]. The whole matrix then gets summed and divided by the number of valid samples, which results in an error. e.g. for 2 samples, both valid the value will be 2x as large as it should be.

The training loss is unnafected, but the metric is wrong

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

Signed-off-by: Carlos Gomes <cgomes@nvidia.com>
@CarlosGomes98
CarlosGomes98 requested review from a team as code owners August 21, 2026 15:15
@copy-pr-bot

copy-pr-bot Bot commented Aug 21, 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.

good catch and thanks for the fix!

@yuki-97

yuki-97 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

/ok to test 45abcca

@yuki-97
yuki-97 enabled auto-merge (squash) August 22, 2026 14:29
@yuki-97 yuki-97 added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Aug 22, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-customer Waiting on the original author to respond label Aug 22, 2026
@yuki-97
yuki-97 merged commit f055732 into NVIDIA-NeMo:main Aug 23, 2026
170 of 173 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Aug 23, 2026
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) community-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants