mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
[Reland][2/N]Port several test files under test/distributed to Intel GPU (#159473)
For https://github.com/pytorch/pytorch/issues/114850, we will port distributed tests to Intel GPU. This PR will work on some test files under test/distributed. We could enable Intel GPU with following methods and try the best to keep the original code styles: - instantiate_device_type_tests() - use "torch.accelerator.current_accelerator()" to determine the accelerator backend - use requires_accelerator_dist_backend to allow both nccl and xccl test - enabled XPU for some test path - Change the hardcoded world_size according to device_count. - Unify some common code under torch/testing/_internal for multiple backend, for example: Added xpu for Backend.backend_capability and dist.Backend.register_backend() Pull Request resolved: https://github.com/pytorch/pytorch/pull/159473 Approved by: https://github.com/guangyey, https://github.com/d4l3k
This commit is contained in:
committed by
PyTorch MergeBot
parent
71b272e4a3
commit
c9485f8ff3
@ -337,10 +337,12 @@ class Backend(str): # noqa: SLOT000
|
||||
# assume default devices "cpu" and "cuda", but warn
|
||||
warnings.warn(
|
||||
f"Device capability of {name} unspecified, assuming `cpu` and "
|
||||
"`cuda`. Please specify it via the `devices` argument of "
|
||||
"`cuda` or `xpu`. Please specify it via the `devices` argument of "
|
||||
"`register_backend`."
|
||||
)
|
||||
Backend.backend_capability[name.lower()] = ["cpu", "cuda"]
|
||||
Backend.backend_capability[name.lower()] = (
|
||||
["cpu", "cuda", "xpu"] if torch.xpu.is_available() else ["cpu", "cuda"]
|
||||
)
|
||||
elif isinstance(devices, str):
|
||||
# Single device string specified. Simply convert to list.
|
||||
Backend.backend_capability[name.lower()] = [devices]
|
||||
|
Reference in New Issue
Block a user