Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenjiao 的贡献)变更摘要
本次 PR 主要面向 torch_extension API 文档,对 36 个文档文件进行统一更新,新增产品型号支持标签,以标识各 API 在不同硬件型号上的兼容性。变更属于纯文档更新,总计新增 224 行、删除 168 行,不涉及任何代码逻辑改动。
主要改动
- 产品型号标签批量添加:在多个
torch_extensionAPI 文档中引入产品型号支持标识,用于说明各接口支持的具体硬件型号(如不同 MLU 系列产品) - 文档内容格式统一调整:对现有文档的标签/元信息区域进行重构,删除或替换旧版描述,使产品型号标签的呈现方式在 36 个文件中保持一致
- API 兼容性信息补全:为原本缺少型号支持说明的 API 文档补全相关信息,提升开发者查阅时的可读性和准确性


代码审查
所有 10 个变更文件已逐一审查完毕。以下是汇总:
审查结论汇总
发现问题统计
| 优先级 | 数量 | 说明 |
|---|---|---|
| P2 | 3 | 文档内容错误,可能误导用户 |
| P3 | 3 | 轻微问题,排版清理失误或信息丢失 |
| P0/P1 | 0 | 无安全漏洞、无破坏性变更 |
各文件审查结论
| 文件 | 结论 |
|---|---|
activation/swiglu_group/docs/torchapi_swiglu_group.md |
无问题 |
activation/swiglu_group_quant/docs/torchapi_swiglu_group_quant.md |
1 个 P3(weight shape 疑似误截断) |
docs/zh/context/quant_mode_introduction.md |
无问题(图片重命名文件均存在) |
matmul/quant_matmul_activation_quant/docs/torchapi_quant_matmul_activation_quant.md |
2 个 P2("P8" 笔误 + 缺失闭合反引号) |
norm/rms_norm_dynamic_quant/docs/torchapi_rms_norm_dynamic_quant.md |
1 个 P3(丢失介词"与") |
quant/.gitignore |
无问题 |
quant/flat_quant/docs/torchapi_flat_quant.md |
无问题(约束信息仅从约束说明节移至参数描述表,信息未丢失) |
quant/grouped_dynamic_mx_quant_with_dual_axis/docs/torchapi_grouped_dynamic_mx_quant_with_dual_axis.md |
无问题 |
quant/mx_to_block_mx_quant/docs/torchapi_mx_to_block_mx_quant.md |
1 个 P2(Ceil 公式除法误改为逗号,与兄弟文档不一致) |
quant/swiglu_group_grad/docs/torchapi_swiglu_group_backward.md |
1 个 P3(Tensor? → Tensor 丢失可选语义) |
整体风险评估
此次 PR 整体为文档格式整理 + 产品型号标签添加,风险较低。发现的 3 个 P2 问题均为排版清理过程中的意外损坏(字符丢失、标点缺失、公式改写),不影响线上运行但会降低文档准确性。建议在合入前修复这 3 个 P2 问题,P3 问题可根据优先级酌情处理。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 5 |
💬 仅评论


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 |
|---|---|---|
| activation | ✅ 汤平川, 范其瑞 (2/2) | ✅ 汤平川 (1/1) |
| docs | ✅ 吴瑶, 汤平川, 范其瑞 (3/2) | ✅ 吴瑶 (1/1) |
| matmul | ✅ 汤平川, 林鹏翔, 范其瑞 (3/2) | ✅ 林鹏翔, 范其瑞 (2/1) |
| norm | ✅ 范其瑞, 汤平川 (2/2) | ✅ 汤平川 (1/1) |
| quant | ✅ 汤平川, 范其瑞, 林鹏翔 (3/2) | ✅ 林鹏翔, 汤平川 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
gitcode-chenjiao, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [aa601d10cdc1407ab5189354451c0ff0][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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_harmony-infer-cpro-nn | ✅ SUCCESS | ||
| UT_Test_report_lcov | ⚠️ WARNING | >>>>> |
[2026-08-04 12:20:16] CI执行结束


流水线任务触发成功
任务链接 [9634452162dc4b22b36b43433d06ecce][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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-08-04 12:07:02] CI执行结束


🟡 Medium Priority
变更将函数原型从 torch.ops.cann_ops_nn.swiglu_group( 改为 cann_ops_nn.swiglu_group((第43行),但下方示例代码(第92行、第107行)仍然使用 torch.ops.cann_ops_nn.swiglu_group(。
- 变更行:第43行(函数原型)
建议:统一示例代码中的 API 调用形式,将第92行和第107行的 torch.ops.cann_ops_nn.swiglu_group( 改为 cann_ops_nn.swiglu_group(,或将函数原型恢复为 torch.ops.cann_ops_nn.swiglu_group(。


🟡 Medium Priority
在功能说明段落中,原文"FP8量化矩阵"(Float Point 8)被误改为"P8量化矩阵"。该文档其余各处(第74、75、82、88、90、127行)均一致使用"FP8",此处"P8"为排版清理过程中意外丢失"F"导致的拼写错误。用户阅读时会误解为某种不存在的"P8"数据类型。
建议:将"P8"修正为"FP8",恢复丢失的字符"F"。
| 28
| - 融合量化的矩阵乘、激活以及动态量化,封装`aclnnQuantMatmulActivationQuantWeightNz`。当前支持激活为gelu、MX量化模式。输入`x1`、`x2`为P8量化矩阵,必选输入`x2_scale`、可选输入`x1_scale`为MX量化缩放因子,`bias`为偏置项;矩阵乘结果经激活函数后做动态量化,输出量化结果`y`和量化尺度`y_scale`。M/N/K维度及转置标志由`x1`、`x2`最后两维自动匹配推导,无需显式传入。 |
|
28 | + 融合量化的矩阵乘、激活以及动态量化,封装`aclnnQuantMatmulActivationQuantWeightNz`。当前支持激活为gelu、MX量化模式。输入`x1`、`x2`为FP8量化矩阵,必选输入`x2_scale`、可选输入`x1_scale`为MX量化缩放因子,`bias`为偏置项;矩阵乘结果经激活函数后做动态量化,输出量化结果`y`和量化尺度`y_scale`。M/N/K维度及转置标志由`x1`、`x2`最后两维自动匹配推导,无需显式传入。 |


🟡 Medium Priority
x2_scale 参数的 shape 描述列中,原文 (随 x2 方向) 在排版清理后变为 (随x2 方向),缺少了 x2后面的闭合反引号 `` ``。对比同一表格中 x1_scale 行(第116行)正确使用了 (随x1方向)(含闭合反引号),此处缺少反引号会导致 Markdown 渲染异常,x2 方向 可能被错误地连带渲染为行内代码。
建议:在 x2 后补上缺失的闭合反引号 `,即 (随x2方向)。
| 115
| - | `x2_scale` | Tensor | 必选 | 矩阵乘计算时x2的MX量化缩放因子。数据格式为ND。batch维须与`x2`一致。 | torch.float8_e8m0fnu | `(..., K//64, N, 2)`或`(..., N, K//64, 2)`(随`x2 |
|
115 | + | `x2_scale` | Tensor | 必选 | 矩阵乘计算时x2的MX量化缩放因子。数据格式为ND。batch维须与`x2`一致。 | torch.float8_e8m0fnu | `(..., K//64, N, 2)`或`(..., N, K//64, 2)`(随`x2`方向) | |


🟡 Medium Priority
变更将函数原型从 torch.ops.cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis( 改为 cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis((第93行),但下方示例代码(第265行)仍然使用 torch.ops.cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis(。
- 变更行:第93行(函数原型)
- 影响:用户阅读文档时看到两种不同的调用形式,会困惑应使用哪一种。若直接复制原型形式但实际只有旧形式可用(或反之),将导致运行时
AttributeError。
建议:统一示例代码中的 API 调用形式,将第265行的 torch.ops.cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis( 改为 cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis(,或将函数原型恢复为 torch.ops.cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis(。


🟡 Medium Priority
在 shape 约束公式中,原文 Ceil(x.shape[-1] / 32)(先除再取上整,语义明确)被系统性地改为 Ceil(x.shape[-1], 32)(双参数形式,语义模糊)。同一算子的兄弟文档 aclnnMxToBlockMxQuant.md(第281/286/291行)、README.md(第106/111/116行)以及 C++ 头文件 mx_to_block_mx_quant_proto.h(第29/39行)均保持使用 Ceil(... / 32) 的除法形式。此 diff 引入的不一致会使用户对 shape 计算公式产生歧义——若将 Ceil(a, b) 解读为"将 a 向上舍入到 b 的整数倍",则计算结果与原文完全不同(例如 x.shape[-1]=64 时,旧公式得 1.5,新解读可能得 32.5)。
受影响位置:
- 第165行:
mxscale.shape[-2] - 第170行:
scale1.shape[-2] - 第175行:
scale2.shape[-3]
建议:将所有 Ceil(x.shape[-1], 32) 恢复为 Ceil(x.shape[-1] / 32),Ceil(x.shape[-2], 32) 恢复为 Ceil(x.shape[-2] / 32),与兄弟文档及源码注释保持一致。


/lgtm
/approve


/lgtm
/approve


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


描述
关联的Issue
#4551
测试
已自验
文档更新
torchapi_*.md
类型标签
AI/Agent生成声明