已合并
[refactor]decomp_2.10.0 #40576
yeh创建于 7月9日
[refactor]decomp_2.10.0 #40576
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 yeh 的贡献)atomgit-bot
7月9日 评论:
7月9日 评论:
变更摘要
本次重构将 npu_decomp.py 中分散的 NPU 分解(decomposition)逻辑整体移除,统一收敛至 torch_npu/_inductor/decomposition.py,同时清理了该文件中不再需要的 _register_npu_inductor_decompositions 分发函数及冗余导入,实现分解注册的集中管理,且不改变原有注册函数的调用点。
主要改动
- 删除
npu_decomp.py文件:移除torch_npu/_inductor/ascend_npu_ir/ascend_npu_ir/npu/npu_decomp.py全部 210 行代码,其中包含batch_norm_decomposition、gelu/gelu_backward、npu_convolution_backward、npu__softmax_backward_data、expm1等函数的定义及其通过inductor_decomp.register_decomposition的注册逻辑,以及remove_decompositions调用。 - 移除
_register_npu_inductor_decompositions分发函数:在decomposition.py中删除该函数及其内部的backend参数判断分支(triton和mlir_dvm),消除了对后端类型进行条件分发的间接层。 - 清理冗余导入:从
decomposition.py中移除pw_cast_for_opmath和out_wrapper两个未被使用的导入,精简模块依赖。


atomgit-bot
7月9日 评论:
7月9日 评论:
代码审查
审查总结
| 优先级 | 数量 | 说明 |
|---|---|---|
| P0 | 1 | _register_npu_inductor_decompositions 函数被删除,但 __init__.py 和 npu_inductor_plugin.py 仍导入并调用它,导致 ImportError 运行时崩溃,且 _register_triton_decompositions / _register_mlir_dvm_decompositions 永远不会被调用 |
| P2 | 1 | 测试文件 test_public_bindings.py 仍引用已删除的 npu_decomp 模块,测试将失败 |
已审查文件:
torch_npu/_inductor/decomposition.py:发现 P0 问题(删除_register_npu_inductor_decompositions但调用方未更新)torch_npu/_inductor/ascend_npu_ir/ascend_npu_ir/npu/npu_decomp.py(已删除):此文件在生产代码中从未被 import,删除本身是安全的清理;但测试文件中的引用需要同步移除
总体风险评估:此变更存在破坏性的 P0 问题,合入将导致 inductor 初始化直接崩溃。 必须修复 _register_npu_inductor_decompositions 调用方,才能安全合入。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


ascend-robot
7月9日 评论:
7月9日 评论:
7月9日 添加了label:ascend-cla/yes
此处折叠了144条消息 查看更多
7月16日 添加了label:approvedlgtm
7月16日 合入了pull request
ascend-robot
7月16日 评论:
7月16日 评论:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


ascend-robot
7月16日 评论:
7月16日 评论:
流水线 pytorch_gitcode_PR_multiVersion#12677 [ commitID:7901ae7e ] 已完成


【合入来源】
【修改方案】
对decomposition代码进行重构,将原先两个文件中的decomp逻辑都合并至torch_npu_inductor\decomposition.py文件,并提取公共注册函数。重构不改变原注册函数调用点。
【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
【CheckList】