Repository: pytorch
Issue: [jit.script] jit.script give uncertain results using torch.half
Labels: oncall: jit,module: nvfuser

### 🐛 Describe the bug

`torch.jit.script` give uncertain results using `torch.half`. The result of the first execution of the function is different from that of the second execution, but the result is the same since the second execution. Here is the code to reproduce.

```
import math
import torch

@torch.jit.script
def f(x):
    return torch.tanh(math.sqrt(2.0 / math.pi) * x)

x = torch.rand((32,), dtype=torch.half).cuda()
res = []
for i in range(5):
    res.append(f(x))
for i in range(5):
    for j in range(i+1, 5):
        print(f"{i} {j}: {(res[i]-res[j]).nonzero().any()}")
```

the result is:

```
0 0: False
0 1: True
0 2: True
0 3: True
0 4: True
1 1: False
1 2: False
1 3: False
1 4: False
2 2: False
2 3: False
2 4: False
3 3: False
3 4: False
4 4: False
```

please note that the problem does not exist using `torch.float`. And also not exists without `@torch.jit.script`

### Versions

Collecting environment information...
PyTorch version: 1.12.0a0+git67ece03
Is debug build: False
CUDA used to build PyTorch: 11.0
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: version 3.22.5
Libc version: glibc-2.27

Python version: 3.9.7 (default, Sep 16 2021, 13:09:58)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-3.10.0-1127.el7.x86_64-x86_64-with-glibc2.27
Is CUDA available: True
CUDA runtime version: 11.0.221
GPU models and configuration: 
GPU 0: NVIDIA A100-SXM4-40GB
GPU 1: NVIDIA A100-SXM4-40GB
GPU 2: NVIDIA A100-SXM4-40GB
GPU 3: NVIDIA A100-SXM4-40GB
GPU 4: NVIDIA A100-SXM4-40GB
GPU 5: NVIDIA A100-SXM4-40GB
GPU 6: NVIDIA A100-SXM4-40GB
GPU 7: NVIDIA A100-SXM4-40GB

Nvidia driver version: 470.103.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.20.3
[pip3] torch==1.12.0a0+git67ece03
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] _pytorch_select           0.1                       cpu_0    https://10.251.102.1/anaconda/pkgs/main
[conda] blas                      1.0                         mkl    https://10.251.102.1/anaconda/pkgs/main
[conda] cudatoolkit               11.3.1               h2bc3f7f_2    https://10.251.102.1/anaconda/pkgs/main
[conda] libmklml                  2019.0.5             h06a4308_0    https://10.251.102.1/anaconda/pkgs/main
[conda] mkl                       2020.2                      256    https://10.251.102.1/anaconda/pkgs/main
[conda] numpy                     1.20.3           py39hdbf815f_1    https://10.251.102.1/anaconda/cloud/conda-forge
[conda] pytorch                   1.11.0          py3.9_cuda11.3_cudnn8.2.0_0    https://10.251.102.1/anaconda/cloud/pytorch
[conda] pytorch-mutex             1.0                        cuda    https://10.251.102.1/anaconda/cloud/pytorch
[conda] torch                     1.12.0a0+git67ece03          pypi_0    pypi
[conda] torchaudio                0.11.0               py39_cu113    https://10.251.102.1/anaconda/cloud/pytorch
[conda] torchvision               0.12.0               py39_cu113    https://10.251.102.1/anaconda/cloud/pytorch