A device is bound for multi-rank jobs, and not for a single-rank one (#8248).
(expect_bound)
| 549 | |
| 550 | |
| 551 | def assert_device_binding(expect_bound): |
| 552 | """A device is bound for multi-rank jobs, and not for a single-rank one (#8248).""" |
| 553 | if get_accelerator().communication_backend_name() != 'nccl': |
| 554 | pytest.skip("device_id is only bound for the nccl backend") |
| 555 | |
| 556 | deepspeed.init_distributed(dist_backend='nccl', auto_mpi_discovery=False) |
| 557 | default_pg = torch.distributed.distributed_c10d._get_default_group() |
| 558 | assert (default_pg.bound_device_id is not None) == expect_bound |
| 559 | |
| 560 | # The eager split new_group() makes when a device is bound is the call that fails in #8248. |
| 561 | device = get_accelerator().device(int(os.environ["LOCAL_RANK"])) |
| 562 | default_backend = default_pg._get_backend(device) |
| 563 | if hasattr(default_backend, "comm_split_count"): |
| 564 | splits_before = default_backend.comm_split_count() |
| 565 | torch.distributed.new_group(ranks=list(range(dist.get_world_size()))) |
| 566 | assert (default_backend.comm_split_count() > splits_before) == expect_bound |
| 567 | |
| 568 | |
| 569 | class TestSingleRankDeviceId(DistributedTest): |
no test coverage detected