Closed
test(export): add NPU adaptation for torch.compiler.is_exporting testcase #43590
makun-2026Add on Aug 2Closed at Aug 17
test(export): add NPU adaptation for torch.compiler.is_exporting testcase #43590
Closed
The current Pull Request has been closed by ascend-robot.
Aug 2 Created pull request, commit d48aee7e
Aug 2 Associated issue: 【社区任务】7月社区任务第二期-Ascend for PyTorch API 一致性开发(96)
atomgit-bot
Aug 2 Comments:
Aug 2 Comments:
变更摘要
本 PR 为 torch.compiler.is_exporting 的官方测试用例 test_is_exporting 增加 NPU 适配。torch.compiler.is_exporting 是纯 Python 状态查询 API,无硬件相关逻辑,因此无需修改 API 实现;已有 test_upstream/test/export/test_export.py.patch 虽已导入 torch_npu,但传入 export() 的张量未迁移到 NPU。本变更在 patch 中为 test_is_exporting 的两个输入张量添加 .npu() 调用,使其在 NPU 环境下运行,同时同步更新了 patch 头部的 index 元数据行。
主要改动
- NPU 张量适配:在
test_upstream/test/export/test_export.py.patch的test_is_exporting用例中,将传入export()的输入张量torch.tensor(False)改为torch.tensor(False).npu()、torch.randn(3, 4)改为torch.randn(3, 4).npu(),使测试输入在 NPU 上创建。 - Patch 元数据更新:同步更新 patch 头部的
index 9fed39d..8bdeea0为index 9fed39d..2313767,保证补丁可正确应用。


Incorrect?
ascend-robot
Aug 2 Comments:
Aug 2 Comments:
atomgit-bot
Aug 2 Comments:
Aug 2 Comments:
47 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#60537 [ commitID:248bc4e4 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | 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.12.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】