Skip to content

[UT]XCCL remains the default backend for XPU #1721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/apply_torch_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('--pr-list', '-n', nargs='+',
default=[
"https://github.com/pytorch/pytorch/pull/155320"
# Fallback to CPU for XPU FP64
"https://github.com/pytorch/pytorch/pull/126516",
# Modify the tolerance level in TIMM benchmark
Expand Down
17 changes: 17 additions & 0 deletions test/xpu/distributed/test_c10d_xccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,23 @@ def test_all_gather_into_tensor(self):
tensor.view(torch.float32),
)

# Ensure xccl always xpu default distributed backend
@requires_xccl()
def test_xccl_priority(self):
dist.Backend.register_backend(
"fake",
lambda store, rank, size, timeout: dist.ProcessGroup(rank, size),
devices=["xpu"],
)
store = dist.FileStore(self.file_name, self.world_size)
dist.init_process_group(
world_size=self.world_size,
rank=self.rank,
store=store,
)
a = torch.randn(2, device="xpu")
dist.all_reduce(a)
Comment on lines +556 to +568
Copy link
Preview

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After registering the fake backend, consider unregistering it in a finally block or teardown step to avoid side effects on other tests.

Suggested change
dist.Backend.register_backend(
"fake",
lambda store, rank, size, timeout: dist.ProcessGroup(rank, size),
devices=["xpu"],
)
store = dist.FileStore(self.file_name, self.world_size)
dist.init_process_group(
world_size=self.world_size,
rank=self.rank,
store=store,
)
a = torch.randn(2, device="xpu")
dist.all_reduce(a)
try:
dist.Backend.register_backend(
"fake",
lambda store, rank, size, timeout: dist.ProcessGroup(rank, size),
devices=["xpu"],
)
store = dist.FileStore(self.file_name, self.world_size)
dist.init_process_group(
world_size=self.world_size,
rank=self.rank,
store=store,
)
a = torch.randn(2, device="xpu")
dist.all_reduce(a)
finally:
dist.Backend.unregister_backend("fake")

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other cases explicit init with backend xccl, it is safely no unregister.



class SetDeviceMethod(Enum):
TORCH_XPU_SET = auto() # torch.xpu.set_device
Expand Down
Loading