Repository navigation
perf(grpo): tune Qwen3-30B sync and async BF16 recipes - #5007
Conversation
Signed-off-by: Youngeun Kwon <[email protected]>
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test dd32c31 |
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 993d29c |
youngeunkwon0405
left a comment
There was a problem hiding this comment.
Agent-team review of head dd32c31 (rl-expert, bug-finder, test-agent, expert-megatron-lm, devil's advocate). Summary: the backward rewrite is correct and the recipe's Megatron/vLLM settings are valid on the pinned stack; the one ask (inline) is the GPU evidence the description already lists as pending.
Verified
ChunkedDistributedLogprob.backwardis equivalent to the previous implementation and toDistributedLogprob.backward: CPU TP=1 (12/12) and a CPU TP=2 emulation with true cross-rank MAX/SUM reductions, including rows whose target lives on the other rank (bf16 gradients bit-identical to the old backward on both ranks; fp32 within 2.4e-7 of full-vocab autograd). The newexp(x-max)/sumnormalizer is slightly closer to fp64 than the oldexp(x-max-log sum). Per-chunk transient memory at B=1, C=1024, V=151,936 drops from ~3.5 GiB to ~0.6 GiB; thezeros_likegradient buffer (~4.6 GiB in bf16) is unchanged.- Mutation testing of the new test: sign, grad weighting, scatter semantics, max-shift (caught by the
logit_scale=40cases) and saved-input aliasing (copy=Falsetrips autograd's version counter at the repeated backward) are all caught. The three TP>1-only behaviours (masked scatter source, the two all-reduces) are unobservable at TP=1 but are exercised on GPU bytest_distributed_logprob.py(tp=2, chunk=4) andtest_get_next_token_logprobs_chunk_equivalencein the Lfast Distributed shard, which is green on this head. - Recipe:
recompute_granularity: selective+recompute_modules: [moe_act]is validated by MCore at startup (validate_megatron_config→ConfigContainer.validate()→ Bridgemodel.finalize()→MCoreTransformerConfig.__post_init__, wheremoe_actrequiresmoe_grouped_gemm, which the parent recipe sets).defer_fp32_logits+logprob_chunk_sizesatisfy the setup guard;check_nccl_reshard_refit_supportpasses on the resolved config; the BF16 TRT-LLMnccl_reshardplacement check resolveslinearby vLLM 0.29.0 default at EP=1; bothNRL_REFIT_BUFFER_MEMORY_RATIOplacements are read (the misc producer and consumer size their buffers independently from their own env) and agree.
Notes (no action needed)
logprob_batch_size: 2(L15) andPYTORCH_CUDA_ALLOC_CONF(L29) are already inherited fromgrpo-qwen3-30ba3b-4n4g.yaml(L14, L38), sotools/config_cli.py minimizestrips exactly these two of the added lines;performance/is outside the pre-commit glob, so nothing fails. Keep for explicitness or drop; the description's "use the validated fixed CUDA allocator" reads as a change but was already in effect.- The sibling async recipes (nemotron3-super 32n4g, deepseek-v3 fp8) pin
NRL_REFIT_NUM_BUFFERS: "1"next to the 0.005 ratio; this recipe keeps the default 2 (two ~0.93 GiB staging buffers per side). Fine if intentional. - Test L17 and L33-37 patch
torch.distributed.nn.functional.all_reduce, which nothing on the chunked forward/backward path calls any more. Harmless dead code. - CI: the three red checks on this head look unrelated to the PR.
fast_L1_Functional_Tests_SingleController_2died inMegatronPolicyWorker.__init__withEADDRINUSEon port 1588 before any training ran;sphinx-buildfailed linkcheck on an opentelemetry.io URL;CI quality checkonly aggregates. Worth a re-trigger. - Follow-ups outside this diff: the comment at
setup.pyL1924-L1928 ("validation doesn't re-run after attribute assignment") is stale given thefinalize()chain above (#2291 may be closable); the exemplar comments atgrpo_math_1B.yamlL261 andpolicy/__init__.pyL435 describe["moe"]as "expert activations only", but MCore'smoereplays the whole MoE layer whilemoe_actis the narrow boundary this recipe uses; the Ray-actor test intest_model_utils.pyL1009-L1016 never runs the chunked backward.
Generated by Claude Code
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 2f9d043 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
LGTM — no actionable findings from static inspection.
Reviewed the backward rewrite, recipe changes, and regression test, including affected batching, packed-loss, refit, and distributed-test paths.
Limitations: no tests, linters, or GPU runs were executed. Upstream Megatron-Bridge, Megatron-LM, and vLLM implementation sources weren't available for independent verification. The description supplies a 137 s → 81 s comparison but still marks current-head GPU validation as pending. One delegated test/evidence report wasn't available; I inspected that topic directly.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 24064b1 |
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test 15ae390 |
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test d55b095 |
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test ff3fe86 |
@youngeunkwon0405, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test ff3fe86 |
Signed-off-by: Youngeun Kwon <[email protected]>
|
/ok to test ac9c312 |
|
Hi @parthmannan can I ask for your approval on this PR? |
…ym rollout) into jthomson04/dynamo-1.7 Brings in NVIDIA-NeMo#4979's merge of main 89329fc (NVIDIA-NeMo#5030, NVIDIA-NeMo#5120, NVIDIA-NeMo#5007, NVIDIA-NeMo#5187, NVIDIA-NeMo#5265). Git merged the five files both sides changed without a conflict: the Dynamo guide, nemo_gym.py and three test files. pyproject.toml, uv.lock and the submodule pins are unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: jthomson04 <[email protected]>
What does this PR do?
Tune the Qwen3-30B-A3B BF16 sync and async 1-off recipes for larger microbatches while controlling memory use.
Recipe changes
moe_actrecomputation to limit memory at the larger batch sizes. Sync keeps activation checkpointing disabled.max_num_seqs=256/max_num_batched_tokens=8192. Async usesnccl_reshardwith a 0.5% memory target per staging buffer to bound refit memory.Logic change
ChunkedDistributedLogprob.backwardnow reuses one owned FP32 buffer andscatter_add_instead of allocating a full-vocabulary int64 one-hot tensor and extra FP32 temporaries. This reduces backward memory use while preserving the gradient formula and leaving saved logits unchanged.BF16 recipe benchmarks
Four nodes / 16 GB200 GPUs, global batch 2,048, maximum sequence length 4,096.
Baseline and sync timings are medians of steps 2–9; final async is the mean of steps 4–8. Source/runtime revisions differ: final async used Rubin development source
e5897ade9, rather than the current PR head. These are recorded benchmark results, not an isolated recipe-only comparison.All runs completed ten updates and evaluation. Numerical outliers remain in the linked runs; these short tests do not establish convergence.