Skip to content

Commit 0d8a556

Browse files
committed
also for pytorch lightning no distributed
1 parent daa215d commit 0d8a556

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/tests_pytorch/utilities/test_imports.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ def test_import_pytorch_lightning_with_torch_dist_unavailable():
117117
code = dedent(
118118
"""
119119
import torch
120+
try:
121+
# PyTorch 2.5 relies on torch,distributed._composable.fsdp not
122+
# existing with USE_DISTRIBUTED=0
123+
import torch._dynamo.variables.functions
124+
torch._dynamo.variables.functions._fsdp_param_group = None
125+
except ImportError:
126+
pass
120127
121128
# pretend torch.distributed not available
122129
for name in list(torch.distributed.__dict__.keys()):
@@ -125,6 +132,11 @@ def test_import_pytorch_lightning_with_torch_dist_unavailable():
125132
126133
torch.distributed.is_available = lambda: False
127134
135+
# needed for Dynamo in PT 2.5+ compare the torch.distributed source
136+
class _ProcessGroupStub:
137+
pass
138+
torch.distributed.ProcessGroup = _ProcessGroupStub
139+
128140
import lightning.pytorch
129141
"""
130142
)

0 commit comments

Comments
 (0)