Qconfig Configuration Introduction
Writing Specifications of set_qconfig
When defining the model to be quantified, the model set_qconfig method needs to be implemented to configure the quantization method.
The current QConfig interface is provided by hat.utils.qconfig_manager. Call hat.utils.qconfig_manager in set_qconfig to implement the setting of the module Qconfig, e.g.:
Customize QAT QConfig Parameters
Using custom QConfig in QAT training is supported in HAT, simply configure the qconfig_params parameter in the qat_solver of the config file:
qconfig_params has five main parameter configuration items: dtype, activation_fake_quant, weight_fake_quant, activation_qkwargs and weight_qkwargs.
-
dtype:
dtypeis the quantization bit type, supporting"qint8"(default). -
activation_fake_quant: Quantifier for activation, supporting
"fake_quant"(default),"lsq", and"pact". -
weight_fake_quant: Quantifier for weight. Supporting
"fake_quant"(default),"lsq", and"pact". -
activation_qkwargs: Parameters of activation quantifier.
- When
activation_fake_quantis"fake_quant",activation_qkwargscan be set as below:
- When
activation_fake_quantis"lsq",activation_qkwargscan be set as below:
- When
activation_fake_quantis"pact",activation_qkwargscan be set as below:
- When
-
weight_qkwargs: Specifies the parameters for the weight quantifier. Except that the default
observerforweight_qkwargsisMovingAveragePerChannelMinMaxObserver, other parameters and usage are the same asactivation_qkwargs.
Generally you can just use the default configurations without changing activation_qkwargs and weight_qkwargs. However, when performing the QAT training after the calibration, you may need to modify averaging_constant.
