Repository: pytorch
Issue: torch.compile() returns a different value than interpreted (NaN vs 1)
Labels: module: cpu,module: NaNs and Infs,oncall: pt2,oncall: cpu inductor

### 🐛 Describe the bug

Snippet:

```python
import torch

class Model(torch.nn.Module):

    def __init__(self):
        super().__init__()

    def forward(self, x):
        x = torch.rsqrt(x)
        x = torch.angle(x)
        x = torch.atan(x)
        x = torch.positive(x)
        x = torch.sin(x)
        return x

func = Model().to('cpu')

x = torch.tensor([0.7886758446693420, -1.1796921491622925,  0.5152440071105957,
         1.4106913805007935,  1.3812966346740723,  0.5720621347427368,
         1.7286888360977173, -2.2948377132415771, -0.3201593160629272,
         1.3686311244964600])

pata = func(x.clone())
print(pata)
func1 = torch.compile(func, fullgraph=True)
tino = func1(x.clone())
print(tino)
print(torch.allclose(pata, tino, equal_nan=True))
print(torch.__version__)
```

Output:

```
tensor([0., nan, 0., 0., 0., 0., 0., nan, nan, 0.])
tensor([0., 1., 0., 0., 0., 0., 0., 1., 1., 0.])
False
2.6.0a0+gitd2f7694
```

### Versions

PyTorch version: 2.6.0a0+gitd2f7694                                                                                       
Is debug build: False                                                                                                                                                                                                                                
CUDA used to build PyTorch: Could not collect                                                                                                                                                                                                        
ROCM used to build PyTorch: N/A                                                                                           
                                                                                                                          
OS: CentOS Stream 9 (x86_64)                                 
GCC version: (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2)                                                                     
Clang version: 18.1.8 (CentOS 18.1.8-3.el9)                                                                               
CMake version: version 3.31.2                                
Libc version: glibc-2.34                                     
                                                             
Python version: 3.12.8 | packaged by Anaconda, Inc. | (main, Dec 11 2024, 16:31:09) [GCC 11.2.0] (64-bit runtime)                                                                                                                                    
Python platform: Linux-6.4.3-0_fbk14_hardened_2601_gcd42476b84e9-x86_64-with-glibc2.34                                                                                                                                                               
Is CUDA available: False                                     
CUDA runtime version: Could not collect                                                                                                                                                                                                              
CUDA_MODULE_LOADING set to: N/A                                                                                                                                                                                                                      
GPU models and configuration:                                                                                                                                                                                                                        
GPU 0: NVIDIA PG509-210                                                                                                   
GPU 1: NVIDIA PG509-210                                                                                                                                                                                                                              
GPU 2: NVIDIA PG509-210                                                                                                                                                                                                                              
GPU 3: NVIDIA PG509-210                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                     
Nvidia driver version: 550.90.07                                                                                                                                                                                                                     
cuDNN version: Could not collect                             
HIP runtime version: N/A                                     
MIOpen runtime version: N/A                                  
Is XNNPACK available: True                                   

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):                             88                                                                                    
On-line CPU(s) list:                0-87                                                                                  
Vendor ID:                          GenuineIntel                                                                                                                                                                                                     
Model name:                         Intel(R) Xeon(R) Platinum 8339HC CPU @ 1.80GHz                                                                                                                                                                   
CPU family:                         6                                                                                     
Model:                              85                                                                                    
Thread(s) per core:                 1                                                                                     
Core(s) per socket:                 88                                                                                                                                                                                                               
Socket(s):                          1                                                                                     
Stepping:                           11                                                                                    
BogoMIPS:                           3591.74                                                                                                                                                                                                          
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni p
clmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept v
pid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512_bf16 arat vnmi umip pku ospke avx512_vnni md_clear flush_l1d ar
ch_capabilities                                              
Virtualization:                     VT-x                                                                                  
Hypervisor vendor:                  KVM                                                                                   
Virtualization type:                full                                                                                  
L1d cache:                          2.8 MiB (88 instances)                                                                
L1i cache:                          2.8 MiB (88 instances)                                                                
L2 cache:                           352 MiB (88 instances)                                                                                                                                                                                           
L3 cache:                           16 MiB (1 instance)                                                                                                                                                                                              
NUMA node(s):                       1                                                                                     
NUMA node0 CPU(s):                  0-87                                                                                                                                                                                                             
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status                                                                                                                                                                          
Vulnerability Itlb multihit:        Not affected                                                                                                                                                                                                     
Vulnerability L1tf:                 Not affected                                                                          
Vulnerability Mds:                  Not affected                                                                                                                                                                                                     
Vulnerability Meltdown:             Not affected                                                                                                                                                                                                     
Vulnerability Mmio stale data:      Vulnerable                                                                                                                                                                                                       
Vulnerability Retbleed:             Vulnerable                                                                                                                                                                                                       
Vulnerability Spec store bypass:    Vulnerable                                                                                                                                                                                                       
Vulnerability Spectre v1:           Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers                                                                                                                           
Vulnerability Spectre v2:           Vulnerable, IBPB: disabled, STIBP: disabled, PBRSB-eIBRS: Vulnerable                                                                                                                                             
Vulnerability Srbds:                Not affected                                                                          
Vulnerability Tsx async abort:      Mitigation; TSX disabled                                                              

Versions of relevant libraries:                              
[pip3] mypy==1.13.0                                                                                                       
[pip3] mypy-extensions==1.0.0                                                                                             
[pip3] numpy==1.26.2                                                                                                                                                                                                                                 
[pip3] onnx==1.17.0                                                                                                       
[pip3] onnxscript==0.1.0.dev20240817                                                                                      
[pip3] optree==0.13.0                                                                                                     
[pip3] torch==2.6.0a0+gitd2f7694                                                                                          
[conda] blas                      1.0                         mkl                                                                                                                                                                                    
[conda] mkl                       2023.1.0         h213fc3f_46344                                                                                                                                                                                    
[conda] mkl-include               2023.1.0         h06a4308_46344                                                                                                                                                                                    
[conda] mkl-service               2.4.0           py312h5eee18b_1                                                         
[conda] mkl_fft                   1.3.11          py312h5eee18b_0                                                                                                                                                                                    
[conda] mkl_random                1.2.8           py312h526ad5a_0                                                                                                                                                                                    
[conda] numpy                     1.26.2                   pypi_0    pypi                                                                                                                                                                            
[conda] optree                    0.13.0                   pypi_0    pypi                                                                                                                                                                            
[conda] torch                     2.6.0a0+gitd2f7694           dev_0    <develop>                                                                                                                                                                    


cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @chauhang @penguinwu