ZeRO-1/2: synchronize IPG buffer reuse per buffer - #8366
Conversation
The broad reverse stream wait prevented ping-pong IPG buffers from being overwritten early, but also stalled unrelated backward work behind the previous reduction tail. Track completion per physical IPG buffer instead. Preserve producer-to-reduction ordering, record completion after the final reduction-stream consumer, and wait only when that same buffer is about to be overwritten. Add focused state and ordering tests plus a two-GPU ZeRO-2 parity stress test covering repeated reuse, multiple bucket sizes, and delayed reductions. Fixes deepspeedai#8364 Signed-off-by: almightychang (Sam, Joochul Chang) <almightychang@icloud.com>
Exercise gradients just below, equal to, and just above the physical IPG bucket size while delayed overlap communication forces reuse pressure. Compare losses, full gradients, and final parameters with non-overlap execution. Also verify that bucketed gradients record and wait for reuse while oversized gradients bypass reuse waits. Signed-off-by: almightychang (Sam, Joochul Chang) <almightychang@icloud.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db34ce6a29
ℹ️ 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".
The BF16 capability check can succeed on NPU, HPU, and XPU hosts even when torch.cuda._sleep is not executable. Require the active DeepSpeed accelerator to be CUDA before running the CUDA-specific delay stress tests. Signed-off-by: almightychang (Sam, Joochul Chang) <almightychang@icloud.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Wait for a physical buffer completion event only once per producer stream and logical bucket fill. Later copies on the same stream are already ordered behind that wait. Parameterize the CUDA stress test so every bucket-size and reduction-delay case is collected by default CI. Signed-off-by: almightychang (Sam, Joochul Chang) <almightychang@icloud.com>
Signed-off-by: almightychang (Sam, Joochul Chang) <almightychang@icloud.com>
Summary
Fixes #8364.
ZeRO-1/2 currently protects IPG ping-pong buffer reuse by making the current/autograd stream wait on the entire reduction stream in
average_tensor(). That reverse dependency also waits for unrelated work already queued on the reduction stream, serializing the next backward bucket behind the preceding collective.This change scopes that dependency to the physical IPG buffer being reused:
Oversized gradients and non-contiguous fallback reductions do not participate in physical IPG buffer reuse. Accelerators that resolve data dependencies implicitly retain their existing path.
Stream ordering: before and after
Time flows left to right.
P0/P1are producer copies,R0/R1are reductions, andE0is the completion event for physical buffer 0.Before: wait on the whole reduction-stream tail
After: wait only before reusing the same physical buffer
Correctness invariants
Tests / validation
pre-commit run --files deepspeed/runtime/zero/stage_1_and_2.py tests/unit/v1/zero/test_overlap_comm_record_stream.pyThe correctness suite deliberately delays reduction-stream work to amplify reuse races. I have not repeated the issue's original 8x H200 profiler experiment in this PR; the performance evidence and expected recoverable interval are documented in #8364.