Repository: pytorch
Issue: No ONNX function found for <OpOverload(op='quantized_decomposed.dequantize_per_channel', overload='default')>
Labels: module: onnx,triaged,OSS contribution wanted

### 🐛 Describe the bug

We tried to leverage per_channel quantization in QAT and exported the trained model in onnx format.

```py
model = dummy pytorch model

export_model = torch.export.export_for_training(
    model, example_inputs).module()

quantizer = XNNPACKQuantizer().set_global(get_symmetric_quantization_config(
    is_per_channel=True,
))
prepared_model = prepare_qat_pt2e(export_model, quantizer)
quantized_model = convert_pt2e(prepared_model)


inp = torch.rand((32, 3, 384, 384))
print(inp.shape)
example_inputs = (inp,)

onnx_program = torch.onnx.export(
    quantized_model,                  # model to export
    example_inputs,        # inputs of the model,
    "my_model.onnx",        # filename of the ONNX model
    opset_version=20,       # the ONNX version to export the model to
    verbose=True,
    input_names=["input"],  # Rename inputs for the ONNX model
    output_names=['output'],  # the model's output names
    dynamic=True,        # create a dynamic ONNX model
    dynamo=True,        # True or False to select the exporter to use
    dynamic_axes={'input': {0: 'batch_size'},    # variable length axes
                  'output': {0: 'batch_size'}},
    verify=True,        # check the model and all its submodules
)

```

we got the following error:

```pytb
---------------------------------------------------------------------------
DispatchError                             Traceback (most recent call last)
File ~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:553, in _add_nodes(exported_program, model, lower, registry)
    [552](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:552) if lower == "at_conversion":
--> [553](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:553)     _handle_call_function_node_with_lowering(
    [554](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:554)         model,
    [555](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:555)         node,
    [556](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:556)         node_name_to_values,
    [557](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:557)         constant_farm,
    [558](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:558)         registry=registry,
    [559](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:559)         opset=opset,
    [560](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:560)     )
    [561](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:561) else:
    [562](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:562)     # No lowering

File ~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:444, in _handle_call_function_node_with_lowering(model, node, node_name_to_values, constant_farm, registry, opset)
    [442](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:442) if onnx_function is None:
    [443](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:443)     # TODO(justinchuby): Fall back to ATen op or do something else?
--> [444](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:444)     raise _errors.DispatchError(
    [445](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:445)         f"No ONNX function found for {node.target!r}. Failure message: {message}"
    [446](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:446)     )
    [448](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:448) # Map FX inputs to ONNX inputs and fill optional inputs.
    [449](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a224c696e7578576f726b53746174696f6e227d.vscode-resource.vscode-cdn.net/home/rxu/Github/rai_lab/multimodal/quantization/~/miniconda3/envs/ims/lib/python3.10/site-packages/torch/onnx/_internal/exporter/_core.py:449) # torch_args and torch_kwargs are for op-level validation

DispatchError: No ONNX function found for <OpOverload(op='quantized_decomposed.dequantize_per_channel', overload='default')>. Failure message: No decompositions registered for the real-valued input
...
<class 'torch.onnx._internal.exporter._errors.DispatchError'>: No ONNX function found for <OpOverload(op='quantized_decomposed.dequantize_per_channel', overload='default')>. Failure message: No decompositions registered for the real-valued input
⬆️
<class 'torch.onnx._internal.exporter._errors.ConversionError'>: Error when translating node %dequantize_per_channel : [num_users=1] = call_function[target=torch.ops.quantized_decomposed.dequantize_per_channel.default](args = (%b__frozen_param0, %b__scale_0, %b__zero_point_0, 0, -127, 127, torch.int8), kwargs = {}). See the stack trace for more information.
```

### Versions

Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: version 3.10.2
Libc version: glibc-2.27

Python version: 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-150-generic-x86_64-with-glibc2.27
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: Quadro RTX 8000
GPU 1: Quadro RTX 8000
GPU 2: Quadro RTX 8000
GPU 3: Quadro RTX 8000

Nvidia driver version: 550.120
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
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
CPU(s):              36
On-line CPU(s) list: 0-35
Thread(s) per core:  2
Core(s) per socket:  18
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               85
Model name:          Intel(R) Xeon(R) W-2295 CPU @ 3.00GHz
Stepping:            7
CPU MHz:             2004.998
CPU max MHz:         4800.0000
CPU min MHz:         1200.0000
BogoMIPS:            6000.00
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            1024K
L3 cache:            25344K
NUMA node0 CPU(s):   0-35
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 hwp hwp_act_window hwp_epp hwp_pkg_req avx512_vnni md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] onnx==1.16.1
[pip3] onnxruntime==1.18.1
[pip3] torch==2.5.1
[pip3] torchvision==0.20.1
[pip3] triton==3.1.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-cublas-cu12        12.4.5.8                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.4.127                 pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.4.127                 pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.1.0.70                 pypi_0    pypi
[conda] nvidia-cufft-cu12         11.2.1.3                 pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.5.147               pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.6.1.9                 pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.3.1.170               pypi_0    pypi
[conda] nvidia-nccl-cu12          2.21.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.4.127                 pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.4.127                 pypi_0    pypi
[conda] torch                     2.5.1                    pypi_0    pypi
[conda] torchvision               0.20.1                   pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi