Repository: pytorch
Issue: RuntimeError: Unsupported qscheme: per_channel_affine.  When using quantise_fx(
Labels: oncall: quantization

### 🐛 Describe the bug

Apply Quantization Aware Training (QAT) to a model using PyTorch's `torch.ao.quantization` module. After preparing the model for QAT and running the simplified training loop, it attempts to finalize the quantization process with the `convert_fx` function. However, a RuntimeError is raised: 
RuntimeError: Unsupported qscheme: per_channel_affine

Here's a snippet of the code that leads to the error


```
import torch
import torch.nn as nn
import torch.optim as optim
from torch.ao.quantization import get_default_qat_qconfig_mapping
from torch.ao.quantization.quantize_fx import prepare_qat_fx, convert_fx
import timm
from tqdm import tqdm
 
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = timm.create_model('efficientnet_b0', pretrained=True, num_classes=5).to(device)
qat_config = get_default_qat_qconfig_mapping("x86")
sample_input = torch.rand((1, 3, 224, 224)).to(device)
model.train()
prepared_model = prepare_qat_fx(model, qat_config, sample_input)
 
def train_model_with_qat(prepared_model, iterations=10, batch_size=32, device='cpu'):
    optimizer = optim.SGD(prepared_model.parameters(), lr=0.001, momentum=0.9)
    loss_function = nn.CrossEntropyLoss()
    prepared_model.train()
    for _ in tqdm(range(iterations), desc="Training Iterations"):
        inputs = torch.rand((batch_size, 3, 224, 224)).to(device)
        labels = torch.randint(0, 5, (batch_size,)).to(device)
        optimizer.zero_grad()
        outputs = prepared_model(inputs)
        loss = loss_function(outputs, labels)
        loss.backward()
        optimizer.step()
 
train_model_with_qat(prepared_model, device=device)
finalized_model = convert_fx(prepared_model)
```


### Versions

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:                      46 bits physical, 57 bits virtual
Byte Order:                         Little Endian
CPU(s):                             144
On-line CPU(s) list:                0-143
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8352V CPU @ 2.10GHz
CPU family:                         6
Model:                              106
Thread(s) per core:                 2
Core(s) per socket:                 36
Socket(s):                          2
Stepping:                           6
CPU max MHz:                        3500.0000
CPU min MHz:                        800.0000
BogoMIPS:                           4200.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 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 hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear pconfig flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          3.4 MiB (72 instances)
L1i cache:                          2.3 MiB (72 instances)
L2 cache:                           90 MiB (72 instances)
L3 cache:                           108 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-35,72-107
NUMA node1 CPU(s):                  36-71,108-143
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             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:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==2.3.0
[pip3] triton==2.3.0
[conda] numpy                     1.23.5                   pypi_0    pypi
[conda] torch                     2.3.0                    pypi_0    pypi
[conda] triton                    2.3.0                    pypi_0    pypi

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