Repository navigation
Conversation
reduce_sum_across_dp_group() fell back to a CPU tensor whenever CUDA was unavailable, which makes the DP all_reduce fail on any other accelerator (Ascend NPU, XPU, ...) with "No backend type associated with device type cpu". dp_mesh is guaranteed to be set at that point and already carries the device type of the collective, so use it instead of assuming CUDA.
Author
|
Gentle ping on this one — it's been quiet for 8 days since the last activity, so I wanted to check whether there's anything else you'd like me to adjust or add before this can move forward. Happy to make changes if so. Thanks! |
Author
|
@PengchengShi00 @jayhenry — would one of you be able to take a look at this when you get a chance? DP all_reduce tensor is built on the wrong device The dataloader creates its all_reduce tensor without a device argument, so it lands on the default device while the mesh may be on another one. It now takes the mesh device. Small and contained. Happy to adjust if the approach doesn't fit. |
This branch has not been deployed
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.
What
reduce_sum_across_dp_group()built the DPall_reducetensor on CPU whenever CUDA was unavailable, which breaks every non-CUDA accelerator (Ascend NPU, XPU, ...) withRuntimeError: No backend type associated with device type cpu.The function already receives the
dp_meshthat owns the process group, anddp_meshis guaranteed non-Noneat this point (the early return above handlesNone), so the device can be taken from the mesh instead of assuming CUDA. This keeps the CPU case working (torch.device("cpu")for a CPU mesh) and removes the CUDA-only branch.Why it matters
Dataloader.get_state_dict()calls this helper, so on Ascend the dataloader state could not be saved/restored at all.Verification
Ascend 910B4 (
torch 2.15.0.dev + torch_npu), 2 processes viatorchrun, real HCCL process group, calling the actualreduce_sum_across_dp_group()from this file (file copied byte-identically to the runner, md5 checked) withDeviceMesh("npu", [0, 1]):before (unmodified file):
after (this PR):
Each rank keeps its own device (
npu:0/npu:1) and the collective result is correct (2 ranks x 3 = 6).Not tested
npumesh type was exercised; CUDA/XPU meshes were not run (the change is a pure device lookup).xtunertraining loop was not run - only this helper under a real multi-process HCCL group. The only stubs were the sibling modules imported bydataloader.py(collator/packing/sampler/utils), which are unrelated to the function under test.Fixes #2126