fix: Only bind device id when needed, Fixes #8248 - #8269
Conversation
Signed-off-by: pengdurice <pengduhit@gmail.com>
Signed-off-by: pengdurice <pengduhit@gmail.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@pengdurice thanks for the PR. I don't fully understand the problem. It appears that this a recent regression. Did you identify regression? |
ebarkhordar
left a comment
There was a problem hiding this comment.
@sfc-gh-truwase on the regression question: yes, and the boundary is the one the reporter names. I traced this in git on a full clone rather than reproducing it, since I have no CUDA machine here.
The device_id binding entered deepspeed/comm/torch.py in ee286e5 (#7266), and v0.17.2 is the last release without it:
$ git rev-parse --is-shallow-repository
false
$ git log -G 'kwargs\.update\(device_id=' --oneline --follow -- deepspeed/comm/torch.py
ee286e53 set `device_id` in torch's `init_process_group` (#7266)
$ git tag --contains ee286e53 | sort -V | head -3
v0.17.3
v0.17.4
v0.17.5
$ git log --oneline v0.17.2..v0.17.3 -- deepspeed/comm/
ee286e53 set `device_id` in torch's `init_process_group` (#7266)
f485e136 Improvements to Communication Logger (#7404)
#8248 reports 0.17.2 working and later versions failing, so the two agree. The only other comm change in that window is the logger one.
Two things in that history bear on the fix. First, #7266's stated purpose was narrow: it set device_id to silence the ProcessGroupNCCL warning that "devices used by this process are currently unknown" during barrier(). A single-rank job has no rank-to-GPU mapping to get wrong, which is the case this PR stops binding for.
Second, this block has already been narrowed once for the same shape of reason. #7542 (08879a3, first released in v0.17.6) added the get_accelerator().device_name() == 'cuda' condition because binding a device blocked creating CPU process groups afterwards. So get_init_process_group_device_id is the second carve-out for a side effect of binding rather than a new kind of exception, and that seems worth saying in the PR description.
What I did not check: I could not run the NCCL path, so I cannot confirm that leaving the device unbound is sufficient to clear CUDA error 600 on the reporter's setup. The git evidence only establishes that the binding is what changed between the two versions they compared.
|
Do we actually know why this happens only with #7266 originally tried to remove this warning and chose the second approach ("call init_process_group() with a device_id). Does anyone think using While investigating this, I also found DeepSpeed ignores |
|
I have never tried barrier with device id, @tohtana question, why would anybody try to init dist on a single gpu. I suppose to make some code work on 1 or many gpus, but nccl won't really be used on a single gpu, correct? if I remember correctly this is just a no-op on nccl level. if the culprit is the init of nccl on a single gpu, why not solve this in a much simpler way - just add |
|
#8248 (comment) |
|
yeah, I propose to keep things simple, your code is valid but I think a simple world>1 check would have a much smaller footprint and it's a way easier to track/understand. |
|
Thank you @stas00 for sharing your thoughts. Then we can take the simplest approach. In this case,
@pengdurice If they don't reply, let's move forward and merge this. I think this PR is already useful. |
|
before merging that no need to pollute the code. |
Fixes #8248.
The change
init_process_groupnow asks a small resolver instead of inlining the condition:DEEPSPEED_SET_DEVICE_IDoverrides the decision, parsed by a newget_env_flaghelper:1/true/yes/on0/false/no/offworld_size > 1Multi-rank behaviour is unchanged.
Tests
tests/unit/comm/test_dist.py