fix: include scalar float/int in metric aggregation#2271
Open
sebawastaken wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Open
fix: include scalar float/int in metric aggregation#2271sebawastaken wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
sebawastaken wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Conversation
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>
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.
What does this PR do ?
Fix metric aggregation to include Python
floatandintscalars, 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:
Additional Information
The
isinstanceguard added in #1773 (2311de49) changed theelsefallback to only acceptnp.ndarrayandlist, inadvertently excluding plainfloat/intscalars produced by.item()calls. This silently drops 12 metrics withSkipping aggregation for <key> (<class 'float'>):baseline_reward/pct_0,pct_1,pct_mixedadvantages/mean,min,max,sumvllm/spec_acceptance_length,spec_acceptance_rate,spec_num_accepted_tokens,spec_num_drafts,spec_num_draft_tokensAdding
float, intto theisinstancecheck restores them while still guarding against non-numeric types (dicts, strings, etc.) that motivated the original change.