Repository: pytorch
Issue: ```torch.nn.functional.pad```: Internal assert failed
Labels: oncall: quantization

### 🐛 Describe the bug

Test code:
```python
import torch

base = torch.randn([1,1,1])
self = torch.quantize_per_tensor(base, 0.1, 10, torch.qint8)

torch.nn.functional.pad(self, (0,0,0,0), "circular", 0)
```
Error log:
```
Traceback (most recent call last):
  File "/home/yonghyeon/pytorch_err_case_py/pad.py", line 6, in <module>
    torch.nn.functional.pad(self, (0,0,0,0), "circular", 0)
  File "/home/yonghyeon/pytorch/pytorch-asan/torch/nn/functional.py", line 4522, in pad
    return torch._C._nn.pad(input, pad, mode, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: false INTERNAL ASSERT FAILED at "/home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/quantized/Quantizer.cpp":444, please report a bug to PyTorch. cannot call qscheme on UnknownQuantizer
```

Test code (c++):
```cpp
#include <torch/torch.h>

int main() {

  auto base = torch::randn({1,1,1});
  torch::Tensor self = at::quantize_per_tensor(base, 0.1, 10, c10::kQInt8);

  c10::optional<double> value = c10::optional<double>(0.0);

  at::pad(self, {0,0,0,0}, "circular", value);

  return 0;
}
```

Error log:
```
terminate called after throwing an instance of 'c10::Error'
  what():  false INTERNAL ASSERT FAILED at "/home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/quantized/Quantizer.cpp":444, please report a bug to PyTorch. cannot call qscheme on UnknownQuantizer
Exception raised from qscheme at /home/yonghyeon/pytorch/pytorch-asan/aten/src/ATen/quantized/Quantizer.cpp:444 (most recent call first):
frame #0: <unknown function> + 0x1e7a6e (0x7fa4f8f10a6e in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #1: <unknown function> + 0x1e7a20 (0x7fa4f8f10a20 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #2: <unknown function> + 0x1e79b0 (0x7fa4f8f109b0 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #3: <unknown function> + 0x1e7860 (0x7fa4f8f10860 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #4: <unknown function> + 0x1e9286 (0x7fa4f8f12286 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #5: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x1b7 (0x7fa4f8f0e4d7 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #6: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x20c (0x7fa4f8f0792c in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #7: c10::detail::torchInternalAssertFail(char const*, char const*, unsigned int, char const*, char const*) + 0x1ae (0x7fa4f8f07f8e in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libc10.so)
frame #8: <unknown function> + 0xd1e0554 (0x7fa5062ef554 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #9: <unknown function> + 0x5055064 (0x7fa4fe164064 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #10: at::native::slice(at::Tensor const&, long, std::optional<long>, std::optional<long>, long) + 0x10fc (0x7fa4fe1635cc in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #11: <unknown function> + 0xa55363b (0x7fa50366263b in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #12: <unknown function> + 0xa554201 (0x7fa503663201 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #13: <unknown function> + 0x91b42c5 (0x7fa5022c32c5 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #14: <unknown function> + 0x91b36ad (0x7fa5022c26ad in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #15: at::_ops::slice_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, long, std::optional<c10::SymInt>, std::optional<c10::SymInt>, c10::SymInt) + 0x5b3 (0x7fa502166e53 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #16: <unknown function> + 0x15120e58 (0x7fa50e22fe58 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #17: <unknown function> + 0x1512004a (0x7fa50e22f04a in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #18: <unknown function> + 0x15123513 (0x7fa50e232513 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #19: <unknown function> + 0x91b42c5 (0x7fa5022c32c5 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #20: <unknown function> + 0x91b36ad (0x7fa5022c26ad in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #21: at::_ops::slice_Tensor::redispatch(c10::DispatchKeySet, at::Tensor const&, long, std::optional<c10::SymInt>, std::optional<c10::SymInt>, c10::SymInt) + 0x5b3 (0x7fa502166e53 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #22: <unknown function> + 0x1319c54b (0x7fa50c2ab54b in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #23: <unknown function> + 0x12ffbfe8 (0x7fa50c10afe8 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #24: <unknown function> + 0x12ffab32 (0x7fa50c109b32 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #25: <unknown function> + 0x12ffcbb3 (0x7fa50c10bbb3 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #26: <unknown function> + 0x91b42c5 (0x7fa5022c32c5 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #27: at::_ops::slice_Tensor::call(at::Tensor const&, long, std::optional<c10::SymInt>, std::optional<c10::SymInt>, c10::SymInt) + 0x111b (0x7fa501eceaeb in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #28: <unknown function> + 0x306acad (0x7fa4fc179cad in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #29: at::native::_pad_circular_symint(at::Tensor const&, c10::ArrayRef<c10::SymInt>) + 0x19e0 (0x7fa4fd9e85e0 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #30: <unknown function> + 0xb424628 (0x7fa504533628 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #31: <unknown function> + 0xb42513b (0x7fa50453413b in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #32: <unknown function> + 0x67d9c01 (0x7fa4ff8e8c01 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #33: at::_ops::_pad_circular::call(at::Tensor const&, c10::ArrayRef<c10::SymInt>) + 0xfa0 (0x7fa5000ea2c0 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #34: <unknown function> + 0x48dc168 (0x7fa4fd9eb168 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #35: at::native::_pad_enum_symint(at::Tensor const&, c10::ArrayRef<c10::SymInt>, long, std::optional<double>) + 0xfb8 (0x7fa4fd9e3178 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #36: at::native::pad_symint(at::Tensor const&, c10::ArrayRef<c10::SymInt>, c10::basic_string_view<char>, std::optional<double>) + 0x419 (0x7fa4fd9e9e59 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #37: <unknown function> + 0xb427dbc (0x7fa504536dbc in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #38: <unknown function> + 0xb428d48 (0x7fa504537d48 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #39: <unknown function> + 0x7434e1c (0x7fa500543e1c in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #40: at::_ops::pad::call(at::Tensor const&, c10::ArrayRef<c10::SymInt>, c10::basic_string_view<char>, std::optional<double>) + 0x16e6 (0x7fa5000ec286 in /home/yonghyeon/pytorch/pytorch-asan/build/lib/libtorch_cpu.so)
frame #41: ./reproduce_pad() [0x4068a9]
frame #42: main + 0x67e (0x404b8e in ./reproduce_pad)
frame #43: <unknown function> + 0x29d90 (0x7fa4ef44cd90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #44: __libc_start_main + 0x80 (0x7fa4ef44ce40 in /lib/x86_64-linux-gnu/libc.so.6)
frame #45: _start + 0x25 (0x404445 in ./reproduce_pad)

Aborted (core dumped)
```



### Versions

PyTorch version: 2.3.0a0+git03969cb
Is debug build: True
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 12.0.1
CMake version: version 3.26.4
Libc version: glibc-2.35

Python version: 3.12.0 | packaged by Anaconda, Inc. | (main, Oct  2 2023, 17:29:18) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-89-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
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):                             96
On-line CPU(s) list:                0-95
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          2
Stepping:                           7
CPU max MHz:                        4000.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           6000.00
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 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 intel_ppin 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 mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke avx512_vnni md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          1.5 MiB (48 instances)
L1i cache:                          1.5 MiB (48 instances)
L2 cache:                           48 MiB (48 instances)
L3 cache:                           71.5 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-23,48-71
NUMA node1 CPU(s):                  24-47,72-95
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
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; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.2
[pip3] optree==0.10.0
[pip3] torch==2.3.0a0+git03969cb
[conda] mkl                       2023.1.0         h213fc3f_46344  
[conda] mkl-include               2023.1.0         h06a4308_46344  
[conda] numpy                     1.26.2                   pypi_0    pypi
[conda] optree                    0.10.0                   pypi_0    pypi
[conda] torch                     2.3.0a0+git03969cb           dev_0    <develop>

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel