Merged
test(gmm): 补充五个算子的 TTK 用例和 golden #15761
test(gmm): 补充五个算子的 TTK 用例和 golden #15761
Merged
zhoushaolongAdd on 17 days ago
zhoushaolong
zhoushaolongCollaborators
17 days ago

描述

为 Ascend 950 的五个 GMM 系列算子补充 TTK 流水线用例和 CPU golden,覆盖 GroupedMatmul、GroupedMatmulActivationQuant、GroupedMatmulFinalizeRouting、GroupedMatmulSwigluQuantV2 和 QuantGroupedMatmulInplaceAdd。

  • 每个算子保留 Kernel、ACLNN、Torch E2E 各 10 条,共 15 张 ST 用例表、150 条用例。优先覆盖各算子适用的量化场景,并兼顾 ND/NZ 权重、转置、分组方式及不同的 M/N/K。部分黄区二级冒烟用例合入对应的基础表。
  • 用例显式提供分组数据,并通过算子仓的 golden 插件生成 CPU 参考结果。使用 ops-test-kit 主线即可运行。
  • 包含静态图、动态图和更多二级冒烟场景的完整用例表已归档到 cann_matmul_test_。

关联的Issue

#7451

测试

在蓝区 Ascend 950PR 上,使用 CANN Toolkit 与 950 ops 9.3.0~weekly.20261014.01、原样的 ops-test-kit 主线 3055592 验证流水线用例。将批跑失败的 GMM E2E 用例替换为 FP8 per-channel 用例后,复跑该表 10 条全部通过。

通路 通过
Kernel 50/50
ACLNN 50/50
Torch E2E 50/50
合计 150/150

文档更新

本次变更涉及 TTK 用例和 golden,未更新算子接口文档。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhoushaolong's contribution.)
zhoushaolongzhoushaolongCollaborators
17 days ago Created pull request, commit 4e3f31f2
atomgit-bot
atomgit-bot
17 days ago Comments:

变更摘要

本 PR 主要为 grouped_matmul_activation_quant(gmmaq)算子补充 MXFP8 相关的 ST 测试用例与 golden(参考实现)插件:新增三份 golden 插件,分别对接 ACLNN 的 NZ 权重视图接口、torch.ops.cann_ops_transformer.grouped_matmul_activation_quant 端到端通路以及 kernel 级参考实现,并修正 golden.py 中 FP8 次正规数舍入的边界处理,使量化参考结果与硬件行为一致。

主要改动

  • 新增 ACLNN NZ 权重 golden 插件:在 gmmaq_aclnn_golden.py 中新增 AclnnGroupedMatmulActivationQuantWeightNzTestSpec,通过 _nz_storage 将按 (e, cols/32, rows/16, 16, 32) 组织的 NZ 物理存储还原为逻辑权重视图,依据权重 stride 判定是否转置并相应交换 weightScale 轴,customize_inputs 则借助 _make_valid_group_list 规范化 groupList,最终以 __spec__ 注册到 aclnnGroupedMatmulActivationQuantWeightNz。
  • 新增 Torch 端到端 golden 插件:在 gmmaq_e2e_golden.py 中新增 GmmaqTorchTestSpec,npu_preprocess 使用 torch_npu.npu_format_cast(source, 29) 在设备侧把权重转为 FRACTAL_NZ 并按需回转置,_decode_scale 以 en_dtypes.float8_e8m0 解码 E8M0 缩放因子,pre_compare 对整数载体输出按 E8M0 编码比较,注册到 torch.ops.cann_ops_transformer.grouped_matmul_activation_quant。
  • 新增 kernel 级 golden 插件:在 gmmaq_kernel_golden.py 中新增 GroupedMatmulActivationQuantTestSpec,customize_inputs 直接复用 _make_valid_group_list 修正分组长度,golden 中显式移除 output_dtypes,以保证量化行为由 kernel 的 y_dtype 决定,默认激活函数为 gelu_tanh。
  • 修正 FP8 次正规数舍入边界:在 golden.py 的 _float_to_fp8_bytes 中,将次正规数尾数裁剪上限由 (1 << mant_bits) - 1 改为 1 << mant_bits,使舍入产生的进位能够正确编码为最小正规数。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
17 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
17 days ago 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
gmm ✅ kknan, wuyi_huawei (2/2) ✅ kknan (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
17 days ago Set yangziqi_007,cheng_zhiwei,chenkang30,juyangokok,monologue815,chaotang233,wuyi_huawei,chen-linxin4,jiang-lirui,Allan_Yu,liudan12,Wei_NaChuan,zhangshuoleiokok,shi-rui,cc-z,kdy18482276080,kknan,wenxin_fight,mabing1118,Julius47 as approver
123 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
16 days ago Added label: approved
wuyi_51
wuyi_51Collaborators
16 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
16 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
16 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
16 days ago Merged pull request