Why two PyTorch tensors with the same content are serialized to two files that differ?

If I a question about saving (pickling) PyTorch tensors.

Let’s take a tensor and make a copy. We end with two exactly the same tensors, e.g. like here:

x = torch.rand(10)
y = torch.zeros_like(x)  
y.copy_(x)

# x and y are the same, you can check with: x.ne(y).sum() == 0

We then save them:

torch.save(x, 'x.pt')
torch.save(y, 'y.pt')

And check if the binary files differ:

diff x.pt y.pt
Binary files x.pt and y.pt differ

They do. Why?

NB: If I do exactly the same for NumPy arrays the pickle files don’t differ.

Over 2 years late, but I tried to replicate this and x.pt and y.pt are identical using Python 3.8.8 and Torch 1.12.1. Using cmp x.pt y.pt and diff x.pt y.pt