[BUG?] Torch.load loads different values for the same file in each time

Hello

I have saved a pytorch tensor which I have obtained from some optimization procedure, and I save it as a file.

I have noticed that i get different values for the same tensor loaded in each time I load it.

First try:

tensor([[ 0.0423,  0.0015,  0.0025,  ..., -0.0053, -0.0032,  0.0013],
        [ 0.0048,  0.0129, -0.0160,  ...,  0.0002, -0.0005, -0.0035],
        [ 0.0763, -0.0221,  0.0303,  ..., -0.0008, -0.0018, -0.0009],
        ...,
        [-0.0067, -0.0207, -0.0157,  ..., -0.0009,  0.0042, -0.0030],
        [ 0.0059, -0.0294, -0.0113,  ..., -0.0066,  0.0115,  0.0053],
        [-0.0429, -0.0239, -0.0362,  ...,  0.0038,  0.0119,  0.0004]])

Second try:

tensor([[ 4.7368e-24,  0.0000e+00,  6.4595e-24,  ..., -5.3488e-03,
         -3.1589e-03,  1.3454e-03],
        [ 4.8110e-03,  1.2933e-02, -1.5969e-02,  ...,  2.2385e-04,
         -4.8361e-04, -3.5191e-03],
        [ 7.6261e-02, -2.2051e-02,  3.0303e-02,  ..., -7.5350e-04,
         -1.7584e-03, -9.4366e-04],
        ...,
        [-6.6854e-03, -2.0729e-02, -1.5737e-02,  ..., -9.4584e-04,
          4.1868e-03, -2.9629e-03],
        [ 5.8720e-03, -2.9389e-02, -1.1321e-02,  ..., -6.6035e-03,
          1.1492e-02,  5.3333e-03],
        [-4.2901e-02, -2.3902e-02, -3.6203e-02,  ...,  3.7728e-03,
          1.1884e-02,  4.2430e-04]])

Third try:

tensor([[-1.7079e+38,  5.6052e-45,  9.2569e-32,  ..., -1.7414e+38,
          3.5733e-43,  2.1366e-34],
        [ 1.4507e-39,  9.5536e-38,  1.1210e-44,  ...,  1.4507e-39,
          3.1854e-23,  1.1210e-44],
        [ 1.2180e-31,  1.3689e-39,  2.7985e-39,  ...,  2.1367e-34,
          2.9186e-39,  7.0129e-21],
        ...,
        [ 1.4486e-39,  3.3822e-26,  9.0042e-41,  ...,  1.4586e-39,
          1.2915e-19,  7.0312e-41],
        [ 3.7297e-34,  1.4586e-39,  1.3919e-16,  ...,  1.4481e-36,
          1.4586e-39,  3.3473e-39],
        [ 5.3249e-44,  3.0248e-39,  1.2986e-39,  ...,  3.0829e-44,
          5.8775e-39,  7.3361e-39]])

Can this be a bug?

Pytorch version is : 1.13.0+cu116

Looks like a bug assuming the file didn’t change. Could you update PyTorch and check if you still observe this issue?

1 Like