Merged
docs: add torch.onnx.ONNXProgram.release #45083
docs: add torch.onnx.ONNXProgram.release #45083
Merged
Zky0803Add on Aug 21
Zky0803
Zky0803
Aug 21

【合入来源】

A2 / A3 / A5 实机验证

本 API 为纯 Python 资源释放接口,不涉及 NPU Kernel,但仍按统一验收标准在
A2 / A3 / A5 三类硬件环境执行 NPU runtime probe 和 release() 功能行为验证。

验证范围保持为已经完成实测的三个运行时版本:

PyTorch 2.7.1
PyTorch 2.11.0
PyTorch 2.12.0

验证矩阵:

验证平台 实机硬件 2.7.1 2.11.0 2.12.0 结果
A2 Ascend910B3 PASS PASS PASS PASS
A3 Ascend910_9382 PASS PASS PASS PASS
A5 Ascend950PR / Ascend950PR_9579(按任务口径等价 Ascend 950DT) PASS PASS PASS PASS

覆盖场景:

1. inference session + tempdir:session 清空、cleanup、gc.collect、返回 None
2. repeated release:重复调用成功且 cleanup 不重复,验证幂等性
3. session only:session 正常释放
4. tempdir only:tempdir 正常 cleanup 并清空

正式日志:

A2:/workspace/onnx_program_release_A2_formal_20260903T100049Z.log
A3:/workspace/onnx_program_release_A3_formal_20260903T100855Z.log
A5:/workspace/onnx_program_release_A5_formal_20260906T053549Z.log

最终硬件验证结论:

A2:PASS
A3:PASS
A5:PASS

新增的 2.9.0 / 2.10.0 / 2.13.0 / 2.14.0 为本轮 Native API 资料同步范围,
本 PR 不把它们表述为新增 A2/A3/A5 runtime 验证结果。

【分支范围】

本资料 PR 面向 master。

根据 2026-09-28 群内最新 Native API 资料要求,当前同步范围为:

pytorch_2-7-1
pytorch_2-9-0
pytorch_2-10-0
pytorch_2-11-0
pytorch_2-12-0
pytorch_2-13-0
pytorch_2-14-0

此前“2.9.0 / 2.10.0 不在资料目录、不涉及本 PR”的旧描述已失效,
本次已按最新 master 和群内要求同步纳入。

资料分支:

源分支:docs/onnx-program-release
目标分支:master
基线提交:142dc619f48b86576690ca25926d82d39c810ca9
Commit:f9d839fcbeaee2094801f04f44c8f9e654e64ad9
提交标题:docs: add torch.onnx.ONNXProgram.release

本 PR 当前保持单一任务提交:

commit_count=1

【修改方案】

补充 torch.onnx.ONNXProgram.release 的 Native API 支持资料,
不修改 API 实现、测试逻辑、Torch-NPU C++ 代码或 NPU Kernel。

最终修改 7 个文件:

docs/zh/api/native_api/pytorch_2-7-1/torch-onnx.md
docs/zh/api/native_api/pytorch_2-9-0/torch-onnx.md
docs/zh/api/native_api/pytorch_2-10-0/torch-onnx.md
docs/zh/api/native_api/pytorch_2-11-0/torch-onnx.md
docs/zh/api/native_api/pytorch_2-12-0/torch-onnx.md
docs/zh/api/native_api/pytorch_2-13-0/torch-onnx.md
docs/zh/api/native_api/pytorch_2-14-0/torch-onnx.md

每个版本均在包含 torch.onnx.ONNXProgram 父 API 原生文档链接的主 section 中新增:

> <font size="3">release()</font>

产品支持信息按群内最新规范使用:

**产品支持情况**:

<!-- npu="910b" idX -->
- <term>Atlas A2训练系列产品</term>:支持
<!-- end idX -->
<!-- npu="A3" idY -->
- <term>Atlas A3训练系列产品</term>:支持
<!-- end idY -->
<!-- npu="950" idZ -->
- <term>Ascend 950DT系列产品</term>:支持
<!-- end idZ -->

实际 marker ID 使用各文件中的唯一数字:

pytorch_2-7-1:106 / 107 / 108
pytorch_2-9-0:37 / 38 / 39
pytorch_2-10-0:37 / 38 / 39
pytorch_2-11-0:37 / 38 / 39
pytorch_2-12-0:37 / 38 / 39
pytorch_2-13-0:37 / 38 / 39
pytorch_2-14-0:37 / 38 / 39

torch.onnx.ONNXProgram.release 为非计算类资源释放 API,与 Tensor dtype 无关,
不增加 fp16、fp32、bf16 等 dtype 限制说明。

【原生文档链接】

PyTorch 2.7.1
https://pytorch.org/docs/2.7/onnx_dynamo.html#torch.onnx.ONNXProgram.release

PyTorch 2.9.0
https://docs.pytorch.org/docs/2.9/onnx_export.html#torch.onnx.ONNXProgram.release

PyTorch 2.10.0
https://docs.pytorch.org/docs/2.10/onnx_export.html#torch.onnx.ONNXProgram.release

PyTorch 2.11.0
https://pytorch.org/docs/2.11/onnx_export.html#torch.onnx.ONNXProgram.release

PyTorch 2.12.0
https://pytorch.org/docs/2.12/onnx_export.html#torch.onnx.ONNXProgram.release

PyTorch 2.13.0
https://pytorch.org/docs/2.13/onnx_export.html#torch.onnx.ONNXProgram.release

PyTorch 2.14.0
https://pytorch.org/docs/2.14/onnx_export.html#torch.onnx.ONNXProgram.release

【社区用例检索与新增必要性】

本 PR 为资料补齐 PR,不新增或修改单元测试。

按最新 TorchNPU API 一致性验收规范复核:

  • PyTorch 已实现 torch.onnx.ONNXProgram.release;
  • PyTorch 社区未发现针对该方法本身的直接测试;
  • release() 仅释放 _inference_session、调用 gc.collect() 并清理 _tempdir;
  • 不接收 Tensor;
  • 不实现独立 NPU 算子;
  • 不调用 NPU Kernel;
  • 不访问 NPU 设备侧计算资源;
  • 不需要修改 torch_npu/csrc;
  • 不需要新增 test_upstream patch。

处理结论:

PyTorch 官方社区无直接用例或覆盖不完整
+
API 为纯 Python 接口、不涉及硬件
→ 无需新增 Torch-NPU 专项测试

旧版规则下四个直接测试 PR #43594 / #43595 / #43596 / #43597 已关闭,
仅保留为历史支持性验证证据。

【资料变更】

涉及。

新增 torch.onnx.ONNXProgram.release Native API 支持状态,同步更新:

PyTorch 2.7.1
PyTorch 2.9.0
PyTorch 2.10.0
PyTorch 2.11.0
PyTorch 2.12.0
PyTorch 2.13.0
PyTorch 2.14.0

7 个版本在修改前均未登记 release(),修改后均唯一登记一次。

产品支持情况:

Atlas A2训练系列产品:支持
Atlas A3训练系列产品:支持
Ascend 950DT系列产品:支持

并按最新资料规范增加 npu="910b" / npu="A3" / npu="950" comment marker。

【接口变更】

不涉及。

本 PR 只更新 Native API 支持资料,不修改:

  • Python API 实现;
  • 函数签名或返回类型;
  • Torch-NPU Python/C++ 实现;
  • NPU Kernel;
  • Torch-NPU 单元测试;
  • test_upstream patch。

【功能验证】

最新提交信息:

base=142dc619f48b86576690ca25926d82d39c810ca9
commit=f9d839fcbeaee2094801f04f44c8f9e654e64ad9
branch=docs/onnx-program-release

最终修改范围:

7 files changed, 140 insertions(+)

验证结果:

strict seven-version validation=PASS
git diff --check=PASS
git diff --cached --check=PASS
pytorch_2-7-1 release_line_count=1
pytorch_2-9-0 release_line_count=1
pytorch_2-10-0 release_line_count=1
pytorch_2-11-0 release_line_count=1
pytorch_2-12-0 release_line_count=1
pytorch_2-13-0 release_line_count=1
pytorch_2-14-0 release_line_count=1
commit_count=1
Git Hooks Checking=PASSED
push_exit_code=0
local_head=f9d839fcbeaee2094801f04f44c8f9e654e64ad9
remote_head=f9d839fcbeaee2094801f04f44c8f9e654e64ad9
REMOTE_VERIFY=PASS
CLA=YES
CI=YES
docs CI=YES
三个验收标签:全部 YES

【最新审核与资料规范处理】

本任务已依次处理:

1. release() 原生文档链接精确化;
2. 支持表格调整为“产品支持情况”;
3. 产品支持信息增加 Markdown 列表标记;
4. 2026-09-28 群内最新规范:
   - 拉取最新 master 资料格式;
   - 产品支持项增加 npu comment marker;
   - 新增 pytorch_2-9-0 / pytorch_2-10-0 / pytorch_2-14-0;
   - 与原有 2.7.1 / 2.11.0 / 2.12.0 / 2.13.0 一并同步。

因最新 master 对目标资料文件已有较大调整,本轮未继续在旧 base 上追加 amend,
而是从最新:

142dc619f48b86576690ca25926d82d39c810ca9

重新构造单一任务提交并使用 --force-with-lease 更新 PR:

old_remote=d696d6d9aaff141e4969431ce7f226b28b325b1d
new_commit=f9d839fcbeaee2094801f04f44c8f9e654e64ad9
push_exit_code=0
Git Hooks Checking=PASSED
remote_verify=PASS
commit_count=1
git diff --check=PASS
7 files changed, 140 insertions(+)
CLA=YES
CI=YES
docs CI=YES
三个验收标签:全部 YES

若对应 review thread 在平台 UI 中仍显示未解决,需要在平台上回复并标记“已解决”;
本 PR 描述不提前宣称该 UI 操作已经完成。

【test_upstream patch】

不涉及。

torch.onnx.ONNXProgram.release 为纯 Python、硬件无关资源释放接口,
无需新增或修改 test_upstream patch。

【CheckList】

likedislike
Pull Request has been successfully merged by ascend-robot.
(Thank you for Zky0803's contribution.)
Zky0803Zky0803
Aug 21 Created pull request, commit a66ef91b
atomgit-bot
atomgit-bot
Aug 21 Comments:

变更摘要

该 PR 为纯文档更新(docs 类型),目标是为 torch.onnx.ONNXProgram 的 release 方法新增使用文档说明。本次改动属于「资料更新」范畴,仅涉及文档内容的补充,不包含任何业务逻辑或实现代码变更;共修改 4 个文件,全部为新增内容(新增 64 行、删除 0 行),PR 描述中未涉及接口变更与功能验证相关内容。

主要改动

  • 新增 torch.onnx.ONNXProgram.release 文档: 为 ONNXProgram 类的 release 方法补充文档说明,介绍其用途与使用方式。
  • 纯文档性改动: 本次 PR 仅新增文档内容(64 行新增、0 行删除),未改动任何代码实现,属于「资料更新」类型的变更。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 21 Comments:

🤖 本次改动均为数据 / 生成 / 二进制文件(如测试用例、锁文件、媒体资源),没有可审查的代码逻辑,已跳过 AI 代码审查。

likedislike
Incorrect?
ascend-robotascend-robotCollaborators
Aug 21 Added label: needs-issue
301 messages are collapsed here。 See more
ascend-robot
ascend-robotCollaborators
Oct 10 Comments:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
群青世界群青世界Collaborators
Oct 10 Resolved final issue
ascend-robotascend-robotCollaborators
Oct 10 Merged pull request
ascend-robot
ascend-robotCollaborators
Oct 10 Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
AtlasAccount
AtlasAccountCollaborators
Oct 10 Comments:
流水线 pytorch_gitcode_PR_multiVersion-onetrack#311 [ commitID:f9d839fc ] 已完成
likedislike