Merged
docs: add support information for PowerSGDState.__getstate__ #44658
docs: add support information for PowerSGDState.__getstate__ #44658
Merged
GokoAdd on Aug 15
Goko
Goko
Aug 15

【合入来源】

如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)
关联任务:https://gitcode.com/Ascend/pytorch/issues/2721
说明性 Issue:https://gitcode.com/Ascend/pytorch/issues/4045

【修改方案】

请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列
如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

本 PR 补充以下 API 的 TorchNPU 支持资料:

torch.distributed.algorithms.ddp_comm_hooks.powerSGD_hook.PowerSGDState.__getstate__

该 API 是纯 Python 状态整理接口,用于返回 PowerSGDState.__slots__ 中除 process_group 以外的状态字典;方法自身不执行 NPU 算子或分布式 collective。PyTorch 官方社区缺少该方法的完整直接用例。依据新版 API 一致性任务要求,不新增测试用例或 NPU 适配 patch,运行验证和判型证据已提交至说明性 Issue #4045。

当前正式资料已列出 PowerSGDState,但遗漏其公开方法 PowerSGDState.__getstate__。本 PR 在 master 统一更新当前保留的四个资料版本:

docs/zh/api/native_api/pytorch_2-7-1/DDP-Communication-Hooks.md
docs/zh/api/native_api/pytorch_2-11-0/DDP-Communication-Hooks.md
docs/zh/api/native_api/pytorch_2-12-0/DDP-Communication-Hooks.md
docs/zh/api/native_api/pytorch_2-13-0/DDP-Communication-Hooks.md

每份资料均进行以下修改:

  1. 新增 PowerSGDState.__getstate__ 独立条目和对应版本的 PyTorch 原生文档链接;
  2. 标记 Atlas A2、Atlas A3 和 Ascend 950DT 均支持,统一使用 ✔ 字符;
  3. 该 API 不涉及输入数据类型限制,因此“限制与说明”填写为 -;
  4. 修正非计算类 PowerSGDState 原有的错误 dtype 限制说明,将其改为 -。

本 PR 仅包含 API 1 的资料更新,不包含测试文件、NPU 适配 patch、功能源码或其他 API 修改。

【资料变更】

请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

涉及。

更新 master 下 PyTorch 2.7.1、2.11.0、2.12.0 和 2.13.0 的 DDP-Communication-Hooks.md,补充目标 API 的支持情况,并修正 PowerSGDState 的非计算类限制说明。

【接口变更】

请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

不涉及。

本 PR 不修改 PowerSGDState、__getstate__、函数签名、返回值、序列化契约或 TorchNPU 功能实现。

【功能验证】

说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤
新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

目标 API 的 PyTorch 2.7.1、2.11.0、2.12.0 三套 TorchNPU NPU 环境验证均为 PASS,详细环境、源码分析和运行截图见说明性 Issue #4045。

资料修改已完成以下本地检查:

changed files: 4
git diff --check: PASS
exact API entries: 4 / 4
Unicode checkmark: U+2714 (✔)
HTML entity check: PASS
official documentation links: PASS
entry ordering: PASS
limitations exactly '-': PASS
overall semantic and character audit: PASS

提交信息:

commit: 902bfd031965a56bfc453b7f979b879141d8bcbe
subject: docs: add PowerSGDState.__getstate__ support
files: 4 modified documentation files
diff: 76 insertions, 4 deletions

Atlas A5(Ascend 950PR)实机验证

补充 Atlas A5 / Ascend 950 系列环境完成独立实机验证。

验证环境:

time: 2026-08-28T13:59:39+00:00
OS: Ubuntu 22.04.5 LTS
architecture: x86_64
NPU: Ascend950PR
NPU Health: OK
npu-smi: 25.7.rc1.6
CANN: 9.1.0
Python: 3.12.13
PyTorch: 2.10.0+cpu
torch-npu: 2.10.0.post4
NPU available: True
NPU device count: 1

关键验证结果:

Hardware check: PASS - genuine Atlas A5 / Ascend 950 series
Basic NPU tensor operation: PASS
API callable: PASS
Pure Python function: PASS
Return type is dict: PASS
process_group excluded: PASS
Returned keys match __slots__ minus process_group: PASS
NPU tensor object identity preserved: PASS
NPU tensor device preserved: PASS
NPU tensor value preserved: PASS
Extra argument rejected: PASS
RESULT: PASS
Validation exit status: 0

完整日志保存在验证环境:

/user_data/torch_npu_api_consistency/logs/api01_a5_950pr/powersgdstate_getstate_a5_950pr_validation.log

资料修改已完成以下本地检查:

changed files: 4
git diff --check: PASS
class-method headings: 4 / 4
obsolete standalone headings: 0
class/method nesting: PASS
div tag balance: PASS
Unicode checkmark: U+2714 (✔)
HTML entity check: PASS
official documentation links: PASS
entry ordering: PASS
limitations exactly '-': PASS
overall semantic and character audit: PASS

提交信息:

commit: ef1815cd3d656c234b6ededee315d183bb6fcf91
subject: docs: add PowerSGDState.__getstate__ support
files: 4 modified documentation files
diff: 76 insertions, 4 deletions

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request has been successfully merged by ascend-robot.
(Thank you for Goko's contribution.)
GokoGoko
Aug 15 Created pull request, commit 029feeba
GokoGoko
Aug 15 Associated issue: 【社区任务】7月社区任务第一期-Ascend for PyTorch API 一致性开发(1),[Usage]: 【API一致性任务】torch.distributed.algorithms.ddp_comm_hooks.powerSGD_hook.PowerSGDState.__getstate__ 纯 Python 接口验证说明
atomgit-bot
atomgit-bot
Aug 15 Comments:

变更摘要

本 PR 属于资料更新,主要为 torch.distributed.algorithms.ddp_comm_hooks.powerSGD_hook.PowerSGDState.__getstate__ 补充 TorchNPU 支持资料。该接口是纯 Python 状态整理接口,用于返回 PowerSGDState.__slots__ 中除 process_group 以外的状态字典,不执行 NPU 算子或分布式 collective。本次在 master 上统一更新 PyTorch 2.7.1、2.11.0、2.12.0、2.13.0 四个资料版本的 DDP-Communication-Hooks.md,不涉及测试用例、NPU 适配 patch 或功能源码修改。

主要改动

  • 新增 API 条目: 在四个版本的 docs/zh/api/native_api/pytorch_2-*-0/DDP-Communication-Hooks.md 中新增 PowerSGDState.__getstate__ 独立条目及对应版本的 PyTorch 原生文档链接。
  • 补充支持矩阵: 为 PowerSGDState.__getstate__ 标记 Atlas A2、Atlas A3 和 Ascend 950DT 均支持,统一使用 ✔(U+2714)字符。
  • 填写限制说明: 由于该 API 不涉及输入数据类型限制,将新增条目的“限制与说明”填写为 -。
  • 修正既有错误说明: 修正非计算类 PowerSGDState 原有的错误 dtype 限制说明,将其改为 -。
  • 变更范围限定: 本 PR 仅包含 API 1 的资料更新,不修改 PowerSGDState、__getstate__ 的签名、返回值、序列化契约或 TorchNPU 功能实现。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 15 Comments:

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

likedislike
Incorrect?
264 messages are collapsed here。 See more
ascend-robotascend-robotCollaborators
Sep 16 Closed associated issue
ascend-robotascend-robotCollaborators
Sep 16 Merged pull request
ascend-robot
ascend-robotCollaborators
Sep 16 Comments:

Pull Request 已合并或已关闭。

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

likedislike
ascend-robot
ascend-robotCollaborators
Sep 16 Comments:

Pull Request 已合并或已关闭。

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

likedislike
AtlasAccount
AtlasAccountCollaborators
Sep 16 Comments:
流水线 pytorch_gitcode_PR_multiVersion-onetrack#93 [ commitID:1526026d ] 已完成
likedislike