Repository navigation
fix: honor NeMo Gym's mask_sample in the Gym rollout path - #3201
linj-glitch wants to merge 1 commit into
Conversation
Gym agent servers set mask_sample on the verify response when a rollout's reward is unreliable (agent/eval timeout, OOM-killed container, failed trace capture), documented as 'downstream RL drops the gradient for this rollout' — but nothing consumed it, so masked rollouts trained on garbage rewards (worst case: reward=1.0 accidental resolves reinforced as positives). - run_async_nemo_gym_rollout zeroes the sample's loss multiplier when full_result carries mask_sample, mirroring truncated-sample handling - the converter emits a prompt-only message log for masked rollouts with no token-annotated generations (e.g. failed trace capture) instead of raising and failing the whole step; unmasked empty rollouts still raise Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
|
@ananthsub @bxyu-nvidia to review |
|
@linj-glitch Gym's I would suggest adding a config setting that let's users decide whether to honor |
Gym flags rollouts that hit max iterations even when they solve the task, and those are samples worth training on (see NVIDIA-NeMo#3201 discussion). Signed-off-by: Michal Futrega <[email protected]>
|
Closing the loop on this one. The problem is real, but this implementation is obsolete:
Closing this draft in favour of #4435 and #4494 (the ported converter tests are already on the #4494 branch). Thanks @jepio for the config-gate feedback; |
What does this PR do ?
Honors NeMo Gym's
mask_samplesignal in the Gym rollout path so rollouts with unreliable rewards are excluded from the gradient instead of trained on (or crashing the step).Gym agent servers (e.g.
swe_agents,anyterminal_agent) setmask_sample: trueon the verify response when a rollout's reward is unreliable — agent/eval timeout, OOM-killed container, failed token-trace capture — and document the contract as "downstream RL drops the gradient for this rollout." Nothing in NeMo RL consumed it, so today:reward=1.0accidental resolves (patch passed but the agent died on max-iteration/context-window) reinforced as positives;ValueErrorin_postprocess_nemo_gym_to_nemo_rl_resultand fails the whole rollout batch.Changes (both mirror existing conventions):
run_async_nemo_gym_rolloutzeroes the sample'sloss_multiplierwhenfull_result["mask_sample"]is truthy — the same mechanism used for truncated samples (loss_multiplier[truncated] = 0).ValueError.Producer side: NeMo Gym promotes
mask_sampleto a top-levelBaseVerifyResponsefield (NVIDIA-NeMo/Gym#2026), so it also lands in the per-agent auto-aggregated metrics (rollouts.pyscalar aggregation) — masked-sample rates become visible in training metrics for free.Issues
None filed; found while validating the Gym↔Switchyard token-capture integration end-to-end (NVIDIA-NeMo/Gym#2026).
Usage
No API change. Any Gym rollout whose verify response carries
mask_sample: trueis now excluded from the gradient:Before your PR is "Ready for review"
Pre checks:
test_nemo_gym_postprocess_masked_rollout_without_generations,test_nemo_gym_postprocess_unmasked_rollout_without_generations_raises)[email protected] check/formatclean)Additional Information
The end-to-end verification that surfaced this: Switchyard token capture → Gym rollout reconstruction → this converter → GRPO tensors, with the masked-sample and non-contiguous-token failure modes reproduced against real code.
🤖 Generated with Claude Code