Closed
test(export): add NPU adaptation for torch.compiler.is_exporting testcase #42199
makun-2026Add on Jul 20Closed at Aug 17
test(export): add NPU adaptation for torch.compiler.is_exporting testcase #42199
Closed
The current Pull Request has been closed by ascend-robot.
Jul 20 Created pull request, commit b8bcbc27
Jul 20 Associated issue: 【社区任务】7月社区任务第二期-Ascend for PyTorch API 一致性开发(96)
atomgit-bot
Jul 20 Comments:
Jul 20 Comments:
变更摘要
此 PR 为 torch.compiler.is_exporting 的测试用例增加 NPU(昇腾)适配。torch.compiler.is_exporting 本身是纯 Python 状态查询 API,无需硬件适配,但测试用例中的输入张量需要迁移到 NPU 设备上才能正常运行。该变更是对已有 patch 文件 test_upstream/test/export/test_export.py.patch 的补充,将 test_is_exporting 用例中传给 export() 的两个输入张量从 CPU 改为 NPU 设备。
主要改动
- 测试输入张量迁移至 NPU:将
test_is_exporting用例中export()调用的第一个参数从torch.tensor(False)改为torch.tensor(False).npu()。 - 随机张量迁移至 NPU:将同一
export()调用的第二个参数从torch.randn(3, 4)改为torch.randn(3, 4).npu()。


Incorrect?
ascend-robot
Jul 20 Comments:
Jul 20 Comments:
atomgit-bot
Jul 20 Comments:
Jul 20 Comments:
106 messages are collapsed here。 See more
Aug 13 Removed label: ci-pipeline-running
Aug 13 Added label: ci-pipeline-passed
ascend-robot
Aug 13 Comments:
Aug 13 Comments:
流水线 PR-pipeline_pytorch#60540 [ commitID:3f076c20 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | ✅ | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| check_error | ✅ | >>> | |
| lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | 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 : 停止流水线


makun-2026
Aug 17 Comments:
Aug 17 Comments:
/close


Aug 17 Close pull request
【合入来源】
关联 issue:
【修改方案】
本 PR 在
test_upstream/test/export/test_export.py.patch中补充torch.compiler.is_exporting的 API 一致性验证用例适配。torch.compiler.is_exporting用于判断当前是否处于torch.export追踪上下文,属于公开的非计算类 Python 状态查询 API。任务 API 功能、社区用例情况与本 PR 动作梳理如下:
torch.compiler.is_exportingtorch.export追踪上下文的状态查询 APItest/export/test_export.py已有TestExport::test_is_exporting直接验证该 API;当前torch-npuv2.11.0 的test_upstream原本不含对应 patchtest_upstreampatch 中对test_is_exporting做最小 NPU 适配,使传入export()的张量运行在 NPU 上主要分析思路:
torch.compiler.is_exporting,确认已有test/export/test_export.py::TestExport::test_is_exporting直接专项用例。True、普通执行态返回False,API 实现无需修改。export()的张量迁移到 NPU。test_upstreampatch,不修改torch.compiler.is_exportingAPI 实现,不改变现有接口行为。修改涉及文件:
本 PR 覆盖的社区用例及验证点如下:
TestExport.test_is_exportingtorch.export追踪过程中torch.compiler.is_exporting()返回True;普通执行路径返回False;传入export()的张量运行在 NPU 上【资料变更】
不涉及本 PR。
torch.compiler.is_exporting为公开非计算类 API,资料支持情况在 master 分支统一补充。【接口变更】
不涉及。本 PR 仅补充
test_upstreampatch,不修改 API 实现,不改变现有接口行为,不新增 torch-npu 对外接口。【功能验证】
运行环境:
执行命令:
python test/export/test_export.py TestExport.test_is_exporting -v执行结果:
测试验证结论:
torch.compiler.is_exporting在 export 追踪过程中返回True,在普通执行路径返回False;【CheckList】