Skip to content

Commit fbdf042

Browse files
authored
ci: add pytorch 2.12 and 2.13 to cpu tests (#21835)
* ci: add pytorch 2.12 and 2.13 to cpu tests * test: avoid global privateuse1 backend pollution breaking CI on PyTorch 2.12/2.13 * test: simplify with monkeypatch.setitem
1 parent 35c8970 commit fbdf042

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

.github/workflows/ci-tests-fabric.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,29 @@ jobs:
4040
matrix:
4141
os: [macOS-14, ubuntu-22.04, windows-2022]
4242
config:
43+
# TODO: follow-up - prune the oldest PyTorch minors (2.1-2.5) now that we test up to 2.13
4344
# Test unified "lightning" package with PyTorch 2.1-2.5
4445
- { pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
4546
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
4647
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
4748
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
4849
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
4950

50-
# Test "fabric" package with PyTorch 2.6-2.11
51+
# Test "fabric" package with PyTorch 2.6-2.13
5152
- { pkg-name: "fabric", python-version: "3.12.7", pytorch-version: "2.6" }
5253
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.7" }
5354
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.8" }
5455
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.9" }
5556
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.10" }
5657
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.11" }
58+
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.12" }
59+
- { pkg-name: "fabric", python-version: "3.12", pytorch-version: "2.13" }
5760
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.8" }
5861
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.9" }
5962
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.10" }
6063
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.11" }
64+
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.12" }
65+
- { pkg-name: "fabric", python-version: "3.13", pytorch-version: "2.13" }
6166

6267
# Test minimum supported versions (oldest)
6368
- { pkg-name: "fabric", pytorch-version: "2.1", requires: "oldest" }

.github/workflows/ci-tests-pytorch.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,29 @@ jobs:
4444
matrix:
4545
os: [macOS-14, ubuntu-22.04, windows-2022]
4646
config:
47+
# TODO: follow-up - prune the oldest PyTorch minors (2.1-2.5) now that we test up to 2.13
4748
# Test unified "lightning" package with PyTorch 2.1-2.5
4849
- { pkg-name: "lightning", python-version: "3.10", pytorch-version: "2.1" }
4950
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.2.2" }
5051
- { pkg-name: "lightning", python-version: "3.11", pytorch-version: "2.3" }
5152
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.4.1" }
5253
- { pkg-name: "lightning", python-version: "3.12.7", pytorch-version: "2.5.1" }
5354

54-
# Test "pytorch" package with PyTorch 2.6-2.11
55+
# Test "pytorch" package with PyTorch 2.6-2.13
5556
- { pkg-name: "pytorch", python-version: "3.12.7", pytorch-version: "2.6" }
5657
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.7" }
5758
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.8" }
5859
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.9" }
5960
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.10" }
6061
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.11" }
62+
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.12" }
63+
- { pkg-name: "pytorch", python-version: "3.12", pytorch-version: "2.13" }
6164
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.8" }
6265
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.9" }
6366
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.10" }
6467
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.11" }
68+
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.12" }
69+
- { pkg-name: "pytorch", python-version: "3.13", pytorch-version: "2.13" }
6570

6671
# Test minimum supported versions (oldest)
6772
- { pkg-name: "pytorch", pytorch-version: "2.1", requires: "oldest" }

tests/tests_fabric/utilities/test_distributed.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,22 +245,14 @@ def test_init_dist_connection_registers_destruction_handler(_, atexit_mock):
245245
atexit_mock.register.assert_not_called()
246246

247247

248-
def test_get_default_process_group_backend_for_device():
248+
def test_get_default_process_group_backend_for_device(monkeypatch):
249249
"""Test that each device type maps to its correct default process group backend."""
250-
# register a custom backend for test
251-
torch.utils.rename_privateuse1_backend("pcu")
252-
253-
def mock_backend(store, group_rank, group_size, timeout):
254-
pass
255-
256-
torch.distributed.Backend.register_backend(
257-
"pccl",
258-
lambda store, group_rank, group_size, timeout: mock_backend(store, group_rank, group_size, timeout),
259-
devices=["pcu"],
260-
)
250+
# patch the map instead of registering a real backend: `rename_privateuse1_backend` is irreversible
251+
# and would leak a dangling "pcu" device into subsequent tests
252+
monkeypatch.setitem(torch.distributed.Backend.default_device_backend_map, "pcu", "pccl")
261253

262254
# test that the default backend is correctly set for each device
263-
devices = [torch.device("cpu"), torch.device("cuda:0"), torch.device("pcu:0")]
255+
devices = [torch.device("cpu"), torch.device("cuda:0"), Mock(type="pcu")]
264256
backends = ["gloo", "nccl", "pccl"]
265257
for device, backend in zip(devices, backends):
266258
assert _get_default_process_group_backend_for_device(device) == backend

0 commit comments

Comments
 (0)