Skip to content

Commit

Permalink
remove duplicate final snapshot path check (#636)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #636

Currently we check if two paths exist (one for snapshot path, and one for snapshot path/.snapshot_metadata) to determine whether to save final checkpoint or not. The first path is not necessary to check, so removing

Reviewed By: galrotem

Differential Revision: D51605223

fbshipit-source-id: bbee62ca74271a8a61317afe5dd2db3295978054
  • Loading branch information
JKSenthil authored and facebook-github-bot committed Nov 28, 2023
1 parent 2d480a5 commit f274a9e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions torchtnt/framework/callbacks/torchsnapshot_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,9 @@ def on_train_end(self, state: State, unit: TTrainUnit) -> None:
)

fs = get_filesystem(snapshot_path)
if fs.exists(snapshot_path):
if fs.exists(os.path.join(snapshot_path, SNAPSHOT_METADATA_FNAME)):
rank_zero_warn(
"Final checkpoint already exists, skipping.", logger=logger
)
return
if fs.exists(os.path.join(snapshot_path, SNAPSHOT_METADATA_FNAME)):
rank_zero_warn("Final checkpoint already exists, skipping.", logger=logger)
return

self._checkpoint_impl(
state,
Expand Down

0 comments on commit f274a9e

Please sign in to comment.