The numpy array and PyTorch tensor should be bitwise accurate, as they are sharing the same underlying data as seen here:
x = torch.tensor(1/3)

print('{:.20f}'.format(x))
print('{:.20f}'.format(x.numpy()))
print('{:.20f}'.format(x.numpy().astype(np.float64)))

y = x.numpy()
y += 0.1

print('{:.20f}'.format(x))
print('{:.20f}'.format(x.numpy()))
print('{:.20f}'.format(x.numpy().astype(np.float64)))




 maxcompression:

I then tried to convert the Pytorch tensors to np.float128, which makes it more precise, but still not sure whether I am capturing the full precision of the Pytorch tensors.


Upcasting the data should not make the result more precise, as the original value was already represented in the lower precision.