Hi,
From a quick look I would say it is one of the two:

Your model.reset_train_data actually changes some tensors inplace that are used in the backward pass or has some unexpected side effect.
If update_episode is large(ish) then yes it can be numerical precision errors. It is expected that even the slightest difference will lead to completely different weights after training.

To check that I would:

Make sure the weights are the same before running tests. Even the slightest difference will give different gradients.
Check that it works for update_episode=1

Check what is the error for update_episode=2, if it is already big, then it’s potentially the first. If the error increases when you increase update_episode, then it is most likely the second.