Skip to content

fix: gate dapo-nanov3.5 automodel nightly on token logprob-error tail metrics - #4459

Open
joyang-nv wants to merge 4 commits into
mainfrom
joyang/logprob-error-tail-metrics
Open

joyang-nv wants to merge 4 commits into
mainfrom
joyang/logprob-error-tail-metrics

Conversation

@joyang-nv

@joyang-nv joyang-nv commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes the randomly failing dapo-nanov3.5-30BA3B-4n8g-automodel nightly by adding two token-level logprob-error metrics and gating the test on them.

Why

Without router replay, MoE top-k flips between vLLM and training leave 0-2 tokens per step whose logprobs differ by tens of nats. token_mult_prob_error is a mean of exp(|error|) over tokens, so a single 30-nat token (exp(30) ≈ 1e13) dominates the whole step: about 20% of steps spike to 1e6-2e7, and the single-step check token_mult_prob_error["20"] < 1.04 failed at random.

Changes

  • feat(grpo): new driver-side metrics over the same tokens as token_mult_prob_error (token_mask * sample_mask), logged by grpo_train, async_grpo_train and grpo_train_sync. They are not logged when force_on_policy_ratio skips the prev_logprobs pass.

    • token_mult_prob_error_p999: the 99.9th percentile (nearest rank) of exp(|error|). It ignores the worst 0.1% of tokens and tracks the bulk mismatch. Errors beyond float range give inf rather than raising.
    • num_tokens_logprob_error_above_10_nats: the rare spike tokens that dominate the mean.
  • fix(nightly): dapo-nanov3.5-30BA3B-4n8g-automodel now runs 10 steps in 120 min (was 20 steps in 240 min) and gates on:

    • max per-step token_mult_prob_error_p999 < 1.55;
    • at most 3 tokens per step above 10 nats;
    • mean gen_kl_error < 0.001;
    • validation accuracy at step 10 > 0.25, a floor that catches a broken run. Steps 1-10 are LR warmup.

    The median token_mult_prob_error check is dropped: with ~20% of steps spiking it would fail about 2% of 10-step runs.

  • fix(logger): the token_mult_prob_error plot no longer picks a filtered-out sample, whose error is 0/0 = NaN, as the "worst" sample.

Results (no router replay)

2 runs × 20 steps 1 run × 10 steps (this config)
token_mult_prob_error_p999 per step 1.407-1.501 (steps 1-10: 1.407-1.431) 1.409-1.435
Tokens per step above 10 nats 0-2 (all spikes 10.8-31 nats; every other token < 9) 0-1
Mean gen_kl_error 0.00082 over steps 1-10 0.00083
Validation accuracy at step 10 0.344-0.348 0.352
Mean token_mult_prob_error spikes up to 1.7e7 step 10 at 2.1e7 from a single 30.9-nat token

The 10-step run passed the new checks and finished in 83 min of its 120 min limit. With automodel router replay (#4458), p999 is 1.23-1.24 and no token exceeds 10 nats.

Net nightly change: −64 GPU hours.

Testing

  • tests/unit/algorithms/test_utils.py: the percentile ignores rare spikes and masked tokens, the spike count is correct, and float overflow gives inf.
  • tests/unit/algorithms/test_grpo.py:
    • grpo_train logs the exact values;
    • grpo_train, async_grpo_train and grpo_train_sync don't log them when prev_logprobs is skipped;
    • grpo_train_sync logs them otherwise.
  • tests/unit/utils/test_logger.py: a NaN sample isn't plotted, and the plot is skipped when no sample has tokens.
  • Results: 367 tests pass across those files plus test_grpo_router_replay_async.py and test_recipes_and_test_suites.py.

Related

Convergence for this model is gated by the 20-step dapo-nanov3.5-30BA3B-4n8g-automodel-r3 test, which comes in the companion automodel router replay PR #4458. The two PRs touch no common files and can merge in either order.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 3, 2026
@joyang-nv joyang-nv added the CI:L0 Run doctests and unit tests label Oct 3, 2026
joyang-nv and others added 4 commits October 8, 2026 01:05
…plot

log_plot_token_mult_prob_error ranked samples by sum(exp(diff)*mask) /
mask.sum(); samples without loss tokens (e.g. filtered by dynamic sampling)
give 0/0 = NaN and torch.argmax returns the NaN, so the logged plot showed
an excluded sample with tiny errors and "token_mult_prob_error=nan" instead
of the sample that caused the spike. Rank such samples last and skip the
plot when no sample has loss tokens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
token_mult_prob_error is a mean of exp(|logprob error|) over tokens, so a
single token tens of nats off (e.g. an MoE top-k routing flip between vLLM
and training; exp(30) ~ 1e13) dominates the whole step. From the driver,
where the full batch is available, log over the same tokens
(token_mask * sample_mask):

- token_mult_prob_error_p999: the 99.9th percentile of exp(|error|); it
  ignores the worst 0.1% of tokens and tracks the bulk mismatch. Errors
  beyond float range (e.g. a -9999 logprob floor) give inf, not an error.
- num_tokens_logprob_error_above_10_nats: the rare spike tokens that the
  percentile ignores and that dominate the mean.

grpo_train, async_grpo_train and grpo_train_sync log them, except when
force_on_policy_ratio skips the prev_logprobs pass (tested for all three).

On dapo-nanov3.5-30BA3B-4n8g-automodel (no router replay), p999 is
1.41-1.50 per step and 0-2 tokens per step exceed 10 nats (all at 10.8-31
nats; every other token stays below 9), while the mean spikes up to 2e7.
With automodel router replay, p999 is 1.23-1.24 and no token exceeds 10
nats.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
…or tails

Without router replay, MoE top-k flips between vLLM and training leave 0-2
tokens per step tens of nats off, so the token_mult_prob_error mean spikes
on ~20% of steps (up to 2e7) and the single-step check at step 20 failed at
random.

Gate on the per-step token_mult_prob_error_p999 < 1.55 instead (1.41-1.44
over steps 1-10 of 3 runs) and allow at most 3 tokens per step above 10
nats (0-2 seen). Drop the median token_mult_prob_error check: with ~20%
spiky steps it would fail ~2% of 10-step runs. Shorten the run to 10 steps
/ 120 min, since the new metrics are stable per step. Those steps are LR
warmup, so accuracy only gets a floor (> 0.25 at step 10; 0.344-0.352
seen) that catches a broken run; convergence with router replay is gated
by the 20-step dapo-nanov3.5-30BA3B-4n8g-automodel-r3 test.

A 10-step run passed in 83 min although its last step's mean was 2e7 from
a single 31-nat token. Saves 64 nightly GPU hours.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
main moved Logger to a pydantic LoggerConfig, so the dict config from the
original test no longer has a log_dir attribute.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Jonas Yang <[email protected]>
@joyang-nv
joyang-nv force-pushed the joyang/logprob-error-tail-metrics branch from 260139b to 538a4a4 Compare October 7, 2026 17:31
@terrykong terrykong added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L0 Run doctests and unit tests labels Nov 5, 2026
@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 2026

This branch has not been deployed

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

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants