Skip to content

Commit

Permalink
Addition of saver_rank processing when on_error is executed
Browse files Browse the repository at this point in the history
  • Loading branch information
linshokaku committed Oct 31, 2023
1 parent c5b4d58 commit 4ffcf4d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pytorch_pfn_extras/training/extensions/_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,10 @@ def _add_cleanup_hook(self, writer: writing.Writer) -> None:
if self._rank == self._saver_rank:
super()._add_cleanup_hook(writer)

def __call__(self, manager: ExtensionsManagerProtocol) -> None:
if self.condition():
# on distributed environments only the designed rank
# saves the snapshot
if self._rank == self._saver_rank:
self._make_snapshot(manager)
if self._size > 1:
torch.distributed.barrier() # type: ignore[no-untyped-call]
def _make_snapshot(self, manager: ExtensionsManagerProtocol) -> None:
# on distributed environments only the designed rank
# saves the snapshot
if self._rank == self._saver_rank:
super()._make_snapshot(manager)
if self._size > 1:
torch.distributed.barrier()

0 comments on commit 4ffcf4d

Please sign in to comment.