Sync v2.0 version of code to github repo

This commit is contained in:
Jiang-Jia-Jun
2025-06-29 23:29:37 +00:00
parent d151496038
commit 92c2cfa2e7
597 changed files with 78776 additions and 22905 deletions

View File

@@ -0,0 +1,62 @@
# WINT2量化
权重经过CCQConvolutional Coding Quantization方法离线压缩。权重实际存储的数值类型是INT8每个INT8数值中打包了4个权重等价于每个权重2bits. 激活不做量化计算时将权重实时地反量化、解码为BF16数值类型并用BF16数值类型计算。
- **支持硬件**GPU
- **支持结构**MoE结构
CCQ WINT2一般用于资源受限的低门槛场景以ERNIE-4.5-300B-A47B为例将权重压缩到89GB可支持141GB H20单卡部署。
## 启动WINT2推理服务
```
python -m fastdeploy.entrypoints.openai.api_server \
--model baidu/ERNIE-4.5-300B-A47B-2Bits-Paddle \
--port 8180 --engine-worker-queue-port 8181 \
--cache-queue-port 8182 --metrics-port 8182 \
--tensor-parallel-size 1 \
--max-model-len 32768 \
--max-num-seqs 32
```
通过指定 `--model baidu/ERNIE-4.5-300B-A47B-2Bits-Paddle` 可自动从AIStudio下载已离线量化好的WINT2模型在该模型的config.json文件中会有WINT2量化相关的配置信息不用再在启动推理服务时设置 `--quantization`.
模型的config.json文件中的量化配置示例如下
```
"quantization_config": {
"dense_quant_type": "wint8",
"moe_quant_type": "w4w2",
"quantization": "wint2",
"moe_quant_config": {
"moe_w4_quant_config": {
"quant_type": "wint4",
"quant_granularity": "per_channel",
"quant_start_layer": 0,
"quant_end_layer": 6
},
"moe_w2_quant_config": {
"quant_type": "wint2",
"quant_granularity": "pp_acc",
"quant_group_size": 64,
"quant_start_layer": 7,
"quant_end_layer": 53
}
}
}
```
- 更多部署教程请参考[get_started](../get_started/ernie-4.5.md)
- 更多模型说明请参考[支持模型列表](https://console.cloud.baidu-int.com/devops/icode/repos/baidu/paddle_internal/FastDeploy/blob/feature%2Finference-refactor-20250528/docs/supported_models.md)。
## WINT2效果
在ERNIE-4.5-300B-A47B模型上WINT2与WINT4效果对比
| 测试集 |数据集大小| WINT4 | WINT2 |
|---------|---------|---------|---------|
| IFEval |500|88.17 | 85.40 |
|BBH|6511|94.43|92.02|
|DROP|9536|91.17|89.97|
## WINT2推理性能