Skip to content

fix(sc): skip reference logprobs when KL is disabled - #3771

Merged
yuki-97 merged 3 commits into
mainfrom
ruit/v2_2672_refit_sc
Aug 24, 2026
Merged

yuki-97 merged 3 commits into
mainfrom
ruit/v2_2672_refit_sc

Conversation

@RayenTian

@RayenTian RayenTian commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Ports the still-applicable reference-policy logprob behavior from #2672 to the SingleController GRPO path (examples/run_grpo_single_controller.py).

When loss_fn.reference_policy_kl_penalty == 0, SingleController now skips reference-policy logprob computation even when grpo.skip_reference_policy_logprobs_calculation is left at its default value. This aligns the runtime decision with trainer setup, which does not initialize a reference model when the KL penalty is disabled.

Scope note

This PR intentionally does not port the non-colocated refit changes from #2672 (offload_before_refit() / prepare_for_training()). Those changes were reverted by #2794 because they caused a performance regression, so only the reference-logprob portion is migrated to SingleController.

Testing

  • Added coverage for KL disabled with explicit skip both false and true, and KL enabled with skip false.
  • Targeted test: 3 passed.
  • Ruff checks passed for the changed files.
  • Commit-time pre-commit hooks passed, including Ruff, Ruff format, and Pyrefly.

Related PRs

@copy-pr-bot

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

@RayenTian RayenTian added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Aug 23, 2026
@RayenTian

Copy link
Copy Markdown
Contributor Author

/ok to test 77ad70a

RayenTian and others added 2 commits August 23, 2026 22:06
With `loss_fn.reference_policy_kl_penalty == 0` the SC path builds no
reference model, so SingleControllerActor skips the reference-logprob
forward. When the config leaves
`grpo.skip_reference_policy_logprobs_calculation` at its default false,
nothing asked for that skip and nothing reported it -- the pass simply
vanished. grpo.py, grpo_sync.py and ppo.py all print a notice in the
equivalent situation; match them.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
@RayenTian
RayenTian force-pushed the ruit/v2_2672_refit_sc branch from 77ad70a to 68fffae Compare August 24, 2026 05:08
@RayenTian

Copy link
Copy Markdown
Contributor Author

/ok to test 68fffae

@RayenTian
RayenTian marked this pull request as ready for review August 24, 2026 05:10
@RayenTian
RayenTian requested review from a team as code owners August 24, 2026 05:10
@RayenTian
RayenTian requested review from terrykong, yfw and yuki-97 August 24, 2026 05:10
Comment thread nemo_rl/algorithms/single_controller.py Resolved
Comment thread nemo_rl/algorithms/single_controller.py Resolved
The SC path gates both the reference model (setup._build_trainer) and the
reference-logprob forward on `> 0`, but ClippedPGLossFn applies the KL term
whenever the penalty is != 0. A negative penalty therefore made the loss read
a reference_policy_logprobs column that was never written. Reject it at setup.

With negatives rejected, the skip notice can key off `== 0` exactly, matching
the message it prints.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
@RayenTian

Copy link
Copy Markdown
Contributor Author

/ok to test e09f8db

@yuki-97
yuki-97 enabled auto-merge (squash) August 24, 2026 09:45
@yuki-97
yuki-97 merged commit aa73950 into main Aug 24, 2026
154 of 158 checks passed
@yuki-97
yuki-97 deleted the ruit/v2_2672_refit_sc branch August 24, 2026 09:55
@yfw yfw mentioned this pull request Aug 29, 2026
4 tasks done
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants