三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

AMCT蒸馏配置文件说明

AMCT蒸馏配置文件说明

蒸馏简易配置文件

【免费下载链接】amctAMCT是CANN提供的昇腾AI处理器亲和的模型压缩工具仓。项目地址: https://gitcode.com/cann/amct

distill_config_pytorch.proto文件参数说明如表1所示,该文件所在目录为:AMCT安装目录/amct_pytorch/proto/distill_config_pytorch.proto。

表 1distill_config_pytorch.proto参数说明

消息

是否必填

类型

字段

说明

AMCTDistillConfig

-

-

-

AMCT蒸馏的简易配置。

optional

uint32

batch_num

蒸馏batch数量,用于ifmr积累数据计算量化因子。

optional

uint32

group_size

蒸馏block中最小蒸馏单元个数。

optional

bool

data_dump

teacher网络block输入输出dump开关。

repeated

DistillGroup

distill_group

用户自定义蒸馏结构。

optional

DistillDataQuantConfig

distill_data_quant_config

蒸馏数据量化配置参数。

optional

DistillWeightQuantConfig

distill_weight_quant_config

蒸馏权重量化配置参数。

repeated

DistillOverrideLayer

distill_override_layers

重写某一层的量化配置。

repeated

DistillOverrideLayerType

distill_override_layer_types

重写某一类型层的量化配置。

repeated

string

quant_skip_layers

不需要量化的层,仍然做蒸馏。

repeated

string

quant_skip_layer_types

不需要量化的算子类型,仍然需要做蒸馏。

DistillGroup

-

-

-

用户自定义蒸馏结构。蒸馏结构中仅支持torch.nn.Module类型的算子。

required

string

start_layer_name

用户自定义蒸馏结构起始层。

required

string

end_layer_name

用户自定义蒸馏结构结束层。

DistillDataQuantConfig

-

-

-

蒸馏数据量化配置。

-

ActULQquantize

ulq_quantize

数据量化的算法,目前仅支持ulq。

ActULQquantize

-

-

-

ULQ数据量化算法配置。算法介绍请参见ULQ数据量化算法。

optional

ClipMaxMin

clip_max_min

初始化的上下限值,如果不配置,默认用ifmr进行初始化。

optional

bool

fixed_min

是否下限不学习且固定为0。默认ReLu后为true,其他为false。

optional

DataType

dst_type

用以选择INT8或INT4量化位宽,默认为INT8。当前版本仅支持INT8量化。

ClipMaxMin

-

-

-

初始上下限。

required

float

clip_max

初始上限值。

required

float

clip_min

初始下限值。

DistillWeightQuantConfig

-

-

-

蒸馏权重量化配置。

-

ARQDistill

arq_distill

ARQ权重量化算法。

-

WtsULQDistill

ulq_distill

ULQ权重量化算法。

ARQDistill

-

-

-

ARQ权重量化算法配置。算法介绍请参见ARQ权重量化算法。

optional

DataType

dst_type

用以选择INT8或INT4量化位宽,默认为INT8。当前版本仅支持INT8量化。

optional

bool

channel_wise

是否做channel wise的arq。

WtsULQDistill

-

-

-

ULQ权重量化算法配置。算法介绍请参见ULQ数据量化算法。

optional

DataType

dst_type

用以选择INT8或INT4量化位宽,默认为INT8。当前版本仅支持INT8量化。

optional

bool

channel_wise

是否做channel wise的ulq。

DistillOverrideLayer

-

-

-

重写的层配置。

required

string

layer_name

层名。

optional

DistillDataQuantConfig

distill_data_quant_config

重写的数据层量化参数。

optional

DistillWeightQuantConfig

distill_weight_quant_config

重写的权重层量化参数。

DistillOverrideLayerType

-

-

-

重写的层类型配置。

required

string

layer_type

层类型。

optional

DistillDataQuantConfig

distill_data_quant_config

重写的数据层量化参数。

optional

DistillWeightQuantConfig

distill_weight_quant_config

重写的权重层量化参数。

基于该文件构造的蒸馏简易配置文件quant.cfg样例如下所示:

batch_num: 1 group_size: 1 data_dump: true distill_group: { start_layer_name: "layer1" end_layer_name: "layer2" } distill_data_quant_config: { ulq_quantize: { clip_max_min: { clip_max: 6.0 clip_min: -6.0 } fixed_min: true dst_type: INT8 } } distill_weight_quant_config: { arq_distill: { channel_wise: true dst_type: INT8 } } quant_skip_layers: "layer3" quant_skip_layer_types: "type1" distill_override_layers : { layer_name: "layer4" distill_data_quant_config: { ulq_quantize: { clip_max_min: { clip_max: 3.0 clip_min: -3.0 } fixed_min: true dst_type: INT8 } } distill_weight_quant_config: { arq_distill: { channel_wise: false dst_type: INT8 } } } distill_override_layer_types : { layer_type: "type2" distill_data_quant_config: { ulq_quantize: { clip_max_min: { clip_max: 3.0 clip_min: -3.0 } fixed_min: true dst_type: INT8 } } distill_weight_quant_config: { ulq_distill: { channel_wise: false dst_type: INT8 } } }

【免费下载链接】amctAMCT是CANN提供的昇腾AI处理器亲和的模型压缩工具仓。项目地址: https://gitcode.com/cann/amct

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

← 返回列表