Repository navigation
feat(automodel): add full-batch single-controller training - #4963
Conversation
|
/ok to test 8b48785 |
|
/ok to test b099dd1 |
|
/ok to test 56b4fc2 |
|
/ok to test 5da3d85 |
1 similar comment
|
/ok to test 5da3d85 |
|
/ok to test 5da3d85 |
|
/ok to test a20f7cf |
|
/ok to test 7fbd340 |
|
/ok to test 8ec0e19 |
|
Validated the AutoModel full-batch single-controller worker against the existing V1 training path using real GRPO training batches.
This establishes numerical equivalence of the full-batch AutoModel SC worker to V1 for the tested configurations and inputs |
|
/ok to test 54a172b |
|
/ok to test 047d31a |
047d31a to
0975247
Compare
|
/ok to test 0975247 |
0975247 to
a61c9a4
Compare
|
/ok to test a61c9a4 |
|
/ok to test c891478 |
c891478 to
7b70178
Compare
|
/ok to test 7b70178 |
…re-centering branch _validate_automodel_single_controller_config already rejects AutoModel TP or CP above 1, so the later score-centering check for that case could only be reached by a test that patched the validator out. Remove the branch, the two AutoModel parameter sets and the patch; TP=2 and CP=2 stay covered by test_unsupported. Addresses review thread C9 on NVIDIA-NeMo#4963. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
Neither the validator nor the worker step methods read expert_parallel_size, so the EP axis in these tests ran the same case twice. test_shipped_config already validates the EP=16 recipe, and real EP coverage lives in the two-GPU parity test. Addresses review thread C7 on NVIDIA-NeMo#4963. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
Put each sentence on one line in the design doc, the guide's AutoModel sections and the data-plane README, restoring the two README bullets whose only change was line breaks. List dynamic sampling and token capture in the unsupported scope, note that the MoE gate-bias and router-load paths are covered by the unit test only, and correct the run_grpo_single_controller comment that said SC supports only Megatron. Addresses review threads C12 and the doc part of C8 on NVIDIA-NeMo#4963. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
Run the SC full-batch smoke from L1_Functional_Tests_AutoModel.sh as a fast test instead of a separate L1 script that added a matrix job per platform. Use a fixed default EXP_DIR that the script removes first, as the sibling SC checkpoint script does, so repeated runs do not leave checkpoint copies behind. Raise the nightly cap by the 112 GPU-hours the three SC entries add, to 5512. Addresses review threads C2, C13 and C14 on NVIDIA-NeMo#4963. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
Build the gate from Automodel's MoEConfig with a positive gate_bias_update_factor and route tokens through its forward in train mode, so the test exercises the real _cumulative_expert_load accumulation, Gate.update_bias and the e_score_correction_bias buffer snapshot and restore. Covers a step that opens with no load, a finish that applies one bias update, and an abort that restores both a pre-existing load and the committed bias. Addresses review thread C8 on NVIDIA-NeMo#4963. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…en the SC nightlies All three AutoModel single-controller nightlies ran lookahead zero, so nothing exercised the lookahead-one path the PR supports. The Gemma4 E2B recipe becomes the lookahead-one guard: it is the model with the longest LA1 validation run and already has a gen_kl gate. The recipe gains the documented LA1 overrides (in_order with max_lookahead_versions 1, both capacities doubled); the driver asserts weight_version_lag reaches 1 so a silent fall back to lockstep fails, and is renamed with the -la1 modifier. Lookahead zero stays covered by the Qwen2.5 1n2g and Qwen3.5 EP=16 entries. Step counts follow the existing nightlies for these models, which run 20 steps: Qwen3.5 EP=16 drops from 50 to 20 steps (100 min), Gemma4 from 100 to 50 steps (120 min). The three SC entries now cost 72 GPU-hours instead of 112, and the nightly cap moves by that difference (5512 -> 5472; dry-run total 5456). The design doc's batch-512 reproduction command returns the renamed recipe to lookahead zero explicitly. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
The stall watchdog logs rollout/* counters every tick keyed by the current train step, so a slow checkpoint save writes two values for one step and --error-on-conflicts fails the TensorBoard dump. Merge like the other SC functional tests; the train/loss step-set gate still catches a resume that re-logs a train step. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
The AutoModel worker always receives one complete batch; lookahead is a sampler concern and buffer capacity is already validated against (lookahead + 1) x num_prompts_per_step. Drop the (0, 1) cap so AutoModel SC matches Megatron SC, parametrize the accepted-lookahead test over 1, 2 and 4, and document a 50-step Gemma4 E2B run at lookahead four (lag held at 4 from step 5, mean gen_kl 4.6e-4, token-mult median 1.009). Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…inite and ratio-branch coverage Review follow-up. json_dump_tb_logs.py gains --allow-conflicts-prefix so the SC smoke can keep --error-on-conflicts for every metric while tolerating the stall watchdog's timer-logged rollout/* counters; a unit test covers both sides. The smoke also asserts gen_kl_error and max_seq_mult_prob_error are finite, since Python's max can skip a NaN that follows a finite value. The parity harness now runs force_on_policy_ratio False as well as True, matching the documented lookahead configuration. The nightly cap follows upstream's 5516 plus the 72 GPU-hours of the three SC entries. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…t-parallel key The shipped dense recipes omit automodel_cfg.expert_parallel_size, and OmegaConf raises on attribute access of a missing key, so the harness failed in setup on its own default recipe. Read the key once with .get() and reuse it; omission keeps the dense path, as production setup does. The dense unit cases now leave the key unset so the matrix covers it. Also drop the stale "lookahead above one unsupported" sentence from the design doc and point the smoke-test guide at EXP_DIR, since the script appends its own logger.log_dir after user overrides. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…arness Main removed loss_fn.token_level_loss (NVIDIA-NeMo#5276), so ClippedPGLossConfig now rejects it. Iterate the parity harness over normalization in ("global_token_mean", "sequence_mean"), which is what True and False resolved to, and key the partition ids and report rows on that name. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…ig for pyrefly Main now gates lint on pyrefly 1.4.0 with a baseline (NVIDIA-NeMo#5298), and the full-batch train path tripped two new errors: automodel_cfg is a union with the disabled variant, so .get() returned object and could not be used in a modulo against the typed microbatch index; and get_microbatch_iterator takes dict[str, Any], which PolicyConfig is not. Cast to AutomodelConfig, which the full-batch path already requires, and cast the policy config at the call like the existing generation-config precedent in this file. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shuang Yu <[email protected]>
…full-batch checks NVIDIA-NeMo#5272 renamed train/weight_version_lag to train/weight_version_lag_max, so the smoke test and the three nightly drivers asserted on a key that is no longer logged, and check_metrics.py fails a check whose key is missing. Also point the design doc at the new metric name and fix a 'below' that refers to a recipe listed above. Signed-off-by: Shuang Yu <[email protected]>
…upport lines Unwrap the five hard-wrapped paragraphs in the AutoModel full-batch guide section, shorten two three-line in-function comments, and correct the sampler-replay and score-centering guides, which still described Automodel token capture as supported although Automodel SC rejects it. Signed-off-by: Shuang Yu <[email protected]>
…vers Remove the checkpoint directory after the checkpoint assertions pass, log nightly runs to the nemo-rl W&B project and drop the exemplar's own project, and rename the Gemma4 lookahead-one recipe and driver from -la1 to -lag1. Signed-off-by: Shuang Yu <[email protected]>
…rop the buffer snapshot The worker repeated nine conditions that the SC config validator already rejects before any worker is built, and cloned every model buffer per step although a train-mode forward only changes the Gate load counter, which router_loads already covers. Remove both, remove the lookahead validator entry that can never reject on its own, and state in the docs and the failed-commit message that a failed dispatch or commit ends the run. Signed-off-by: Shuang Yu <[email protected]>
… between train() and the SC step The SC step methods repeated three calls from train() argument for argument, and every recently added argument has a default, so a copy that misses one runs with the feature silently off. Move the calls into private helpers that both paths use. Signed-off-by: Shuang Yu <[email protected]>
This reverts commit 745a57c. Signed-off-by: Shuang Yu <[email protected]>
…ction The shared-helper refactor inserted the new helpers between the wrap_with_nvtx_name decorator and train(), so the decorator wrapped _make_loss_post_processor and train() lost its profiler range. Signed-off-by: Shuang Yu <[email protected]>
Build the Policy on a RayVirtualCluster like test_megatron_split_parity.py and compare loss, grad norm and per-microbatch metrics of train() against begin_train_step / train_microbatch / finish_train_step. Each case also aborts one dispatched step and runs logprob inference before the commit. Delete the torchrun harness tests/functional/automodel_sc_full_batch_parity.py, whose only runner was this test, and point the guide at the unit test. Signed-off-by: Shuang Yu <[email protected]>
…acy recipe Replace the 1n2g full-batch nightly with grpo-qwen2.5-math-1.5b-instruct-1n8g-automodel-single-controller, which inherits the legacy 1n8g AutoModel recipe and turns off what AutoModel SC rejects. The smoke test takes the exemplar plus CLI overrides, so the 1n2g recipe is removed. Lower the Gemma4 SC nightly limit to 30 minutes. The new driver's 240-minute limit is copied from the Megatron SC twin and the GPU-hour cap follows it; both are to be set from a measured run. Signed-off-by: Shuang Yu <[email protected]>
…checks from H100 runs All three AutoModel SC nightly drivers were run unmodified at 3a4062c in the nightly container on H100 nodes; every existing gate passed. - grpo-qwen2.5-math-1.5b-instruct-1n8g-automodel-single-controller: 450 steps in 97 min, so NUM_MINUTES drops from 240 to 200. Adds mean(train/reward) > 0.3 (measured 0.47; the first 50 steps average 0.32) and the sibling 1n8g recipes' step-time bound mean(timing/train/total_step_time, 2) < 25 (measured 11.5 s). - grpo-gemma4-e2b-it-1n8g-automodel-single-controller-full-batch-lag1: 15 min, NUM_MINUTES=30 stays. Adds mean(train/reward) > 0.2 (measured 0.34, and 0.36 in an earlier run). - grpo-qwen3.5-35ba3b-base-3n8g-automodel-ep16-single-controller-full-batch: 56 min, NUM_MINUTES=100 stays. Adds mean(train/reward) > 0.05 (measured 0.10, and 0.13 in an earlier run). The nightly GPU-hour cap goes from 5600 to 5594: main's 5524 at the merge base plus 26 + 4 + 40 for the three SC entries. The dry run totals exactly 5594. Signed-off-by: Shuang Yu <[email protected]>
a0d3be8 to
541505e
Compare
|
/ok to test 541505e |
The shared _clip_policy_grad_norm helper now reads self.pipeline for the PP-aware clip arguments (from NVIDIA-NeMo#4960). The split-state fixture builds the worker with object.__new__ and never set the attribute, so three tests failed with AttributeError in L0_Unit_Tests_Automodel_Policy_{1,2,3}. Match the existing worker fixtures in test_automodel_worker.py. Signed-off-by: Shuang Yu <[email protected]>
|
/ok to test 0e29d0b |
|
Hi @yuki-97 Thank you very much for your review and comments! I have got all of them addressed, conducted the validation again, and updated the PR description accordingly. Would you please give another round of review? Thank you! |
What and why
Single-controller (SC) training could not use the AutoModel backend: the AutoModel worker only had the one-shot V1
train()call, not the step lifecycle the controller drives.This PR adds full-batch text GRPO for AutoModel through the existing SC lifecycle: begin a step, dispatch the complete DP-sharded batch, then commit once.
flowchart LR B[begin_train_step] --> M[train_microbatch<br/>per microbatch, gradients stay live] M --> F[finish_train_step<br/>clip, optimizer step, MoE gate-bias update] M -. unit tests only .-> A[abort_train_step<br/>drop gradients, restore router loads]How it works
begin_train_step,train_microbatch,finish_train_stepandabort_train_steponAutomodelPolicyWorkerImpl. Dense and MoE models use the same lifecycle, including AutoModel's expert-parallel mesh, dispatch, synchronization and clipping.train()and the SC step methods call the same three private helpers (_make_loss_post_processor,_forward_backward,_clip_policy_grad_norm), so the loss, forward/backward and clip wiring exists once. V1's control flow is unchanged, including the pipeline-parallel branch from feat(automodel): add pipeline parallelism to the Automodel policy worker #4960.(lookahead + 1) × num_prompts_per_step.make_sequence_length_divisible_bytogether with producer and batching alignment constraints, which the Qwen3.5 HybridEP recipe needs.Support matrix
max_lookahead_versionsScore centering and sampler replay are unavailable on AutoModel SC: both need
top_logprobs > 0, which requires token capture, which AutoModel SC rejects. The validator branch that allowed them on AutoModel at TP=CP=1 described a path that never existed (main's SC guide said AutoModel was untested on SC), so it and the matching lines in the score-centering and sampler-replay guides were removed.Usage
Docs: AutoModel full-batch design and the single-controller guide.
New nightlies, each with a recipe and a driver: Qwen2.5-Math-1.5B-Instruct (1n8g, 450 steps, the SC twin of the legacy
.v3recipe), Gemma4 E2B IT (1n8g, 50 steps, lookahead one), and Qwen3.5-35B-A3B Base EP=16 (3n8g, 20 steps). The nightly GPU-hour cap moves from 5652 to 5722 for these three entries.The FP32
A_logrefit change that was part of this PR moved to #5456 at review request.Issues
None
Convergence / perf / functionality proof
Head
0e29d0bb0821a756045845531c334cad6d53b5a9, 59 commits rebased onto maindfe2dcd7d, no merge commits. Everything in this section was measured at541505e6f04832f4bbb0ca54fd336f61b427b09f, the previous head; the only commit after it is a one-line unit-test fixture fix that does not touch training code. The earlier per-head validation history is in this comment.Nightly drivers at the PR head
Unmodified drivers, nightly container, H100 nodes with 8 GPUs each. "Gates" is the driver's
check_metricslist.gen_kl_errortoken_mult_prob_errormediangrpo-gemma4-e2b-it-1n8g-automodel-single-controller-full-batch-lag1weight_version_lag_maxreaches 1grpo-qwen2.5-math-1.5b-instruct-1n8g-automodel-single-controllergrpo-qwen3.5-35ba3b-base-3n8g-automodel-ep16-single-controller-full-batchgrpo-qwen2.5-math-1.5b-instruct-1n8g-automodel.v3grpo-qwen3.5-35ba3b-2n8g-automodel-ep16grpo-qwen3.5-35ba3b-2n8g-automodel-ep8pp2The V1 rows exercise the shared helpers from the legacy
train()path: the dense twin, the expert-parallel clip, and the pipeline-parallel clip arguments that the rebase touched. The Qwen2.5 V1 and SC twins track each other across all 450 steps (first-50 reward 0.317 / 0.320, last-50 0.538 / 0.543,gen_kl_error1.79e-4 / 1.80e-4, step time 12.4 s on 8 GPUs / 11.5 s on 4 training GPUs). The Qwen2.5 SC driver's time limit (200 min) and the reward floors in all three SC drivers were set from these runs' predecessors at the pre-rebase head, which gave the same numbers within run-to-run noise (Qwen2.5 97 min, mean reward 0.47; Gemma4 0.34; Qwen3.5 0.10).Unit, functional and static checks
test_automodel_split_parity.py: builds a realPolicyon a Ray cluster and comparestrain()with the SC step on loss, grad norm and every per-microbatch metric atrtol=1e-5; 4 of 4 cases pass (dense and Qwen3 MoE EP=2, unchunked and chunked logprobs). Removing the gradient clearing frombegin_train_stepmakes it fail at step 0 (grad norm 2.03 against 1.02), so the test is sensitive.automodel_sc_full_batch_smoke.shon two GPUs: both launches, checkpoint save at step 1 and resume through step 4, every metric gate includingweight_version_lag_max == 0. Runs in CI underL1_Functional_Tests_AutoModel.sh.--automodel-only). The three Automodel policy CI shards failed at the previous head because the split-state fixture did not setpipeline, which the rebased clip helper now reads; fixed in the follow-up commit; the recipe, test-suite and config-validation suite passes with the nightly cap test at 5722 (dry run totals exactly 5722).Training comparisons (matched V1 versus SC)
Same seed, batch, optimizer, sampling and token limits in each pair; dynamic sampling and reward shaping off; SC at lookahead zero. Measured before the rebase; the training code under test is unchanged by it.
An exact real-batch replay at EP=16 (six consecutive Qwen3.5-35B-A3B updates on 16 training GPUs, identical starting state) matched V1 and SC gradients, metrics, parameters, optimizer, scheduler and RNG state at
rtol=atol=0.Lookahead one
Full-batch lookahead 0 versus 1 on four models, same seed, batch, learning rate and layout in each pair. Last-100-update means:
gen_kl_errorLA0 / LA1Reward tracks LA0 in every pair;
gen_kl_errorrises later in training under LA1. Step times come from independently sampled workloads, not a fixed-work benchmark. Methodology and per-model caveats are in the design doc.Qualifications
gate_bias_update_factor=0.0.A_logchange now in fix(automodel): preserve native FP32 A_log during refit #5456, the LA0 reference did not; fix(automodel): preserve native FP32 A_log during refit #5456's matched before/after shows no measurable effect ongen_kl_errorortoken_mult_prob_error.b916107a5is used unmodified. The long runs used the pinned dependency set, not a clean rebuild from the lockfile; PR dependency pins are unchanged.Needs upstream changes
None
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./nightly-ci test-case=<test>: run NVIDIA's nightly CI for the PR head; eligible teams only./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.🤖 Generated with Claude Code