Is it impossible to pickle model with hook?

Hi, I am facing a similar situation with these questions from different years:

And all of them don’t have an answer yet. So, Is it impossible to pickle a PyTorch model that contains hook?

Interesting, the easiest way to solve this is to

It might be possible to also pickle hooks if you wrap them in classes as a nice to have cc @albanD but regardless in the meantime state_dict() is the way to go

Serializing only the state_dict is the way around pickle’s limitations yes!

I see… thank you for the clarification!