Repository: pytorch
Issue: [ROCm] sorting torch.bool tensor viewed from torch.uint8 type produces incorrect results
Labels: module: rocm,triaged

### 🐛 Describe the bug

Small tensor with radix sort:
```
a = torch.randint(0, 100, [100], dtype=torch.uint8, device="cuda")
>>> torch.sort(a)
torch.return_types.sort(
values=tensor([ 0,  0,  1,  1,  5,  5,  6,  6,  9, 10, 11, 12, 13, 14, 16, 17, 17, 18,
        19, 19, 20, 23, 23, 25, 25, 25, 27, 28, 29, 29, 30, 32, 33, 33, 34, 35,
        35, 37, 38, 38, 39, 40, 42, 42, 43, 46, 47, 48, 48, 50, 56, 56, 57, 59,
        60, 61, 62, 62, 63, 64, 64, 67, 68, 68, 69, 69, 70, 70, 71, 72, 72, 74,
        78, 79, 80, 82, 82, 82, 82, 82, 82, 83, 83, 84, 84, 86, 87, 88, 89, 91,
        92, 93, 94, 94, 94, 94, 94, 95, 98, 99], device='cuda:0',
       dtype=torch.uint8),
indices=tensor([15, 25, 49, 68,  7, 76, 18, 41, 39, 45, 46,  4, 57, 20, 59, 44, 67,  9,
        16, 89, 21, 30, 40, 34, 84, 85, 90, 10, 12, 24, 69, 17,  8, 62, 94, 52,
        78, 95, 26, 47, 58, 63, 82, 96, 66, 13, 88, 43, 99, 14, 37, 75, 61, 31,
        79, 60, 48, 83, 80,  3, 50, 22,  2, 97,  0, 65, 27, 54, 53, 42, 87, 92,
        71, 19, 93, 29, 32, 38, 51, 56, 77, 11, 23,  1, 73,  5,  6, 55, 28, 72,
        86, 81, 35, 36, 64, 74, 98, 33, 70, 91], device='cuda:0'))
>>> torch.sort(a.view(torch.bool))
torch.return_types.sort(
values=tensor([ True,  True,  True,  True,  True, **False**,  True,  True, **False**,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True,  True,  True,  True,  True,  True,  True,  True,  True],
       device='cuda:0'),
indices=tensor([ 1,  2,  3,  4, 10, 15, 17, 21, 25, 37, 42, 43, 50, 55, 59, 63, 73, 75,
        79, 86, 87, 93, 97, 99,  0,  7,  8, 12, 24, 28, 34, 39, 44, 49, 57, 60,
        61, 62, 65, 67, 68, 76, 81, 84, 85, 95,  0,  0,  0,  0,  0,  0,  0,  0,
         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
         0,  0,  5,  9, 13, 14, 18, 20, 26, 27, 29, 32, 35, 36, 38, 41, 45, 47,
        48, 51, 54, 56, 64, 69, 70, 71, 74, 77], device='cuda:0'))
```

For large tensor, the stable sort from cub produces wildly off results:

```
>>> a = torch.randint(0, 100, [8000], dtype=torch.uint8, device="cuda")
>>> torch.sort(a)
torch.return_types.sort(
values=tensor([ 0,  0,  0,  ..., 99, 99, 99], device='cuda:0', dtype=torch.uint8),
indices=tensor([ 396,  451,  759,  ..., 7751, 7771, 7834], device='cuda:0'))
>>> torch.sort(a.view(torch.bool))
torch.return_types.sort(
values=tensor([False, False, False,  ..., False, False,  True], device='cuda:0'),
indices=tensor([                396,                 451,                 759,
         ..., 9187343241974906880, 9187343239835811840,
                       7167], device='cuda:0'))
```

### Versions

top of trunk

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang @naromero77amd