Repository: pytorch
Issue: inconsistency in ```torch.special.entr``` on CPU and GPU
Labels: triaged,module: correctness (silent),module: special

### 🐛 Describe the bug

getting different results on CPU and GPU when computing ```torch.special.entr```

``` python # 
#include <iostream>
#include <torch/torch.h>

int main(){
    torch::Tensor tensor = torch::tensor({
    {
        {
            {{-1.4375, -1.1172}, {-0.3379, -0.2910}},
            {{-0.7227, -0.6094}, {0.1611, 0.1992}}
        },
        {
            {{0.0464, -1.6797}, {1.5156, -0.5039}},
            {{-0.9531, -0.0569}, {-0.0757, 2.7969}}
        }
    },
    {
        {
            {{-0.0444, -0.2441}, {0.8164, -2.0625}},
            {{0.0046, -0.5547}, {-1.8750, 1.7422}}
        },
        {
            {{1.9375, 0.2930}, {0.2480, -0.9180}},
            {{-0.7305, 0.1426}, {0.0605, 0.2578}}
        }
    }
    }, torch::kBFloat16);

    auto tensor_cuda = tensor.cuda();
    
    std::cout << "initialized tensor (CPU):\n" << tensor << std::endl;

    auto result_cpu = torch::special::entr(tensor);

    auto result_gpu = torch::special::entr(tensor_cuda);

    std::cout << "CPU result: \n" << result_cpu << std::endl;
    std::cout << "GPU result: \n" << result_gpu << std::endl;

    bool inconsistent = !torch::allclose(result_cpu, result_gpu.cpu(), 1e-03, 1e-02);
    std::cout << "inconsistency with atol=1e-02 and rtol=1e-03: " << std::boolalpha << inconsistent << std::endl;
}

```
outputs (take a look at matrix (2,1,2,.,.) in cpu and gpu results):
```
initialized tensor (CPU):
(1,1,1,.,.) = 
 -1.4375 -1.1172
 -0.3379 -0.2910

(2,1,1,.,.) = 
 -0.0444 -0.2441
  0.8164 -2.0625

(1,2,1,.,.) = 
  0.0464 -1.6797
  1.5156 -0.5039

(2,2,1,.,.) = 
  1.9375  0.2930
  0.2480 -0.9180

(1,1,2,.,.) = 
 -0.7227 -0.6094
  0.1611  0.1992

(2,1,2,.,.) = 
  0.0046 -0.5547
 -1.8750  1.7422

(1,2,2,.,.) = 
 -0.9531 -0.0569
 -0.0757  2.7969

(2,2,2,.,.) = 
 -0.7305  0.1426
  0.0605  0.2578
[ CPUBFloat16Type{2,2,2,2,2} ]

CPU result: 
(1,1,1,.,.) = 
 -inf -inf
 -inf -inf

(2,1,1,.,.) = 
    -inf    -inf
  0.1660    -inf

(1,2,1,.,.) = 
  0.1426    -inf
 -0.6289    -inf

(2,2,1,.,.) = 
 -1.2812  0.3594
  0.3457    -inf

(1,1,2,.,.) = 
    -inf    -inf
  0.2949  0.3223

(2,1,2,.,.) = 
 0.01 *
  2.4780    -inf
     -inf -96.4844

(1,2,2,.,.) = 
    -inf    -inf
    -inf -2.8906

(2,2,2,.,.) = 
    -inf  0.2773
  0.1689  0.3496
[ CPUBFloat16Type{2,2,2,2,2} ]

GPU result: 
(1,1,1,.,.) = 
 -inf -inf
 -inf -inf

(2,1,1,.,.) = 
    -inf    -inf
  0.1660    -inf

(1,2,1,.,.) = 
  0.1426    -inf
 -0.6289    -inf

(2,2,1,.,.) = 
 -1.2812  0.3594
  0.3457    -inf

(1,1,2,.,.) = 
    -inf    -inf
  0.2949  0.3223

(2,1,2,.,.) = 
 0.01 *
  2.4780    -inf
     -inf -96.8750

(1,2,2,.,.) = 
    -inf    -inf
    -inf -2.8750

(2,2,2,.,.) = 
    -inf  0.2773
  0.1699  0.3496
[ CUDABFloat16Type{2,2,2,2,2} ]

inconsistency with atol=1e-02 and rtol=1e-03: true
```

### Versions

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 16.0.4 (https://github.com/llvm/llvm-project ae42196bc493ffe877a7e3dff8be32035dea4d07)
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.9.19 (main, May 6 2024, 19:43:03) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-105-generic-x86_64-with-glibc2.35
Is CUDA available: N/A
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration:
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090
GPU 2: NVIDIA GeForce RTX 3090
GPU 3: NVIDIA GeForce RTX 3090

Nvidia driver version: 550.78
cuDNN version: Probably one of the following:
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.2
/usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.2
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 96
On-line CPU(s) list: 0-95
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
CPU family: 6
Model: 85
Thread(s) per core: 2
Core(s) per socket: 24
Socket(s): 2
Stepping: 7
CPU max MHz: 4000.0000
CPU min MHz: 1200.0000
BogoMIPS: 6000.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 1.5 MiB (48 instances)
L1i cache: 1.5 MiB (48 instances)
L2 cache: 48 MiB (48 instances)
L3 cache: 71.5 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-23,48-71
NUMA node1 CPU(s): 24-47,72-95
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] optree==0.11.0
[pip3] torch==2.2.0a0+git9fa3350
[conda] magma-cuda121 2.6.1 1 pytorch
[conda] mkl 2023.1.0 h213fc3f_46344
[conda] mkl-include 2023.1.0 h06a4308_46344
[conda] numpy 1.26.4 pypi_0 pypi
[conda] optree 0.11.0 pypi_0 pypi
[conda] torch 2.2.0a0+git9fa3350 dev_0

cc @mruberry @kshitij12345