feat: length-aware DP partitioning for variable seq lengths (#13)#109
Open
ppraneth wants to merge 2 commits into
Open
feat: length-aware DP partitioning for variable seq lengths (#13)#109ppraneth wants to merge 2 commits into
ppraneth wants to merge 2 commits into
Conversation
Contributor
Author
|
@yubofredwang Could you take a look at this PR and share your feedback? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d894e2f4d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: ppraneth <pranethparuchuri@gmail.com>
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.
Closes #13
Replaces round-robin in
_partition_resultswith longest-first greedy bin-packing, with a per-rank capacity cap so each rank still gets exactlyper_dp_rank_batch_sizesamples per dispatch.Sequence length is read from
tensor_shapes["input_ids"][-1]same field the data fetcher already uses. No new field onInferenceOutput.Falls back to round-robin when there's at most one sample per rank(eval dispatch, USP, or
per_dp_rank_batch_size=1) since there's nothing to balance in that case.Why approach A and not B/C
Went with A from the issue because it's the smallest safe change. C (pre-sorting at preprocessing) doesn't really survive async inference generation length is variable and dispatch order tracks inference completion. B (larger buffer) is the bigger win but changes dispatch timing and needs real measurement before landing.
Honest caveat
Step time per dispatch is bounded by
longest_sample * mbswhichever rank holds the longest sample pads to that length. So this PR mostly reduces wasted FLOPs on the other ranks rather than dropping step time. The real lever for step time is Approach B (larger candidate buffer so we can defer outliers). Leaving that as a follow-up once we can measure.Tests
Added
tests/test_partition_results.py— pure Python, no GPU, no Ray cluster (uses the sameray.remotepatch trick astest_capacity_handling.py). Covers:_seq_len(missinginput_idskey,tensor_shapes=None)I haven't run an end-to-end training job. Someone with a cluster should validate by logging
max_seq_in_batchper DP rank before/after to confirm imbalance actually drops on real workloads and that tells us whether B is worth doing.