RL icon indicating copy to clipboard operation
RL copied to clipboard

Nemotron-3-Nano-30B-A3B: train/generation logprob divergence persists on vLLM 0.20

Open nvegesna-netizen opened this issue 2 months ago • 0 comments

Summary

The Nemotron-3-Nano guide states that the vLLM↔Megatron logprob divergence affecting "certain sequences" is fixed in vLLM 0.17.0 (note added in #2128).

We observe a severe generation-versus-Megatron-recompute divergence on NeMo-RL v0.7.0 with nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-Base-BF16. Our evidence establishes a divergence on vLLM 0.20; it does not establish that this is the same root cause as the pre-0.17 bug. The mismatch persists with CUDA graphs disabled and with BF16/no quantization, and forcing the Triton MoE backend did not repair it. seq_logprob_error_threshold contains the retained-sample numerics, but masks approximately 60–71% of pre-threshold eligible sequences (approximately 50–58% of the configured 512 samples, median by arm).

Primary question: is the 0.17.0 fix complete for this model/configuration, and is seq_logprob_error_threshold still required on vLLM 0.20?

Environment

Model nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-Base-BF16 @ e0ac9ee3dfd02be21b5479edfc2f671ed269d0a2
Tokenizer nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16
NeMo-RL v0.7.0, commit 19244a0949fb363326f71675223da75e09d14866 (uses vLLM 0.20.0)
Recipe base examples/modelopt/qa_grpo_nano3_megatron.yaml, with the overrides below
Precision BF16, quant_cfg: null (policy and generation; the recipe's default NVFP4 configuration was overridden)
Hardware H100 80GB, 4–6 nodes × 8 GPU
Generation vLLM TP4 / EP4, enforce_eager: true, mamba_ssm_cache_dtype: float32, non-colocated, refit_backend: nvshmem
Training Megatron TP2 / EP8 / PP1 (32 GPU); also TP2 / EP4 / PP3 (24 GPU)
Already set moe_router_dtype: fp64, bias_activation_fusion: false, moe_router_load_balancing_type: none
Not set seq_logprob_error_threshold: null, use_importance_sampling_correction: false
Filtering overlong_filtering: true, dynamic sampling disabled
Algorithm synchronous GRPO, 26 updates, OpenMathInstruct-2, no validation, no checkpointing

Observed

Median over updates 5–25, TP2/EP8, representative run:

metric median max
train/token_mult_prob_error 15,410 2.14e10
train/policy_kl_error 15,409 2.14e10
train/gen_kl_error 0.0166 0.0327
train/mean_seq_mult_prob_error 14,296 7.91e10
train/min_seq_mult_prob_error 1.0048 1.0131
train/num_masked_seqs_by_logprob_error 0 0

Two structural notes:

  1. The severe exponential tail is predominantly in the prev - gen < 0 direction. In the pinned loss_functions.py:340-378, for d = prev_logprobs - generation_logprobs, TMPE is exp(abs(d)), generation KL is exp(d) - 1 - d, and policy KL is exp(-d) - 1 + d. TMPE closely tracks policy KL while generation KL remains much smaller. This supports a negative extreme tail, where vLLM assigns higher probability than the Megatron recompute. It does not imply that every token has d << 0. Generation KL is also not blind to this direction, but it grows only approximately linearly there while TMPE and policy KL grow exponentially, making a generation-KL-only check much less sensitive.
  2. The error is sparse at token level but reaches many sequences. In the matched EP8 diagnostic, approximately 1.29–1.41% of valid tokens exceeded 2× probability error and 0.343–0.371% exceeded 10×. Because sequences contain many tokens, this sparse tail affects a large fraction of otherwise-valid sequences.

Breadth: the collected corpus contains 128 heterogeneous configuration runs across four seeds, including two GPU topologies, three workload sizes, and multiple clock policies. All 72 EP8 runs have median TMPE >= 893 (largest median 1.59e6). Median severity increases monotonically across the small/medium/large workload cells: 3.9e3 / 2.0e4 / 7.3e4. These are not 128 repetitions of one identical configuration.

Loss exposure

With importance-sampling correction disabled, the generation-versus-recompute ratio is not applied as an explicit actor-loss importance weight. However, probs_ratio measures the current-policy/previous-training-policy PPO ratio; it is not a generation-versus-training refit check. Likewise, a mean sampling_importance_ratio near one can coexist with the measured sparse extreme tail. These metrics therefore do not prove that weight refit is correct or that the generation/recompute disagreement cannot affect learning through the sampled trajectories, rewards, and advantages.

Tested diagnostics

The backend comparison was a matched single-variable experiment. The remaining rows describe conditions directly observed in the broader run corpus.

Hypothesis Test Result
vLLM CUDA-graph staleness on MoE refit enforce_eager: true Graphs confirmed off in engine logs (CUDAGraphMode.NONE, "Cudagraph is disabled under eager mode"). Divergence persists, so CUDA-graph staleness is not required for the failure.
MoE kernel backend moe_backend: auto (resolves to FlashInfer CUTLASS Unquantized) vs forced Triton, at EP4 Auto/FlashInfer was invalid at update 6. Triton was invalid at updates 3 and 5 (first at update 3). Forcing Triton did not repair the mismatch; the experiment does not establish that backend has no effect on magnitude or onset.
Quantization quant_cfg: null throughout The mismatch occurs in BF16/no-quantization runs.
Router precision moe_router_dtype: fp64 FP64 router computation did not restore validity.
GPU clock configuration multiple settings including governor/default No tested clock setting restored numerical validity; this does not establish that clock has no effect on magnitude.

Training expert-parallel degree is strongly implicated

Matched single-knob comparison, one seed and one allocation per arm, eight updates. Generation was held at vLLM EP4 in both arms. Ordered prompt hashes and prompt-token counts matched at every update; exact generated-response identity was not recorded as a matching condition.

Training EP median tmpe median policy_kl behaviour
EP8 6,421.43 6,420.34 invalid on all 8 updates
EP4 1.1768 0.1388 valid updates 1–5; invalid 6–8 (13.14, 3.15, 450.07)

The observed median difference is approximately 5,500× and strongly implicates training EP in the magnitude and onset of the mismatch under this matched setup. The one-seed comparison does not by itself establish a general causal effect, and EP4 delays onset rather than removing the divergence.

Token-level structure. At EP8, approximately 1.29–1.41% of valid tokens exceed 2× probability error, and the recorded extreme tail is dominated by token IDs 1436 and 3944. EP4 reduces this to 0.053–0.103% through update 7, rising to 0.565% at update 8 with a different token pattern.

seq_logprob_error_threshold contains it, at high cost

2×2 over threshold and IS correction, eight updates and one seed. Values are medians over updates unless otherwise stated:

Threshold IS post-mask tmpe post-mask policy_kl masked / pre-threshold eligible seqs final valid-token yield
2.0 No 1.2339 0.1642 59.9% 14.5%
2.0 Yes 1.2375 0.1670 61.9% 14.8%
1.2 No 1.0971 0.03261 69.4% 9.2%
1.2 Yes 1.1052 0.03828 71.4% 8.5%

The configured batch contains 512 generated sequences. Existing validity filters leave roughly 410–451 sequences eligible before applying the logprob threshold. As a fraction of all 512 configured samples, the median threshold-masked fractions are 49.9%, 53.0%, 57.4%, and 58.4% for the four rows above. Across arms and updates, 46.3–62.7% of all configured samples were masked by the threshold.

final valid-token yield is the median per-update ratio of final valid training response tokens to all generated response tokens. It includes the effect of pre-existing validity filters as well as the logprob threshold, so the approximately 85–91% final token exclusion cannot be attributed to the logprob threshold alone.

Retained-sample numerics are flat across all eight updates at threshold 1.2 (TMPE 1.094–1.104), with no late-onset growth. IS correction gave no measurable numerical improvement at either threshold in this eight-update, one-seed diagnostic. Neither threshold repairs the pre-mask generation/recompute mismatch; both act as loss guards by removing affected sequences.

Router Replay produced a promising but confounded clean trace

A colocated run with router_replay.enabled: true, EP8, and enforce_eager: false (CUDA graphs on) recorded:

  • token_mult_prob_error 1.0252–1.0294, flat across seven updates
  • policy_kl_error approximately 0.001
  • max_seq_mult_prob_error 1.05–1.09

That run terminated on an apparently unrelated vLLM indexing error and is not a complete result:

IndexError: index 1929600 is out of bounds for axis 0 with size 1928448
  in VllmGenerationWorker.generate()

This trace is consistent with a routing-related explanation and motivates a matched Router Replay test. It does not establish routing as the cause because it was colocated, used CUDA graphs, and did not finish; it also does not establish that Router Replay works for our non-colocated setup.

Questions

  1. Is the vLLM 0.17.0 fix referenced in #2128 complete for this model/configuration? We observe a severe generation/recompute mismatch on 0.20, but have not established that it is the same bug.
  2. Is seq_logprob_error_threshold still required for this model on 0.20? If so, the "fixed in 0.17.0" framing in the guide may need qualification.
  3. Is masking approximately 60–71% of pre-threshold eligible sequences expected for this model? If not, what would you expect, and what might that imply about our configuration?
  4. Is examples/modelopt/qa_grpo_nano3_megatron.yaml intended as the base for BF16 GRPO after overriding its default NVFP4 quant_cfg values to null? It is the only in-repo recipe pinning this exact model and tokenizer, but it inherits seq_logprob_error_threshold: null, whereas examples/nemo_gym/grpo_nanov3.yaml sets the threshold to 2.
  5. Is training EP != generation EP a supported configuration? grpo_nanov3.yaml uses generation expert_parallel_size: 1; we use 4. The matched EP result suggests that expert sharding across the refit boundary is relevant.
  6. Is Router Replay usable with non-colocated generation? It produced the only healthy numerical trace we observed, but that run was colocated and incomplete.

Happy to provide per-update metric series and full resolved configs.

nvegesna-netizen avatar Sep 22 '26 16:09 nvegesna-netizen