float operation are not associative I’m afraid. So it’s going to be impossible to make them match exactly unless you know exactly in which order each op is executed.
From that point, depending on the other values, the small difference might increase quite fast.
Your code looks ok.
I would compute the difference between the prediction and the ground truth once and reuse it.
You can check the intermediary results to see if it’s just an error getting bigger and bigger.