Skip to content

fix(train): select XCCL as the XPU distributed backend instead of NCCL - #3786

Open
li-lizhe wants to merge 1 commit into
modelscope:mainfrom
li-lizhe:fix/xpu-dist-backend-xccl
Open

li-lizhe wants to merge 1 commit into
modelscope:mainfrom
li-lizhe:fix/xpu-dist-backend-xccl

Conversation

@li-lizhe

Copy link
Copy Markdown
Contributor

Summary

get_default_dist_backend() returns "nccl" for every device that is not Ascend NPU. Since
get_accelerator_device_type() does select XPU, an XPU run reaches
init_process_group(backend="nccl") and cannot start at all on a build without NCCL
(RuntimeError: Distributed package doesn't have NCCL built in) - the same class of failure #3771
fixed for Ascend NPU. This is the follow-up tracked in #3777, which was kept out of #3771 only
because that change had no XPU hardware to exercise the new path.

Change

  • add the XPU entry to _ACCELERATOR_DIST_BACKENDS: "xpu": ("xccl", "ccl");
  • the existing probe logic does the rest: torch.distributed.is_xccl_available() wins, a build that
    only exposes the former oneCCL name (is_ccl_available()) resolves to "ccl", and a build that
    exposes no probe keeps the first (canonical) name, "xccl" - the same convention already used for
    HCCL on Ascend;
  • docstring/comment updated: the "XPU is deliberately absent" note that this follow-up was waiting
    on is gone;
  • tests/test_distributed_device_setup.py: the case that pinned XPU to the historical "nccl" is
    replaced by three: XPU resolves to "xccl", "xccl" wins when both probes report available, and
    "ccl" is used when only that probe does.

Fixes #3777.

Verification

probe state on the build get_default_dist_backend() for XPU
before this change "nccl"
is_xccl_available() true "xccl"
only is_ccl_available() true "ccl"
no probe exposed "xccl" (first/canonical name)

Local CPU-only venv (torch 2.8.0+cpu, pytest 9.1.1), pytest tests/test_distributed_device_setup.py:
10 passed with this change; with only the _ACCELERATOR_DIST_BACKENDS line reverted and the new
tests kept: 3 failed, 7 passed (the three new XPU cases), so the cases do lock the behaviour.

Not tested: a real 2-rank torchrun on Intel XPU with XCCL. No XPU device exists in this
environment, so the runtime path is only verified as far as the backend selection itself - I am
flagging that here rather than claiming an XPU run. The CUDA and Ascend NPU paths are untouched. If
you would rather hold this until someone with XPU hardware confirms it end to end, the change is a
one-line mapping plus tests and is easy to revert.

get_default_dist_backend() returned the historical "nccl" for every device
that is not Ascend NPU, but get_accelerator_device_type() does select XPU, so an
XPU run reached init_process_group(backend="nccl") and could not start on a
build without NCCL. Resolve XPU to XCCL (legacy oneCCL name "ccl" where that is
the only probe the build exposes).

Fixes modelscope#3777.

Signed-off-by: li-lizhe <147392333@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dist] XPU distributed backend selection (XCCL / oneCCL) is unverified — needs XPU hardware

1 participant