Merged
feat: 开源 GroupedMatmul 转置融合 pass #8546
zhoushaolongAdd on Jul 9
feat: 开源 GroupedMatmul 转置融合 pass #8546
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhoushaolong's contribution.)Jul 9 Created pull request, commit 17efe013
atomgit-bot
Jul 9 Comments:
Jul 9 Comments:
变更摘要
该 PR 开源了 GMM(GroupedMatmul)的图融合 Pass,核心功能是在图编译阶段自动消除 GroupedMatmul 算子前的 Transpose/TransposeD 节点,将其语义折叠到 GroupedMatmul 自身的 transpose_x 和 transpose_weight 属性中,从而减少图中的冗余转置操作。同时新增了 OP_GRAPH_UT 对应的 CMake 构建支持和单元测试。
主要改动
- 新增
GroupedMatmulTransposeFusionPass图融合 Pass:实现了gmm/grouped_matmul/op_graph/fusion_pass/下的头文件和实现文件(共约 813 行),该 Pass 继承自FusionBasePass,通过模式匹配识别GroupedMatmul各输入端(x、weight、scale、antiquant_scale、per_token_scale)上游的Transpose/TransposeD节点及其 Reshape/Bitcast 组合模式,经验证后将上游直接连接到数据源并设置transpose_x/transpose_weight属性,支持 Dav3510(Ascend950)平台的特殊逻辑和权重量化(MX quant)模式。 - CMake 构建系统扩展:在
cmake/ut.cmake中新增OP_GRAPH_UT选项,添加add_opgraph_ut_modules函数以构建 op_graph 单元测试所需的目标库和编译依赖,同时在add_modules_ut_sources中增加HOSTNAME参数支持及OP_GRAPH_UT测试用例的自动收集逻辑(匹配test_*_pass.cpp文件)。 - 新增单元测试用例:
test_grouped_matmul_transpose_fusion_pass.cpp(219 行)构造了一个包含TransposeD+GroupedMatmul的测试图,验证 Weight 维度的转置融合后TransposeD节点被移除且transpose_weight属性被正确设置为true。 - 新增 op_graph UT 入口:
test_op_graph_main.cpp提供标准的 Google Testmain入口,用于运行 op_graph 相关的所有单元测试。


Incorrect?
Jul 9 Added label: stat/needs-squash
Jul 9 Added label: cann-cla/yes
CANN-robot
Jul 9 Comments:
Jul 9 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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| cmake | ✅ 蒋礼锐, wang-minbo (2/2) | ✅ wang-minbo, 蒋礼锐 (2/1) |
| gmm | ✅ 蒋礼锐, kknan (2/2) | ✅ 蒋礼锐 (1/1) |
| tests | ✅ wang-minbo, 蒋礼锐 (2/2) | ✅ wang-minbo, 蒋礼锐 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies 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. 👍


204 messages are collapsed here。 See more
Aug 5 Added label: approved
kknan
Aug 5 Comments:
Aug 5 Comments:
/lgtm


Aug 5 Added label: lgtm
Aug 5 Closed associated issue
Aug 5 Merged pull request
描述
开源 GroupedMatmul(GMM)算子的图融合 pass \GroupedMatmulTransFusionPass\。该 pass 在图编译阶段识别 GroupedMatmul 输入前的 Transpose/TransposeD(及 Reshape+Transpose+Reshape、Bitcast+Transpose)模式,将其语义折叠到 GroupedMatmul 的 \ ranspose_x\ / \ ranspose_weight\ 属性中,并移除冗余转置节点,减少不必要的计算和数据搬运。
主要改动:
关联的Issue
#3796
测试
新增 op_graph 单元测试,通过 CSV 参数化驱动 5 个测试用例:
测试覆盖融合状态码、转置节点残留数、transpose 属性值、输入 shape 还原四类断言。
文档更新
无额外文档更新。
类型标签