Repository navigation
fix(rollout): stop dynamic sampling from leaking generation past the rollout - #324
Open
OnePunchMonk wants to merge 4 commits into
Open
OnePunchMonk wants to merge 4 commits into
OnePunchMonk wants to merge 4 commits into
Conversation
…rollout Dropping a group fetched a whole new over_sampling_batch_size batch, and state.reset() discarded the extra tasks without cancelling them. They kept generating on the background event loop through offload, training and weight sync, doubled generation cost, and the prompts they held were skipped (the data source position was already past them). Top up only the groups the filter dropped, and cancel and await any leftover tasks in a finally block so an error mid-rollout also leaves the engines idle and the shared state clean.
OnePunchMonk
requested review from
Rockdu,
guapisolo and
zhihengy
as code owners
October 17, 2026 13:49
Contributor
Author
|
Note:
|
Collaborator
|
Hi @OnePunchMonk, Example: 4 engines, target 4 groups, one group takes 1 time unit, same keep/drop outcome for each group in both runs (green = kept, gray = dropped, red = extra).
|
Topping up only the dropped count left one group running at the tail while the other engines sat idle. Keep enough groups in flight to reach the target and, on a drop, also fill every idle engine. Extra groups not needed once the target is met go back to the data buffer untouched.
Contributor
Author
|
Added an abort endpoint to SGL diffusion here: sgl-project/sglang#44953 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
over_sampling_batch_sizebatch.generate_rollout_asyncreturns (or raises), cancel and await any tasks still running, then reset the shared state.Why
With
--dynamic-sampling-filter-path(including the stockcheck_reward_nonzero_std), a single dropped group made the loop fetchrollout_batch_sizenew groups. Once enough groups were kept,state.reset()discarded the running tasks without cancelling them. They run on the background event loop, which never stops, so they kept generating on the engines while the trainer offloaded them, trained on the same GPUs (colocated) or pushed new weights.Measured with the real
generate_rolloutand a fake engine (8 groups per rollout, 1 in 4 groups with all-equal rewards, 3 rollouts), base vs this PR:The skipped prompts also advance the data-source position saved in the checkpoint, so a resume skipped them too. The kept set was whichever groups finished first, which biased training toward prompts that generate fast.
Unused groups never need
data_source.add_samplesnow: after a successful rollout, fetched = kept + dropped.Validation
tests/fast/rollout/test_dynamic_sampling_rollout.py(2 tests): no work in flight after the rollout returns, fetched = kept + dropped across rollouts, and a failing group cancels the rest and leaves clean state for the next rollout. Both fail on base and pass here.stage-a-cpujob (Ubuntu 24.04,sglang-miles): 496 passed.Notes on the GPU run:
--colocateuses (pidfd_getfd: Operation not permitted), so I ran non-colocated.sglang-mileschecked out over its sglang, as CI does.fsdp_utils-> H3 weight bridge ->vsacallstorch.cuda.get_device_capability(0). I stubbedvsain my probe harness only. This is separate from this PR.Review: an independent Codex pass raised one point, that kept groups past the target could be dropped silently. That cannot happen here since kept <= submitted - dropped <= target; it was true on base and the test asserts it.
Tradeoff
Refills now arrive in rounds sized to the drops, so a rollout with many drops can wait for one extra group's generation per round. In exchange, no extra groups are generated.
Files
miles/rollout/sglang_diffusion_rollout.py: top up only the dropped count, and cancel and await leftover tasks in afinallybefore resetting state.tests/fast/rollout/test_dynamic_sampling_rollout.py: regression tests.Checklist
stage-a-cpugreen on a Modal replica (496 passed)