Pull Request已成功合入, 合并人@ascend-robot
(感谢 hbhu_bin 的贡献)变更摘要
该 PR 主要完成两项工作:一是移除了编译构建脚本中用于控制 DVM(Device Virtual Memory)延迟融合编译的环境变量 _TORCH_NPU_ENABLE_DVM,二是为 DVM 的 eager 模式补充了多个测试用例,覆盖 viewstore 原地操作和 native_batch_norm_backward 等场景。同时更新了 third_party/op-plugin 子模块的指针,以配合环境变量移除后的编译行为变更。
主要改动
- 移除
_TORCH_NPU_ENABLE_DVM环境变量:在build_libtorch_npu.py和setup.py中删除了os.environ.setdefault("_TORCH_NPU_ENABLE_DVM", "1")的设置逻辑,表明 DVM 延迟融合编译不再需要通过该环境变量显式开启。 - 新增 viewstore 原地操作测试:在
test/test_dvm.py的TestDvmFusionPatterns类中新增test_viewstore_inplace_strided_3d_view和test_viewstore_inplace_sibling_views两个用例,验证对非连续视图(view)执行原地加法、乘法、激活等操作时,DVM 开启与关闭状态下结果一致。 - 新增
native_batch_norm_backward测试:在test/test_dvm.py中新增test_native_batch_norm_backward_train_weight_only和test_native_batch_norm_backward_train_masks两个用例,覆盖仅有权重梯度以及多种[train, train, train]掩码组合下的反向传播场景,确保 DVM 融合后的计算正确性。 - 更新
third_party/op-plugin子模块:将op-plugin的提交指针从1473204更新至0556ee9,适配移除_TORCH_NPU_ENABLE_DVM后 op-plugin 的编译方式变化。


代码审查
经过全面审查,以下是审查结论。
审查摘要
变更文件:4 个 | 发现问题:1 个(P3)
| 文件 | 审查结果 |
|---|---|
build_libtorch_npu.py |
无问题 — _TORCH_NPU_ENABLE_DVM 环境变量及注释已干净移除,无残留引用 |
setup.py |
无问题 — 同上,移除操作一致且干净 |
test/test_dvm.py |
1 个 P3 建议 — 新增 4 个测试方法逻辑正确,仅变量命名 save_var 与实际 API 语义(save_invstd)不一致,不影响测试正确性 |
third_party/op-plugin |
无问题 — 子模块指针更新,与移除 _TORCH_NPU_ENABLE_DVM 的目标一致;全仓搜索确认无残留引用 |
整体风险评估:低风险。 变更范围明确:移除一个不再需要的环境变量标志,配套更新 op-plugin 子模块,并新增 4 个 eager DVM 测试用例。测试代码逻辑正确,环境变量移除干净无遗漏。唯一标记的 P3 项为命名一致性建议,不影响正确性或安全性。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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 | ✅ liujunzhu, ffmh (2/2) | ✅ liujunzhu (1/1) |
| test | ✅ liujunzhu, ffmh (2/2) | ✅ liujunzhu (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
hbhu_bin, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Linking Issue Notice
@hbhu_bin , 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 .


当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.7.1-26.1.0 | ||
| v2.9.0-26.1.0 | ||
| v2.10.0-26.1.0 | ||
| v2.12.0-26.1.0 | ||
| v2.11.0-26.1.0 | ||
| v2.9.0 | ||
| v2.10.0 | ||
| v2.11.0 | ||
| v2.12.0 | ||
| v2.7.1 | ||
| ci-test |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | 🕚 | >>> |
| Build_ARM | 🕚 | >>> | |
| Build_LibTorch_x86 | 🕚 | >>> | |
| Build_LibTorch_ARM | 🕚 | >>> | |
| Build_X86_torchair | 🕚 | >>> | |
| Build_ARM_torchair | 🕚 | >>> | |
| patch_test | 🕚 | >>> | |
| 恶意代码检查 | Antipoison | 🟨 | >>> |
| 编码安全与规范检查 | CodeCheck | 🟨 | >>> |
| check_error | 🟨 | >>> | |
| CodeCheck_lintrunner | 🟨 | >>> | |
| 开源片段检查 | SCA | 🟨 | >>> |
| 开发者测试 | UT_X86_Part_01 | 🕚 | >>> |
| UT_X86_Part_02 | 🕚 | >>> | |
| 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 | 🟨 | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


ascend docs pipeline is running...


ascend docs pipeline is running...


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


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


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| 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 | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/approve


/lgtm




【合入来源】
https://gitcode.com/Ascend/pytorch/issues/2264
【修改方案】
增加DVM测试用例+删除选择编译代码
【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
不涉及
【CheckList】