已关闭
[Bug]: Qwen3-30B-A3B模型执行w4a8量化叠加gptq量化算法,量化报错ERROR - Original exception: ZeroDivisionError('division by zero') #30
mominhua创建于  2月6日关闭于  2月13日
mominhua成员
2月6日 创建

在提交新问题之前,请确保您已经在社区中搜索过相关问题,并使用了社区中提供的资源/工具后,仍未找到满意的解决方式。

⚠️ 安全信息提醒:请仔细检查提供的文本内容,确保其不包含敏感数据信息,包括但不限于:

  • API 令牌或密钥
  • 密码或身份验证凭证
  • 私有网址或接口地址
  • 个人或机密数据
  • ...

在分享配置信息或代码示例时,请将敏感信息脱敏处理,或使用 <TOKEN> 等占位符替代原有内容。

环境信息

例如:
- 操作系统
- 昇腾硬件信息
- CANN软件版本
- 安装的对应软件版本

msmodelslim拉取的本代码仓master源码
环境为A2环境

🐛 问题描述

yaml配置如下:
apiversion: modelslim_v1

default_w8a8_dynamic: &default_w8a8_dynamic
act:
scope: "per_token"
dtype: "int8"
symmetric: True
method: "minmax"
weight:
scope: "per_channel"
dtype: "int8"
symmetric: True
method: "ssz"

default_w4a8_dynamic: &default_w4a8_dynamic
act:
scope: "per_token"
dtype: "int8"
symmetric: True
method: "minmax"
weight:
scope: "per_channel"
dtype: "int4"
symmetric: True
method: "gptq"
ext:
group_size: 64

spec:
process:
- type: "flex_smooth_quant"
enable_subgraph_type:
- 'norm-linear'
- 'ov'
include:
- ""
- type: "group"
configs:
- type: "linear_quant"
qconfig: default_w8a8_dynamic
include: ["self_attn"]
- type: "linear_quant"
qconfig: default_w8a8_dynamic
include: ["mlp"]
exclude: ["gate", "mlp.experts."]
- type: "linear_quant"
qconfig: default_w8a8_dynamic
include: ["model.layers.41.mlp.experts", "model.layers.41.mlp.experts", "model.layers.42.mlp.experts", "model.layers.43.mlp.experts", "model.layers.44.mlp.experts", "model.layers.45.mlp.experts", "model.layers.46.mlp.experts", "model.layers.47.mlp.experts"]
- type: "linear_quant"
qconfig: default_w4a8_dynamic
include: ["mlp.experts"]
exclude: ["model.layers.41.
", "model.layers.42.
", "model.layers.43.
", "model.layers.44.
", "model.layers.45.
", "model.layers.46.", "model.layers.47."]

save:
- type: "ascendv1_saver"
part_file_size: 4

执行量化命令:
msmodelslim quant --model_path /packages/models_weight/Qwen3-30B-A3B/ --save_path /home/msmodelslim/model_quant/Qwen3-30B-A3B-w4a8-gptq-per-token-per-channel --model_type Qwen3-30B --device npu --config_path /home/msmodelslim/yaml/qwen3-30b-w4a8-per_token_gptq_per_channel.yaml --trust_remote_code True

量化报错:
2026-02-06 15:07:52,674 - msmodelslim.app.naive_quantization - ERROR - [UnexpectedError] Code: 500, Message: Unexpected error., TIP: Please report this issue to the msModelSlim developers. Repository: https://gitcode.com/Ascend/msmodelslim Q&A: https://gitcode.com/Ascend/msmodelslim/blob/master/docs/zh/faq.md
2026-02-06 15:07:52,674 - msmodelslim.app.naive_quantization - ERROR - Original exception: ZeroDivisionError('division by zero')
image.png
image.png

欢迎加入社区,感谢您对社区的贡献 🎉!

likedislike
Mmominhua成员
2月6日 关联了里程碑:MindStudio 26.0.0
Mmominhua成员
2月6日 添加了label:bug, high-priority
Mmominhua成员
2月6日 修改了issue 的描述
SuperMeixc成员
2月6日 评论:

您好,问题已收到,我们会尽快修复,请关注此issue进展

likedislike
SuperMeixc成员
2月6日 评论:

/label add triaged

likedislike
ascend-robotascend-robot成员
2月6日 添加了label:triaged
Mmominhua成员
2月9日 添加了label:medium-priority;删除了label:high-priority
SSuperMeixc成员
2月9日 关联了pull request:【bugfix】MOE模型GPTQ量化报错场景优化
SuperMeixc成员
2月10日 评论:

/label add resolved

likedislike
ascend-robotascend-robot成员
2月10日 添加了label:resolved
SuperMeixc成员
2月10日 评论:

/label remove triaged

likedislike
ascend-robotascend-robot成员
2月10日 删除了label:triaged
SSuperMeixc成员
2月11日 issue状态由 TODO 改变为 DONE
SSuperMeixc成员
2月11日 关闭了 issue
SSuperMeixc成员
2月13日 issue状态由 DONE 改变为 TODO
SSuperMeixc成员
2月13日 重新打开了 issue
SuperMeixc成员
2月13日 评论:

问题已解决,请进行验证

likedislike
mominhua成员
2月13日 评论:

测试通过,问题已解决

1、检查资料增加moe模型相关限制说明
资料增加限制:https://gitcode.com/Ascend/msmodelslim/blob/master/docs/zh/algorithms_instruction/gptq.md
image.png

2、使用moe模型,跑gptq算法,报错日志清晰
image.png

likedislike
Mmominhua成员
2月13日 issue状态由 TODO 改变为 DONE
Mmominhua成员
2月13日 关闭了 issue
zeshengzongzeshengzong成员
3月11日 关联了里程碑:MindStudio 26.0.0