Skip to content

Commit

Permalink
Fix torch-numpy compatibility conflict in tests (#20004)
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli authored Jun 22, 2024
1 parent 709a2a9 commit e330da5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements/fabric/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ torch >=2.0.0, <2.4.0
fsspec[http] >=2022.5.0, <2024.4.0
packaging >=20.0, <=23.1
typing-extensions >=4.4.0, <4.10.0
lightning-utilities >=0.8.0, <0.12.0
lightning-utilities >=0.10.0, <0.12.0
2 changes: 1 addition & 1 deletion requirements/pytorch/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ fsspec[http] >=2022.5.0, <2024.4.0
torchmetrics >=0.7.0, <1.3.0 # needed for using fixed compare_version
packaging >=20.0, <=23.1
typing-extensions >=4.4.0, <4.10.0
lightning-utilities >=0.8.0, <0.12.0
lightning-utilities >=0.10.0, <0.12.0
4 changes: 2 additions & 2 deletions src/lightning/fabric/utilities/testing/_runif.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Dict, List, Optional, Tuple

import torch
from lightning_utilities.core.imports import compare_version
from lightning_utilities.core.imports import RequirementCache, compare_version
from packaging.version import Version

from lightning.fabric.accelerators import XLAAccelerator
Expand Down Expand Up @@ -112,7 +112,7 @@ def _runif_reasons(
reasons.append("Standalone execution")
kwargs["standalone"] = True

if deepspeed and not _DEEPSPEED_AVAILABLE:
if deepspeed and not (_DEEPSPEED_AVAILABLE and RequirementCache(module="deepspeed.utils")):
reasons.append("Deepspeed")

if dynamo:
Expand Down
5 changes: 5 additions & 0 deletions tests/tests_fabric/strategies/test_ddp_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pytest
import torch
from lightning.fabric import Fabric
from lightning_utilities.core.imports import RequirementCache
from torch._dynamo import OptimizedModule
from torch.nn.parallel.distributed import DistributedDataParallel

Expand All @@ -27,6 +28,10 @@
from tests_fabric.test_fabric import BoringModel


@pytest.mark.skipif(
RequirementCache("torch<2.4") and RequirementCache("numpy>=2.0"),
reason="torch.distributed not compatible with numpy>=2.0",
)
@pytest.mark.parametrize(
"accelerator",
[
Expand Down
5 changes: 5 additions & 0 deletions tests/tests_fabric/utilities/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
_sync_ddp,
is_shared_filesystem,
)
from lightning_utilities.core.imports import RequirementCache

from tests_fabric.helpers.runif import RunIf

Expand Down Expand Up @@ -121,6 +122,10 @@ def test_collective_operations(devices, process):
spawn_launch(process, devices)


@pytest.mark.skipif(
RequirementCache("torch<2.4") and RequirementCache("numpy>=2.0"),
reason="torch.distributed not compatible with numpy>=2.0",
)
@pytest.mark.flaky(reruns=3) # flaky with "process 0 terminated with signal SIGABRT" (GLOO)
def test_is_shared_filesystem(tmp_path, monkeypatch):
# In the non-distributed case, every location is interpreted as 'shared'
Expand Down

0 comments on commit e330da5

Please sign in to comment.