JIT returns different values for a model on cuda and returns a strange error message on cpu
Labels: oncall: jit, module: correctness (silent)

### 🐛 Describe the bug

JIT returns different values for a model on cuda and returns a strange error message on cpu

On cuda, the return values are different with and without JIT

```py
import torch

device = torch.device('cuda')

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, inp):
        inp1 = torch.add(inp, torch.tensor(-15, dtype=torch.float32, device=device))
        inp.sin_()
        inp2 = torch.chunk(inp1, 1, dim=0)[0]
        inp = inp2
        return inp.neg()

fn = M().to(device)

torch.random.manual_seed(35221)
inp = torch.empty([5], dtype=torch.float32, device=device)
inp.uniform_(-64, 31)
inp = inp.to(device)

print(fn(inp.clone()))

jit_fn = torch.jit.trace(fn, (inp.clone(), ))
print(jit_fn(inp.clone()))
```

```
tensor([47.3687, 70.6420, 70.5528,  6.1166, 78.2205], device='cuda:0')
tensor([15.8151, 14.2125, 14.1608, 14.4847, 15.3789], device='cuda:0')
```

---

On cpu, the JIT model will return a strange error message "RuntimeError: _Map_base::at"

```py
import torch

device = torch.device('cpu')

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, inp):
        inp1 = torch.add(inp, torch.tensor(-15, dtype=torch.float32, device=device))
        inp.sin_()
        inp2 = torch.chunk(inp1, 1, dim=0)[0]
        inp = inp2
        return inp.neg()

fn = M().to(device)

torch.random.manual_seed(35221)
inp = torch.empty([5], dtype=torch.float32, device=device)
inp.uniform_(-64, 31)
inp = inp.to(device)

print(fn(inp.clone()))

jit_fn = torch.jit.trace(fn, (inp.clone(), ))
print(jit_fn(inp.clone()))
```

```
tensor([42.1028, 54.1574, 62.6319, -9.9247,  2.0634])

RuntimeError: _Map_base::at
```

### Versions

```
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.3
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Clang version: 14.0.0-1ubuntu1
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.9.13 (main, Aug 25 2022, 23:26:10)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.19.5-051905-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060
Nvidia driver version: 515.65.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] functorch==0.2.1
[pip3] numpy==1.23.3
[pip3] torch==1.13.0.dev20220923+cu116
[pip3] torchaudio==0.13.0.dev20220923+cu116
[pip3] torchvision==0.14.0.dev20220923+cu116
[conda] _tflow_select             2.3.0                       mkl  
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.3.1               h2bc3f7f_2  
[conda] functorch                 0.2.1                    pypi_0    pypi
[conda] libblas                   3.9.0            12_linux64_mkl    conda-forge
[conda] libcblas                  3.9.0            12_linux64_mkl    conda-forge
[conda] liblapack                 3.9.0            12_linux64_mkl    conda-forge
[conda] mkl                       2021.4.0           h06a4308_640  
[conda] mkl-service               2.4.0            py39h7f8727e_0  
[conda] mkl_fft                   1.3.1            py39hd3c417c_0  
[conda] mkl_random                1.2.2            py39h51133e4_0  
[conda] numpy                     1.23.3                   pypi_0    pypi
[conda] numpy-base                1.23.1           py39ha15fc14_0  
[conda] pytorch                   1.12.1          py3.9_cuda11.3_cudnn8.3.2_0    pytorch
[conda] pytorch-cuda              11.7                 h67b0de4_0    pytorch-nightly
[conda] pytorch-mutex             1.0                        cuda    pytorch-nightly
[conda] tensorflow-base           2.9.1           mkl_py39h353358b_0  
[conda] torch                     1.12.1                   pypi_0    pypi
[conda] torchaudio                0.13.0.dev20220923+cu116          pypi_0    pypi
[conda] torchvision               0.14.0.dev20220923+cu116          pypi_0    pypi
```