Skip to content

fix: Qwen3.5-397B training stability and async-GRPO robustness - #3382

Open
michal2409 wants to merge 3 commits into
NVIDIA-NeMo:mainfrom
michal2409:mlperf-training-qwen35-main-v2
Open

fix: Qwen3.5-397B training stability and async-GRPO robustness#3382
michal2409 wants to merge 3 commits into
NVIDIA-NeMo:mainfrom
michal2409:mlperf-training-qwen35-main-v2

Conversation

@michal2409

@michal2409 michal2409 commented Jul 28, 2026

Copy link
Copy Markdown

What does this PR do?

Core-algorithm remainder of the Qwen3.5-397B reference training bring-up, targeting main. Per review feedback the independent pieces were split into their own PRs and removed from this branch; what stays here are the changes that touch the core async-GRPO path. Same lineage as #3364 (which targets opt/dev per the agreed workflow).

Included commits:

  • feat(megatron): make DDP check_for_nan_in_grad configurable — plumbed through distributed_data_parallel_config (absent keeps the always-on default).
  • fix(vllm): async-server robustness for multi-turn agentic rollouts — normalize non-list/str message content before template rendering, and rebuild the isolated prefix render from vLLM's normalized message representation (Qwen3.5 re-renders assistant history with normalized reasoning content, so the raw deepcopy diverged token-wise). Includes replace_prefix_tokens unit tests.
  • feat(grpo): async-GRPO robustness for long-horizon SWE rollouts — start trajectory collection only after the initial refit; drain in-flight rollouts before in-loop validation; close pause races at validation boundaries; optional env.nemo_gym.backfill_failed_rollouts; refit-safe prefix caching (invalidate vLLM prefix cache on every refit path); positional advantage grouping for NeMo-Gym rollouts (_stable_group_ids); replay buffer consumes trajectories staged for future steps instead of stalling; opt-in NRL_LP_MASK_DEBUG diagnostics.

Split out per review (separate PRs, removed from this branch):

Also removed from this branch:

Diff is now 11 files, +843/−116 (was 17 files, +1542/−204).

Convergence data

The commits here are a subset of the branch validated end-to-end on the benchmark (results below from that full stack; the removed pieces are config-gated features that were active in the run via their split-PR equivalents).

Setup
64×GB300 (4 GPUs/node): 16 training nodes (Megatron TP4·PP2·EP32, sequence
packing @ 65 536 tokens, bf16) + 48 generation nodes (24 vLLM engines, TP8/EP8, async
engine). GBS 256 = 16 prompts × 16 generations/step, async GRPO lag-1, NeMo-Gym
OpenHands agents on R2E-Gym easy (curriculum-v2 train set), validation = 256 instances
× 4 generations @ temp 0.1 / top-p 0.95, seed 3978.

Training reward (fraction of 256 rollouts solved, per step):

step 1 2 3 4 5 6 7 8 9 10
reward .406 .441 .406 .434 .520 .387 .410 .457 .629 .598
step 11 12 13 14 15 16 17 18 19 → eval@20
reward .602 .461 .617 .586 .637 .613 .648 .574 .605 0.789

@michal2409
michal2409 requested review from a team as code owners July 28, 2026 08:09
@michal2409
michal2409 requested a review from terrykong July 28, 2026 08:09
@michal2409
michal2409 requested a review from a team as a code owner July 28, 2026 08:09
@michal2409
michal2409 requested a review from yuki-97 July 28, 2026 08:09
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 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.

michal2409 and others added 3 commits July 29, 2026 06:32
Plumb check_for_nan_in_grad through
megatron_cfg.distributed_data_parallel_config (NotRequired; absent keeps
the always-on default). Long large-scale MoE runs disable the per-step
NaN grad check to trade it for throughput.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Michal Futrega <mfutrega@nvidia.com>
- normalize non-list/str message content before template rendering
  (500s on every chat/tokenize request otherwise)
- rebuild the isolated prefix render from vLLM's normalized message
  representation, dropping NeMo-RL token-bookkeeping fields
  (prompt_token_ids/generation_token_ids/generation_log_probs): Qwen3.5
  re-renders assistant history with normalized reasoning content, so the
  raw deepcopy diverged token-wise from what the model produced
- replace_prefix_tokens unit tests for the EOS-splice edge cases

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Michal Futrega <mfutrega@nvidia.com>
- start trajectory collection only after the initial weight refit
  (engines with load_format=dummy produced random-weight rollouts)
- drain in-flight rollouts before async in-loop validation
- close pause races that launched train batches into validation windows
- optional env.nemo_gym.backfill_failed_rollouts: back-fill failed/NaN/
  empty rollouts as zero-reward trajectories instead of aborting the
  batch (absent/false keeps the fail-fast default; long multi-node
  benchmark runs enable it)
- invalidate the vLLM prefix cache on every refit path so prefix caching
  is refit-safe (stale KV blocks are keyed only by token ids)
- positional advantage grouping for NeMo-Gym rollouts (_stable_group_ids):
  per-generation first-turn prompts tokenize non-deterministically, so
  token-id grouping degenerates into singleton groups with zero advantage
- replay buffer: consume trajectories staged for a future step instead of
  stalling (target_weight_version >= current)
- opt-in per-sequence logprob-mask debug line (NRL_LP_MASK_DEBUG=1)

Co-authored-by: Al Rigazzi <arigazzi@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Michal Futrega <mfutrega@nvidia.com>
@michal2409
michal2409 force-pushed the mlperf-training-qwen35-main-v2 branch from f82b9ba to 83c082a Compare July 29, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant