已合并
inductor: port DVM support to v2.8 #31058
SorryNaCN创建于 2月26日
inductor: port DVM support to v2.8 #31058
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 SorryNaCN 的贡献)AtlasAccount
2月26日 评论:
2月26日 评论:
ascend-robot
2月26日 评论:
2月26日 评论:
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 |
|---|---|---|
| repo-Ascend/pytorch | ✅ guoqi1024, li_jing_hw (2/2) | ✅ guoqi1024, li_jing_hw (2/1) |
| test | ✅ guoqi1024, li_jing_hw, zichun_ye (3/2) | ✅ li_jing_hw, zichun_ye, guoqi1024 (3/1) |
| torch_npu/_inductor | ✅ guoqi1024, li_jing_hw, zichun_ye (3/2) | ✅ guoqi1024, li_jing_hw, zichun_ye (3/1) |
| torch_npu/csrc/inductor | ✅ zichun_ye, guoqi1024, li_jing_hw (3/2) | ✅ li_jing_hw, zichun_ye, guoqi1024 (3/1) |
| torch_npu/utils | ✅ guoqi1024, li_jing_hw, zichun_ye (3/2) | ✅ zichun_ye, guoqi1024, li_jing_hw (3/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


2月26日 添加了label:ascend-cla/yes
SorryNaCN
2月26日 评论:
2月26日 评论:
compile


此处折叠了47条消息 查看更多
zichun_ye
3月4日 评论:
3月4日 评论:
/lgtm


3月5日 添加了label:lgtm
ascend-robot
3月5日 评论:
3月5日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: li_jing_hw, zichun_ye, guoqi1024.
Reviewers who wrote a comment of /lgtm are: guoqi1024, li_jing_hw, zichun_ye.


3月5日 合入了pull request
What type of PR is this?
/kind feature
What does this PR do / why do we need it
本 PR 将
v2.7.1分支中的 DVM 相关能力迁移到v2.8.0,为 inductor 增加 DVM 融合支持,并补齐绑定、构建与测试。主要改动:
_C初始化阶段注册npu_backend=dvmDVM 融合模式说明(按当前代码更新)
当前 DVM 支持两种融合路径:
mlir_fusion:复用 Inductor-MLIR 主流程,只替换融合范围与 codegen 引擎为 DVMgraph_fusion:独立图分区融合路径,通过CapabilityBasedPartitioner做子图融合并落到 DVM1) mlir_fusion
设计:
特点:
2) graph_fusion
设计:
DvmGraphFusionPatch挂接 post-grad passCapabilityBasedPartitioner划分可融合子图dvm::fused_graph_*自定义算子并在代码生成阶段替换为 DVM kernel 调用特点:
使用方式(更新后的正确接口)
A. 启用 mlir_fusion 路径
推荐三种方式(二选一即可):
import torch import torch_npu import torch_npu._inductor torch._inductor.config.npu_backend = "dvm" compiled = torch.compile(model, backend="inductor", dynamic=True) out = compiled(*inputs)compiled = torch.compile( model, backend="inductor", dynamic=True, options={"npu_backend": "dvm"} )torch.compile前设置)import os os.environ["TORCHINDUCTOR_NPU_BACKEND"] = "dvm"B. 启用 graph_fusion 路径
import torch import torch_npu from torch_npu._inductor.dvm.graph_fusion import DvmGraphFusionPatch with DvmGraphFusionPatch(): compiled = torch.compile(model, backend="inductor", dynamic=False) out = compiled(*inputs)两种模式对比
dvm_fused_*dvm_graph_fused_*注意:矩阵相关算子(
mm/bmm/addmm)仅在graph_fusion融合模式支持。Which issue(s) this PR fixes
Fixes #
Special notes for your reviewers
v2.7.1DVM 实现保持一致,冲突已按v2.8.0基线语义对齐。_C初始化与 DVM pybind 注册torch_npu._inductor后端分支与npu_backend=dvm使能逻辑mlir_fusion/graph_fusion两条路径的行为一致性