Skip to content

Commit b9c9efd

Browse files
committed
Fix test
1 parent 2f7ab75 commit b9c9efd

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/core/test_results.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from torch.utils.data import DataLoader
2222

2323
import tests.helpers.utils as tutils
24-
from pytorch_lightning import Trainer
24+
from pytorch_lightning import LightningModule, Trainer
2525
from pytorch_lightning.core.step_result import Result
2626
from tests.helpers import BoringDataModule, BoringModel
2727
from tests.helpers.runif import RunIf
@@ -36,24 +36,20 @@ def _setup_ddp(rank, worldsize):
3636
dist.init_process_group("gloo", rank=rank, world_size=worldsize)
3737

3838

39-
def _ddp_test_fn(rank, worldsize, result_cls: Result):
39+
def _ddp_test_fn(rank, worldsize):
4040
_setup_ddp(rank, worldsize)
4141
tensor = torch.tensor([1.0])
42-
43-
res = result_cls()
44-
res.log("test_tensor", tensor, sync_dist=True, sync_dist_op=torch.distributed.ReduceOp.SUM)
45-
46-
assert res["test_tensor"].item() == dist.get_world_size(), "Result-Log does not work properly with DDP and Tensors"
42+
actual = LightningModule._LightningModule__sync(tensor, sync_dist=True, sync_dist_op=torch.distributed.ReduceOp.SUM)
43+
assert actual.item() == dist.get_world_size(), "Result-Log does not work properly with DDP and Tensors"
4744

4845

4946
@RunIf(skip_windows=True)
5047
def test_result_reduce_ddp():
5148
"""Make sure result logging works with DDP"""
5249
tutils.reset_seed()
5350
tutils.set_random_master_port()
54-
5551
worldsize = 2
56-
mp.spawn(_ddp_test_fn, args=(worldsize, Result), nprocs=worldsize)
52+
mp.spawn(_ddp_test_fn, args=(worldsize, ), nprocs=worldsize)
5753

5854

5955
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)