Skip to content

Commit

Permalink
also for pytorch lightning no distributed
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi committed Nov 7, 2024
1 parent fe2a044 commit 272605d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tests_pytorch/utilities/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def test_import_pytorch_lightning_with_torch_dist_unavailable():
code = dedent(
"""
import torch
try:
# PyTorch 2.5 relies on torch,distributed._composable.fsdp not
# existing with USE_DISTRIBUTED=0
import torch._dynamo.variables.functions
torch._dynamo.variables.functions._fsdp_param_group = None
except ImportError:
pass
# pretend torch.distributed not available
for name in list(torch.distributed.__dict__.keys()):
Expand All @@ -125,6 +132,11 @@ def test_import_pytorch_lightning_with_torch_dist_unavailable():
torch.distributed.is_available = lambda: False
# needed for Dynamo in PT 2.5+ compare the torch.distributed source
class _ProcessGroupStub:
pass
torch.distributed.ProcessGroup = _ProcessGroupStub
import lightning.pytorch
"""
)
Expand Down

0 comments on commit 272605d

Please sign in to comment.