Skip to content

Commit

Permalink
Update src/accelerate/accelerator.py
Browse files Browse the repository at this point in the history
Co-authored-by: Zach Mueller <[email protected]>
  • Loading branch information
SunMarc and muellerzr authored Nov 7, 2023
1 parent eda082f commit 5419ad2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/accelerate/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2580,9 +2580,8 @@ def save_model(

os.makedirs(save_directory, exist_ok=True)

for param in model.parameters():
if param.device == torch.device("meta"):
raise RuntimeError("You can't save the model since some parameters are on the meta device.")
if any(param.device == torch.device("meta") for param in model.parameters()):
raise RuntimeError("You can't save the model since some parameters are on the meta device.")

# get the state_dict of the model
state_dict = self.get_state_dict(model)
Expand Down

0 comments on commit 5419ad2

Please sign in to comment.