Repository navigation
Description
Summary
A NeMo Gym verifier can already return decoupled reward components — the example_tool_call_multireward environment returns reward_components: {name: score} plus the summed scalar reward. But when such an environment is trained through NeMo-RL, those components are silently dropped: NeMo-RL's NeMo Gym rollout path in nemo_rl/experience/rollouts.py reads only the scalar full_result["reward"] (into total_reward) and ignores reward_components entirely. This gap should be addressed to support use of multi-objective training with NeMo Gym environments.
Why it happens: GDPO's advantage estimator consumes per-component keys (reward1, reward2, ...) from the training batch, and those keys are only produced by NeMo-RL's generic EnvironmentInterface.step() path (which returns a 2D rewards tensor). The NeMo Gym path bypasses step() entirely (NemoGym.step() is NotImplementedError), so nothing ever converts the verifier's components into reward1..K.
Current behavior (RL v0.6)
nemo_rl/experience/rollouts.py(NeMo Gym path): the final batch sets only"total_reward": torch.tensor([r["full_result"]["reward"] for r in results]). Noreward1..Kkeys are emitted.nemo_rl/environments/nemo_gym.py:NemoGym.step()raisesNotImplementedError("NeMo-Gym will handle the rollouts entirely");_postprocess_nemo_gym_to_nemo_rl_result()carries the verify result through asfull_result.nemo_rl/algorithms/advantage_estimator.py: GDPO readsreward1, reward2, ...viaget_gdpo_reward_component_keys()(requires >= 2 components).- A repo-wide search finds no code that reads a
reward_componentsfield (onlynum_reward_components, a local variable, and a comment/doc reference). - On the Gym side, the
example_tool_call_multirewardenv'sverify()returnsreward_components: {name: score}plusreward(the sum), but those components never reach training.
Proposed change
In the NeMo Gym rollout path, when full_result contains a reward_components dict ({component_name: score}):
- Map it to per-component batch keys
reward1, reward2, .... GDPO computes each component's advantage independently and then sums them (advantage_estimator.py) - Per-index consistency across samples:
reward1must denote the same component for every response, becausecalculate_baseline_and_std_per_promptbuilds a per-component baseline across all responses to a prompt. So derive the dict→reward{n}mapping deterministically (e.g. sort component names) and apply it identically to every sample, and validate that all rollouts in the batch expose the same component key set (fail fast on mismatch). - Keep
total_reward = full_result["reward"](the scalar sum) for GRPO / single-reward consumers. - When
reward_componentsis absent, behavior is unchanged (scalar-only; GRPO).
This mirrors the generic step() 2D-rewards path, but sourced from the verify-result dict instead of a tensor.
Contract notes / open questions
- Keep
reward_componentsas a dict (dict[str, float]) on the producer (NeMo Gym) side — the names are explicit and self-documenting. Converting to orderedreward{n}keys is the bridge's responsibility, not the verifier's. - The field name
reward_componentsand itsdict[str, float]shape would become the cross-repo contract between NeMo Gym verifiers and NeMo-RL GDPO. Worth documenting indocs/guides/environments.md. - Companion NeMo Gym issue proposes a shared
MultiRewardVerifyResponse(definingreward_components) once this bridge lands, to formalize the contract on the producer side.
Acceptance criteria
- A NeMo Gym env whose verifier returns
reward_componentstrains undergrpo.adv_estimator.name: gdpo, withreward1..Kpopulated from the components. - Scalar-only NeMo Gym envs are unaffected (still GRPO via
total_reward).
Activity
anjalibshah commentedon Jun 23, 2026
The RL-side wiring proposed in #2892 is already implemented in #2680 (open since Jun 3), so #2892 is effectively resolved by that PR rather than net-new work. Suggestion: link #2892 to #2680 and #2681 (Resolves #2892) and track the validation decision on the PR, to avoid implementing the bridge twice.
Mapping the proposal to what's there:
One open question worth deciding, since it's the single place the PR and the proposal differ:
These aren't equivalent — zero-filling a missing component feeds 0.0 into that component's per-prompt baseline (calculate_baseline_and_std_per_prompt), which can skew advantages, whereas fail-fast surfaces the mismatch instead. Decision needed: strict fail-fast (as #2892 proposes) or union+zero-fill (as #2680 does today)? Easy to add the validation to #2680 if we prefer strict fail fast. @terrykong @ananthsub - can you please comment on whether we should support strict fail fast or union + zero-fill?