Merged
feat: support grouped matmul scale nz tiling #9728
feat: support grouped matmul scale nz tiling #9728
Merged
jayshuAdd on Aug 7
jayshu
jayshuCollaborators
Aug 7

描述

  • 在 GroupedMatmul MX 量化场景中支持 scaleOptional 使用 scale NZ 昇腾亲和格式。
  • 新增 scale format、dtype、storage shape 等校验,仅在 scaleOptional 为 FRACTAL_NZ、dtype 为 FLOAT8_E8M0、weight 为 FRACTAL_NZ 且 transpose_weight=false 时进入 scale NZ 目标通路。
  • kernel 侧根据 scale NZ 标识选择 scaleB layout,并通过 TensorAPI tuple 方式传递给 tensor 仓 BlockMmad。
  • scale ND、weight ND、非 MX、float4、非目标 groupType 等存量通路保持原有处理逻辑。

关联的Issue

测试

  • 二级冒烟 + 泛化验证

文档更新

  • 更新 gmm/grouped_matmul/docs/aclnnGroupedMatmulWeightNz.md,补充 scale NZ 昇腾亲和格式的 storage shape 和使用约束。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for jayshu's contribution.)
jayshujayshuCollaborators
Aug 7 Created pull request, commit e505e5fb
atomgit-bot
atomgit-bot
Aug 7 Comments:

变更摘要

此 PR 为 grouped_matmul 算子的 MX 量化路径新增了 scale 张量的 FRACTAL_NZ_C0_2 格式(ScaleNZ)支持。通过在 tiling key 模板体系中引入 SCALE_FORMAT 参数,区分 ScaleND 与 ScaleNZ 两种布局,并将其传递到内核模板 GmmTensorApiMxKernel 中,驱动 GroupedMatmulWithScaleMx 策略的分发。同时,在 host 端 tiling 阶段增加对 scale 格式的检测逻辑,当识别为 MX 微缩放且格式为 FRACTAL_NZ_C0_2 时自动启用 ScaleNZ 标记。

主要改动

  • 新增 SCALE_FORMAT tiling 模板参数:在 gqmm_tiling_key.h 中定义 GMM_SCALE_ND 和 GMM_SCALE_NZ 两个常量,并将 SCALE_FORMAT 追加到所有已存在的模板组合声明中 — MX 路径同时支持两种格式,非 MX 路径仅支持 GMM_SCALE_ND,确保向后兼容。

  • Host 端 scale 格式检测与标记传递:在 GroupedQmmTiling::AnalyzeDtype() 中从动态输入描述符获取 scale 的原始格式,当满足 MX 微缩放条件且格式为 FORMAT_FRACTAL_NZ_C0_2 时设置 scaleNzFlag;该标记随后通过 GetTilingKey() 编入 tiling key,参与内核模板选择。

  • GQmmInputInfo 新增字段:在 grouped_quant_matmul_tiling.h 中添加 scaleFormat 和 scaleNzFlag 两个成员变量,并在 Reset() 中初始化为默认值(FORMAT_ND / false),完成生命周期管理。

  • 内核模板扩展 ScaleNz 参数:GmmTensorApiMxKernel 新增 bool ScaleNz 模板参数(默认 false),用于配置 GroupedMatmulWithScaleMx 策略;在 grouped_matmul_apt.cpp 的宏展开中,将 (SCALE_FORMAT == GMM_SCALE_NZ) 作为实参传入。

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 7 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 7 Comments:

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
*/*/docs/acl*.md ✅ 陈娇, 马兵 (2/2) ✅ 陈娇 (1/1)
*/*/op_host/*_def.cpp ✅ 马兵, 王永光 (2/2) ✅ 王永光 (1/1)
gmm ✅ 马兵, kknan (2/2) ✅ 马兵 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Aug 7 Set chenkang30,juyangokok,monologue815,chaotang233,wuyi_huawei,chen-linxin4,jiang-lirui,Allan_Yu,liudan12,shi-rui,cc-z,kknan,wenxin_fight,mabing1118 as approver
292 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Aug 29 Removed label: lgtmapproved
fuyong
fuyongCollaborators
Aug 29 Comments:

/lgtm

likedislike
CANN-robot
CANN-robotCollaborators
Aug 29 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
Coopermassaki

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Aug 29 Merged pull request