Skip to content

Commit

Permalink
Merge pull request #780 from linshokaku/distributed-snapshot-on-error
Browse files Browse the repository at this point in the history
Fix on_error method in DistributedSnapshot
  • Loading branch information
kmaehashi authored Nov 1, 2023
2 parents 54e9ab9 + 5e5d5d3 commit 979a706
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() # type: ignore

0 comments on commit 979a706

Please sign in to comment.