Pull Request已成功合入, 合并人@CANN-robot
(感谢 季骏 的贡献)变更摘要
本次变更修复了 dynamic_mx_quant 量化过程中,当数据块全为零时,maxLowBound(最大下界)会错误地将全零块提升为非零值,导致量化后的共享指数(mxScale)未能正确反映原始零块属性的问题。修复方案是在计算共享指数时,先检测全零块,再通过掩码将对应位置的 mxScale 强制置零,确保全零块的量化结果保持为零。
主要改动
-
全零块检测:在
dynamic_mx_quant_not_tail_axis_optimize_high_perf_large_tail.h和dynamic_mx_quant_not_tail_axis_optimize_high_perf_small_tail.h中,均新增了Reg::CompareScalar<uint32_t, CMPMODE::NE>比较指令,在应用maxLowBound_之前将数据块与FP32_NUMBER_ZERO比较,生成零块掩码pZeroBlock/maxLowBoundMask。 -
零块 mxScale 强制置零:两文件中在 mxScale 计算完成后,若处于
MODE_ONE模式,新增Reg::Select<uint32_t>指令,利用零块掩码将对应位置的mxScale0FP32/mxScale1FP32/mxScaleU32替换为zeroU32(即FP32_NUMBER_ZERO)。 -
新增寄存器资源:两文件均新增了
Reg::RegTensor<uint32_t> zeroU32寄存器的声明与Reg::Duplicate(zeroU32, FP32_NUMBER_ZERO)初始化;large_tail文件还新增了Reg::MaskReg pZeroBlock掩码寄存器。


代码审查
审查总结
| 优先级 | 数量 |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 0 |
| P3 | 2 |
整体风险评估:低风险。 本次 diff 的逻辑正确,在 MODE_ONE 计算模式下为两个高性能优化变体(large_tail 和 small_tail)新增了零块(全零数据块)的 scale 清零处理。零块检测的时机(在 Maxs(maxLowBound_) 之前捕获原始 manAbs0FP32 / absMaxU32)和覆写时机(在 Pack 之前用 Select 将 scale 置零)均正确。报告的两项 P3 问题均为掩码/字段命名与语义不符,不影响当前代码正确性,但建议修改以避免后续维护中的理解错误。
各文件审查结果
quant/dynamic_mx_quant/op_kernel/arch35/dynamic_mx_quant_not_tail_axis_optimize_high_perf_large_tail.h:1 项 P3(pZeroBlock命名与语义相反)quant/dynamic_mx_quant/op_kernel/arch35/dynamic_mx_quant_not_tail_axis_optimize_high_perf_small_tail.h:1 项 P3(maxLowBoundMask字段名与实际用途不符)
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| quant | ✅ 苏跃明, 王星 (2/2) | ✅ 苏跃明, 王星 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


compile


流水线任务触发成功
任务链接 [06a66a95d7de4e6e9bfb61b688ce5bb3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-nn | ✅ SUCCESS | ||
| UT_Test_harmony-infer-chs-nn-1 | ✅ SUCCESS | ||
| UT_Test_report_lcov | ✅ SUCCESS | >>>>> |
[2026-07-24 11:08:50] CI执行结束


流水线任务触发成功
任务链接 [c47604c6875b45b1b8d26f99cff12a90][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> |
[2026-07-24 10:56:39] CI执行结束


/lgtm
/approve


/lgtm
/approve


描述
dynamic_mx_quant的maxLowBound逻辑,不同模板不统一的修改
关联的Issue
#4310
测试
已通过ST测试
文档更新
不涉及
类型标签
AI/Agent生成声明