What
NVIDIA-NeMo/RL #3665
actually does. Builds on
#3589.
All permalinks pin the PR head ad048f9.
Companion page: why a lost rollout used to end the run.
The SingleController runs two loops at once: one generates completions ("rollout pump"), one trains on
them ("train pump"), joined by a buffer. With the in_order sampler, every batch the rollout
pump sends out is given the number of the training step it belongs to, and step N will only train on
groups carrying the number N
(staleness_sampler.py:409).
So if a prompt fails every retry and is given up on, step N is one group short and nobody else's work
can fill the hole. This PR adds three ways out, and picks between them automatically. The numbers below use
a batch of 4 prompts per step.
Case 1 is just arithmetic. The train pump asks how many groups this step should wait for, every time around the loop, instead of assuming it is always the configured batch size:
_target_groups_for_step ยท
the loop that re-reads it every pass:
single_controller.py:838
(on main this line was the fixed num_prompts_per_step) ยท
the floor: min_step_batch_fraction
Cases 2 and 3 are the same code path โ the task that lost its prompt keeps running and tries again with a spare. Whether it works for step 0 or for step 1 is decided by whether a later step has finished work to lend:
the retry loop that keeps the task alive ยท _divert_batch_to_reserve fills the pool ยท _drain_reserve_into_steps trains on whatever spares are left at the end, so no data is thrown away
Four similar-sounding numbers decide how big a step is. Two are settings you write in YAML; two are working values the trainer recomputes as it goes. Mixing them up is the easiest way to misread this feature.
| value | where it lives | what it is | when it changes |
|---|---|---|---|
num_prompts_per_step | your YAML | groups a full step wants | never |
min_step_batch_fraction | your YAML | how much of that is still acceptable | never |
min_groups_for_streaming_train | your YAML | smallest chunk worth starting a training pass on โ a speed setting | never |
floor = ceil(N × fraction) | worked out at startup | below this the run stops with an error | never |
target_groups | working value | what this step will actually train on | once per step, per lost prompt |
max_prompt_groups | working value | how many this step still needs right now | every pass of the loop |
min_prompt_groups | working value | smallest chunk to ask for right now | every pass of the loop |
Two things that trip people up. The floor is a check, not a target โ losing 1 prompt out
of 4 gives target_groups = 3, not 4 × fraction; the floor is only what 3 gets
compared against. And min_prompt_groups is capped by what is left
(single_controller.py:871),
so a chunk size of 30 never blocks a step that only needs 17 โ and never reaches into the next step to top
itself up, because the take is capped at max_prompt_groups and the groups for other steps carry
a different step number anyway.
Nobody has posted a run. There is no W&B link, no before/after step-count, and no log from a job that actually lost a shard mid-training. The PR is covered by unit tests that drive the real rollout and train loops with fake samplers, and CI is green โ but that only shows the bookkeeping adds up, not that a real fleet outage is survived.
The one thing worth asking for before merge is a single long run with a generation worker killed on
purpose part way through, reporting the three new per-step numbers
(dropped_prompt_groups, replaced_prompt_groups, promoted_prompt_groups,
single_controller.py:1043)
and the reward curve next to a clean baseline. That would show both that the run survives and that training
quality is unchanged.
shrink means some steps compute
their gradient from a smaller batch, and min_step_batch_fraction is the guard that says how much
smaller you will accept โ at the default 0.9, a batch of 8 or fewer prompts tolerates no losses
at all. replace keeps the batch size but can leave the trainer waiting on a fresh completion,
which is why the code borrows finished work from a later step whenever it can. One thing to know before you
turn it on: these settings only do anything with the in_order sampler, because it is the only
one that labels batches with a step number.