Merged
fix: 将5个eager算子编译延迟到dispatcher首次调用, import不再触发编译 #9734
weihao18Add on Aug 7
fix: 将5个eager算子编译延迟到dispatcher首次调用, import不再触发编译 #9734
Merged
Merged fromDeleted :fix-issue-4154intocann/ops-transformermaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for weihao18's contribution.)Aug 7 Associated issue: [torch_extension] import cann_ops_transformer 强制编译 5 个 eager 算子,影响首次加载耗时
Aug 7 Associated issue: [torch_extension] import cann_ops_transformer 强制编译 5 个 eager 算子,影响首次加载耗时
atomgit-bot
Aug 7 Comments:
Aug 7 Comments:
变更摘要
此 PR 将 5 个 eager 算子的编译时机从模块 import 阶段延迟到各算子 dispatcher 首次调用时,解决 import 即触发编译导致启动开销过大的问题(关联 Issue #4154)。核心做法是移除模块顶层立即执行的 OpBuilder.load() 调用,改为在对应的算子函数内部按需调用,确保只有在实际执行运算时才完成 JIT 编译加载。
主要改动
dense_lightning_indexer_softmax_lse.py: 移除模块级op_module = ...load()预加载,改为在dense_lightning_indexer_softmax_lse_metadata和dense_lightning_indexer_softmax_lse两个函数内部首次调用时才执行load()。inplace_partial_rotary_mul.py: 删除模块级inplace_partial_rotary_mul_op_builder.load()预加载调用及其注释,不再在 import 时触发编译。inplace_partial_rotary_mul_backward.py: 删除模块级inplace_partial_rotary_mul_backward_op_builder.load()预加载调用及其注释,编译延迟到算子实际调用时。moe_finalize_routing.py: 移除模块级_op_module = ...load()预加载,改为在_moe_finalize_routing函数内部按需执行load()。quant_flash_attn.py: 移除模块级op_module = ...load()预加载,改为在quant_flash_attn_metadata和quant_flash_attn两个函数内部首次调用时才执行load()。


Incorrect?
Aug 7 Added label: cann-cla/yes
CANN-robot
Aug 7 Comments:
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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| sig-ops-transformer | ✅ 蒋礼锐, 刘丹 (2/2) | ✅ 刘丹, 蒋礼锐 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
weihao18, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Aug 7 Modify description of pull request
Aug 7 Set monologue815,jiang-lirui,Allan_Yu,liudan12,mabing1118 as approver
Aug 7 Set monologue815,jiang-lirui,Allan_Yu,liudan12,mabing1118 as approver
weihao18
Aug 7 Comments:
Aug 7 Comments:
compile


Aug 7 Pre merge succeeded (commit_id: 596e5cc0e522d4c0a4df4ae68634334aa23f3853)
Aug 7 Added label: ci-pipeline-running
CANN-robot
Aug 7 Comments:
Aug 7 Comments:
流水线任务触发成功
任务链接 [f9be1261f2b74f2795db7b4a29707dfe][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_9030_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_harmony-infer-chs-transformer | ✅ SUCCESS | ||
| UT_Test_harmony-infer-cpro-transformer | ✅ SUCCESS | ||
| UT_Test_report_lcov | ⚠️ WARNING | >>>>> |
[2026-08-07 10:51:46] CI执行结束


CANN-robot
Aug 7 Comments:
Aug 7 Comments:
流水线任务触发成功
任务链接 [113fa35d0f5b414d967655727d1f2f63][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_checkpr | ✅ SUCCESS | ||
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-08-07 10:32:17] CI执行结束


Aug 7 Added label: api-check-pass
Aug 7 Removed label: ci-pipeline-running
Aug 7 Added label: ci-pipeline-passed
Aug 7 Modify description of pull request
liudan12
Aug 7 Comments:
Aug 7 Comments:
/lgtm
/approve


Aug 7 Added label: approved
jiang-lirui
Aug 7 Comments:
Aug 7 Comments:
/approve
/lgtm


Aug 7 Added label: lgtm
Aug 7 Closed associated issue
Aug 7 Merged pull request
描述
fix: 将5个eager算子编译延迟到dispatcher首次调用, import不再触发编译
关联的Issue
https://gitcode.com/cann/ops-transformer/issues/4154
测试
本地验证不触发编译
文档更新
类型标签