已关闭
docs: add torch.serialization.default_restore_location #45113
Zky0803创建于 8月21日关闭于 8月21日
docs: add torch.serialization.default_restore_location #45113
已关闭
Zky0803创建于 8月21日关闭于 8月21日
Zky0803
8月21日

【合入来源】

【分支范围】

本资料 PR 面向 master 目标分支。

当前 master/docs/zh/api/native_api 资料体系包含:

pytorch_2-7-1
pytorch_2-11-0
pytorch_2-12-0
pytorch_2-13-0

pytorch_2-9-0、pytorch_2-10-0 已不在当前 Native API 资料目录中,
本 PR 不涉及这两个版本。

资料分支:

源分支:docs/default-restore-location
目标分支:master
基线提交:ba2fae9d04c4909a34ca50312fe7a651ac77d7c9
Commit:d0399a5db9f6520a3a06bb83f0f0ba19b74d98ba
提交标题:docs: add torch.serialization.default_restore_location

本 PR 为 docs-only 单提交,未包含测试代码或功能代码修改。

【修改方案】

补充公开 API:

torch.serialization.default_restore_location(storage, location)

的 Native API 支持资料。

四套资料原有 Serialization 章节均已包含:

torch.save
torch.load

但补齐前均未登记:

torch.serialization.default_restore_location

因此本 PR 在各版本 torch.md 的 torch.load 之后、## Parallelism
之前增加目标 API 条目。

修改文件:

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

新增结构:

## Serialization
### torch.save
### torch.load
### torch.serialization.default_restore_location
## Parallelism

各版本分别链接对应 PyTorch 2.7、2.11、2.12、2.13 的原生文档页面。

【支持情况】

支持状态与各版本现有 torch.load Serialization 条目保持一致:

硬件 是否支持
Atlas A2 训练系列产品 ✔
Atlas A3 训练系列产品 ✔
Ascend 950DT ✔

torch.serialization.default_restore_location 为序列化位置恢复/调度类 API,
不属于 Tensor 数值计算接口,因此本 PR 不增加 fp16、fp32、bf16 等数据类型限制说明。

新增支持状态使用当前资料规范的 ✔ / ✘ 形式。

【社区用例与代码 PR 说明】

PyTorch 社区已有 torch.load(..., map_location=...) 的间接覆盖,但未发现直接调用:

torch.serialization.default_restore_location(storage, location)

并验证 NPU restore 行为的目标测试。

根据当前任务分类,代码侧在 Torch-NPU 已有测试文件:

test/npu/test_serialization.py

中补充直接 NPU 测试,代码 PR 分别面向:

master
v2.7.1
v2.11.0
v2.12.0

当前官方仓库未提供 v2.13.0 代码目标分支,因此不创建第五个 v2.13.0 代码 PR;
但 pytorch_2-13-0 Native API 资料目录已存在,因此本资料 PR 同步维护 2.13.0 资料。

本资料 PR 不依赖 test_upstream patch。

【接口变更】

不涉及。

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

  • torch.serialization.default_restore_location Python 实现;
  • API 签名、返回值或异常契约;
  • Torch-NPU Python/C++ 实现;
  • NPU Kernel;
  • Torch-NPU 单元测试;
  • test_upstream patch。

【功能验证】

本 PR 为资料变更,已完成资料结构、修改范围和 Git diff 静态验证。

提交与远端验证:

branch=docs/default-restore-location
base=ba2fae9d04c4909a34ca50312fe7a651ac77d7c9
commit=d0399a5db9f6520a3a06bb83f0f0ba19b74d98ba
commit_file_count=4
test_file_count=0
worktree_status_count=0
cached_diff_check_rc=0
push_rc=0
remote_head=d0399a5db9f6520a3a06bb83f0f0ba19b74d98ba
REMOTE_VERIFY=PASS

目标 API 在四套资料中的位置:

pytorch_2-7-1:line 2128
pytorch_2-11-0:line 2100
pytorch_2-12-0:line 2100
pytorch_2-13-0:line 2100

【test_upstream patch】

不涉及。

本资料 PR 不修改 PyTorch 官方测试文件,也不新增或修改 Torch-NPU
test_upstream patch。

【流程规范说明】

本任务按当前 API 一致性要求独立维护各目标代码分支,并将资料补齐统一提交到
master 的独立 docs PR。

不使用同步创建其他版本 PR 的 /sync 流程。

【CheckList】

likedislike
当前Pull Request已关闭, 关闭人@Zky0803
ZZky0803
8月21日 创建了 pull request,commit c5070e71
atomgit-bot
atomgit-bot
8月21日 评论:

变更摘要

本 PR 为纯资料更新类改动(标题以 docs 开头),目标是为 PyTorch 序列化模块中的 torch.serialization.default_restore_location 接口补充文档说明。根据 PR 统计,改动共涉及 4 个文件、新增 68 行、无删除行,属于文档内容新增,不涉及功能代码、接口或配置的变更。任务中未内嵌具体文件的补丁内容,因此以下说明仅基于 PR 标题、描述与文件统计信息。

主要改动

  • 新增 torch.serialization.default_restore_location 文档: 依据 PR 标题,本次改动为该接口补充使用说明,属于资料更新(docs 类型),不涉及任何功能逻辑变更。
  • 纯新增、无删除的文档变更: 改动统计为新增 68 行、删除 0 行,说明全部为增量文档内容,不影响现有代码行为。
likedislike
不准确?
atomgit-bot
atomgit-bot
8月21日 评论:

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

likedislike
不准确?
ascend-robotascend-robot成员
8月21日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
8月21日 评论:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.


PR Approval Progress

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
**/*.md ❌ (0/2)(You can also ask: huangjingwei, molly123321, lyx324521, zhenyu10, zichun_ye) ❌ (0/1)(You can also ask: huangjingwei, zhenyu10, renyujin, wjlflyer, chenrayray)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

Zky0803, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
8月21日 添加了label:needs-issue
ascend-robot
ascend-robot成员
8月21日 评论:

当前仓库存在以下 保护分支 :

Protected Branch Version Release
master
v2.7.1-26.1.0
v2.9.0
v2.11.0-26.1.0
v2.12.0-26.1.0
v2.7.1
v2.11.0
v2.10.0
v2.9.0-26.1.0
v2.12.0
v2.10.0-26.1.0
ci-test

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
ascend-robot
ascend-robot成员
8月21日 评论:

Linking Issue Notice

@Zky0803 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

likedislike
ascend-robotascend-robot成员
8月21日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
8月21日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
8月21日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
8月21日 评论:
流水线 PR-pipeline_pytorch#62990 [ commitID:d0399a5d ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_X86 🛑 >>>
Build_ARM 🛑 >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
Build_X86_213 🛑 >>>
Build_ARM_213 🛑 >>>
恶意代码检查 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 🛑 >>>
UT_ARM_A2_Part_01_213 🛑 >>>
UT_ARM_A2_Part_02_213 🛑 >>>
UT_ARM_A2_Part_03_213 🛑 >>>
UT_inductor_Part_01_213 🛑 >>>
UT_inductor_Part_02_213 🛑 >>>
UT_inductor_Part_03_213 🛑 >>>
UT_inductor_Part_04_213 🛑 >>>
UT_DIST_ARM_Part_01_213 🛑 >>>
UT_DIST_ARM_Part_02_213 🛑 >>>
UT_DIST_ARM_Part_03_213 🛑 >>>
UT_DIST_ARM_Part_04_213 🛑 >>>
UT_ARM_A2_Select_Part_01_213 🛑 >>>
UT_ARM_A2_Select_Part_02_213 🛑 >>>
流水线 PR-pipeline_pytorch ✅ >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan, Jesse, WSs_321]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
ZZky0803
8月21日 修改了pull request 的描述
ascend-robotascend-robot成员
8月21日 删除了label:needs-issue
Zky0803
8月21日 评论:

compile

likedislike
ascend-robotascend-robot成员
8月21日 删除了label:ci-pipeline-passed
ascend-robotascend-robot成员
8月21日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
8月21日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
8月21日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
8月21日 评论:
流水线 PR-pipeline_pytorch#62994 [ commitID:d0399a5d ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
阶段 任务名 状态 详情
编译构建 Build_X86 🛑 >>>
Build_ARM 🛑 >>>
Build_X86_torchair 🛑 >>>
Build_ARM_torchair 🛑 >>>
patch_test 🛑 >>>
Build_X86_213 🛑 >>>
Build_ARM_213 🛑 >>>
恶意代码检查 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 🛑 >>>
UT_ARM_A2_Part_01_213 🛑 >>>
UT_ARM_A2_Part_02_213 🛑 >>>
UT_ARM_A2_Part_03_213 🛑 >>>
UT_inductor_Part_01_213 🛑 >>>
UT_inductor_Part_02_213 🛑 >>>
UT_inductor_Part_03_213 🛑 >>>
UT_inductor_Part_04_213 🛑 >>>
UT_DIST_ARM_Part_01_213 🛑 >>>
UT_DIST_ARM_Part_02_213 🛑 >>>
UT_DIST_ARM_Part_03_213 🛑 >>>
UT_DIST_ARM_Part_04_213 🛑 >>>
UT_ARM_A2_Select_Part_01_213 🛑 >>>
UT_ARM_A2_Select_Part_02_213 🛑 >>>
流水线 PR-pipeline_pytorch ✅ >>>
此流水线已支持下列评论快捷指令,仅PR创建者和白名单成员[wujinyuan1, huangjingwei, liangsongwei, yashi999, culechan, Dring, wuyouqi1, L1919_snow, qq_52711437, WhiteNight12, nomiz, xiu_21, ffmh, wanglijun55, hss-shuai, husichao, smallsilly, lanshaozuishuai, jimmyisme1, lzy0920232, alpha-junh, Sunshine_Youngster, wei_zhuoyi, zhangyihuiben, zyw-hw, zzzkeke, rmch, yangch0324, LucciC, AACAES, renyujin, wjlflyer, senzhen-town, pengjingyou, qsc97, limuan, yule100, xiaoqi-zhou, kuhn7, chenxingying, hanye02, zichun_ye, anyrenwei, kkjocker, wangzili121, Lu_G, yvjc, puddingfjz, HandsoemLemon, bigprestigee1, huawuyi, zhenyu10, dairenjie, du-jin-hang, zou-jieyu, adelaideliu, TrHan, wanlinan, Windwindzzz, pengqihw, kisnwang, yuheng_wang, honghao_wang, jizewei, zhangguoguang, sunyu-xuan, chenrayray, hbhu_bin, liujunzhu, c_34, LiNuoh, maoyuanpeng1, zzhongmin, zhaoyu65, bellatan, jiabaolin, zhuofanshen, wencaiwen, lu_zhuge, caoshuyang, molly12, lyx324521, LQ1206, gitcode-chenjiao, cai-weiwei1989, CHDong, ogqin, yuanlipingGit, xuqinglin1, lqz2, zouwei1, chaoluoa, paradox325, jackzhang1116, yaoyao, akh, yujiacheng, dengjie0116, Hubert11111, Shine_Ws, wslhj555, longqiand, OYtao666, JiaqingQiang, luyyyy, Kingbelial, zhanghaiyu0101, wenxp1018, yanliu-luoluo, ksun_sekiro, liyong328, wgzheng, tangky, vivi_is_coding, aoiaoisola, weixin_44494597, wangmengmengwang65667, hid57809721, qq_35468730, comeonup, C547032, gcw_m5OQChA4, yao_yao_ling_xian, cnnbwcy, szqfes_12, cora_19, cann_lilin, can, shawnylee233, fanglanyue0916, hhz0, LiNuohang, taohuoquan, Jesse, WSs_321]评论有效
  • compile、compile_inductor、compile_torchair : 运行流水线
  • retry : 重试流水线所有失败子任务
  • retry <任务名> : 仅重试指定失败子任务
  • stop : 停止流水线
likedislike
Zky0803
8月21日 评论:

@ascend-robot 本 PR 为 docs 资料变更,docs CI 未自动触发(对比同批次资料 PR #45079/#45083 均可自动触发),请协助调度 docs 流水线,谢谢。

likedislike
ZZky0803
8月21日 关闭了 pull request
ZZky0803
8月21日 重新打开了 pull request
ZZky0803
8月21日 update merge request[project id:7404318, iid:45113, commit_id:737e889901eea84530ea55588fb2f97ecee31bc4], virtual merging success
ascend-robotascend-robot成员
8月21日 删除了label:ascend-cla/yes
ascend-robotascend-robot成员
8月21日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
8月21日 评论:

当前仓库存在以下 保护分支 :

Protected Branch Version Release
master
v2.7.1
v2.10.0-26.1.0
v2.9.0-26.1.0
v2.10.0
v2.7.1-26.1.0
v2.9.0
v2.11.0-26.1.0
v2.12.0-26.1.0
v2.11.0
v2.12.0
ci-test

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
ZZky0803
8月21日 关闭了 pull request