Solved by KFrank in post #2 
              
              
                Hi py! 

This is floating-point round-off error.  First cast X to a 
dtype = torch.double tensor, and then redo your test. 
Your “right” numbers and “wrong” numbers will now agree 
to about twice as many decimal places. 
Best. 
K. Frank