Repository: pytorch
Issue: torch.compile Conv1d AssertionError
Labels: triaged,oncall: pt2,module: inductor

### 🐛 Describe the bug

The following code will raise the AseertionError
```
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.c = torch.nn.Conv1d(in_channels=1, out_channels=5, kernel_size=1)

    def forward(self, input):
        input = input.permute(0, 2, 1)
        return self.c(input)

model = M()
model = torch.compile(model)

input = torch.randn(5, 30, 1)
output = model(input)
```

However, if I remove the permute or change the input channel other than 1, no error raised

i.e.
```
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.c = torch.nn.Conv1d(in_channels=1, out_channels=5, kernel_size=1)

    def forward(self, input):
        return self.c(input)

model = M()
model = torch.compile(model)

input = torch.randn(5, 1, 30)
output = model(input)
```
```
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.c = torch.nn.Conv1d(in_channels=2, out_channels=5, kernel_size=1)

    def forward(self, input):
        input = input.permute(0, 2, 1)
        return self.c(input)

model = M()
model = torch.compile(model)

input = torch.randn(5, 30, 2)
output = model(input)
```

### Error logs

```
Traceback (most recent call last):
  File "/mnt/ec/ness/fokxon/tests/test1.py", line 16, in <module>
    output = model(input)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 489, in _fn
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/tests/test1.py", line 8, in forward
    def forward(self, input):
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 489, in _fn
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/external_utils.py", line 17, in inner
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py", line 901, in forward
    return compiled_fn(full_args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 81, in g
    return f(*args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/runtime_wrappers.py", line 83, in runtime_wrapper
    all_outs = call_func_at_runtime_with_args(
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 105, in call_func_at_runtime_with_args
    out = normalize_as_list(f(args))
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 81, in g
    return f(*args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/autograd/function.py", line 553, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 408, in forward
    fw_outs = call_func_at_runtime_with_args(
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 105, in call_func_at_runtime_with_args
    out = normalize_as_list(f(args))
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_inductor/codecache.py", line 864, in __call__
    return self.get_current_callable()(inputs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_inductor/codecache.py", line 892, in _run_from_cache
    return compiled_graph.compiled_artifact(inputs)
  File "/tmp/torchinductor_fokxon/ms/cmslmgjtq7rmx363kqoqtubogdo3qi4bzwjepkevqexhnru5uba3.py", line 36, in call
    assert_size_stride(buf0, (5, 5, 30), (150, 30, 1))
AssertionError: expected size 5==5, stride 1==30 at dim=1
```

### Minified repro

```
[2024-04-03 12:39:34,011] torch._dynamo.debug_utils: [WARNING] Writing minified repro to:
[2024-04-03 12:39:34,011] torch._dynamo.debug_utils: [WARNING] /mnt/ec/ness/fokxon/tests/torch_compile_debug/run_2024_04_03_12_39_33_916237-pid_694450/minifier/minifier_launcher.py
Traceback (most recent call last):
  File "/mnt/ec/ness/fokxon/tests/test1.py", line 16, in <module>
    output = model(input)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 489, in _fn
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/tests/test1.py", line 8, in forward
    def forward(self, input):
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/eval_frame.py", line 489, in _fn
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/external_utils.py", line 17, in inner
    return fn(*args, **kwargs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/aot_autograd.py", line 901, in forward
    return compiled_fn(full_args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 81, in g
    return f(*args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/runtime_wrappers.py", line 83, in runtime_wrapper
    all_outs = call_func_at_runtime_with_args(
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 105, in call_func_at_runtime_with_args
    out = normalize_as_list(f(args))
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 81, in g
    return f(*args)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/autograd/function.py", line 553, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 408, in forward
    fw_outs = call_func_at_runtime_with_args(
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_functorch/_aot_autograd/utils.py", line 105, in call_func_at_runtime_with_args
    out = normalize_as_list(f(args))
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/repro/after_aot.py", line 112, in deferred_for_real_inputs
    return inner_debug_fn(real_inputs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_dynamo/repro/after_aot.py", line 162, in inner_debug_fn
    out = inner_compiled_fn(real_inputs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_inductor/codecache.py", line 864, in __call__
    return self.get_current_callable()(inputs)
  File "/mnt/ec/ness/fokxon/mambaforge/envs/testing/lib/python3.9/site-packages/torch/_inductor/codecache.py", line 892, in _run_from_cache
    return compiled_graph.compiled_artifact(inputs)
  File "/tmp/torchinductor_fokxon/ms/cmslmgjtq7rmx363kqoqtubogdo3qi4bzwjepkevqexhnru5uba3.py", line 36, in call
    assert_size_stride(buf0, (5, 5, 30), (150, 30, 1))
AssertionError: expected size 5==5, stride 1==30 at dim=1
```

### Versions

```
PyTorch version: 2.2.2                                                                                                                                                                                                                                                          
Is debug build: False                                                                                                                                                                                                                                                           
CUDA used to build PyTorch: 12.1                                                                                                                                                                                                                                                
ROCM used to build PyTorch: N/A                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                
OS: Ubuntu 20.04.5 LTS (x86_64)                                                                                                                                                                                                                                                 
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0                                                                                                                                                                                                                              
Clang version: Could not collect                                                                                                                                                                                                                                                
CMake version: version 3.16.3                                                                                                                                                                                                                                                   
Libc version: glibc-2.31                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                
Python version: 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:50:21)  [GCC 12.3.0] (64-bit runtime)                                                                                                                                                                 
Python platform: Linux-5.15.0-92-generic-x86_64-with-glibc2.31                                                                                                                                                                                                                  
Is CUDA available: True                                                                                                                                                                                                                                                         
CUDA runtime version: Could not collect                                                                                                                                                                                                                                         
CUDA_MODULE_LOADING set to: LAZY                                                                                                                                                                                                                                                
GPU models and configuration:                                                                                                                                                                                                                                                   
GPU 0: NVIDIA GeForce RTX 3090                                                                                                                                                                                                                                                  
GPU 1: NVIDIA GeForce RTX 3090                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                
Nvidia driver version: 535.154.05                                                                                                                                                                                                                                               
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, 48 bits virtual
CPU(s):                             32
On-line CPU(s) list:                0-31
Thread(s) per core:                 2
Core(s) per socket:                 8
Socket(s):                          2
NUMA node(s):                       2
Vendor ID:                          GenuineIntel
CPU family:                         6
Model:                              79
Model name:                         Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
Stepping:                           1
CPU MHz:                            1200.000
CPU max MHz:                        3000.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           4199.91
Virtualization:                     VT-x
L1d cache:                          512 KiB
L1i cache:                          512 KiB
L2 cache:                           4 MiB
L3 cache:                           40 MiB
NUMA node0 CPU(s):                  0-7,16-23
NUMA node1 CPU(s):                  8-15,24-31
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: 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; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; Clear CPU buffers; SMT vulnerable
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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor 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 cdp_l3 invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear flush_l1d

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.2.2
[pip3] torchaudio==2.2.2
[pip3] torchvision==0.17.2
[pip3] triton==2.2.0
[conda] blas                      2.116                       mkl    conda-forge
[conda] blas-devel                3.9.0            16_linux64_mkl    conda-forge
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] libblas                   3.9.0            16_linux64_mkl    conda-forge
[conda] libcblas                  3.9.0            16_linux64_mkl    conda-forge
[conda] libjpeg-turbo             2.0.0                h9bf148f_0    pytorch
[conda] liblapack                 3.9.0            16_linux64_mkl    conda-forge
[conda] liblapacke                3.9.0            16_linux64_mkl    conda-forge
[conda] mkl                       2022.1.0           h84fe81f_915    conda-forge
[conda] mkl-devel                 2022.1.0           ha770c72_916    conda-forge
[conda] mkl-include               2022.1.0           h84fe81f_915    conda-forge
[conda] numpy                     1.26.4           py39h474f0d3_0    conda-forge
[conda] pytorch                   2.2.2           py3.9_cuda12.1_cudnn8.9.2_0    pytorch
[conda] pytorch-cuda              12.1                 ha16c6d3_5    pytorch
[conda] pytorch-mutex             1.0                        cuda    pytorch
[conda] torchaudio                2.2.2                py39_cu121    pytorch
[conda] torchtriton               2.2.0                      py39    pytorch
[conda] torchvision               0.17.2               py39_cu121    pytorch
```

cc @ezyang @msaroufim @bdhirsh @anijain2305 @chauhang @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov @ColinPeppler @amjames @desertfire