Skip to content
Merged
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
7 changes: 6 additions & 1 deletion test/distributed/fsdp/test_fsdp_tp_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
parallelize_module,
RowwiseParallel,
)
from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
from torch.testing._internal.common_distributed import (
skip_if_lt_x_gpu,
skip_if_not_powerof2_worldsize_xpu,

)
from torch.testing._internal.common_fsdp import FSDPTest
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
Expand Down Expand Up @@ -230,6 +234,7 @@ def _get_grads_as_flattened(
return torch.cat(all_grads_per_param).contiguous()

@skip_if_lt_x_gpu(4)
@skip_if_not_powerof2_worldsize_xpu()
def test_fsdp_tp_integration(self):
self.run_subtests(
{
Expand Down
18 changes: 18 additions & 0 deletions torch/testing/_internal/common_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class TestSkip(NamedTuple):
"importerror": TestSkip(88, "Test skipped due to missing import"),
"no_accelerator": TestSkip(89, "accelerator is not available."),
"not-support-multithread": TestSkip(90, "backend not support multithread."),
"power-of-two": TestSkip(91, "world size needs to be power of two on xpu."),
}


Expand Down Expand Up @@ -210,6 +211,23 @@ def wrapper(*args, **kwargs):
return decorator


def skip_if_not_powerof2_worldsize_xpu():
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
if TEST_XPU:
x = torch.xpu.device_count()
print(f"skip_if_not_powerof2_worldsize_xpu x: {x}")
if (x & (x - 1)) == 0:
return func(*args, **kwargs)
sys.exit(TEST_SKIPS[f"power-of-two"].exit_code)
return func(*args, **kwargs)

return wrapper

return decorator


# This decorator helps avoiding initializing cuda while testing other backends
def nccl_skip_if_lt_x_gpu(backend, x):
def decorator(func):
Expand Down