You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
As title, this indicates to callers if the states were restored or not. This allows callers to do logic like:
```
restored = TorchSnapshotSaver.restore_from_latest(...)
# no prior checkpoints, so initialize weights for the first attempt
if not restored:
<initialization logic>
```
Reviewed By: daniellepintz
Differential Revision: D48207346
fbshipit-source-id: 6ea20dced7ee433aa9ee27f52998e3855a9f217e
Copy file name to clipboardExpand all lines: torchtnt/framework/callbacks/torchsnapshot_saver.py
+25-22
Original file line number
Diff line number
Diff line change
@@ -226,7 +226,6 @@ def restore(
226
226
restore_train_progress: Whether to restore the training progress state.
227
227
restore_eval_progress: Whether to restore the evaluation progress state.
228
228
storage_options: Additional keyword options for the storage plugin to use, to be passed to `torchsnapshot.Snapshot <https://pytorch.org/torchsnapshot/stable/api_reference.html#torchsnapshot.Snapshot>`_. See each storage plugin's documentation for customizations.
229
-
230
229
"""
231
230
232
231
_validate_snapshot_available()
@@ -268,7 +267,7 @@ def restore_from_latest(
268
267
restore_train_progress: bool=True,
269
268
restore_eval_progress: bool=True,
270
269
storage_options: Optional[Dict[str, Any]] =None,
271
-
) ->None:
270
+
) ->bool:
272
271
"""
273
272
Given a parent directory where checkpoints are saved, restore the snapshot state from the latest checkpoint in the directory.
274
273
@@ -282,10 +281,13 @@ def restore_from_latest(
282
281
restore_train_progress: Whether to restore the training progress state.
283
282
restore_eval_progress: Whether to restore the evaluation progress state.
284
283
storage_options: Additional keyword options for the storage plugin to use, to be passed to `torchsnapshot.Snapshot <https://pytorch.org/torchsnapshot/stable/api_reference.html#torchsnapshot.Snapshot>`_. See each storage plugin's documentation for customizations.
284
+
285
+
Returns:
286
+
True if the latest snapshot directory was found and successfully restored, otherwise False.
0 commit comments