已合并
[sync] PR-39678: revert: detect Ascend950 SoC for TORCH_NPU_USE_COMPATIBLE_IMPL default #39725
ascend-robot创建于 6月30日
[sync] PR-39678: revert: detect Ascend950 SoC for TORCH_NPU_USE_COMPATIBLE_IMPL default #39725
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)6月30日 创建了 pull request,commit 9b9db34e
6月30日 关联了issue:[Bug]:一致性路径路由环境变量默认值回退
ascend-robot
6月30日 评论:
6月30日 评论:
6月30日 添加了label:ascend-cla/yes
ascend-robot
6月30日 评论:
6月30日 评论:
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 | ✅ liangsongwei, ffmh (2/2) | ✅ liangsongwei (1/1) |
| test | ✅ ffmh, liangsongwei (2/2) | ✅ liangsongwei (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ascend-ds-bot, thanks for your pull request. All authors of the commits have signed the CLA. 👍


6月30日 添加了label:ci-pipeline-running
atomgit-bot
6月30日 评论:
6月30日 评论:
变更摘要
此 PR 回退了之前在 torch_npu/__init__.py 中引入的 Ascend950 SoC 自动检测逻辑及相关测试。原先的改动会通过 aclrtGetSocName 动态检测当前是否为 Ascend950,并根据检测结果自动设置 TORCH_NPU_USE_COMPATIBLE_IMPL 环境变量的默认值;本次回退移除了所有这些代码,恢复到由用户显式控制该环境变量的行为。
主要改动
- 移除
_is_ascend950()函数:从torch_npu/__init__.py中删除该函数,其原本通过ctypes.CDLL加载libascendcl.so并调用aclrtGetSocName来判断 SoC 是否为 Ascend950。 - 移除基于 SoC 的环境变量自动赋值逻辑:删除了在 C++ 初始化前根据
_is_ascend950()返回值将TORCH_NPU_USE_COMPATIBLE_IMPL默认设为"1"或"0"的代码块,不再自动覆盖该环境变量。 - 删除测试文件
test/test_compatible_impl_soc_detect.py:移除包含 4 个测试用例(test_is_ascend950_returns_bool、test_is_ascend950_matches_cpp_soc_version、test_compatible_impl_default_matches_soc、test_compatible_impl_respects_user_value)的完整测试文件。


atomgit-bot
6月30日 评论:
6月30日 评论:
代码审查
审查总结
| 优先级 | 数量 | 说明 |
|---|---|---|
| P1 | 1 | benchmarks/torchbench/torchbench.py:50 调用已删除的 _is_ascend950(),触发 AttributeError |
| P3 | 1 | torch_npu/__init__.py:4 import ctypes 在删除函数后成为死代码 |
已审查文件清单:
torch_npu/__init__.py:移除_is_ascend950()及TORCH_NPU_USE_COMPATIBLE_IMPL自动设置逻辑,核心回退正确,但遗留一个未使用的import ctypes(P3)。test/test_compatible_impl_soc_detect.py:整体删除,无其他文件引用,清理完整,无问题。
整体风险评估:中等。 核心回退逻辑正确,但跨文件的调用方未同步更新是真实回归,该 benchmark 脚本在 NPU 环境下会因 AttributeError 直接崩溃。建议在合入前同步修复该调用方。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


ascend-robot
6月30日 评论:
6月30日 评论:
ascend docs pipeline is running...


6月30日 添加了label:docs-ci-pipeline-running
ascend-robot
6月30日 评论:
6月30日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


6月30日 删除了label:docs-ci-pipeline-running
6月30日 添加了label:docs-ci-pipeline-success
6月30日 删除了label:ci-pipeline-running
6月30日 添加了label:ci-pipeline-passed
ascend-robot
6月30日 评论:
6月30日 评论:
流水线 PR-pipeline_pytorch#40290 [ commitID:43f8b614 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | 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 : 停止流水线


梁松伟
6月30日 评论:
6月30日 评论:
/approve


6月30日 添加了label:approved
ffmh
6月30日 评论:
6月30日 评论:
/lgtm


6月30日 添加了label:lgtm
6月30日 合入了pull request
ascend-robot
6月30日 评论:
6月30日 评论:
流水线 pytorch_gitcode_PR_multiVersion#11622 [ commitID:43f8b614 ] 已完成


1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/39678
2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/2561
3. Original pull request related commit(s):
This reverts commit acebf35339791ea6fcac6f116acdb242a1c09096.
Removes the _is_ascend950() SoC auto-detection and the SoC-based default-value assignment for TORCH_NPU_USE_COMPATIBLE_IMPL in torch_npu/init.py, and drops test_compatible_impl_soc_detect.py.
Co-Authored-By: Claude noreply@anthropic.com