---
title: 蒸馏简易配置文件
description: "distill_config_pytorch.proto文件参数说明如表1所示，该文件所在目录为：AMCT安装目录/amct_pytorch/proto/distill_config_pytorch.proto。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/amct/atlasamct_16_0135.html
sourcePath: /source/zh/canncommercial/900/devaids/amct/atlasamct_16_0135.html
indexId: 6c1e0af6caea2f90cad8c0a54e0612e44cd6bb11d32099d8923aa8a99e73840a65
---
# 蒸馏简易配置文件

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


**表1 distill_config_pytorch.proto参数说明**

| 消息 | 是否必填 | 类型 | 字段 | 说明 |
| --- | --- | --- | --- | --- |
| AMCTDistillConfig | \- | \- | \- | AMCT蒸馏的简易配置。 |
| AMCTDistillConfig | optional | uint32 | batch\_num | 蒸馏batch数量，用于ifmr积累数据计算量化因子。 |
| AMCTDistillConfig | optional | uint32 | group\_size | 蒸馏block中最小蒸馏单元个数。 |
| AMCTDistillConfig | optional | bool | data\_dump | teacher网络block输入输出dump开关。 |
| AMCTDistillConfig | repeated | DistillGroup | distill\_group | 用户自定义蒸馏结构。 |
| AMCTDistillConfig | optional | DistillDataQuantConfig | distill\_data\_quant\_config | 蒸馏数据量化配置参数。 |
| AMCTDistillConfig | optional | DistillWeightQuantConfig | distill\_weight\_quant\_config | 蒸馏权重量化配置参数。 |
| AMCTDistillConfig | repeated | DistillOverrideLayer | distill\_override\_layers | 重写某一层的量化配置。 |
| AMCTDistillConfig | repeated | DistillOverrideLayerType | distill\_override\_layer\_types | 重写某一类型层的量化配置。 |
| AMCTDistillConfig | repeated | string | quant\_skip\_layers | 不需要量化的层，仍然做蒸馏。 |
| AMCTDistillConfig | repeated | string | quant\_skip\_layer\_types | 不需要量化的算子类型，仍然需要做蒸馏。 |
| DistillGroup | \- | \- | \- | 用户自定义蒸馏结构。蒸馏结构中仅支持torch.nn.Module类型的算子。 |
| DistillGroup | required | string | start\_layer\_name | 用户自定义蒸馏结构起始层。 |
| DistillGroup | required | string | end\_layer\_name | 用户自定义蒸馏结构结束层。 |
| DistillDataQuantConfig | \- | \- | \- | 蒸馏数据量化配置。 |
| DistillDataQuantConfig | \- | ActULQquantize | ulq\_quantize | 数据量化的算法，目前仅支持ulq。 |
| ActULQquantize | \- | \- | \- | ULQ数据量化算法配置。算法介绍请参见ULQ数据量化算法。 |
| ActULQquantize | optional | ClipMaxMin | clip\_max\_min | 初始化的上下限值，如果不配置，默认用ifmr进行初始化。 |
| ActULQquantize | optional | bool | fixed\_min | 是否下限不学习且固定为0。默认ReLu后为true，其他为false。 |
| ActULQquantize | optional | DataType | dst\_type | 用以选择INT8或INT4量化数据类型，默认为INT8。当前版本仅支持INT8量化。 |
| ClipMaxMin | \- | \- | \- | 初始上下限。 |
| ClipMaxMin | required | float | clip\_max | 初始上限值。 |
| ClipMaxMin | required | float | clip\_min | 初始下限值。 |
| DistillWeightQuantConfig | \- | \- | \- | 蒸馏权重量化配置。 |
| DistillWeightQuantConfig | \- | ARQDistill | arq\_distill | ARQ权重量化算法。 |
| DistillWeightQuantConfig | \- | WtsULQDistill | ulq\_distill | ULQ权重量化算法。 |
| ARQDistill | \- | \- | \- | ARQ权重量化算法配置。算法介绍请参见ARQ。 |
| ARQDistill | optional | DataType | dst\_type | 用以选择INT8或INT4量化数据类型，默认为INT8。当前版本仅支持INT8量化。 |
| ARQDistill | optional | bool | channel\_wise | 是否做channel wise的arq。 |
| WtsULQDistill | \- | \- | \- | ULQ权重量化算法配置。算法介绍请参见ULQ数据量化算法。 |
| WtsULQDistill | optional | DataType | dst\_type | 用以选择INT8或INT4量化数据类型，默认为INT8。当前版本仅支持INT8量化。 |
| WtsULQDistill | optional | bool | channel\_wise | 是否做channel wise的ulq。 |
| DistillOverrideLayer | \- | \- | \- | 重写的层配置。 |
| DistillOverrideLayer | required | string | layer\_name | 层名。 |
| DistillOverrideLayer | optional | DistillDataQuantConfig | distill\_data\_quant\_config | 重写的数据层量化参数。 |
| DistillOverrideLayer | optional | DistillWeightQuantConfig | distill\_weight\_quant\_config | 重写的权重层量化参数。 |
| DistillOverrideLayerType | \- | \- | \- | 重写的层类型配置。 |
| DistillOverrideLayerType | required | string | layer\_type | 层类型。 |
| DistillOverrideLayerType | optional | DistillDataQuantConfig | distill\_data\_quant\_config | 重写的数据层量化参数。 |
| DistillOverrideLayerType | 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
}
}
}
```
