Repository: pytorch
Issue: ELU quantization parameters (scale + zp) missing from model's state_dict
Labels: oncall: quantization,module: serialization,triaged

### 🐛 Describe the bug

I'm been trying to statically quantize a model of mine and its outputs were always zero. While debugging, I noticed the output of every ELU was off and that they had the defaults: scale of 1.0 and zero point of 0.0, after loading the PQT calibrated state_dict. While checking the latter, I noticed the scale and zero point of all ELUs were missing!
In short, the model behaves as expected after calibration and converting it to its quantized form but it doesn't if its state_dict is saved after conversion and re-loaded afterwards.

Here's a dummy model to reproduce my issue. I'm comparing it with LeakyReLU:

Model with LeakyReLU:
```
class SimpleModel(torch.nn.Module):
  def __init__(self, input_shape):
    super().__init__()
    
    self.quant = torch.ao.quantization.QuantStub()
    self.d1 = torch.nn.Linear(input_shape, 64)
    self.leaky= torch.nn.LeakyReLU()
    self.d2 = torch.nn.Linear(64, 1)
    self.dequant = torch.ao.quantization.DeQuantStub()

  def forward(self, x):
    
    x = self.quant(x)
    x = self.d1(x)
    x = self.leaky(x)
    x = self.d2(x)
    x = self.dequant(x)

    return x

model = SimpleModel(16)
model.qconfig = torch.ao.quantization.default_qconfig
model = torch.ao.quantization.prepare(model)

rand_input = torch.rand(8, 16)

out = model(rand_input)

model = torch.ao.quantization.convert(model)

print(model.state_dict().keys())
```
Output:
`odict_keys(['quant.scale', 'quant.zero_point', 'd1.scale', 'd1.zero_point', 'd1._packed_params.dtype', 'd1._packed_params._packed_params', 'leaky.scale', 'leaky.zero_point', 'd2.scale', 'd2.zero_point', 'd2._packed_params.dtype', 'd2._packed_params._packed_params'])`

Model with ELU:
```
class SimpleModel(torch.nn.Module):
  def __init__(self, input_shape):
    super().__init__()
    
    self.quant = torch.ao.quantization.QuantStub()
    self.d1 = torch.nn.Linear(input_shape, 64)
    self.elu = torch.nn.ELU()
    self.d2 = torch.nn.Linear(64, 1)
    self.dequant = torch.ao.quantization.DeQuantStub()

  def forward(self, x):
    
    x = self.quant(x)
    x = self.d1(x)
    x = self.elu(x)
    x = self.d2(x)
    x = self.dequant(x)

    return x

model = SimpleModel(16)
model.qconfig = torch.ao.quantization.default_qconfig
model = torch.ao.quantization.prepare(model)

rand_input = torch.rand(8, 16)

out = model(rand_input)

model = torch.ao.quantization.convert(model)

print(model.state_dict().keys())
```
Output:
`odict_keys(['quant.scale', 'quant.zero_point', 'd1.scale', 'd1.zero_point', 'd1._packed_params.dtype', 'd1._packed_params._packed_params', 'd2.scale', 'd2.zero_point', 'd2._packed_params.dtype', 'd2._packed_params._packed_params'])`


Notice how the "scale" and "zero_point" exist in the state_dict of the LeakyReLU model whereas that of the ELU model are missing.


### Versions

<details>
<summary>Collecting environment information... </summary>
PyTorch version: 2.1.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.9.18 (main, Sep 11 2023, 13:41:44)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
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 3070 Ti Laptop GPU
Nvidia driver version: 537.70
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, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             20
On-line CPU(s) list:                0-19
Vendor ID:                          GenuineIntel
Model name:                         12th Gen Intel(R) Core(TM) i7-12800H
CPU family:                         6
Model:                              154
Thread(s) per core:                 2
Core(s) per socket:                 10
Socket(s):                          1
Stepping:                           3
BogoMIPS:                           5606.40
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm serialize flush_l1d arch_capabilities
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          480 KiB (10 instances)
L1i cache:                          320 KiB (10 instances)
L2 cache:                           12.5 MiB (10 instances)
L3 cache:                           24 MiB (1 instance)
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
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:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] onnx==1.15.0
[pip3] tf2onnx==1.16.1
[pip3] torch==2.1.1
[pip3] triton==2.1.0
[conda] numpy                     1.23.5                   pypi_0    pypi
[conda] torch                     2.1.1                    pypi_0    pypi
[conda] triton                    2.1.0                    pypi_0    pypi
</details>



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