-
Notifications
You must be signed in to change notification settings - Fork 451
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
Load state dicts to CPU #328
Conversation
load_fsdp_optim_state(self.fsdp_model, self.optim, optim_state_dict) | ||
|
||
# Load other state. | ||
try: | ||
train_state_dict = torch.load(resource_path(load_path, "train.pt", local_cache=local_cache)) | ||
train_state_dict = load_state_dict(load_path, "train.pt", local_cache=local_cache) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no map_location="cpu"
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only one tiny tensor in the trainer state - the GPU RNG state. Which needs to go on GPU anyway.
@@ -218,7 +218,13 @@ def save_state_dict( | |||
upload(target_path, upload_target, save_overwrite=save_overwrite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibeltagy if this doesn't avoid OOM with our LUMI runs we will have to set |
It turns out we can load (legacy) sharded and unsharded checkpoints to CPU via
torch.load()
sinceFSDP.load_state_dict()
will copy tensors to the right device anyway.This should save some GPU memory.