Repository: pytorch
Issue: RuntimeError: HalfTensor is not supported
Labels: oncall: quantization

### 🐛 Describe the bug

I am getting the following error in the FX Graph Mode Quantization QAT

Traceback (most recent call last):
File “”, line 1, in
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/fx/graph_module.py”, line 738, in call_wrapped
return self._wrapped_call(self, *args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/fx/graph_module.py”, line 316, in call
raise e
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/fx/graph_module.py”, line 303, in call
return super(self.cls, obj).call(*args, **kwargs) # type: ignore[misc]
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1562, in _call_impl
return forward_call(*args, **kwargs)
File “<eval_with_key>.2”, line 197, in forward
activation_post_process_84 = self.activation_post_process_84(matmul); matmul = None
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1562, in _call_impl
return forward_call(*args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/ao/quantization/fake_quantize.py”, line 199, in forward
self.activation_post_process(X.detach())
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/nn/modules/module.py”, line 1562, in _call_impl
return forward_call(*args, **kwargs)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/ao/quantization/observer.py”, line 1230, in forward
self.reset_histogram(x, min_val, max_val)
File “/home/HassanBinHaroon/anaconda3/envs/FX_Graph_Mode_Env/lib/python3.9/site-packages/torch/ao/quantization/observer.py”, line 1203, in reset_histogram
torch.histc(
RuntimeError: HalfTensor is not supported

### Versions

# Define quantization configuration for QAT
act_static_qconfig = FakeQuantize.with_args(
    observer=HistogramObserver.with_args(
        quant_min=0,
        quant_max=255,
        dtype=torch.quint8,
        qscheme=torch.per_tensor_affine,
    )
)

global_qconfig = QConfig(
    activation=act_static_qconfig,
    weight=torch.quantization.default_fused_per_channel_wt_fake_quant
)

# Set global quantization config for the whole model
qconfig_map = QConfigMapping().set_global(global_qconfig)

# Prepare the model for QAT
fx_model = prepare_qat_fx(resnet18, qconfig_map, torch.rand(1, 3, 256, 448).to(device))

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