SIGN IN SIGN UP

[distributed] Run legacy-only NCCL tests with nccl-legacy (#193240)

Several tests rely on legacy ProcessGroupNCCL-specific APIs, deferred collective communicator creation, or multiple devices per process. Select nccl-legacy explicitly for those compatibility tests so switching the nccl alias to NCCL2 does not change what they are intended to exercise.

Test Plan:

```bash
CUDA_VISIBLE_DEVICES=0,1 VIRTUAL_ENV=/home/tristanr/pytorch/.venv PATH=/home/tristanr/pytorch/.venv/bin:$PATH /home/tristanr/.local/bin/uv run --no-project test/distributed/test_c10d_nccl.py ProcessGroupNCCLInitTest.test_init_wo_backend_str
CUDA_VISIBLE_DEVICES=0,1,2,3 VIRTUAL_ENV=/home/tristanr/pytorch/.venv PATH=/home/tristanr/pytorch/.venv/bin:$PATH /home/tristanr/.local/bin/uv run --no-project test/distributed/test_device_mesh.py DeviceMeshTest.test_2d_mesh_non_eager_init_subgroup
CUDA_VISIBLE_DEVICES=0,1,2,3 VIRTUAL_ENV=/home/tristanr/pytorch/.venv PATH=/home/tristanr/pytorch/.venv/bin:$PATH /home/tristanr/.local/bin/uv run --no-project test/distributed/optim/test_zero_redundancy_optimizer.py TestZeroRedundancyOptimizerDistributed -k zero_model_parallel
```

Authored with an AI assistant.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/193240
Approved by: https://github.com/kapilsh
ghstack dependencies: #193237, #193238
T
Tristan Rice committed
94055e9ef64834496cd136a1bf5ddd2621a5be83
Parent: f29a285
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com> on 8/25/2026, 6:43:17 AM