已合并
fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load #32381
dinglaiping创建于 3月25日
fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load #32381
已合并
从已删除 :fixtest-jit-api-2.7.1合入到Ascend/pytorchv2.7.1
Pull Request已成功合入, 合并人@ascend-robot
(感谢 dinglaiping 的贡献)3月25日 创建了 pull request,commit e8e49829
Ddinglaiping
3月25日 关联了issue:[Bug]: 验证torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load这4个API的时候发现官网test目录下test_jit.py文件存在错误
3月25日 关联了issue:[Bug]: 验证torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load这4个API的时候发现官网test目录下test_jit.py文件存在错误
ascend-robot
3月25日 评论:
3月25日 评论:
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 |
|---|---|---|
| test | ✅ liwei386, AACAES, yuhaiyan (3/2) | ✅ liwei386 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
dinglaiping, thanks for your pull request. All authors of the commits have signed the CLA. 👍


3月25日 添加了label:ascend-cla/yes
AtlasAccount
3月25日 评论:
3月25日 评论:
dinglaiping
3月25日 评论:
3月25日 评论:
compile


3月25日 添加了label:ci-pipeline-running
3月25日 删除了label:ci-pipeline-running
3月25日 添加了label:ci-pipeline-passed
ascend-robot
3月25日 评论:
3月25日 评论:
流水线 PR-pipeline_pytorch#12425 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| Build_ARM_inductor | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | ✅ | >>> |
| UT_X86_Part_02 | ✅ | >>> | |
| UT_ARM_A3_Part_01 | ✅ | >>> | |
| UT_ARM_A3_Part_02 | ✅ | >>> | |
| UT_DIST_X86_Part_01 | 🛑 | >>> | |
| UT_DIST_X86_Part_02 | 🛑 | >>> | |
| UT_DIST_X86_Part_03 | 🛑 | >>> | |
| UT_DIST_X86_Part_04 | 🛑 | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


Ddinglaiping
3月27日 修改标题为 “fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load”,原标题为“fix(nn): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load”
3月27日 修改标题为 “fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load”,原标题为“fix(nn): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load”
3月27日 修改了pull request 的描述
haiyan8
3月27日 评论:
3月27日 评论:
/lgtm


3月27日 添加了label:lgtm
3月27日 添加了label:approved
ascend-robot
3月27日 评论:
3月27日 评论:
3月27日 合入了pull request
【合入来源】
【修改方案】
2.7.1及以上版本提示additional_module_tests、new_module_tests和module_tests找不到,要把additional_module_tests换成get_all_nn_module_tests并且删除new_module_tests和module_tests,最后在调用的时候使用get_all_nn_module_tests()。
【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
整体结论:
本次验证基于torch-npu 官方test_jit.py用例全量复用的方式,在完成最小化的文件、代码、环境适配后,于 NPU环境下完成torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load四个核心 API 的全量验证,所有指定的测试方法均执行成功。验证结果表明,torch-npu 官方 JIT 用例可完整覆盖四个 API 的核心功能,使用官网用例完成 NPU 适配验证已足够;四个 API 在 NPU环境下的基础能力、协同逻辑均正常可用,完全满足 NPU 场景下模型编译优化、序列化部署、跨设备迁移、推理执行的实际业务需求。
运行日志:
root@hostname-fqv42:~/torchnpuapi/torch-npu/2.7.1/pytorch/test# python -m unittest test_jit.TestJit.test_restore_device test_jit.TestJit.test_import_method test_jit.TestJit.test_torch_load_zipfile_check test_jit.TestScript.test_repeated_script_on_function test_jit.TestJit.test_script_fn_pkl test_jit.TestJit.test_trace_retains_train test_jit.TestFrontend.test_dictionary_as_example_inputs_for_jit_trace -v
monkeytype is not installed. Skipping tests for Profile-Directed Typing
test_restore_device (test_jit.TestJit.test_restore_device) ... ok
test_import_method (test_jit.TestJit.test_import_method) ... ok
test_torch_load_zipfile_check (test_jit.TestJit.test_torch_load_zipfile_check) ... ok
test_repeated_script_on_function (test_jit.TestScript.test_repeated_script_on_function) ... ok
test_script_fn_pkl (test_jit.TestJit.test_script_fn_pkl) ... ok
test_trace_retains_train (test_jit.TestJit.test_trace_retains_train) ... ok
test_dictionary_as_example_inputs_for_jit_trace (test_jit.TestFrontend.test_dictionary_as_example_inputs_for_jit_trace) ... ok
Ran 7 tests in 0.104s
OK
root@hostname-fqv42:~/torchnpuapi/torch-npu/2.7.1/pytorch/test#
【CheckList】