Error when saving model in accelerate

Here’s what you should really do instead to make sure it all works well. This is how we have Accelerator.save_state currently as well:

def save_model(self, accelerator, model_to_save, model_save_path):
  state = self.accelerator.get_state_dict(model_to_save) # This will call the unwrap model as well
  self.accelerator.save(state, model_save_path)

Can you try this and see if it fixes your problem?

2 Likes