Repository navigation
feat(sc): enable single-controller dynamic sampling - #4588
Conversation
|
Tried this with Lightning 3.5 SingleController, ready_first, token_capture.enabled=true, GBS 4096. The filter never fired. Committed groups were 32.9% zero-variance, same as the run without it (32.7%), and dropped_prompt_groups stayed 0. With token capture the pump calls generate_for_finalization and hands off to the finalizer actors (single_controller.py, around L1596). It never calls generate_and_push, where the check lives. Should the check move before the finalizer commit? Also, ready_first stamps no step, so on_dropped_prompt=replace does nothing. Does a filtered group still use up an admission slot with no refund? At ~33% I'd expect the window to starve after a few steps. Has this run past 3 steps? Logging zero_variance_groups as a metric would make a no-op like this visible. |
d7434e7 to
46ce5b8
Compare
|
Can we also have a metric to keep track of the reward before dynamic sampling? it would be very useful because in dynamic sampling |
46ce5b8 to
97782d0
Compare
32cc804 to
77b759a
Compare
|
/ok to test 8e98c7c |
8e98c7c to
e55ff23
Compare
|
/ok to test e55ff23 |
|
/ok to test 0b888b4 |
|
/ok to test 4a29761 |
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main and resolve conflicts.
Thanks for bringing dynamic sampling to the single-controller path, and for the clear write-up of its scope and limitations.
Great to see the V1-vs-V2 and token-capture-vs-not runs posted in the description; the effect of the filter can be read straight off them.
Scope: the structure of the single-controller dynamic sampling path, at 4a29761. A detailed review will follow once the two comments below are addressed.
Remaining comments are on:
- Moving token-capture support to a follow-up PR that borrows from later steps like the non-capture path
- A dynamic-sampling budget of its own, counted separately from rollout fault tolerance
Addresses both review comments on #4588. Scope it to the non-capture path. On the token-capture path a replacement cannot borrow a finished group from a later step the way the non-capture path does, so every drop waits out a full fresh rollout with the trainer idle. Dynamic sampling makes drops routine, so that cost would land on every step. Setup now rejects use_dynamic_sampling together with token_capture.enabled, and FinalizedGroup.zero_variance goes away with the capture-side filtering. Mirroring the borrow on that path is its own change. Separate the budgets. A zero-variance drop is a data decision about a rollout that succeeded, not a rollout failure, so sharing the fault-tolerance knobs let each kind of drop redefine the other. generate_and_push now returns a distinct RolloutOutcome.FILTERED, counted against the new grpo.dynamic_sampling_max_replacements_per_slot rather than max_replacement_attempts. Filtering no longer reads on_dropped_prompt: a uniform group is never worth training on, so it is replaced under "shrink" too and the spare pool is filled either way. Exhausting the budget raises, as v1 does past dynamic_sampling_max_gen_batches, instead of crediting a shortfall against min_step_batch_fraction; an empty pool still shrinks, since that is the dataloader ending rather than a mis-tuned filter. The default budget of 32 is sized from the drop rate, not from how many resamples feel reasonable: a slot exhausts it with probability p**(N+1), and every slot of every step takes that draw. At 32 a 4096-group step over 1000 steps is quiet below roughly a 78% drop rate, well clear of the ~33% seen in practice, and raises above it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
4a29761 to
3bfe02f
Compare
|
/ok to test 83f4879 |
Addresses both review comments on #4588. Scope it to the non-capture path. On the token-capture path a replacement cannot borrow a finished group from a later step the way the non-capture path does, so every drop waits out a full fresh rollout with the trainer idle. Dynamic sampling makes drops routine, so that cost would land on every step. Setup now rejects use_dynamic_sampling together with token_capture.enabled, and FinalizedGroup.zero_variance goes away with the capture-side filtering. Mirroring the borrow on that path is its own change. Separate the budgets. A zero-variance drop is a data decision about a rollout that succeeded, not a rollout failure, so sharing the fault-tolerance knobs let each kind of drop redefine the other. generate_and_push now returns a distinct RolloutOutcome.FILTERED, counted against the new grpo.dynamic_sampling_max_replacements_per_slot rather than max_replacement_attempts. Filtering no longer reads on_dropped_prompt: a uniform group is never worth training on, so it is replaced under "shrink" too and the spare pool is filled either way. Exhausting the budget raises, as v1 does past dynamic_sampling_max_gen_batches, instead of crediting a shortfall against min_step_batch_fraction; an empty pool still shrinks, since that is the dataloader ending rather than a mis-tuned filter. The default budget of 32 is sized from the drop rate, not from how many resamples feel reasonable: a slot exhausts it with probability p**(N+1), and every slot of every step takes that draw. At 32 a 4096-group step over 1000 steps is quiet below roughly a 78% drop rate, well clear of the ~33% seen in practice, and raises above it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: ruit <[email protected]>
a88bc72 to
ede988d
Compare
|
/ok to test ede988d |
|
/ok to test af69573 |
Give dynamic sampling an independent raw-prompt pool with an internal one-PPS low-water mark. Refill while admission or dispatch is blocked, notify consumers on replenishment and EOF, and bound initial plus replacement generation with dynamic_sampling_max_gen_batches. Signed-off-by: ruit <[email protected]>
Wait for filtered replacements outside checkpoint mutation ownership. Recheck the pool after acquiring the cut and keep prompt consumption and ledger transfer atomic, charging each replacement once. Exercise empty-pool, checkpoint and competing-consumer races. Signed-off-by: ruit <[email protected]>
At genuine data exhaustion, train only when retained groups meet ceil(PPS * min_step_batch_fraction); otherwise abort accumulated gradients and skip the optimizer update. Release consumed data, advance scheduling, and preserve checkpoint publication without ranking a skipped step by missing metrics. Signed-off-by: ruit <[email protected]>
Move reward participation, the shared zero-signal predicate, per-step reward state and record/drain implementations into experience/dynamic_sampling.py. Keep RolloutManager methods as thin delegates and route v1 and SC through the same predicate. Include the module in static type checking. Signed-off-by: ruit <[email protected]>
Add the Nano 3.5 Megatron/vLLM DAPOMath17K H100 two-node single-controller nightly. Set memory requirements in its CONFIG, place outputs under logs/results, and calibrate checks and the 140-minute budget against the completed ten-step run. Signed-off-by: ruit <[email protected]>
Signed-off-by: ruit <[email protected]>
Signed-off-by: ruit <[email protected]>
Signed-off-by: ruit <[email protected]>
Share rollout masking helpers, align dynamic-sampling documentation and diagnostics, and remove the unpublished reserve-setting migration. Refill filtering pools during restored rollout waits and require actual filtered outcomes in nightly validation. Signed-off-by: ruit <[email protected]>
Signed-off-by: ruit <[email protected]>
95a3381 to
a23b936
Compare
|
/ok to test a23b936 |
|
Quote reply to @yuki-97's review:
The full 10-step nightly with Tested commit: 95a3381.
|
…recipe Replace the Megatron-generation 2n8g DAPO capture nightly with one that inherits the #4588 dynamic-sampling recipe (Lightning-30B, Megatron training, vLLM generation, 4n8g) and routes the math task through NeMo-Gym (OpenMathReasoning via math_with_judge) so token capture is exercised on the faster vLLM path. MAX_STEPS=5 and the check_metrics thresholds are calibrated on a completed Gym run (unfiltered reward ~0.25, token_mult_prob_error median 1.018/max 1.029, ~1040s/step). Nightly GPU-hour budget stays under 5310 (5283). Signed-off-by: ruit <[email protected]>
…recipe Replace the Megatron-generation 2n8g DAPO capture nightly with one that inherits the #4588 dynamic-sampling recipe (Lightning-30B, Megatron training, vLLM generation, 4n8g) and routes the math task through NeMo-Gym (OpenMathReasoning via math_with_judge) so token capture is exercised on the faster vLLM path. MAX_STEPS=5 and the check_metrics thresholds are calibrated on a completed Gym run (unfiltered reward ~0.25, token_mult_prob_error median 1.018/max 1.029, ~1040s/step). Nightly GPU-hour budget stays under 5310 (5283). Signed-off-by: ruit <[email protected]>
…recipe Replace the Megatron-generation 2n8g DAPO capture nightly with one that inherits the #4588 dynamic-sampling recipe (Lightning-30B, Megatron training, vLLM generation, 4n8g) and routes the math task through NeMo-Gym (OpenMathReasoning via math_with_judge) so token capture is exercised on the faster vLLM path. MAX_STEPS=5 and the check_metrics thresholds are calibrated on a completed Gym run (unfiltered reward ~0.25, token_mult_prob_error median 1.018/max 1.029, ~1040s/step). Nightly GPU-hour budget stays under 5310 (5283). Signed-off-by: ruit <[email protected]>
…mpling under exclude_infra main's SingleController dynamic sampling (#4588, #5202) decides whether a group carries signal from its voting rewards (voting_rewards). It treated exclude_infra like include, so an infrastructure-failed row still voted there although the advantage stage leaves it out. With rewards [0 (infra), 1, 1] the group was kept as mixed, and every row's advantage was then 0. voting_rewards now takes the exclude_infra flags (rollouts.infra_failure_flags) and drops the flagged rows: - native path: RolloutManager._voting_rewards computes them from the completions with grpo.policy_failure_kinds; - token-capture path: the finalizer carries them per reward row as FinalizedGroup.reward_infra_failure. Under include and exclude nothing changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…ompts One conflict, in tests/unit/experience/test_rollouts.py. Both sides changed the end of the file. main rewrote test_mask_sample_flags_read_either_form_of_the_flag (#4588) and appended test_restored_turn_is_dispatched_to_its_checkpoint_owner (#4500). This branch appended _postprocess_rollouts and test_postprocess_nemo_gym_group_counts_distinct_first_prompts. Both stay: main's tests first, then this branch's helper and test. Signed-off-by: alexandery <[email protected]> Co-Authored-By: Claude Fable 5.2 <[email protected]>

What does this PR do?
Adds DAPO-style dynamic sampling to GRPO on the SingleController async path. Prompt groups with no reward signal under the configured masking policy are filtered and replaced. While data remains available, replacement keeps the target step at
grpo.num_prompts_per_stepgroups; at final dataset exhaustion, the remaining batch is trained or skipped according to the configured minimum batch fraction.Related issue: #1365.
Behavior
masked_reward_policyandoverlong_filtering. Filtering and reward-metric helpers live innemo_rl/experience/dynamic_sampling.py.num_prompts_per_step), and it refills on demand even while admission or dispatch is blocked. There is no separate dynamic-sampling reserve-size setting.grpo.dynamic_sampling_max_gen_batchesbounds generation attempts for each target step, counting the original batch. This is independent of rollout-failure retry budgets and the fault-tolerance spare pool. Filtering works with eitheron_dropped_prompt: replaceorshrink; rollout failure policy does not disable dynamic sampling.ceil(num_prompts_per_step * min_step_batch_fraction). Otherwise it discards accumulated gradients and skips the optimizer update. Skips advance the scheduling step/version, but not the optimizer or trained-sample count. Dataset iteration handles epoch transitions before declaring final exhaustion.train/rewardremains the trained-rows mean;train/unfiltered_rewardis the pre-filter progress signal. For V1 comparisons, align V1rewardwith SCunfiltered_reward, and V1filtered_rewardwith SCreward(naming alignment is tracked in Align v1's dynamic-sampling reward metrics with the SingleController naming #5039).Supported configurations
grpo.adv_estimator.name: grpoand at least two generations per prompt. PPO, Reinforce++, and OPD estimators are rejected for this filtering rule.async_rl.sampler.name: in_orderonly. Other built-in samplers andcustomare rejected; broader sampler support is tracked in feat(single-controller): support dynamic sampling for streaming sampler #4784.token_capture.enabled: false. Token-capture cannot borrow a finished future group and is explicitly unsupported here.invalid_tool_call_advantageormalformed_thinking_advantageoverrides are rejected;0andnullremain supported.grpo.batch_multiplier: 1; it batches prompts directly rather than using V1's batch multiplier.Replacements consume ordinary dataloader prompts, so a finite epoch can produce fewer training steps than an unfiltered run. Increase
max_num_epochs, or usenullfor unbounded epoch iteration, when a fixed step target requires more prompts.Usage
max_lookahead_versions: 1permits one version of lookahead; it does not promise strictly on-policy rollouts.max_replacement_attemptsandreplacement_reserve_promptsremain rollout-failure controls, not dynamic-sampling tuning parameters.See the dynamic-sampling guide for masking and metric semantics.
Nightly coverage and validation
Adds
dapo-nanov3.5-30BA3B-4n8g-megatron-vllm-noncolocated-single-controller.yamland its matching nightly driver: Nano3.5, DAPOMath17K, Megatron training (TP1/CP1/EP8), vLLM generation (TP4), and non-colocated 16-GPU training / 16-GPU generation. The driver runs 10 steps. Reward scaling (#4878) and reward shaping (#4882) remain disabled pending those PRs; their enablement comments are retained in the recipe.The four-node validation run
xvci4dbbcompleted all 10 training steps. Its exported metrics passed all 11 updated checks when rerun locally. The original post-run check invocation failed because of an inherited broken virtual-environment interpreter path, so this is not claimed as a successful end-to-end nightly invocation.The checks also require 10 recorded training losses and finite loss/probability-error metrics. Nightly timeout is 140 minutes; the current-head suite's dry-run budget is 5310 GPU-hours against a 5310-hour cap.
Unit regressions cover filtering and masking, independent budgets, admission/refill wakeups, epoch exhaustion, tail training/skipping, checkpoint cuts and recovery, and reward metrics. GPU checkpoint probes verified nonempty-pool save/restore and tail-step skipping, including a first skipped step with no optimizer update. The CI retry-fixture regression and related generation-failure tests pass locally (89 tests) after the latest rebase. CI has been requested for the latest pushed revision; its result is not claimed here.
V1 / SC comparison
The following plot is retained as the earlier non-token-capture comparison of V1 synchronous and SC asynchronous dynamic sampling. It is not evidence for the current four-node nightly configuration; reward curves need the metric-name alignment described above.
Nightly Test Result