Repository: pytorch
Issue: `torch.compile` tries to invoke a torch op on numpy.ndarray in nightly release
Labels: triaged,oncall: pt2,module: dynamo

### 🐛 Describe the bug

I'm not sure if this is the intended behavior or a bug.

Using the nightly release (`torch-2.6.0.dev20241115+cu124`), when I run the following code (lifted out of [dynamo/test_misc.py#test_numpy_gt()](https://github.com/pytorch/pytorch/blob/main/test/dynamo/test_misc.py#L2530)) but running it with the default device set to `"cuda"` instead of `"cpu"`)

```python
import torch
import numpy as np

with torch.device("cuda"):
      x = np.arange(10)

      def fn(y):
        return y >= 3

      r = torch.compile(fn)(x)
      print(r)
```

I get the following error:

```
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/kiuk/.pyenv/versions/venv311/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 2674, in __call__
    method_callable = getattr(obj, self.method)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.TorchRuntimeError: Failed running call_function <Wrapped method <original ge>>(*(FakeTensor(..., device='cuda:0', size=(10,), dtype=torch.int64), 3), **{}):
'ndarray' object has no attribute 'ge'
```

Which seems to indicate that the compiled fn is trying to invoke `torch.ge()` on the input `x` as an `np.ndarray` without first converting `x` into a `torch.Tensor`.

The code above runs fine on `torch-2.5.1`.

I also noticed that the same type of error happens for `test_numpy_as_global` and `test_numpy_min` in `dynamo/test_misc.py` if these tests are run with `"cuda"` as the default device.

### Versions

Collecting environment information...
PyTorch version: 2.6.0.dev20241115+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux rodete (x86_64)
GCC version: (Debian 13.2.0-13) 13.2.0
Clang version: 16.0.6 (26)
CMake version: version 3.29.6
Libc version: glibc-2.38

Python version: 3.11.4 (main, Mar 27 2024, 15:05:58) [GCC 13.2.0] (64-bit runtime)
Python platform: Linux-6.9.10-1rodete5-amd64-x86_64-with-glibc2.38
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA RTX A5000
Nvidia driver version: 535.183.01
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:                        43 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               24
On-line CPU(s) list:                  0-23
Vendor ID:                            AuthenticAMD
Model name:                           AMD Ryzen Threadripper PRO 3945WX 12-Cores
CPU family:                           23
Model:                                49
Thread(s) per core:                   2
Core(s) per socket:                   12
Socket(s):                            1
Stepping:                             0
Frequency boost:                      enabled
CPU(s) scaling MHz:                   84%
CPU max MHz:                          4425.7808
CPU min MHz:                          2200.0000
BogoMIPS:                             7984.65
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sev sev_es
Virtualization:                       AMD-V
L1d cache:                            384 KiB (12 instances)
L1i cache:                            384 KiB (12 instances)
L2 cache:                             6 MiB (12 instances)
L3 cache:                             64 MiB (4 instances)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-23
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec rstack overflow:   Mitigation; Safe RET
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] flake8==6.1.0
[pip3] flake8-bugbear==23.3.23
[pip3] flake8-comprehensions==3.15.0
[pip3] flake8-executable==2.1.3
[pip3] flake8-logging-format==0.9.0
[pip3] flake8-pyi==23.3.1
[pip3] flake8-simplify==0.19.3
[pip3] mypy==1.10.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.0
[pip3] optree==0.12.1
[pip3] pytorch-triton==3.1.0+cf34004b8a
[pip3] torch==2.6.0.dev20241115+cu124
[pip3] torchsummary==1.5.1
[pip3] triton==3.1.0
[conda] magma-cuda110             2.5.2                         1    pytorch
[conda] mkl-include               2024.1.0              intel_691    intel
[conda] mkl-static                2024.1.0              intel_691    intel

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @ezyang