Repository navigation
feat(gym): apply effort-level reward shaping in the SingleController - #3770
Merged
Merged
Conversation
RayenTian
force-pushed
the
ruit/v2_2770_effort_level_gym
branch
from
August 23, 2026 03:41
31960c0 to
316182c
Compare
Contributor
Author
|
/ok to test 316182c |
yuki-97
reviewed
Aug 24, 2026
…ller rollout path PR #2770 only wired length-based effort reward shaping into the run_grpo.py (v1) synchronous paths. The SingleController (v2) path runs its own NeMo-Gym rollout via RolloutManager/AsyncNemoGymRolloutImpl, which never applied it. - Thread EffortLevelsConfig through RolloutManager into AsyncNemoGymRolloutImpl and call the shared _apply_effort_shaping before completions are built, so the shaped reward flows into Completion.reward. - Fold the effort length/reward metrics into _compute_rollout_metrics. - setup.py resolves the config via the shared _get_effort_config helper. No behaviour change when env.nemo_gym.effort_levels is unset (_get_effort_config returns None -> shaping is a no-op). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
Applying effort shaping in the SingleController path broke four unit tests
in the L0_Unit_Tests_Other shard, in two independent ways:
- `_run_rollouts` reads `self._effort_config` unconditionally, but
`test_rollout_generation_failures._make_gym_impl` and the stand-in in
`test_rollouts` build the impl via `object.__new__` and never set it
-> AttributeError.
- `_compute_rollout_metrics` gained a required third positional param,
while the monkeypatched stub in `test_rollouts` still took two
-> TypeError.
Extract the shared `_effort_shaping_metrics` helper in rollouts.py and have
both the batched v1 path and the rollout manager `update` from it. The SC
metric block was a line-by-line copy of the v1 one, so this removes the
duplication and, because the caller now updates the dict itself,
`_compute_rollout_metrics` keeps its original two-argument signature -- the
TypeError disappears with no test change. The impl stand-ins get an explicit
`_effort_config = None`.
Verified the helper is equivalent to the inline blocks it replaces over 500
randomized inputs, including the empty case.
Also add the wiring coverage this path never had: the existing
test_effort_shaping cases only exercised `_apply_effort_shaping` as a pure
function. The new cases drive the real `_run_rollouts` so they pin down that
shaping happens before `_result_to_completion` -- otherwise `Completion.reward`,
which becomes `total_reward` in the train batch, keeps the env's raw reward --
plus `_get_effort_config` resolution through `setup_single_controller`.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
Co-authored-by: Yuki Huang <[email protected]> Signed-off-by: Rayen <[email protected]>
Signed-off-by: ruit <[email protected]>
RayenTian
force-pushed
the
ruit/v2_2770_effort_level_gym
branch
from
August 25, 2026 06:40
58d4e9f to
bbc8191
Compare
Contributor
Author
|
/ok to test bbc8191 |
yuki-97
approved these changes
Aug 25, 2026
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.
PR #2770 only wired length-based effort reward shaping into the run_grpo.py (v1) synchronous paths. The SingleController (v2) path runs its own NeMo-Gym rollout via RolloutManager/AsyncNemoGymRolloutImpl, which never applied it.
No behaviour change when env.nemo_gym.effort_levels is unset (_get_effort_config returns None -> shaping is a no-op).
result
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information