perf: use deque for FIFO queues in sequence parallel, superoffload, and compile#7880
Merged
tohtana merged 1 commit intodeepspeedai:masterfrom Mar 1, 2026
Merged
Conversation
19b15d0 to
22d7251
Compare
…nd compile Three files drain lists front-to-back via .pop(0): - ulysses_sp.py: micro_batches queue for sequence parallel data - superoffload_stage3.py: params_in_ipg_bucket_buffer for gradient bucketing - compile/backend.py: remaining_schedule for compile pass scheduling Each .pop(0) is O(n); switching to collections.deque with .popleft() gives O(1) front removal. Signed-off-by: g97iulio1609 <giulio97.leone@gmail.com>
22d7251 to
1656c47
Compare
Contributor
Author
|
Friendly ping — CI is green and this is ready for review. Happy to address any feedback. Thanks! |
sfc-gh-truwase
approved these changes
Feb 28, 2026
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.
Problem
Three files use
.pop(0)for FIFO queue processing, which is O(n) per removal:ulysses_sp.py: Micro-batch queue for sequence parallel data shardingsuperoffload_stage3.py: Parameter buffer for IPG gradient bucketingcompile/backend.py: Compile pass schedule queueSolution
Switch to
collections.dequewith.popleft()for O(1) front removal.Changes
deepspeed/runtime/sequence_parallel/ulysses_sp.pymicro_batchesFIFO queuedeepspeed/runtime/superoffload/superoffload_stage3.pyparams_in_ipg_bucket_bufferdrain loopdeepspeed/compile/backend.pyremaining_schedulestep-by-step consumption