The difference is caused in the large number in hist[0] and hist2[0].
The default float32 dtype can represent integers between 0 and 16777216 exactly but starts to round for larger (or smaller negative integers) as:

Integers between 2**24=16777216 and 2**25=33554432 round to a multiple of 2 (even number)
Integers between 2**25 and 2**26 round to a multiple of 4
…
Integers between 2**n and 2**n+1 round to a multiple of 2**n-23


as given in this Wikipedia article.
As you can see in your code, hist[0] will contain values >2**25 so will necessarily apply rounding during the accumulation.
Since the order of operations is not equal, you can’t expect to see the same results when shuffling is enabled or disabled. Use float64 to compare such large numbers instead (or long int etc.).
Initializing hist as:
hist = torch.zeros(bins).double()

gives a zero difference.