Skip to content

feat: add raw_rewards_and_lengths to group-level reward profile metrics - #2771

Open
arendu wants to merge 1 commit into
mainfrom
adithyare/add-raw-rewards-and-lengths
Open

arendu wants to merge 1 commit into
mainfrom
adithyare/add-raw-rewards-and-lengths

Conversation

@arendu

@arendu arendu commented Aug 25, 2026

Copy link
Copy Markdown

What does this PR do?

Adds a raw_rewards_and_lengths field to each per-task (group-level) row in the
reward profiling output produced by RewardProfiler.profile_from_data.

The field contains one entry per rollout, sorted by rollout index, with
_ng_rollout_index, reward, and input_tokens/output_tokens/total_tokens
(token keys included only when present in the rollout's usage). It is a cheap
projection of the existing rollout_infos, so it flows through unchanged to both
the *_reward_profiling.jsonl artifact and the group-level metrics returned by
compute_aggregate_metrics.

Motivation: aggregate stats like pass rate discard the per-rollout evidence
behind them. Preserving each rollout's reward and length in the profiled output
enables downstream length-aware filtering, checking whether passing rollouts are
systematically shorter/longer than failing ones, and re-deriving pass rates
(passed = count(reward > 0), total = len(list)) without re-running rollouts.

Changes (+25 lines, no deletions):

  • nemo_gym/reward_profile.py: build raw_rewards_and_lengths from the sorted
    rollout_infos in profile_from_data (+8)
  • tests/unit_tests/test_reward_profile.py: assert the new field's exact
    per-rollout contents in test_rollout_infos_are_sorted_and_pass_rate_is_recoverable,
    and add the key to the _clean_metrics ignore set (+17)

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format/copyright pass).
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

Each per-task row in the reward profiling output now includes a
raw_rewards_and_lengths field: one entry per rollout (sorted by rollout
index) with _ng_rollout_index, reward, and input/output/total token
counts. This preserves the per-rollout evidence behind aggregate stats
like pass rate, enabling downstream length-aware filtering and
re-derivation of pass rates from profiled rollouts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: adithyare <adithya.r@gmail.com>

Copilot AI 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.

Pull request overview

This PR enhances NeMo Gym’s reward profiling outputs by preserving per-rollout evidence (reward and token lengths) alongside aggregate metrics, enabling downstream analyses (e.g., length-aware filtering and pass-rate re-derivation) without re-running rollouts.

Changes:

  • Add a raw_rewards_and_lengths field to each per-task (group-level) metrics row produced by RewardProfiler.profile_from_data, derived from the already-sorted rollout_infos.
  • Update unit tests to (1) assert the exact contents of the new field in the “sorted rollout infos” test and (2) ignore the new key in _clean_metrics where appropriate.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
nemo_gym/reward_profile.py Adds raw_rewards_and_lengths as a lightweight projection of sorted rollout_infos into group-level metrics rows.
tests/unit_tests/test_reward_profile.py Updates metrics-cleaning to ignore the new key and adds a precise assertion for raw_rewards_and_lengths contents/order.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cmunley1

cmunley1 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Doesnt the output already contain the fields in raw_rewards_and_lengths, for example from https://github.com/NVIDIA-NeMo/Gym/blob/main/resources_servers/longmt_eval/data/example_rollouts_reward_profiling.jsonl#L1C1-L2C1

    {
      "rollout_id": "28:0",
      "_ng_task_index": 28,
      "_ng_rollout_index": 0,
      "reward": 0.7699517591132058,
      "input_tokens": 3690,
      "output_tokens": 4182,
      "total_tokens": 7872,
      "comet_qe": 0.7699517591132058,
      "lang_fidelity": 1.0,
      "total_seg": 108,
      "misaligned_seg": 1
    }

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Aug 26, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work waiting-on-customer Waiting on the original author to respond labels Oct 20, 2026

This branch was previously deployed

1 inactive deployment
public — 6c6fae07 Deployed Aug 25, 2026 by copy-pr-bot[bot] via release / finalize / notify #1826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work sla:review-overdue Review response is over the one-business-day SLA waiting-on-customer Waiting on the original author to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants