Skip to content

Commit 857637a

Browse files
committed
linting
1 parent 7293e6e commit 857637a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lightning/pytorch/loops/training_epoch_loop.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from typing import Any, Optional, Union
1919

2020
import torch
21-
import torch.distributed as dist
2221
from typing_extensions import override
2322

2423
import lightning.pytorch as pl
@@ -258,13 +257,13 @@ def _broadcast_sigterm_tensor(self):
258257
[1 if getattr(self.trainer, "received_sigterm", False) else 0],
259258
device=self.trainer.strategy.root_device,
260259
)
261-
dist.broadcast(sigterm_tensor, src=0)
260+
torch.distributed.broadcast(sigterm_tensor, src=0)
262261
except Exception:
263262
sigterm_tensor = torch.tensor([0], device=self.trainer.strategy.root_device)
264263

265264
if sigterm_tensor.item() == 1:
266265
with contextlib.suppress(Exception):
267-
dist.barrier() # prevent deadlocks by syncing all ranks before exit
266+
torch.distributed.barrier() # prevent deadlocks by syncing all ranks before exit
268267
raise SIGTERMException()
269268

270269
def advance(self, data_fetcher: _DataFetcher) -> None:
@@ -292,7 +291,7 @@ def advance(self, data_fetcher: _DataFetcher) -> None:
292291

293292
# =====================================================================
294293

295-
if dist.is_available() and dist.is_initialized() and self.trainer.world_size > 1:
294+
if torch.distributed.is_available() and torch.distributed.is_initialized() and self.trainer.world_size > 1:
296295
self._broadcast_sigterm_tensor()
297296

298297
# =====================================================================

0 commit comments

Comments
 (0)