Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way load_path is handled #132

Merged
merged 7 commits into from
Jan 7, 2025
Merged

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented Jan 6, 2025

No description provided.

@epwalsh epwalsh requested review from dirkgr and 2015aroras January 6, 2025 18:48
Copy link
Contributor

@2015aroras 2015aroras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -75,17 +75,19 @@ class LoadStrategy(StrEnum):

if_available = "if_available"
"""
Only load from the load path if a checkpoint exists there.
The trainer will attempt to load a checkpoint from the save folder or load path (in that order)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating these! I started reviewing before you updated them and got confused.

elif self.load_strategy == LoadStrategy.if_available:
self.maybe_load_checkpoint(load_path)
if not self.checkpoint_loaded and self.load_strategy != LoadStrategy.never:
if not self.maybe_load_checkpoint(self.save_folder) and self.load_path is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'm not a fan of self.maybe_load_checkpoint(self.save_folder) being in the if statement due to its side-effect nature of setting self._checkpoint_loaded.

Moreover, I'm not a fan of self.maybe_load_checkpoint returning a bool that isn't self._checkpoint_loaded. Imo we should either

  1. remove self._checkpoint_loaded
  2. (my favorite) make self.maybe_load_checkpoint not return anything and rely explicitly on self.checkpoint_loaded
  3. make self.maybe_load_checkpoint return self.checkpoint_loaded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point about the if statement, changed in d01aafc.

But I do think it's a useful part of the API for maybe_load_checkpoint() to return a boolean, and this shouldn't necessarily be the value of self._checkpoint_loaded, since self._checkpoint_loaded tells you whether any checkpoint has been loaded at any point in time, whereas the return value of maybe_load_checkpoint tells you if a checkpoint was loaded this time from the given load path.

Copy link
Member

@dirkgr dirkgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change, but didn't read the code closely, since @2015aroras is already on it.

@epwalsh epwalsh merged commit 7519e0a into main Jan 7, 2025
14 checks passed
@epwalsh epwalsh deleted the epwalsh/checkpoint-fixes branch January 7, 2025 21:41
Copy link

This PR has been released in v1.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants