Skip to content

fix: include scalar float/int in metric aggregation#2271

Open
sebawastaken wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
sebawastaken:fix/metric-aggregation-scalar-types
Open

fix: include scalar float/int in metric aggregation#2271
sebawastaken wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
sebawastaken:fix/metric-aggregation-scalar-types

Conversation

@sebawastaken
Copy link
Copy Markdown

What does this PR do ?

Fix metric aggregation to include Python float and int scalars, restoring logging for 12 silently dropped metrics.

Issues

Regression introduced in #1773 (2311de49).

Usage

No usage change — metrics that were silently skipped now appear in WandB/TensorBoard as expected.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests? — No new tests needed: 1-line type fix restoring pre-existing behavior.
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? — No documentation change needed.

Additional Information

The isinstance guard added in #1773 (2311de49) changed the else fallback to only accept np.ndarray and list, inadvertently excluding plain float/int scalars produced by .item() calls. This silently drops 12 metrics with Skipping aggregation for <key> (<class 'float'>):

  • baseline_reward/pct_0, pct_1, pct_mixed
  • advantages/mean, min, max, sum
  • vllm/spec_acceptance_length, spec_acceptance_rate, spec_num_accepted_tokens, spec_num_drafts, spec_num_draft_tokens

Adding float, int to the isinstance check restores them while still guarding against non-numeric types (dicts, strings, etc.) that motivated the original change.

The isinstance guard added in NVIDIA-NeMo#1773 (2311de4) inadvertently excludes
plain Python float and int scalars from metric aggregation, causing them
to be silently dropped with 'Skipping aggregation for <key> (<class float>)'.

Affected metrics (12 total):
  - baseline_reward/pct_0, pct_1, pct_mixed
  - advantages/mean, min, max, sum
  - vllm/spec_acceptance_length, spec_acceptance_rate,
    spec_num_accepted_tokens, spec_num_drafts, spec_num_draft_tokens

These metrics are produced by .item() calls which return Python float,
but the aggregation loop only accepted np.ndarray and list types.

Adding float and int to the isinstance check restores logging for all
scalar metrics while still guarding against non-numeric types (dicts,
strings, etc.) that motivated the original change.

Signed-off-by: sebawastaken <605763+sebawastaken@users.noreply.github.com>
@sebawastaken sebawastaken requested a review from a team as a code owner April 15, 2026 09:40
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot bot commented Apr 15, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants