Repository navigation
fix(gym): per-agent_ref truncation/token metrics (#3970, #4030) - #4379
Merged
Merged
Conversation
Port of 72fc46b (per-agent-ref truncation rate) and 95d3cc3 (per-agent_ref {total,gen}_tokens_per_sample) onto this branch. Adds {agent}/truncation_rate, {agent}/total_tokens_per_sample/* and {agent}/gen_tokens_per_sample/* in both the batched NeMo-Gym postprocess path (rollouts.py) and AsyncNemoGymRolloutImpl._compute_rollout_metrics. Live token metrics are emitted after full-result metrics so similarly named env metadata cannot overwrite them. In receipt mode the per-agent token metrics use the manifest-derived counts; a test covers this. Signed-off-by: Peter Jin <[email protected]>
yfw
approved these changes
Oct 5, 2026
Contributor
|
/ok to test b28cc80 |
Contributor
|
/ok to test 6833b58 |
yfw
enabled auto-merge (squash)
October 8, 2026 02:40
linj-glitch
added a commit
to linj-glitch/RL
that referenced
this pull request
Oct 13, 2026
Reconciles the straggler cutoff with what main gained on the NeMo-Gym rollout path since the branch was cut: reward penalties and effort shaping (NVIDIA-NeMo#4099), per-prompt-group length penalties (NVIDIA-NeMo#4553) and per-agent token metrics (NVIDIA-NeMo#4379). - A cut placeholder is not a model output. _postprocess_single_nemo_gym_group now runs effort shaping and the reward-penalty checks over the scored rows only, and reports the penalty rates over that population, so an empty placeholder response is not counted as an "empty final answer". Cut rows also stay out of main's new per-agent token/truncation metrics, alongside the existing exclusion from the per-agent full_result means. Length penalties need no change: they only adjust rows with a positive reward. - Token-capture (receipt) mode is unsupported: a cancelled rollout has no receipt for the finalizer to rebuild. The actor now logs once and runs the batch uncut, the same fallback as a Gym without aclose(); the warning text names the reason. Tests: receipt-mode fallback; penalty rate and rewards with a cut row under penalize_empty_final_answer; per-agent gen-token mean excludes the cut row. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
pjin-nvidia
added a commit
that referenced
this pull request
Oct 14, 2026
Signed-off-by: Peter Jin <[email protected]> Co-authored-by: Yi-Fu Wu <[email protected]> (cherry picked from commit 26e0b07) Signed-off-by: Peter Jin <[email protected]>
pjin-nvidia
added a commit
that referenced
this pull request
Oct 14, 2026
With token capture the controller logged no rollout metrics:
total_reward, turns_per_sample, {total,gen}_tokens_per_sample,
max_gen_tokens_per_turn, truncation_rate, natural_termination_rate,
the per-agent metrics and timing/rollout/* were all missing (a 40-node
MOPD run logged 134 non-Ray scalars per step, against 3688 for the
same configuration without capture). The capture dispatch dropped the
PromptGroupRecord that run_rollout returns, and the finalizer
published its KVBatchMeta without extra_info[ROLLOUT_METRICS], the
only place the train pump reads rollout metrics from. The dropped
receipt-mode values were also wrong: a root call's delta_len includes
its prompt, so sum(delta_len) measured the whole row rather than the
generated tokens, and receipts were never marked truncated.
The finalizer now measures each group's canonical rows and publishes
the metrics with them, under the token path's names and per-sample
definitions: rewards over every rollout; turns (model calls on the
trained chain), total and generated tokens, the longest call's
generation and truncation (row length == max_seq_len, the rule
behind the published truncated column) over the rows that verified;
and the per-agent token and truncation metrics of #4379 under the
resolved agent name. The dispatcher's own metrics (agent results,
rollout timing) ride the ReassemblyRequest, filtered to numbers and
number lists for the metadata-only RPC, and are published beneath
the measured ones. The receipt branch of _compute_rollout_metrics no
longer emits its manifest proxies.
The teacher enricher and the sampler already carry extra_info through
to aggregate_rollout_metrics; a finalizer lifecycle test now pins the
enricher side. A resumed group whose siblings were all sealed before
the restart regenerates nothing and carries no dispatcher metrics;
the finalizer still measures its rows.
Signed-off-by: Peter Jin <[email protected]>
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.
Port of 72fc46b (per-agent-ref truncation rate) and 95d3cc3 (per-agent_ref {total,gen}_tokens_per_sample) onto this branch.
Adds {agent}/truncation_rate, {agent}/total_tokens_per_sample/* and {agent}/gen_tokens_per_sample/* in both the batched NeMo-Gym postprocess path (rollouts.py) and AsyncNemoGymRolloutImpl._compute_rollout_metrics. Live token metrics are emitted after full-result metrics so similarly named env metadata cannot overwrite them. In receipt mode the per-agent token metrics use the manifest-derived counts; a test covers this.