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.