已合并
fix: npugraph_ex补充用户自定义backend和自定义pass缺失的接口 #30367
Xu Zhenhua创建于 2月2日
fix: npugraph_ex补充用户自定义backend和自定义pass缺失的接口 #30367
已合并
Xu Zhenhua创建于 2月2日
Xu Zhenhua
Xu Zhenhua
2月2日

【合入来源】

(如有)请关联需求文档/issue链接

【修改方案】

请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列
如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

  1. npugraph_ex补充用户自定义backends接口
  2. npugraph_ex补充用户自定义passes相关接口
    2.1 补充注册replacement接口
    2.2 补充自定义pass流record接口

【资料变更】

请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

已在新版本资料中补充接口说明,资料配套发布。

【接口变更】

请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

  1. 补充user-defined backends接口
def my_backend(gm: torch.fx.GraphModule, example_inputs):
    compiler = torch.npu.npugraph_ex.compile_fx()
    return aot_module_simplified(gm, example_inputs, fw_compiler=compiler)
  1. 补充user-defined passes接口
torch.npu.npugraph_ex.register_replacement(
    search_fn=search_fn,
    replace_fn=replace_fn,
    example_inputs=(input_tensor(), input_tensor(), kwargs_tensor()),
    extra_check=extra_check
)
# record and wait should be used in pairs
with torch.npu.npugraph_ex.scope.npu_stream_switch('1'):
    # ...
    record = torch.npu.npugraph_ex.ops.record()
    # ...
torch.npu.npugraph_ex.ops.wait([record])

【功能验证】

说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤
新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

新增测试用例看护:

  1. compile_fx接口用例:
    /test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_compile_fx
  2. 自定义pass接口用例:
    /test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_register_replacement
    /test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_record_and_wait
    image.png

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Xu Zhenhua 的贡献)
Xu ZhenhuaXu Zhenhua
2月2日 创建了 pull request,commit 22979574
ascend-robot
ascend-robot成员
2月2日 评论:

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

以下是根据您提交的修改文件推荐的Reviewer和Committer序列,需各模块评审通过后方可合入.

Module List Reviewers Committers
repo-Ascend/pytorch kuhn7, liangsongwei, dilililiwhy, wangchao430, zqwenn liwei386, dilililiwhy, shaoyf, wangchao285, wangqiang160
likedislike
ascend-robotascend-robot成员
2月2日 添加了label:stat/needs-squash
ascend-robotascend-robot成员
2月2日 添加了label:ascend-cla/yes
Xu Zhenhua
Xu Zhenhua
2月2日 评论:

compile

likedislike
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-running
此处折叠了5条事件消息 查看更多
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
2月2日 评论:
流水线 PR-pipeline_pytorch#5671 (重试第1次)运行失败
阶段 任务名 状态 详情
编译构建 Build_X86 🕚 >>>
Build_LibTorch 🕚 >>>
Build_ARM 🕚 >>>
Build_ARM_inductor 🕚 >>>
Build_X86_py311 🕚 >>>
Build_ARM_py311 🕚 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
check_error >>>
开源片段检查 SCA >>>
开发者测试 UT_DIST_X86 🕚 >>>
UT_X86_Part_01 🕚 >>>
UT_X86_Part_02 🕚 >>>
UT_ARM_A2_Part_01 🕚 >>>
UT_ARM_A2_Part_02 🕚 >>>
UT_inductor_Part_01 🕚 >>>
UT_inductor_Part_02 🕚 >>>
UT_inductor_Part_03 🕚 >>>
UT_inductor_Part_04 🕚 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
Xu Zhenhua
Xu Zhenhua
2月2日 评论:

compile

likedislike
ascend-robotascend-robot成员
2月2日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
2月2日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
2月2日 评论:
流水线 PR-pipeline_pytorch#5683 运行失败
阶段 任务名 状态 详情
编译构建 Build_X86 🕚 >>>
Build_LibTorch 🕚 >>>
Build_ARM 🕚 >>>
Build_ARM_inductor 🕚 >>>
Build_X86_py311 🕚 >>>
Build_ARM_py311 🕚 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
check_error >>>
开源片段检查 SCA >>>
开发者测试 UT_DIST_X86 🕚 >>>
UT_X86_Part_01 🕚 >>>
UT_X86_Part_02 🕚 >>>
UT_ARM_A2_Part_01 🕚 >>>
UT_ARM_A2_Part_02 🕚 >>>
UT_inductor_Part_01 🕚 >>>
UT_inductor_Part_02 🕚 >>>
UT_inductor_Part_03 🕚 >>>
UT_inductor_Part_04 🕚 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
Xu ZhenhuaXu Zhenhua
2月2日 update merge request[project id: 7404318, iid: 30367, commit_id: 049342cf1dcb6a8be02041b3316b3e42d4f4d672] virtual merging success
Xu ZhenhuaXu Zhenhua
2月2日 推送  1 个提交:3a4a4064-Decouple npugraph_ex and torchair-ge
Xu ZhenhuaXu Zhenhua
2月2日 update merge request[project id: 7404318, iid: 30367, commit_id: 748608f788d8370b87aec18099497eb9d5835915] virtual merging success
ascend-robot
ascend-robot成员
2月2日 评论:

CLA Signature Pass

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

likedislike
AtlasAccountAtlasAccount成员
2月2日 删除了label:ci-pipeline-failed
AtlasAccountAtlasAccount成员
2月2日 添加了label:ci-pipeline-failed
Xu Zhenhua
Xu Zhenhua
2月2日 评论:

compile

likedislike
ascend-robotascend-robot成员
2月2日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
2月2日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
2月2日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
2月2日 评论:
流水线 PR-pipeline_pytorch#5684 已完成
阶段 任务名 状态 详情
编译构建 Build_X86 >>>
Build_LibTorch >>>
Build_ARM >>>
Build_ARM_inductor 🛑 >>>
Build_X86_py311 🛑 >>>
Build_ARM_py311 🛑 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
check_error >>>
开源片段检查 SCA >>>
开发者测试 UT_DIST_X86 🛑 >>>
UT_X86_Part_01 >>>
UT_X86_Part_02 >>>
UT_ARM_A2_Part_01 🛑 >>>
UT_ARM_A2_Part_02 🛑 >>>
UT_inductor_Part_01 🛑 >>>
UT_inductor_Part_02 🛑 >>>
UT_inductor_Part_03 🛑 >>>
UT_inductor_Part_04 🛑 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
Xu ZhenhuaXu Zhenhua
2月4日 修改标题为 “fix: npugraph_ex补充用户自定义backend和自定义pass缺失的接口”,原标题为“Provides npugraph_ex APIs for user-defined backends and passes”
Xu ZhenhuaXu Zhenhua
2月4日 修改了pull request 的描述
yushikang
yushikang成员
2月4日 评论:

/approve

likedislike
ascend-robotascend-robot成员
2月4日 添加了label:lgtm
薛鹏
薛鹏成员
2月4日 评论:

/approve

likedislike
ascend-robotascend-robot成员
2月4日 添加了label:approved
ascend-robot
ascend-robot成员
2月4日 评论:

Review Guide

This Pull-Request Passes Review.
Committers who wrote a comment of /approve are: wasd1111222, medivh-x.
Reviewers who wrote a comment of /lgtm are: wasd1111222, medivh-x.

likedislike
ascend-robotascend-robot成员
2月4日 合入了pull request
薛鹏
薛鹏成员
2月4日 评论:

/approve

likedislike