One thing I always recommend when doing this sort of experiment is to check whether it is more likely to be numerical accuracy or an algorithmic difference.
So if you add the dtype=torch.double argument to the torch.linspace call, you’ll see that the difference goes down significantly (for me from 9e-4ish to 7e-14ish).
This points to the algorithms computing the same result but perhaps having a different order for the additions, which typically leads to some discrepancy due to numerical precision.
Best regards
Thomas