Wow. This thread is really complex.
Here’s what I do to serialize my model after training:
torch.save(model.state_dict(), save_model_filename)

Here’s what I do to deserialize my model:
model = AutoModel.from_pretrained(model_name)
model.load_state_dict(torch.load(save_model_filename))

I’ve use the above code successfully. Let me know if I’ve done anything wrong.