I would consider this a workaround and would try to make sure your model is still working as intended.
E.g. you could create some tests using predefined data and compare the outputs, gradients, losses etc.
The recommended way would be to store the state_dict instead of the model directly.