已合并
[inductor] migrate NPU Fast Launch to ACL host-args API #44648
Erwinnn创建于 9 天前
[inductor] migrate NPU Fast Launch to ACL host-args API #44648
已合并
Erwinnn创建于 9 天前
Erwinnn
9 天前

【合入来源】

【修改方案】

  1. 将 NPU Fast Launch 的 Kernel 启动接口统一迁移至 aclrtLaunchKernelWithHostArgs,移除旧私有接口依赖。
  2. SIMT 场景通过 ACL 属性传递动态 UBUF 大小。
  3. 更新静态 UT,校验仅使用新的 ACL 启动接口。

【资料变更】

不涉及。

【接口变更】

不涉及跨仓及客户可见接口变更。

【功能验证】

相关静态 UT 及 PR CI 流水线执行通过。

【CheckList】

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Erwinnn 的贡献)
EErwinnn
9 天前 创建了 pull request,commit bfb3b606
atomgit-bot
atomgit-bot
9 天前 评论:

变更摘要

该 PR 主要将 NPU Fast Launch 的 kernel 启动路径从私有 rtKernelLaunch / rtKernelLaunchWithFlagV2 接口迁移到 ACL 提供的 host-args API aclrtLaunchKernelWithHostArgs,并同步更新了对应测试的源码断言。核心改动集中在 torch_npu/_inductor/experimental/python_wrapper_fast_launch/csrc/bindings.cpp:移除了为旧接口自定义的任务配置结构体和弱符号声明,新增 <acl/acl_rt.h> 头文件依赖,并在 SubmitLaunch 中统一通过 aclrtLaunchKernelWithHostArgs 提交 kernel,SIMT 场景下通过 aclrtLaunchKernelAttraclrtLaunchKernelCfg 传递动态 UBUF 大小。

主要改动

  • 启动接口迁移为 ACL host-args APISubmitLaunch 中将原来的 rtKernelLaunchrtKernelLaunchWithFlagV2 调用统一替换为 aclrtLaunchKernelWithHostArgs,kernel、block 数量、stream、参数指针和大小均以对应 ACL 类型传入。
  • 移除旧私有接口相关定义:删除了 FastLaunchRtTaskCfgInfoFastLaunchRtHostInputInfoFastLaunchRtArgsExInfo 等结构体及其 static_assert,并移除 rtKernelLaunchWithFlagV2extern "C" 弱符号声明和 FastLaunchRtKernelLaunchWithFlagV2 类型别名。
  • 新增 ACL 头文件依赖:在 bindings.cpp 中引入 #include <acl/acl_rt.h>,以支持 aclrtLaunchKernelWithHostArgs 及相关结构体、枚举的使用。
  • SIMT 动态 UBUF 配置改用 ACL 属性:在 enableSimt 分支中,通过 aclrtLaunchKernelAttr(属性 ACL_RT_LAUNCH_KERNEL_ATTR_DYN_UBUF_SIZE)和 aclrtLaunchKernelCfg 传递 sharedMemDynamicSize,替代原先通过 FastLaunchRtTaskCfgInfo.localMemorySize 的传参方式。
  • 同步更新测试断言test_npu_fast_launch_static.py 中改为断言生成的源码包含 aclrtLaunchKernelWithHostArgsACL_RT_LAUNCH_KERNEL_ATTR_DYN_UBUF_SIZE,同时不再包含 rtKernelLaunch(rtKernelLaunchWithFlagV2
likedislike
atomgit-bot
atomgit-bot
9 天前 评论:

代码审查

我已审查完两个改动文件。

审查结论

发现的问题(2 个):

优先级 文件:行 问题
P0 bindings.cpp:349 launchAttr.value.dynUBufSize 不是 aclrtLaunchKernelAttrValue 的成员,应使用 localMemorySize,否则编译失败
P1 bindings.cpp:16 #include <acl/acl_rt.h> 与仓库主构建惯例不一致,主构建可能无法解析该头文件

各文件审查确认

  • torch_npu/_inductor/experimental/python_wrapper_fast_launch/csrc/bindings.cpp — 发现 2 个问题(如上)。核心逻辑迁移方向正确(enableSimt 分支、aclrtLaunchKernelWithHostArgs 参数顺序、返回值处理均与仓库参考实现 cpp_wrapper_npu.py 一致),但属性值字段名写错会直接阻断编译。
  • test/_inductor/experimental/python_wrapper_fast_launch/test_npu_fast_launch_static.py — no issues。静态断言更新正确(aclrtLaunchKernelWithHostArgsACL_RT_LAUNCH_KERNEL_ATTR_DYN_UBUF_SIZE 的 assertIn,以及旧 API 的 assertNotIn 均为有效子串匹配,不会误报)。

总体风险判断

高风险,存在编译阻断。P0 的 dynUBufSize 字段名错误几乎必然导致 bindings.cpp 编译失败(仓库自身参考实现使用 localMemorySize),必须修复后才能合入;P1 的 include 路径问题也需按仓库惯例统一,否则主 CMake 构建可能找不到头文件。

类型 数量
🔴 阻塞 1
🟡 建议 0

⛔ 需要修改

likedislike
ascend-robotascend-robot成员
9 天前 添加了label:ascend-cla/no
ascend-robot
ascend-robot成员
9 天前 评论:

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
test crazyDannyBoy, TonyYA (2/2) crazyDannyBoy (1/1)
torch_npu/_inductor crazyDannyBoy, TonyYA (2/2) crazyDannyBoy (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
9 天前 添加了label:needs-issue
ascend-robot
ascend-robot成员
9 天前 评论:

Linking Issue Notice

@jiabiao_o , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

likedislike
ascend-robot
ascend-robot成员
9 天前 评论:

当前仓库存在以下 保护分支

Protected Branch Version Release
master
v2.12.0
v2.11.0
v2.7.1
v2.10.0
v2.9.0
v2.7.1-26.1.0
v2.11.0-26.1.0
v2.12.0-26.1.0
v2.10.0-26.1.0
v2.9.0-26.1.0
ci-test

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
ascend-robotascend-robot成员
9 天前 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
9 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
9 天前 添加了label:docs-ci-pipeline-running
Erwinnn
9 天前 评论:

/retest

likedislike
ascend-robot
ascend-robot成员
9 天前 评论:

✅ 跳过 docs ci 检查,没有需要检查的文档文件

likedislike
ascend-robotascend-robot成员
9 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
9 天前 添加了label:docs-ci-pipeline-success
EErwinnn
9 天前 修改了pull request 的描述
EErwinnn
9 天前 修改了pull request 的描述
atomgit-bot
atomgit-bot9 天前进行代码检视2
torch_npu/_inductor/experimental/python_wrapper_fast_launch/csrc/bindings.cpp
@@ -412,1 +348,3 @@
412- kernelStub, packed.blockNum, args, argsSize, nullptr, packed.stream);
348+ launchAttr.id = ACL_RT_LAUNCH_KERNEL_ATTR_DYN_UBUF_SIZE;
349+ launchAttr.value.dynUBufSize =
350+ static_cast<uint32_t>(sharedMemDynamicSize);
atomgit-bot
atomgit-bot9 天前评论:

🔴 Critical

建议:将 launchAttr.value.dynUBufSize 改为 launchAttr.value.localMemorySize,与仓库内 cpp_wrapper_npu.py 中同属性的赋值方式保持一致。

改动建议
350
+ launchAttr.value.localMemorySize =
350
351
  static_cast<uint32_t>(sharedMemDynamicSize);
应用建议
likedislike
Erwinnn
7 天前 评论:

使用 ACL_RT_LAUNCH_KERNEL_ATTR_DYN_UBUF_SIZE 搭配 value.dynUBufSize,符合当前 ACL API 定义。仓库内cpp_wrapper_npu.py 的 localMemorySize 属于旧写法,后续应反向更新为 dynUBufSize,不建议本 PR 回退

ascend-robotascend-robot成员
9 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
9 天前 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
9 天前 评论:
流水线 PR-pipeline_pytorch#61284 [ commitID:c5e18f45 ] 运行失败
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_X86 >>>
Build_ARM >>>
Build_LibTorch_x86 >>>
Build_LibTorch_ARM >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 codecheck_pre-commit >>>
check_error >>>
lintrunner >>>
开源片段检查 SCA >>>
开发者测试 UT_ARM_A3_Part_01 🛑 >>>
UT_ARM_A3_Part_02 🛑 >>>
UT_ARM_A2_Part_01 >>>
UT_ARM_A2_Part_02 >>>
UT_ARM_A2_Part_03 >>>
UT_inductor_Part_01 >>>
UT_inductor_Part_02 >>>
UT_inductor_Part_03 >>>
UT_inductor_Part_04 >>>
UT_DIST_ARM_Part_01 🛑 >>>
UT_DIST_ARM_Part_02 🛑 >>>
UT_DIST_ARM_Part_03 🛑 >>>
UT_DIST_ARM_Part_04 🛑 >>>
UT_ARM_A2_Select_Part_01 >>>
UT_ARM_A2_Select_Part_02 >>>
流水线 PR-pipeline_pytorch >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan, Jesse, WSs_321]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
Erwinnn
7 天前 评论:

/check-cla

likedislike
ascend-robotascend-robot成员
7 天前 删除了label:ascend-cla/no
ascend-robotascend-robot成员
7 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
7 天前 评论:

CLA检查已通过,详情可参考这里

likedislike
Erwinnn
7 天前 评论:

/retry

likedislike
Erwinnn
7 天前 评论:

retry UT_inductor_Part_04

likedislike
ascend-robotascend-robot成员
7 天前 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
7 天前 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
7 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
7 天前 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
7 天前 评论:
流水线 PR-pipeline_pytorch#61284 (重试第1次) [ commitID:c5e18f45 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_X86 >>>
Build_ARM >>>
Build_LibTorch_x86 >>>
Build_LibTorch_ARM >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
恶意代码检查 Antipoison >>>
编码安全与规范检查 codecheck_pre-commit >>>
check_error >>>
lintrunner >>>
开源片段检查 SCA >>>
开发者测试 UT_ARM_A3_Part_01 🛑 >>>
UT_ARM_A3_Part_02 🛑 >>>
UT_ARM_A2_Part_01 >>>
UT_ARM_A2_Part_02 >>>
UT_ARM_A2_Part_03 >>>
UT_inductor_Part_01 >>>
UT_inductor_Part_02 >>>
UT_inductor_Part_03 >>>
UT_inductor_Part_04 >>>
UT_DIST_ARM_Part_01 🛑 >>>
UT_DIST_ARM_Part_02 🛑 >>>
UT_DIST_ARM_Part_03 🛑 >>>
UT_DIST_ARM_Part_04 🛑 >>>
UT_ARM_A2_Select_Part_01 >>>
UT_ARM_A2_Select_Part_02 >>>
流水线 PR-pipeline_pytorch >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan, Jesse, WSs_321]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
EErwinnn
7 天前 修改了pull request 的描述
pangjiayi
pangjiayi
7 天前 评论:

/lgtm

likedislike
dezheng889成员
7 天前 评论:

/lgtm
/approve

likedislike
ascend-robotascend-robot成员
7 天前 添加了label:approvedlgtm
Erwinnn
7 天前 评论:

/check-pr

likedislike
ascend-robot
ascend-robot成员
7 天前 评论:

The following label exists.

needs-issue: The pull request must be linked to at least one issue.

likedislike
Llvjiangdong成员
7 天前 解决了最后一个问题
EErwinnn
7 天前 修改了pull request 的描述
EErwinnn
7 天前 修改了pull request 的描述
ascend-robotascend-robot成员
7 天前 删除了label:needs-issue
ascend-robotascend-robot成员
7 天前 合入了pull request
ascend-robot
ascend-robot成员
7 天前 评论:

Pull Request 已合并或已关闭。

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

likedislike
Erwinnn
7 天前 评论:

/check-issue

likedislike
ascend-robot
ascend-robot成员
7 天前 评论:
流水线 pytorch_gitcode_PR_multiVersion#14118 [ commitID:c5e18f45 ] 已完成
likedislike