训练后量化简易配置文件
【免费下载链接】amctAMCT是CANN提供的昇腾AI处理器亲和的模型压缩工具仓。项目地址: https://gitcode.com/cann/amct
calibration_config_pytorch.proto文件参数说明如表1所示,该文件所在目录为:AMCT安装目录/amct_pytorch/proto/calibration_config_pytorch.proto。
表 1calibration_config_pytorch.proto参数说明
基于该文件构造的训练后量化简易配置文件quant.cfg样例如下所示:
# global quantize parameter batch_num : 2 activation_offset : true skip_layers : "Opname" skip_layer_types:"Optype" do_fusion: true skip_fusion_layers : "Opname" common_config : { arq_quantize : { channel_wise : true quant_bits : 7 } ifmr_quantize : { search_range_start : 0.7 search_range_end : 1.3 search_step : 0.01 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : true } dmq_balancer : { migration_strength : 0.5 } } override_layer_types : { layer_type : "Conv2d" calibration_config : { arq_quantize : { channel_wise : false quant_bits : 6 } ifmr_quantize : { search_range_start : 0.8 search_range_end : 1.2 search_step : 0.02 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : false } dmq_balancer : { migration_strength : 0.5 } } } override_layer_configs : { layer_name : "Opname" calibration_config : { arq_quantize : { channel_wise : true } ifmr_quantize : { search_range_start : 0.8 search_range_end : 1.2 search_step : 0.02 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : false } dmq_balancer : { migration_strength : 0.5 } } }如果数据量化算法使用HFMG,则上述配置文件中加粗部分可以替换成如下参考参数信息,举例如下(如下配置信息只是样例,请根据实际情况进行修改):
# global quantize parameter activation_offset : true batch_num : 2 ... common_config : { hfmg_quantize : { num_of_bins : 4096 asymmetric : false } ... }基于该文件构造的自适应舍入简易配置文件_ada_round.cfg_样例如下所示:
common_config : { ada_quantize : { num_iteration : 10000 warm_start : 0.2 reg_param : 0.01 beta_range_start : 20 beta_range_end : 2 channel_wise : false } }基于该文件构造的量化数据均衡预处理简易配置文件dmq_balancer.cfg样例如下所示:
# global quantize parameter batch_num : 2 activation_offset : true skip_layers : "Opname" skip_layer_types:"Optype" do_fusion: true skip_fusion_layers : "Opname" common_config : { arq_quantize : { channel_wise : true } ifmr_quantize : { search_range_start : 0.7 search_range_end : 1.3 search_step : 0.01 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : true } dmq_balancer : { migration_strength : 0.5 } } override_layer_types : { layer_type : "Optype" calibration_config : { arq_quantize : { channel_wise : false } ifmr_quantize : { search_range_start : 0.8 search_range_end : 1.2 search_step : 0.02 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : false } dmq_balancer : { migration_strength : 0.5 } } } override_layer_configs : { layer_name : "Opname" calibration_config : { arq_quantize : { channel_wise : true } ifmr_quantize : { search_range_start : 0.8 search_range_end : 1.2 search_step : 0.02 max_percentile : 0.999999 min_percentile : 0.999999 asymmetric : false } dmq_balancer : { migration_strength : 0.5 } } }
【免费下载链接】amctAMCT是CANN提供的昇腾AI处理器亲和的模型压缩工具仓。项目地址: https://gitcode.com/cann/amct
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考