Repository navigation
Conversation
…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
force-pushed
the
joyang/logprob-error-tail-metrics
branch
from
October 7, 2026 17:31
260139b to
538a4a4
Compare
This was referenced Oct 8, 2026
This branch has not been deployed
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?
Fixes the randomly failing
dapo-nanov3.5-30BA3B-4n8g-automodelnightly 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_erroris 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 checktoken_mult_prob_error["20"] < 1.04failed at random.Changes
feat(grpo): new driver-side metrics over the same tokens astoken_mult_prob_error(token_mask * sample_mask), logged bygrpo_train,async_grpo_trainandgrpo_train_sync. They are not logged whenforce_on_policy_ratioskips theprev_logprobspass.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-automodelnow runs 10 steps in 120 min (was 20 steps in 240 min) and gates on:token_mult_prob_error_p999< 1.55;gen_kl_error< 0.001;The median
token_mult_prob_errorcheck is dropped: with ~20% of steps spiking it would fail about 2% of 10-step runs.fix(logger): thetoken_mult_prob_errorplot no longer picks a filtered-out sample, whose error is 0/0 = NaN, as the "worst" sample.Results (no router replay)
token_mult_prob_error_p999per stepgen_kl_errortoken_mult_prob_errorThe 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_trainlogs the exact values;grpo_train,async_grpo_trainandgrpo_train_syncdon't log them whenprev_logprobsis skipped;grpo_train_synclogs them otherwise.tests/unit/utils/test_logger.py: a NaN sample isn't plotted, and the plot is skipped when no sample has tokens.test_grpo_router_replay_async.pyandtest_recipes_and_test_suites.py.Related
Convergence for this model is gated by the 20-step
dapo-nanov3.5-30BA3B-4n8g-automodel-r3test, 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