Skip to content

refactor(loss): remove the deprecated token level loss selector - #5276

Merged
terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
u-brixton:remove-token-level-loss
Nov 25, 2026
Merged

terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
u-brixton:remove-token-level-loss

Conversation

@u-brixton

@u-brixton u-brixton commented Nov 17, 2026 •

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

What and why

This PR follows #4947, which is now merged into main.

Remove the deprecated loss_fn.token_level_loss selector. Migrate all 31 checked-in YAML configs, including example recipes, Gym and ModelOpt configs, the research template, and reference fixtures. Update
the docs, CLI overrides, tests, and numerical golden fixture to use loss_fn.normalization. The public PR explainer skill now names the canonical selector.

Older configs must replace true with global_token_mean and false with sequence_mean. Delete the old key when its value is null. Both the config entrypoints and direct ClippedPGLossConfig
construction report that migration. The golden generator still translates the canonical selector when it runs against its pinned historical implementation.

Before the first trainer checkpoint, the rollout bootstrap identity includes the serialized loss config. Recover a bootstrap snapshot written before this removal with its original NeMo-RL version and config,
then save a trainer checkpoint before upgrading. The GRPO guide documents this recovery path.

Convergence / perf / functionality proof

  • Local CPU checks passed with 320 tests and one expected skip across outdated configuration, normalization, objective reduction, group token means, adaptive PPO clipping, score centering, and OPD full. The
    isolated CPU environment used PyTorch 2.8.0.
  • Verified the migration preserves the selected reduction for all 31 YAML configs and changes only the selector in the numerical golden fixture.
  • Ruff, Python syntax, shell syntax, and git diff --check passed locally.
  • GitHub CI is requested for the restacked head.

Needs upstream changes

None

@u-brixton u-brixton added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 17, 2026
@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.

@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test c3356af

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 17, 2026
@u-brixton
u-brixton requested a review from mehraakash November 17, 2026 21:32
@u-brixton
u-brixton marked this pull request as ready for review November 17, 2026 21:32

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

I found no blocking correctness defect in the supplied diff, including the stacked reduction changes. C1 requests training evidence for the new objective; C2 is a test-maintenance suggestion.

This was a static review across three assigned topics. I did not execute tests or verify CI. Pinned third-party source and review threads from the prerequisite PRs were unavailable, so I could not independently check those references.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_rl/algorithms/loss/interfaces.py Resolved
@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from c3356af to 9c68ff7 Compare November 18, 2026 07:33
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 9c68ff7

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from 9c68ff7 to cbd3db0 Compare November 18, 2026 21:24
@u-brixton u-brixton added CI:L1 Run doctests, unit tests, and functional tests and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 18, 2026
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test cbd3db0

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from cbd3db0 to c9b2794 Compare November 19, 2026 15:35
@u-brixton u-brixton added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Nov 19, 2026
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test c9b2794

@mehraakash mehraakash 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.

Thanks for the clean removal and migration. I reviewed this layer only (the one commit on top of #4947) and found no blocking issue.

Verified

  • No reader of token_level_loss remains outside the rejection code, its tests and the golden generator.
  • All 31 YAMLs keep their reduction; the effective reduction of 466 YAMLs under examples, research and tests is unchanged between the stack base and this head.
  • Both rejection paths (the model validator and check_outdated_config) each have a test that fails when that path is removed. CPU run of the touched unit files: 768 passed, 49 skipped (47 need CUDA).

Notes, no action required in this PR

  • The branch conflicts with main; please restack after #4946 and #4947 land.
  • loss_fn is part of the rollout bootstrap fingerprint (rollout_checkpointing/manifest.py:55). Could you confirm whether a snapshot written before this rename still resumes, and add the remedy to the guide if not? I did not reproduce a failure.
  • The one-word edit in skills/pr-html-concise-public/SKILL.md is correct; a line in the description would help reviewers.

Two inline test nits follow.

Generated by Claude Code

@terrykong

Copy link
Copy Markdown
Collaborator

/resolve-conflict

svcnvidia-nemo-ci pushed a commit to u-brixton/RL that referenced this pull request Nov 20, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added CI:L2 Run doctests, unit tests, functional tests, and convergence tests and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 20, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test ab546c9

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from ab546c9 to 4c133f3 Compare November 20, 2026 18:40
@u-brixton u-brixton added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L2 Run doctests, unit tests, functional tests, and convergence tests labels Nov 20, 2026
@github-actions github-actions Bot added CI:L2 Run doctests, unit tests, functional tests, and convergence tests and removed CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Nov 20, 2026
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 4c133f3

@u-brixton

u-brixton commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

loss_fn is part of the rollout bootstrap fingerprint (rollout_checkpointing/manifest.py:55). Could you confirm whether a snapshot written before this rename still resumes, and add the remedy to the guide if not? I did not reproduce a failure.

confirmed that resuming from old snapshot will fail, added to the guide!

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from 4c133f3 to 138f037 Compare November 20, 2026 20:48
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 138f037

@u-brixton u-brixton added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L2 Run doctests, unit tests, functional tests, and convergence tests labels Nov 20, 2026
@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from 138f037 to 599b0e2 Compare November 23, 2026 19:48
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 599b0e2

@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 152d7aa

@u-brixton u-brixton left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM — no actionable findings at 152d7aa. The selector migration preserves existing loss reductions, rejects the removed key with migration guidance, and documents bootstrap recovery.

Four collaborating agents covered five specialist roles, an independent adversarial review in two passes, and an editorial pass.

Validation: 106 outdated-config tests passed with one expected skip. All 31 YAML edits preserve selector meaning, and the golden fixture's numerical values and provenance are unchanged. Pinned Ruff 0.9.9 lint, import and format checks passed, along with Python and shell syntax and diff whitespace checks.

Full numerical, GPU, distributed and functional tests were not run. Full pre-commit could not start because the installed uv cannot parse the current TOML. The Ruff fallback does not replace full type and config CI.

nemo-rl-review: kind=self harness=codex/0.169.0 model=gpt-6.1-sol effort=medium review-pr-team=v2 reviewed=152d7aa

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from 152d7aa to 0d4aebb Compare November 24, 2026 07:36
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 0d4aebb

@u-brixton
u-brixton force-pushed the remove-token-level-loss branch from 0d4aebb to 16ebdc1 Compare November 24, 2026 21:06
@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test 16ebdc1

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for finishing this removal. Old configs that still set token_level_loss now fail at startup with the exact fix to apply, which is much better than finding out in a convergence run. The leftover L1 override is fixed in 4341c72, and the snapshot note now names the removed key.

Generated by Claude Code

@terrykong
terrykong merged commit 9acde7d into NVIDIA-NeMo:main Nov 25, 2026
98 of 101 checks passed
sharonyu-115 added a commit to sharonyu-115/RL that referenced this pull request Nov 26, 2026
…arness

Main removed loss_fn.token_level_loss (NVIDIA-NeMo#5276), so ClippedPGLossConfig now
rejects it. Iterate the parity harness over normalization in
("global_token_mean", "sequence_mean"), which is what True and False
resolved to, and key the partition ids and report rows on that name.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shuang Yu <[email protected]>
sharonyu-115 added a commit to sharonyu-115/RL that referenced this pull request Nov 27, 2026
…arness

Main removed loss_fn.token_level_loss (NVIDIA-NeMo#5276), so ClippedPGLossConfig now
rejects it. Iterate the parity harness over normalization in
("global_token_mean", "sequence_mean"), which is what True and False
resolved to, and key the partition ids and report rows on that name.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shuang Yu <[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.

4 participants