已合并
torch_extension API文档新增产品型号标签 #8233
chenjiao创建于 10 天前
torch_extension API文档新增产品型号标签 #8233
已合并
chenjiao创建于 10 天前
chenjiao成员
10 天前

描述

  1. torchapi_*.md增加产品型号标签注释
  2. 中文png改为英文文件名

关联的Issue

#4551

测试

已自验

文档更新

torchapi_*.md

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • [x ] 文档更新
  • 其他,请描述:

AI/Agent生成声明

  • AI辅助编写
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenjiao 的贡献)
Cchenjiao成员
10 天前 创建了 pull request,commit 46d65869
atomgit-bot
atomgit-bot
10 天前 评论:

变更摘要

本次 PR 主要面向 torch_extension API 文档,对 36 个文档文件进行统一更新,新增产品型号支持标签,以标识各 API 在不同硬件型号上的兼容性。变更属于纯文档更新,总计新增 224 行、删除 168 行,不涉及任何代码逻辑改动。

主要改动

  • 产品型号标签批量添加:在多个 torch_extension API 文档中引入产品型号支持标识,用于说明各接口支持的具体硬件型号(如不同 MLU 系列产品)
  • 文档内容格式统一调整:对现有文档的标签/元信息区域进行重构,删除或替换旧版描述,使产品型号标签的呈现方式在 36 个文件中保持一致
  • API 兼容性信息补全:为原本缺少型号支持说明的 API 文档补全相关信息,提升开发者查阅时的可读性和准确性
likedislike
atomgit-bot
atomgit-bot
10 天前 评论:

代码审查

所有 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

💬 仅评论

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
10 天前 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
CANN-robot
CANN-robot成员
10 天前 评论:

CLA Signature Pass

gitcode-chenjiao, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
10 天前 将zengjuan,sxb154714,chenfeng61,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,gitee-duhuiping,renruhai,su-yueming,zhajianqing123,chenqi317,LinPX,wang-xing001,liubo75,tangweiwei2,wangzitao_leo,xubinglin,liujie12345678,pingchuantang,Chen_HaoWen,zhouwenfang,wuyao51511,liuyang_806,caiwenwen设为评审人
此处折叠了11条事件消息 查看更多
CANN-robotCANN-robot成员
10 天前 添加了label:cann-cla/yes
chenjiao成员
10 天前 评论:

compile

likedislike
Cchenjiao成员
10 天前 update merge request[project id: 7665709, iid: 8233, commit_id: 6fb3c341e2572ce95d46d4d137824b805d349754] virtual merging success
CANN-robotCANN-robot成员
10 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
10 天前 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robot
CANN-robot成员
10 天前 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
10 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
10 天前 添加了label:ci-pipeline-passed
atomgit-bot
atomgit-bot10 天前进行代码检视1
activation/swiglu_group/docs/torchapi_swiglu_group.md
@@ -29,3 +41,3 @@
2941 
3042```python
31-torch.ops.cann_ops_nn.swiglu_group(
43+cann_ops_nn.swiglu_group(
atomgit-bot
atomgit-bot10 天前评论:

🟡 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(

likedislike
atomgit-bot
atomgit-bot10 天前进行代码检视1
matmul/quant_matmul_activation_quant/docs/torchapi_quant_matmul_activation_quant.md
@@ -14,3 +26,3 @@
1426- 接口功能:
1527 
16- 融合量化的矩阵乘、激活以及动态量化,封装 `aclnnQuantMatmulActivationQuantWeightNz`。当前支持激活为 gelu、MX 量化模式。输入 `x1`、`x2` FP8 量化矩阵,必选输入 `x2_scale`、可选输入 `x1_scale` MX 量化缩放因子,`bias` 为偏置项;矩阵乘结果经激活函数后做动态量化,输出量化结果 `y` 和量化尺度 `y_scale`。M/N/K 维度及转置标志由 `x1`、`x2` 最后两维自动匹配推导,无需显式传入。
28+ 融合量化的矩阵乘、激活以及动态量化,封装`aclnnQuantMatmulActivationQuantWeightNz`。当前支持激活为gelu、MX量化模式。输入`x1`、`x2`为P8量化矩阵,必选输入`x2_scale`、可选输入`x1_scale`为MX量化缩放因子,`bias`为偏置项;矩阵乘结果经激活函数后做动态量化,输出量化结果`y`和量化尺度`y_scale`。M/N/K维度及转置标志由`x1`、`x2`最后两维自动匹配推导,无需显式传入。
atomgit-bot
atomgit-bot10 天前评论:

🟡 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`最后两维自动匹配推导,无需显式传入。
应用建议
likedislike
atomgit-bot
atomgit-bot10 天前进行代码检视1
matmul/quant_matmul_activation_quant/docs/torchapi_quant_matmul_activation_quant.md
@@ -116,1 +113,3 @@
116-| `dst_type_max` | float | 选 | 目标数据类型大值,用于量化范围控制,默认值 0.0(表示使用目标类型默认最大值)。 | float32 | - |
113+| `x1` | Tensor | 选 | 矩阵乘运算中的左矩阵。数据格式为ND。后两维为`(M, K)`或`(K, M)`,由与`x2`维度匹配自动推导。 | torch.float8_e4m3fn、torch.float8_e5m2 | 2-6维,`(..., M, K)`或`(..., K, M)` |
114+| `x2` | Tensor | 必选 | 矩阵乘运算中的右矩阵。数据格式为FRACTAL_NZ。最后两维为`(K, N)`或`(N, K)`,由与`x1`的维度匹配自动推导。 | torch.float8_e4m3fn | 2-6维,`(..., K, N)``(..., N, K)` |
115+| `x2_scale` | Tensor | 必选 | 矩阵乘计算时x2的MX量化缩放因子。数据格式为ND。batch维须与`x2`一致。 | torch.float8_e8m0fnu | `(..., K//64, N, 2)`或`(..., N, K//64, 2)`(随`x2 方向) |
atomgit-bot
atomgit-bot10 天前评论:

🟡 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`方向) |
应用建议
likedislike
atomgit-bot
atomgit-bot10 天前进行代码检视1
quant/grouped_dynamic_mx_quant_with_dual_axis/docs/torchapi_grouped_dynamic_mx_quant_with_dual_axis.md
@@ -79,3 +91,3 @@
7991 
8092```python
81-torch.ops.cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis(
93+cann_ops_nn.grouped_dynamic_mx_quant_with_dual_axis(
atomgit-bot
atomgit-bot10 天前评论:

🟡 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(

likedislike
atomgit-bot
atomgit-bot10 天前进行代码检视1
quant/mx_to_block_mx_quant/docs/torchapi_mx_to_block_mx_quant.md
@@ -175,2 +173,3 @@
173+- 关于输出`scale2`的shape约束说明如下:
175174 - rank(scale2) = rank(x) + 1。
176- - scale2.shape[-3] = ((Ceil(x.shape[-2] / 32) + 2 - 1) / 2) * 2 / 2。
175+ - scale2.shape[-3] = ((Ceil(x.shape[-2], 32) + 2 - 1) / 2) * 2 / 2。
atomgit-bot
atomgit-bot10 天前评论:

🟡 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),与兄弟文档及源码注释保持一致。

likedislike
TangPC
TangPC成员
10 天前 评论:

/lgtm
/approve

likedislike
Cchenjiao成员
10 天前 修改了pull request 的描述
Cchenjiao成员
10 天前 修改了pull request 的描述
吴瑶成员
10 天前 评论:

/lgtm
/approve

likedislike
林鹏翔成员
10 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:approved
范其瑞
范其瑞成员
10 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:lgtm
CANN-robotCANN-robot成员
10 天前 解决了最后一个问题
CANN-robotCANN-robot成员
10 天前 关闭了关联的issue
CANN-robotCANN-robot成员
10 天前 合入了pull request
CANN-robot
CANN-robot成员
10 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike