Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenfeng 的贡献)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)
CLA Signature Pass
chenfeng61, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [6a85d9c148c7442f9858d1d3d24d1a99][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-06-29 09:50:58] CI执行结束


变更摘要
该 PR 对 SwiGLU MX 量化算子的 arch35 架构实现进行了多项优化和修复,主要涉及缓冲区大小计算修正、双缓冲降级为单缓冲、tiling 参数硬编码化,以及 scale2 数据交织操作的 API 替换。
主要改动
-
scale2Ub计算常量修正: 在swiglu_mx_quant_with_dual_axis_tiling_arch35.cpp中,scale2Ub的计算将乘数从DIGIT_TWO(2) 改为DIGIT_HTREE(3),匹配 scale2 实际需要的 3 行缓冲区大小。 -
Queue 双缓冲降级为单缓冲:
inQueue_、outQueue1_、outQueue2_、mxScaleQueue1_、mxScaleQueue2_的模板参数从DB_BUFFER(2) 改为1,移除所有队列的双缓冲机制以节省 UB 空间。 -
ubRowLen_与ubRowCount_硬编码:InitParams()中ubRowLen_改用新增常量ONCE_ROW_LEN(256) 替代tilingData_->blockW,ubRowCount_改用DOUBLE_BLOCK_SIZE(64) 替代tilingData_->splitBlockH,不再依赖 tiling 数据。 -
mxScale2缓冲区大小简化:mxScale2BufferSize从ubRowLen_ * ((ubRowCount_ / DOUBLE_BLOCK_SIZE) * DIGIT_TWO)简化为ubRowLen_ * DIGIT_THREE;tmpScale2BufferSize从ubRowLen_ * ((ubRowCount_ / DOUBLE_BLOCK_SIZE) * DIGIT_TWO) * sizeof(xDtype)简化为ubRowLen_ * DIGIT_TWO * sizeof(xDtype)。 -
交织操作改用
ComputeInterleave: 新增ComputeInterleave方法,内部使用MicroAPI::DataCopy配合DIST_INTLV_B8交织存储模式完成 scale2 数据的字节级交织,替代原有的Interleave函数调用。


流水线任务触发成功
任务链接 [c5c1b3e1b9bb401b94998d27d7fa6cfb][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| SCA | ✅ SUCCESS | >>>>> |
[2026-06-29 09:49:36] CI执行结束


代码审查
审查总结
| 优先级 | 数量 | 说明 |
|---|---|---|
| P0 | 0 | 无 |
| P1 | 0 | 无 |
| P2 | 2 | 队列深度不匹配、DataCopy 越界加载风险 |
| P3 | 1 | tiling data 契约被硬编码绕过(可选建议) |
各文件审查结果:
-
quant/swiglu_mx_quant_with_dual_axis/op_host/arch35/swiglu_mx_quant_with_dual_axis_tiling_arch35.cpp— 仅 1 行改动(DIGIT_TWO→DIGIT_HTREE),与 kernel 侧的 mxScale2 缓冲区增大一致,无独立问题。 -
quant/swiglu_mx_quant_with_dual_axis/op_kernel/arch35/swiglu_mx_quant_with_dual_axis_regbase.h— 34 行新增/修改,发现 3 个问题(2 个 P2 + 1 个 P3)。
整体风险评估:中等。P2 的两个问题分别涉及 AscendC pipeline 框架的队列契约不一致和可能的 UB 越界读取,在特定条件下可能导致运行时错误或精度异常。建议优先修复队列深度与 InitBuffer 的匹配问题,并确认 ComputeInterleave 中的 DataCopy 加载 API 用法的正确性。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


🟡 Medium Priority
diff 将 5 个队列的模板深度从 DB_BUFFER(2) 改为 1(第 149-154 行),但对应的 InitBuffer 调用(第 251、253-256 行)仍然传递 DB_BUFFER(2) 作为 buffer 数量。
在 AscendC 框架中,TQue<Pos, N> 的 N 表示队列 pipeline 深度,InitBuffer(queue, cnt, size) 的 cnt 表示物理 buffer 数量,二者应保持一致。当前的不匹配意味着:
- 若框架以 TQue 深度为准,则只使用 1 个 buffer,另 1 个 buffer 被分配但从不使用(浪费 UB 内存);
- 若框架以 InitBuffer 为准,则 pipeline 深度为 1 但物理 buffer 为 2,可能导致 EnQue/DeQue 时 buffer 管理出错。
受影响的队列:inQueue_, outQueue1_, outQueue2_, mxScaleQueue1_, mxScaleQueue2_。
此变更的意图似乎是简化 pipeline(单缓冲),但遗漏了同步更新 InitBuffer 调用。
建议:方案一(推荐):若确实只需单缓冲,将 InitBuffer 的第二个参数从 DB_BUFFER 改为 1,并同步更新 host 侧的 UB 大小校验(减少 scale1Ub/scale2Ub/y1Ub 等的 DB 因子)。
方案二:若仍需双缓冲,将 TQue 模板参数恢复为 DB_BUFFER。


HTREE?拼错了THREE?


compile


流水线任务触发成功
任务链接 [e561a03fda46466cac3fcefd31878df3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-06-29 10:39:08] CI执行结束


/approve
/lgtm


流水线任务触发成功
任务链接 [d56d9017e2cb4842901ad186928502f8][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_style | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
| SCA | ✅ SUCCESS | >>>>> |
[2026-06-29 10:34:50] CI执行结束


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
对 SwigluMxQuantWithDualAxis 算子 arch35 偶现精度问题修改:
关联的Issue
https://gitcode.com/cann/ops-nn/issues/3641
测试
文档更新
无
类型标签
AI/Agent生成声明