fix(dp_schedule): drop trailing rollouts when the aligned micro-batch target exceeds the sample count#2065
Open
EazyReal wants to merge 2 commits into
Open
Conversation
edd17fe to
4ce9792
Compare
4ce9792 to
09fe712
Compare
Contributor
Author
|
@zhuzilin could you review this one? The DP schedule can align the micro-batch target above the available sample count; this drops only the trailing rollouts that cannot fit, avoiding invalid empty/misaligned groups. |
… target exceeds the sample count
a767e28 to
d6147ce
Compare
Contributor
Author
|
@zhuzilin refreshed on latest main and checks are green. This drops trailing rollout groups when the aligned micro-batch target exceeds the sample count, preventing invalid DP scheduling. Could you review when you have bandwidth? |
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 changed
In
build_dp_schedule(slime/utils/dp_schedule.py), whenuse_dynamic_batch_sizeandalign_to > 1, drop the minimum number of whole trailing rollouts before aligning the micro-batch count, so the up-rounded target (ceil(K/align_to)*align_to) stays reachable. The kept rollout count is recorded inglobal_batch_sizes[s](previously always the constantglobal_batch_size) so per-step loss scaling and LR increments track the samples that actually train. If rollout atomicity makes alignment impossible (no whole-rollout prefix has a sample count divisible byalign_to), the bareAssertionErroris replaced with aValueErrornaming the step, kept sample count, andalign_to.The micro-batch target computation is factored into
_aligned_target, and per-step sample collection / packing into_collect_step_samples/_pack, reused across the drop loop.Why
In the long-trajectory dynamic-batch regime, first-fit packing puts roughly one sample per micro-batch, so the micro-batch count equals the sample count. When
align_to(=dp_size, ordp_size * mb_groupunder VPP) rounds that count up past the sample count,expand_bins_by_splittingcannot reach the target — it stops early once every bin is a singleton — andbuild_dp_scheduledied on a bareAssertionError. Concretely at DP4, a step of 514 single-sample bins needs 516 micro-batches, which is unreachable.Dropping whole trailing rollouts keeps GRPO groups atomic (a multi-sample rollout is never split across the drop) and keeps the kept rollouts a contiguous
0..k-1prefix. The drop floor is sample-count based: keep dropping while the target is unreachable as long as a full aligned block (>= align_tosamples) remains. The loop is a no-op on the common one-sample-per-rollout and static-batch paths, where the aligned target never exceeds the sample count andglobal_batch_sizesstays equal toglobal_batch_size.Validation
tests/test_dp_schedule.pyis CPU-only / torch-free and already registered in the cpu-unittest job. Three new@pytest.mark.unitcases:global_batch_sizes == [510], equal micro-batch count per rank, no rollout split.[3,2,3,1,2]at DP4: drops past the naivedp_sizefloor down to the 3-rollout / 8-sample prefix that aligns.[1,1,4,1,3,1]at DP4 (prefix sample counts 1,2,6,7,10,11, none divisible by 4): asserts the actionableValueError.Run:
python tests/test_dp_schedule.py(orpytest tests/test_dp_schedule.py). The existing suite, including the FLOPs-balancing cases, continues to pass.