已合并
docs(01.06): 补充 5.1 节 ScaleA/B 三维 Shape 的硬件对齐背景说明 #752
docs(01.06): 补充 5.1 节 ScaleA/B 三维 Shape 的硬件对齐背景说明 #752
已合并
XieQianyi创建于 28 天前
XieQianyi
XieQianyi
28 天前

关联 Issue

fixes #94

背景

Issue #94 反馈 5.1 节「MX 量化参数规格」中 ScaleA/ScaleB 的 Shape 为三维 (m, ceil(k/64), 2),但未说明原因。按照 3.4 节 G 量化定义(group size=32),逻辑形状应为 (m, ceil(k/32)),二者差异容易让读者困惑。

修改内容

在 5.1 节计算公式之后、5.2 节标题之前,补充一段说明,解释三维 Shape 的由来:

  • float8_e8m0 仅占 1 字节,而硬件访存最小粒度通常为 2 字节
  • 因此将 K 轴方向相邻的两个 scale 打包成 2 字节一起读取,减少访存次数、提升带宽利用率
  • 当 K 为 64 的倍数时(见 5.3 节约束 baseK 必须是 64 的整数倍),ceil(k/64) * 2 = ceil(k/32),与逻辑形状元素总数等价

修改文件

  • tutorials/matmul_operator_development/01_matmul_basic_operator_development/01.06_matmul_quantization_modes_and_implementation.ipynb(+6 行)
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 XieQianyi 的贡献)
XieQianyiXieQianyi
28 天前 创建了 pull request,commit 3dd6e759
XieQianyiXieQianyi
28 天前 关联了issue:[Documentation|文档反馈]: 5.1节 ScaleA/B Shape设计原因未说明,建议补充硬件对齐背景
atomgit-bot
atomgit-bot
28 天前 评论:

变更摘要

本 PR 针对文档 01.06_matmul_quantization_modes_and_implementation.ipynb 中 5.1 节「MX 量化参数规格」的 ScaleA/ScaleB Shape 说明进行补充,旨在回应用户对三维形状 (m, ceil(k/64), 2) 与 3.4 节 G 量化逻辑形状不一致的疑问。改动在 5.1 节计算公式之后新增一段说明文字,解释该三维 Shape 是出于硬件访存对齐考虑,并论证其与逻辑形状在元素总数上的等价性。

主要改动

  • 新增 Shape 说明段落:在 5.1 节计算公式之后、5.2 节标题之前补充「ScaleA/ScaleB Shape 说明」,说明 ScaleA 逻辑形状应为 (m, ceil(k/32))ScaleB 应为 (n, ceil(k/32)),而三维形状 (m, ceil(k/64), 2) 是出于硬件访存对齐考虑。
  • 说明打包访存原因:新增说明指出 float8_e8m0 仅占 1 字节,而硬件访存最小粒度通常为 2 字节,因此将 K 轴方向相邻的两个 scale 打包成 2 字节一起读取,以减少访存次数、提升带宽利用率。
  • 补充元素总数等价关系:新增说明指出当 K 为 64 的倍数时(见 5.3 节约束),ceil(k/64) * 2 = ceil(k/32),二者元素总数等价。
likedislike
不准确?
atomgit-bot
atomgit-bot
28 天前 评论:

代码审查

审查总结

本次审查覆盖了变更文件 tutorials/matmul_operator_development/01_matmul_basic_operator_development/01.06_matmul_quantization_modes_and_implementation.ipynb(+6 行文档说明),已逐行核对新增内容及其上下文(3.4 节 G 量化定义、5.1 节公式与规格表、5.3 节约束)。

发现结果按优先级统计:

  • P0:0
  • P1:0
  • P2:1
  • P3:0

整体风险判断:变更本身为文档说明补充,不涉及代码、配置或依赖,无构建/安全风险;但新增说明中 ScaleB 的逻辑形状与其引用的 3.4 节定义及同节公式存在转置矛盾,属于中等严重度的文档正确性缺陷,建议修正后再合入。

已审查文件确认:

  • tutorials/matmul_operator_development/01_matmul_basic_operator_development/01.06_matmul_quantization_modes_and_implementation.ipynb:发现 1 个问题(ScaleB 逻辑形状写反)。
类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
不准确?
CANN-robotCANN-robot成员
28 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
28 天前 评论:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/cann-learning-hub fuyangchenghu, waimaidaole (2/2) fuyangchenghu (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
XieQianyi
XieQianyi
28 天前 评论:

compile

likedislike
XieQianyiXieQianyi
28 天前 update merge request[project id: 9260575, iid: 752, commit_id: 1a977636404c358714839fdd3e3b3e9ca48b4a8d] virtual merging success
CANN-robotCANN-robot成员
28 天前 添加了label:ci-pipeline-running
atomgit-bot
atomgit-bot28 天前进行代码检视2
tutorials/matmul_operator_development/01_matmul_basic_operator_development/01.06_matmul_quantization_modes_and_implementation.ipynb
已过期
@@ -363,6 +363,12 @@
363363 "\n",
364364 "其中 G 为 group size,在 MX 量化场景固定取值为32。\n",
365365 "\n",
366+ "**ScaleA/ScaleB Shape 说明**:按照 3.4 节 G 量化的定义,group size=32 时 ScaleA 的逻辑形状应为 `(m, ceil(k/32))`、ScaleB 为 `(n, ceil(k/32))`。上表中的三维形状 `(m, ceil(k/64), 2)` 是出于硬件访存对齐的考虑:\n",
atomgit-bot
atomgit-bot28 天前评论:

🟡 Medium Priority

新增第 366 行将 ScaleB 的逻辑形状写为 (n, ceil(k/32)),并声称「按照 3.4 节 G 量化的定义」。但 3.4 节(第 179 行)明确写的是「右矩阵 (k, n) 的 Scale shape 为 (k/gs, n)」,即 group size=32 时应为 (ceil(k/32), n),与新增说明互为转置。同时本节 5.1 的计算公式(第 361 行)使用 scaleB_{g, j}(g 沿 K 轴分组、j 沿 N 轴),也对应 (k/32, n) 而非 (n, ceil(k/32))。读者对照 3.4 节或公式时会发现新增说明自相矛盾,反而加剧了 #94 想要消除的 ScaleB 形状困惑。建议将 ScaleB 逻辑形状修正为 (ceil(k/32), n) 以与 3.4 节和公式一致;若文档确实采用转置约定(5.1 表中 b 为 (n, k)、scaleB 为 (n, ceil(k/64), 2)),则不应把该形状归因于 3.4 节,并需将公式与表格一并统一。

建议:将新增说明中 ScaleB 的逻辑形状改为 (ceil(k/32), n),与 3.4 节 (k/gs, n) 及第 361 行公式 scaleB_{g,j} 保持一致;并确认 5.1 表中 scaleB 的 (n, ceil(k/64), 2) 是否也需要相应调整为 (ceil(k/64), n, 2)(或明确说明采用转置约定并与公式统一)。

likedislike
不准确?
System
系统消息系统
28 天前 评论:

changed this line on 2843e022 view diff detail

CANN-robotCANN-robot成员
28 天前 删除了label:ci-pipeline-running
此处折叠了5条事件消息 查看更多
CANN-robotCANN-robot成员
28 天前 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
28 天前 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

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

compile

likedislike
XieQianyiXieQianyi
28 天前 update merge request[project id: 9260575, iid: 752, commit_id: 2bd182ebfc61465354d8e09576383384642c8214] virtual merging success
CANN-robotCANN-robot成员
28 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
28 天前 评论:

流水线任务触发成功
任务链接 [37366e33b62848978e5f12ffc11637c5][流水线指导]

任务名称状态日志下载链接
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
codecheck_style ✅ SUCCESS >>>>>
pre-commit ✅ SUCCESS

[2026-08-17 15:33:42]    CI执行结束

likedislike
CANN-robotCANN-robot成员
28 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
28 天前 添加了label:ci-pipeline-passed
CANN-robotCANN-robot成员
28 天前 删除了label:ci-pipeline-passed
CANN-robotCANN-robot成员
28 天前 添加了label:ci-pipeline-passed
meme成员
28 天前 评论:

/lgtm

likedislike
fuyangchenghu成员
24 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
24 天前 添加了label:lgtmapproved
CANN-robot
CANN-robot成员
24 天前 评论:

The MR can not be merged, because of CodeReview discussion not resolved

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

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

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
XieQianyi
XieQianyi
21 天前 评论:

/check-pr

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

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
XieQianyi
XieQianyi
21 天前 评论:

/check-pr

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

The MR can not be merged, because of CodeReview discussion not resolved

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

likedislike
Mmeme成员
21 天前 解决了最后一个问题
CANN-robotCANN-robot成员
21 天前 合入了pull request