The mistake is to compare floating point variables with == instead of torch.allclose.
What you are seeing is that floating point numbers are not as nice as actual real numbers. For example, addition (of multiple values) does not commute due to numerical precision effects: Try print(1e20 + 1 - 1e20).
One of my recommendations to get a first impression of whether you hit numerical accuracy is to do the same computation with dtype=torch.double tensors. If the difference ((r1-r2).abs().max()) goes down dramatically (say from 1e-5ish to 1e-13ish in your example), this points to numerical accuracy issues. If it stays the same, this might point to a different issue (if only an approximation somewhere in the computation).
Best regards
Thomas