DeepSpeed Comm. Backend v1 - #1985
Merged
Merged
Conversation
Co-authored-by: Quentin Anthony <qganthony@yahoo.com> Co-authored-by: Ammar Ahmad Awan <ammar.awan@microsoft.com> Co-authored-by: Jeff Rasley <jerasley@microsoft.com>
awan-10
requested review from
RezaYazdaniAminabadi,
ShadenSmith,
cli99,
conglongli,
eltonzheng,
jeffra,
minjiaz,
samyam and
tjruwase
as code owners
May 27, 2022 22:29
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
awan-10
commented
May 27, 2022
…pSpeed into staging-comms-next
Collaborator
|
@SeanNaren can you take a look at the lightning test failure? We're seeing this on other PRs and in |
Contributor
jeffra
approved these changes
Jun 7, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
tjruwase
reviewed
Jun 9, 2022
This reverts commit 9976681.
tjruwase
approved these changes
Jun 10, 2022
This was referenced Jun 13, 2022
banxingmjj
pushed a commit
to openanolis/DeepSpeed
that referenced
this pull request
Aug 24, 2026
…ync on MPS (deepspeedai#8303) ## Summary Resolves @delock's review note on deepspeedai#8293 (deepspeedai#8293 (comment)): `irecv` is asynchronous by contract and has no `async_op` parameter, so the MPS CPU-staging wrapper must handle it explicitly. Two fixes: 1. **`deepspeed/comm/comm.py`** — `isend`/`irecv` dispatched to the *blocking* `cdb.send`/`cdb.recv` (since the original comm backend, deepspeedai#1985). Callers got a blocking call and `recv`'s return value (the source rank `int`) instead of a waitable handle, so `dist.irecv(...).wait()` raised `AttributeError`. This affects every backend, not just MPS — e.g. the 1-bit comm helpers (`runtime/comm/{compressed,hccl,nccl}.py`) call `dist.isend/irecv(...).wait()`. They now route to `cdb.isend`/`cdb.irecv`. 2. **`deepspeed/comm/torch.py`** — with the routing fixed, the MPS staging wrapper's copy-back decision (keyed on an `async_op` argument) ran immediately for `irecv`, before the transfer completed. A new `always_async` flag on `stage_on_cpu` defers the copy-back to the handle's `wait()` for `isend`/`irecv`. `StagedWork.wait()` now also returns the underlying work's wait result. ### Verified (M5 Max, macOS 26.3, torch 2.13) - Real two-process gloo run with MPS tensors: on master, `dist.irecv` returns an `int` and `.wait()` crashes; with this PR it returns a handle and the buffer holds the correct payload after `wait()`. - `DS_ACCELERATOR=mps pytest unit/comm/test_dist.py`: 10 passed (multi-rank cases skip on 1 device). - ZeRO-2/3 smoke training unaffected. ### Test Adds `TestDistIsendIrecv` (world size 2) to the existing `tests/unit/comm/test_dist.py`: rank 0 `isend`s, rank 1 `irecv`s, both assert a waitable handle and verify the payload after `wait()`. Backend-agnostic, so it exercises the routing fix on CUDA/CPU CI as well. ### Relation to deepspeedai#8301 deepspeedai#8301 addresses the same note with a more extensive `StagedWork` (futures, result identity restoration, weakref buffer tracking). This PR makes the fix more concise and accurate: no current DeepSpeed users calls `Work.result()`/`get_future()` on staged P2P ops, and the staged CPU buffer for `isend` is kept alive by the deferred copy-back closure until `wait()`. Huge Credit to @FU-max-boop for the thorough analysis of the Work semantics and fixes. --------- Signed-off-by: PKUWZP <zhipeng.rainbowserie@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.
This PR introduces the DeepSpeed Comm. Backend (v1).
Current advanced communication schemes rely on mixing python-level communication packages (e.g. torch.distributed, mpi4py for 1-bit Adam). In order to simplify comms prototypes, we're looking to add support for custom communication backends within DeepSpeed built directly on top of their respective libraries (e.g. NCCL, MPI, etc).
This PR completes the first phase towards this goal by introducing:
deepspeed.commstorch.distributedcalledTorchBackendfor backwards-compatibilityCo-authored-by: Quentin Anthony qganthony@yahoo.com
Co-authored-by: Ammar Ahmad Awan ammar.awan@microsoft.com
Co-authored-by: Jeff Rasley jerasley@microsoft.com