Simplified QAT Configuration File
Table 1 describes the fields in the retrain_config_caffe.proto file. Find the file in /amct_caffe/proto/retrain_config_caffe.proto under the AMCT installation directory.
Parameter |
Required/Optional |
Type |
Field |
Description |
|---|---|---|---|---|
AMCTRetrainConfig |
- |
- |
- |
Simplified QAT configuration of AMCT. |
Repeated |
String |
skip_layers |
Layers to skip quantization. It is globally effective, which efficiently realizes the same functionality for extended features. If this field is set, you can skip the settings of the extended quant_skip_layers and xxx_skip_layers. If both skip_layers and quant_skip_layers are set, their union is used. |
|
Repeated |
String |
skip_layer_types |
Types of layers to skip quantization. (Not supported currently.) It is globally effective, which efficiently realizes the same functionality for extended features. If this field is set, you can skip the settings of the extended quant_skip_types and xxx_skip_types. If both skip_layer_types and quant_skip_types are set, their union is used. |
|
Repeated |
RetrainOverrideLayer |
override_layer_configs |
Layers to override. It is used to determine which layers are to be differentiatedly quantized. By using this parameter, you can perform differentiated quantization on some layers to change the initial upper and lower bounds from [–0.6, +0.6] to [–0.3, +0.3]. Parameter priority:
|
|
Repeated |
RetrainOverrideLayerType |
override_layer_types |
Types of layers to override. It is used to determine which layers are to be differentiatedly quantized. By using this parameter, you can perform differentiated quantization on some layers to change the initial upper and lower bounds from [–0.6, +0.6] to [–0.3, +0.3]. Parameter priority:
|
|
Optional |
UInt32 |
batch_num |
Batch number for quantization. |
|
Required |
RetrainDataQuantConfig |
retrain_data_quant_config |
Activation quantization configuration parameter for QAT. It is a global quantization configuration parameter. Parameter priority: override_layer_configs > override_layer_types > retrain_data_quant_config/retrain_weight_quant_config |
|
Required |
RetrainWeightQuantConfig |
retrain_weight_quant_config |
Weight quantization configuration parameter for QAT. It is a global quantization configuration parameter. Parameter priority: override_layer_configs > override_layer_types > retrain_data_quant_config/retrain_weight_quant_config |
|
Repeated |
String |
quant_skip_layers |
Layers to skip quantization. Applicable to quantization. If both skip_layers and quant_skip_layers are set, their union is used. |
|
Repeated |
String |
quant_skip_types |
Types of layers to skip quantization. (Not supported currently.) Applicable to quantization. If both skip_layer_types and quant_skip_types are set, their union is used. |
|
RetrainDataQuantConfig |
- |
- |
- |
Activation quantization configuration for QAT. |
- |
ULQuantize |
ulq_quantize |
Activation quantization algorithm. Currently, only ULQ is supported. |
|
ULQuantize |
- |
- |
- |
ULQ quantization algorithm configuration. For details about the algorithm, see ULQ Algorithm. |
Optional |
ClipMaxMin |
clip_max_min |
Initial upper and lower bounds. IFMR is used for initialization by default. |
|
Optional |
Boolean |
fixed_min |
Whether to fix the lower bound at 0. Set to true for ReLU or false for other algorithms. |
|
ClipMaxMin |
- |
- |
- |
Initial upper and lower bounds. |
Required |
Float |
clip_max |
Initial upper bound. |
|
Required |
Float |
clip_min |
Initial lower bound. |
|
RetrainWeightQuantConfig |
- |
- |
- |
Weight quantization configuration for QAT. |
- |
ARQRetrain |
arq_retrain |
Weight quantization algorithm. Currently, only ARQ is supported. |
|
ARQRetrain |
- |
- |
- |
ARQ algorithm configuration. For details about the algorithm, see ARQ Algorithm. |
Required |
Boolean |
channel_wise |
Channel-wise ARQ enable. |
|
RetrainOverrideLayer |
- |
- |
- |
Layer overriding configuration. |
Required |
String |
layer_name |
Layer name. |
|
Required |
RetrainDataQuantConfig |
retrain_data_quant_config |
Activation quantization configuration to override. |
|
Required |
RetrainWeightQuantConfig |
retrain_weight_quant_config |
Weight quantization configuration to override. |
|
RetrainOverrideLayerType |
- |
- |
- |
Type of the layer to override. |
Required |
String |
layer_type |
Layer type. |
|
Required |
RetrainDataQuantConfig |
retrain_data_quant_config |
Activation quantization configuration to override. |
|
Required |
RetrainWeightQuantConfig |
retrain_weight_quant_config |
Weight quantization configuration to override. |
The following is an example of the simplified configuration file (quant.cfg) for QAT:
# global quantize parameter
retrain_data_quant_config: {
ulq_quantize: {
clip_max_min: {
clip_max: 6.0
clip_min: -6.0
}
}
}
retrain_weight_quant_config: {
arq_retrain: {
channel_wise: true
}
}
skip_layers: "conv_1"
override_layer_types : {
layer_type: "InnerProduct"
retrain_weight_quant_config: {
arq_retrain: {
channel_wise: false
}
}
}
override_layer_configs : {
layer_name: "fc_5"
retrain_weight_quant_config: {
arq_retrain: {
channel_wise: false
}
}
}