Repository: pytorch
Issue: Internal assert triggered at ivalue_inl.h:1966, Expected IntList but got Int
Labels: oncall: jit,module: onnx,module: error checking,triaged

### 🐛 Describe the bug

When using `torch.jit.script(model, dummy_input)`, I got the error
```
Traceback (most recent call last):
  File "/data1/xuyuheng/codes/onnx/sr/5_export_onnx.py", line 29, in <module>
    scripted = torch.jit.script(model_G, dummy_input)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 1432, in script
    return _script_impl(
           ^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 1146, in _script_impl
    return torch.jit._recursive.create_script_module(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 559, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 632, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 649, in _construct
    init_fn(script_module)
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 608, in init_fn
    scripted = create_script_module_impl(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 632, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 649, in _construct
    init_fn(script_module)
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 608, in init_fn
    scripted = create_script_module_impl(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 632, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 649, in _construct
    init_fn(script_module)
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 608, in init_fn
    scripted = create_script_module_impl(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 632, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 649, in _construct
    init_fn(script_module)
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 608, in init_fn
    scripted = create_script_module_impl(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 636, in create_script_module_impl
    create_methods_and_properties_from_stubs(
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 468, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 1037, in compile_unbound_method
    create_methods_and_properties_from_stubs(concrete_type, (stub,), ())
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 468, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 1037, in compile_unbound_method
    create_methods_and_properties_from_stubs(concrete_type, (stub,), ())
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 468, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_recursive.py", line 1004, in try_compile_fn
    return torch.jit.script(fn, _rcb=rcb)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 1432, in script
    return _script_impl(
           ^^^^^^^^^^^^^
  File "/home/xuyuheng/miniconda3/envs/pytorch/lib/python3.12/site-packages/torch/jit/_script.py", line 1204, in _script_impl
    fn = torch._C._jit_script_compile(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: isIntList() INTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1720538455419/work/aten/src/ATen/core/ivalue_inl.h":1966, please report a bug to PyTorch. Expected IntList but got Int
```

I'm sorry I can't provide an example currently, but by commenting and uncommenting code I found that a line
```python3
x = F.unfold(x, K)
```
is causing the problem; comment it and I wouldn't hit pytorch internal assertions. However, just that line itself in a single model doesn't trigger the fault. 

EDIT: Now I have an example, see below

### Versions

```shell
python -m torch.utils.collect_env 

<frozen runpy>:128: RuntimeWarning: 'torch.utils.collect_env' found in sys.modules after import of package 'torch.utils', but prior to execution of 'torch.utils.collect_env'; this may result in unpredictable behaviour
Collecting environment information...
PyTorch version: 2.4.0
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.1 LTS (x86_64)
GCC version: (GCC) 13.3.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31

Python version: 3.12.2 | packaged by Anaconda, Inc. | (main, Feb 27 2024, 17:35:02) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-113-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 12.0.76
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA RTX A6000
GPU 1: NVIDIA RTX A6000
GPU 2: NVIDIA RTX A6000
GPU 3: NVIDIA RTX A6000
GPU 4: NVIDIA RTX A6000
GPU 5: NVIDIA RTX A6000
GPU 6: NVIDIA RTX A6000
GPU 7: NVIDIA RTX A6000

Nvidia driver version: 525.89.02
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
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 57 bits virtual
CPU(s):                          64
On-line CPU(s) list:             0-63
Thread(s) per core:              2
Core(s) per socket:              16
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           106
Model name:                      Intel(R) Xeon(R) Silver 4314 CPU @ 2.40GHz
Stepping:                        6
Frequency boost:                 enabled
CPU MHz:                         900.000
CPU max MHz:                     2401.0000
CPU min MHz:                     800.0000
BogoMIPS:                        4800.00
Virtualization:                  VT-x
L1d cache:                       1.5 MiB
L1i cache:                       1 MiB
L2 cache:                        40 MiB
L3 cache:                        48 MiB
NUMA node0 CPU(s):               0-15,32-47
NUMA node1 CPU(s):               16-31,48-63
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          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
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
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 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 invpcid_single 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 rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] onnx==1.16.0
[pip3] onnxruntime-gpu==1.17.1
[pip3] pytorch-lightning==2.3.3
[pip3] torch==2.4.0
[pip3] torchaudio==2.4.0
[pip3] torchmetrics==1.4.0.post0
[pip3] torchvision==0.19.0
[pip3] triton==3.0.0
[conda] blas                      1.0                         mkl    defaults
[conda] cudatoolkit               11.8.0               h6a678d5_0    defaults
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344    defaults
[conda] mkl-service               2.4.0           py312h5eee18b_1    defaults
[conda] mkl_fft                   1.3.8           py312h5eee18b_0    defaults
[conda] mkl_random                1.2.4           py312hdb19cb5_0    defaults
[conda] numpy                     1.26.4          py312hc5e2394_0    defaults
[conda] numpy-base                1.26.4          py312h0da6c21_0    defaults
[conda] pytorch                   2.4.0           py3.12_cuda12.1_cudnn9.1.0_0    pytorch
[conda] pytorch-cuda              12.1                 ha16c6d3_5    pytorch
[conda] pytorch-lightning         2.3.3              pyhd8ed1ab_0    conda-forge
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                2.4.0               py312_cu121    pytorch
[conda] torchmetrics              1.4.0.post0        pyhd8ed1ab_0    conda-forge
[conda] torchtriton               3.0.0                     py312    pytorch
[conda] torchvision               0.19.0              py312_cu121    pytorch
```

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel @malfet