I would say that it should work always you add nn.parameters or buffers which are the ones tracked by the state_dict.
If you try to save other type of variables it will fail. I would recommend to pass them in the init function such that the constructor can recover them at the time of instantiating the class.
Another possibility is you are kind of hardcoding them not using the tools provided which properly register parameters.