Compare commits

...
393 Commits
Author SHA1 Message Date
LucciC 86cc7b214b fix(_inductor): drop triton driver dependency in config
Co-authored-by: LucciC<cuiliangcheng2@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!45441 merge v2.10.0-26.0.0_fix_inductor_triton_dep into v2.10.0-26.0.0

fix(_inductor): drop triton driver dependency in config

Created-by: LucciC
Commit-by: LucciC
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!45441
2026-08-28 11:05:02 +08:00
pta-robot 8a33cdd6f1 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!45110 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-08-21 18:03:24.

See merge request: Ascend/pytorch!45110
2026-08-21 18:56:22 +08:00
pta-robot 62ef1b6df3 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!43776 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-08-04 22:02:33.

See merge request: Ascend/pytorch!43776
2026-08-15 17:02:23 +08:00
pta-robot 91bb6f941b Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!42999 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-27 22:02:39.

See merge request: Ascend/pytorch!42999
2026-07-31 22:51:27 +08:00
pta-robot fe9bcc6ead Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!41692 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-14 22:02:45.

See merge request: Ascend/pytorch!41692
2026-07-20 09:25:23 +08:00
pta-robot edc8f9b651 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!40607 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-09 22:02:25.

See merge request: Ascend/pytorch!40607
2026-07-13 09:27:38 +08:00
pta-robot 77e7e34b40 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!40408 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-07 22:02:35.

See merge request: Ascend/pytorch!40408
2026-07-09 12:00:00 +08:00
ascend-robot cfdd471501 【translate】Add English security statement
Co-authored-by: l60114168<liuyaxiong6@h-partners.com>



# message auto-generated for no-merge-commit merge:
!40463 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

【translate】Add English security statement

Created-by: lyx324521
Commit-by: l60114168
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单https://gitcode.com/Ascend/pytorch/issues/1880
- [ ] 重构优化
- [x] 资料更新

# 【修改方案】
新增英文的安全声明

# 【资料变更】
涉及

# 【接口变更】
不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!40463
2026-07-09 10:39:35 +08:00
wuyouqi1 38ac3740a3 fix : cache log gate and harden isACLGlobalLogOn in ShouldLogAclApi
Co-authored-by: wuyouqi1<wuyouqi1@h-partners.com>



# message auto-generated for no-merge-commit merge:
!40449 merge personal/v2.10.0-26.0.0-fix-once into v2.10.0-26.0.0

fix : cache log gate and harden isACLGlobalLogOn in ShouldLogAclApi

Created-by: wuyouqi1
Commit-by: wuyouqi1
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

- [ ] 需求
- [ ] 问题单
- [x] issue/工单 https://gitcode.com/Ascend/pytorch/issues/2611
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】

`ACL_CALL_LOG` 宏外层仅靠 `ShouldLogAclApi(api_name)` 门控,该函数**默认 `return true`**(只屏蔽 api 名含 "Query"/"Event" 的接口)。默认推理场景(日志未开)宏仍进 try 块,每次 acl 调用都付 ostringstream 构造 + args_expr 拼接 + 2 次 `.str().c_str()` + `GetAclLogger`。84 处调用点在推理热路径累积开销,致 TPOT 劣化。

修复:`AclCallDecorator.cpp` 新增 `g_log_enabled` + `InitFilter` 内解析级别(PTA acl-logger 级别 ≤ INFO OR ASCEND global ACL_INFO 开),`ShouldLogAclApi` 加 `if (!g_log_enabled) return false` 前置短路

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】

场景:推理服务 TPOT 性能验证
- 基线(无 acl log):9.1ms
- 修复前(`ShouldLogAclApi` 默认 true,每次进拼接块):10ms
- 修复后(`call_once` 缓存级别门控,默认 false 短路):9.1ms

UT:不涉及(性能修复 + 无新增接口)。

# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!40449
2026-07-08 14:24:06 +08:00
pta-robot 826dcaec2b Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!40250 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-06 22:02:32.

See merge request: Ascend/pytorch!40250
2026-07-07 21:01:04 +08:00
pta-robot a2d14f4fbe Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!39951 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-07-03 10:01:51.

See merge request: Ascend/pytorch!39951
2026-07-04 15:47:35 +08:00
wanlinan 8751b36d5d [fix] use real device for set_device in createHCCLComm and startCoalescing
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!39065 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[fix] use real device for set_device in createHCCLComm and startCoalescing

Created-by: wanlinan
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
[[Bug]: MindSpeed-qwen3vl-8B模型子通信域调用allreduce报端口已被占用](https://gitcode.com/Ascend/pytorch/issues/2455)
[[Bug]: 分布式CI问题,test_avoid_batch_isend_irecv_hccl异常报错](https://gitcode.com/Ascend/pytorch/issues/2429)

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
原来的getDeviceForRank(getRank())推断在子通信域中可能会出现推断错误,把原先的通过getDeviceForRank(getRank())推断device改成直接获取device。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
下游MindSpeed冒烟验证通过

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!39065
2026-06-24 15:26:53 +08:00
pta-robot 069bed1e89 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!38881 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-18 22:02:39.

See merge request: Ascend/pytorch!38881
2026-06-22 15:24:51 +08:00
wanlinan 908eedd0d6 [fix] add set_device in startcoalescing
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!38252 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[fix] add set_device in startcoalescing

Created-by: wanlinan
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
[[Bug]: batch_send_recv接口报错HcclGroupEnd: not in a group call.](https://gitcode.com/Ascend/pytorch/issues/2355)

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
hccl变更导致的下游问题,hccl把一个计数变量的作用范围改成了线程内,暴露了线程混乱问题。
分析根因是调RunOpApiV3前没有做set_device,修改方案是在调用前加set_device。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
社区用例测试通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/b0f2b429-2558-4df4-8bef-7805a4326652/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!38252
2026-06-15 16:07:58 +08:00
pta-robot 9c849f1850 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!38420 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-12 22:02:50.

See merge request: Ascend/pytorch!38420
2026-06-15 14:45:06 +08:00
pta-robot 10543555d5 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!38135 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-10 18:02:00.

See merge request: Ascend/pytorch!38135
2026-06-15 09:10:17 +08:00
wanlinan 758911c7ae [fix]add Ascend910_9392 in batch_isend_irecv supported_device_name
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!38098 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[fix]add Ascend910_9392 in batch_isend_irecv supported_device_name

Created-by: wanlinan
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
[[Bug]: group下发send/recv的机器限制导致9392机型走不到新特性下](https://gitcode.com/Ascend/pytorch/issues/2344)

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
已和HCCL确认Ascend910_9392 机型支持group下发send/recv,在机型条件判断中加入该机型。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
无

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!38098
2026-06-10 19:08:26 +08:00
pta-robot b483085a27 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!37898 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-08 22:02:16.

See merge request: Ascend/pytorch!37898
2026-06-10 09:22:18 +08:00
zhenyu10 b8e04e5054 [sync] PR-37817: Fix NPU tensor rebuild requires_grad load
Co-authored-by: zhenyu10<shizhenyu5@huawei.com>



# message auto-generated for no-merge-commit merge:
!37997 merge sync-pr37817-master-storage-requires-grad-fix-to-v2.10.0-26.0.0 into v2.10.0-26.0.0

[sync] PR-37817: Fix NPU tensor rebuild requires_grad load

Created-by: ascend-ds-bot
Commit-by: zhenyu10
Merged-by: ascend-robot
Description: 
### 1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/37817

### 2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/2297

### 3. Original pull request related commit(s):
| Sha | Datetime | Message |
|---|---|---|
|[0da3bbf9](https://gitcode.com/Ascend/pytorch/commit/0da3bbf9dc789aedd8696a7339f1d956a88ecfeb)|2026-06-08 10:38:44 +0800 CST|Fix NPU tensor rebuild requires_grad load<br>|


See merge request: Ascend/pytorch!37997
2026-06-10 09:15:55 +08:00
wanlinan 7eac5e5f50 [fix]npu_format_cast in batch_isend_irecv
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!37815 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[fix]npu_format_cast in batch_isend_irecv

Created-by: wanlinan
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当recv输入tensor格式为NZ,调用_batch_isend_irecv接口时,在endcoalescing接口增加类型转换。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
在调用_batch_isend_irecv前转换数据格式为NZ
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e2d626de-423d-4ac2-83cf-1ad36a0a80ea/image.png 'image.png')
验证通过:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/09350ba1-25b0-4cea-860a-006535f3b0f8/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!37815
2026-06-09 20:23:47 +08:00
pta-robot 13275105bb Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!37744 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-05 22:02:36.

See merge request: Ascend/pytorch!37744
2026-06-05 22:35:30 +08:00
pta-robot 37429d93bf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!37386 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-06-01 22:02:39.

See merge request: Ascend/pytorch!37386
2026-06-02 10:53:05 +08:00
fengyixing d688d3a5d5 [sync] PR-35956: test: devide arm_a2 testcases into npu core and selective
Co-authored-by: fengyixing<fengyixing@huawei.com>



# message auto-generated for no-merge-commit merge:
!37186 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[sync] PR-35956: test: devide arm_a2 testcases into npu core and selective

Created-by: fengyixing
Commit-by: fengyixing
Merged-by: ascend-robot
Description: 
### 1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/35956

### 2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/2090

### 3. Original pull request related commit(s):
| Sha | Datetime | Message |
|---|---|---|
|[653e467e](https://gitcode.com/Ascend/pytorch/commit/653e467e95ceb40ca6b05b3bb7a3a04ee2c3b76b)|2026-05-20 11:00:12 +0800 CST|devide arm_a2 testcases into npu core testcases and selective testcases<br>|


See merge request: Ascend/pytorch!37186
2026-06-01 09:49:24 +08:00
chansinging 349b125fb3 bump version to 2.10.0.post2
Co-authored-by: Chansinging<1183520536@qq.com>



# message auto-generated for no-merge-commit merge:
!36973 merge v2.10.0-post1 into v2.10.0-26.0.0

bump version to 2.10.0.post2

Created-by: chansinging
Commit-by: Chansinging
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
社区演进
# 【资料变更】
不涉及
# 【接口变更】
不涉及
# 【功能验证】
流水线已通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e5b38730-0fc8-4050-b8db-ae05cdc3e76d/image.png 'image.png')
# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!36973
2026-05-29 09:16:55 +08:00
pta-robot 6893d1e1f8 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!36412 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-05-21 22:02:37.

See merge request: Ascend/pytorch!36412
2026-05-21 23:40:54 +08:00
pta-robot edf00af982 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!36155 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-05-20 10:01:42.

See merge request: Ascend/pytorch!36155
2026-05-21 13:03:15 +08:00
pta-robot 281d927004 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!35456 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-05-12 22:03:38.

See merge request: Ascend/pytorch!35456
2026-05-12 22:54:18 +08:00
ascend-robot c63b6a7a5b modify document
Co-authored-by: l60114168<liuyaxiong6@h-partners.com>



# message auto-generated for no-merge-commit merge:
!35309 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

modify document

Created-by: lyx324521
Commit-by: l60114168
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
https://gitcode.com/Ascend/pytorch/issues/1880
- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [x] 资料更新

# 【修改方案】
修改2.10.0的维护策略。修改链接

# 【资料变更】
涉及

# 【接口变更】
不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!35309
2026-05-12 10:31:29 +08:00
pta-robot 49f07568cb Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!35176 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-05-09 22:03:37.

See merge request: Ascend/pytorch!35176
2026-05-09 22:52:28 +08:00
pta-robot cd3918ecaf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34989 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-05-07 16:02:32.

See merge request: Ascend/pytorch!34989
2026-05-08 13:25:39 +08:00
pta-robot 077efbc622 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34840 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-30 16:03:35.

See merge request: Ascend/pytorch!34840
2026-04-30 16:52:35 +08:00
pta-robot 94f8a8e6b5 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34767 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-29 17:12:49.

See merge request: Ascend/pytorch!34767
2026-04-29 18:36:30 +08:00
gleaming-spark 1db6b10322 [fix]修改接口aclrtMallocHostWithCfg约束的驱动版本号
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!34672 merge v2.10.0-26.0.0_fix_hdk into v2.10.0-26.0.0

[fix]修改接口`aclrtMallocHostWithCfg`约束的驱动版本号

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
接口存在性判断增加对驱动版本的判断

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
https://gitcode.com/Ascend/op-plugin/pull/4870

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!34672
2026-04-29 16:50:42 +08:00
zhukkk 9cf3a046c6 sk头文件和cann保持一致
Co-authored-by: zhukkk<zhuke11@huawei.com>



# message auto-generated for no-merge-commit merge:
!34591 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

sk头文件和cann保持一致

Created-by: zhukkk
Commit-by: zhukkk
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
acl_sk头文件和cann下面的super_kernel头文件保持名称和内容一致

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
![验证.png](https://raw.gitcode.com/user-images/assets/7404318/404c4dc1-21b1-499b-a4d6-37a49347bbad/验证.png '验证.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!34591
2026-04-28 21:44:26 +08:00
SCh_zx 69ddf5c474 skip ci error (update cann)
Co-authored-by: SCh_zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!34629 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

skip ci error (update cann)

Created-by: SCh_zx
Commit-by: SCh_zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

详见关联issue
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!34629
2026-04-28 19:14:27 +08:00
jizewei e41a0d4bf6 PREMUL_SUM dtype constraints
Co-authored-by: jizewei<jizewei@huawei.com>



# message auto-generated for no-merge-commit merge:
!34514 merge v2.10.0-26.0.0_fix_premul_sum into v2.10.0-26.0.0

PREMUL_SUM dtype constraints

Created-by: jizewei
Commit-by: jizewei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1. aclnnInplaceMuls对齐cuda,不支持int32 * float,修改不合理用例
2. PREMUL_SUM增加dtype校验,对齐NCCL

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

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

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

现有UT用例看护
![image.png](https://raw.gitcode.com/user-images/assets/7404318/91e5b9bf-0baf-4703-a234-94bd7a66b447/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!34514
2026-04-28 10:27:20 +08:00
pta-robot 8e45176f06 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34566 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-27 21:03:26.

See merge request: Ascend/pytorch!34566
2026-04-27 22:33:24 +08:00
pta-robot 49aeaee7e8 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34529 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-27 16:03:38.

See merge request: Ascend/pytorch!34529
2026-04-27 17:31:00 +08:00
pta-robot 70e58cf5cd Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34422 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-25 22:01:28.

See merge request: Ascend/pytorch!34422
2026-04-27 10:20:31 +08:00
pta-robot 41386beebf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34444 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-26 10:02:33.

See merge request: Ascend/pytorch!34444
2026-04-26 11:18:25 +08:00
huangyunlong2022 76c1e6740b add COMPATIBLE for autograd
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!34358 merge 2.10mat-6 into v2.10.0-26.0.0

add COMPATIBLE for autograd

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!34358
2026-04-25 16:33:16 +08:00
pta-robot 2787b98f40 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34313 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-24 16:04:10.

See merge request: Ascend/pytorch!34313
2026-04-25 11:01:51 +08:00
pta-robot bc3ff2ca13 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34258 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-23 16:13:35.

See merge request: Ascend/pytorch!34258
2026-04-23 18:17:50 +08:00
pta-robot 24c0528b64 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34108 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-21 16:06:32.

See merge request: Ascend/pytorch!34108
2026-04-21 18:14:53 +08:00
adelaideliu c0234d11e6 [fix] add USE_FP32_ADD for cube_math_type=4
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!34035 merge v2.10.0_cube_4_26 into v2.10.0-26.0.0

[fix] add USE_FP32_ADD for cube_math_type=4

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
因为需求变化,算子端cube_math_type=4功能有改动,现有枚举值名称不符合语义;同时防止已有用户在使用原cube_math_type=4的枚举值,新增cube_math_type=4的枚举值

# 【资料变更】
涉及,在另一个pr里提交了修改
![image.png](https://raw.gitcode.com/user-images/assets/7404318/60dd1693-95fa-4223-8dad-ae49b8859f39/image.png 'image.png')

# 【接口变更】
不涉及

# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/0a4e67a2-cf62-4ec5-91cd-1a07baa538bc/image.png 'image.png')
![image.png](https://raw.gitcode.com/user-images/assets/7404318/1671df01-e2be-4c5f-8feb-24ebca2da49f/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!34035
2026-04-21 12:16:16 +08:00
zhaoyu65 2807964f7c add dcmiv interface: dcmiv2_get_affinity_cpu_info_by_dev_id
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!33985 merge v2.10.0-26.0.0-dcmiv2 into v2.10.0-26.0.0

add dcmiv interface: dcmiv2_get_affinity_cpu_info_by_dev_id

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
1、适配HDK新增的dcmiv2_get_affinity_cpu_info_by_dev_id接口(dcmiv2_get_affinity_cpu_info_by_device_id的新版本);
2、优化了之前代码中,重复执行GET_FUNC的问题;

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证OK

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33985
2026-04-20 19:22:19 +08:00
pta-robot 17b3e1dfff Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!34018 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-20 16:08:31.

See merge request: Ascend/pytorch!34018
2026-04-20 17:47:39 +08:00
ascend-robot 2798d1d260 fix SIGSEGV in HeartbeatMonitor due to thread-unsafe getenv/setenv race
Co-authored-by: dinghongzou<zoudinghong3@huawei.com>



# message auto-generated for no-merge-commit merge:
!33819 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix SIGSEGV in  HeartbeatMonitor due to thread-unsafe getenv/setenv race

Created-by: Windwindzzz
Commit-by: dinghongzou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

初始化时读取并保存所有环境变量,get_env时直接从该文件中读取
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

已验证飞行日志dump功能正常
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33819
2026-04-20 17:32:26 +08:00
pta-robot a037a51b31 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33946 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-17 21:02:06.

See merge request: Ascend/pytorch!33946
2026-04-17 23:55:02 +08:00
ascend-robot b2ed6ae5bc Fixbug: ErrCode and pta_error were not imported correctly.
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!33935 merge cherry-pick-mr-33934-1776416011415-auto into v2.10.0-26.0.0

Fixbug: ErrCode and pta_error were not imported correctly.

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
问题:
1)torch_npu/utils/__init__.py 中使用到了ErrCode,但是没有正确导入
2)报错类型应该用pta_error,而不是prof_error
方案:
1)添加from torch_npu.utils._error_code import ErrCode, pta_error
2)将prof_error改为pta_error

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33935
2026-04-17 21:26:04 +08:00
ascend-robot ae2e41880b Deleted error code
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!33139 merge cherry-pick-mr-33137-1775210020620-auto into v2.10.0-26.0.0

Deleted error code

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
如果环境中cann没有正确配置, from torch_npu.utils._error_code import ErrCode, pta_error 的时候就会报错,导致后续的错误信息不能正常打印

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33139
2026-04-17 18:33:46 +08:00
HandsoemLemon 07a900bcd4 Remove the ATen operator whose participation in fusion under MLIR mode results in performance degradation
Co-authored-by: zhangafei<zhangafei@huawei.com>



# message auto-generated for no-merge-commit merge:
!33891 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Remove the ATen operator whose participation in fusion under MLIR mode results in performance degradation

Created-by: HandsoemLemon
Commit-by: zhangafei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
在运行图模式mlir后端时 aten.cat, aten.slice_scatter, aten.constant_pad_nd, aten.split, aten.split_with_sizes 参与Inductor IR lowering会导致算子性能或算子编译时间严重劣化,将其从白名单中删除,禁止其参与融合。

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33891
2026-04-17 17:21:58 +08:00
pta-robot 5e55982fd6 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33885 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-16 21:02:08.

See merge request: Ascend/pytorch!33885
2026-04-16 22:00:48 +08:00
LiNuohang 3685e9b194 [sync] PR-33676: 【fix】ut of _host_emptyCache patch
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!33710 merge sync-pr33676-ec-26-7-to-v2.10.0-26.0.0 into v2.10.0-26.0.0

[sync] PR-33676: 【fix】ut of _host_emptyCache patch

Created-by: ascend-robot
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: 
### 1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/33676

### 2. Original pull request related issue(s):

### 3. Original pull request related commit(s):
| Sha | Datetime | Message |
|---|---|---|
|[6be10308](https://gitcode.com/Ascend/pytorch/commit/6be103088ea20c4bf09862713dcf9ec3fd0dd51c)|2026-04-14 14:51:42 +0800 CST|[fix] ut of _host_emptyCache patch<br>|


See merge request: Ascend/pytorch!33710
2026-04-15 17:19:46 +08:00
pta-robot df984bfcae Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33769 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-15 14:29:09.

See merge request: Ascend/pytorch!33769
2026-04-15 17:13:57 +08:00
pta-robot f8b6489a9c Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33636 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-13 22:02:03.

See merge request: Ascend/pytorch!33636
2026-04-15 08:49:34 +08:00
pta-robot a3c8552f09 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33742 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-14 21:05:06.

See merge request: Ascend/pytorch!33742
2026-04-14 21:50:56 +08:00
luochao60 de1a78510a fix: fix from blob bug
Co-authored-by: luochao60<luochao60@huawei.com>



# message auto-generated for no-merge-commit merge:
!33195 merge pta_fix_from_blob_20260212_v2.10.0-26.0.0 into v2.10.0-26.0.0

fix: fix from blob bug

Created-by: luochao60
Commit-by: luochao60
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1. 修复 `torch_npu/csrc/aten/common/from_blob.cpp` 中 `TensorMaker::computeStorageSize()` 计算 storage size 时对 `storage_offset_` 的处理 bug:原代码将 `storage_offset_`(按元素数计)直接累加到字节大小上,缺少 `* itemsize`,导致非 float32 类型或带偏移的 tensor 计算出的 storage size 偏小,from_blob 创建的 tensor storage 不足。修复后两处分支均改为 `storage_size += storage_offset_.value() * itemsize;`。

2. 修复 `torch_npu/csrc/npu/Module.cpp` 中 `_weak_ref_tensor` 实现:原实现通过 `t.data_ptr()` + `t.sizes()` + `t.strides()` 调用 `from_blob` 构造新 tensor,丢失了原 tensor 的 `storage_offset` 信息,且当原 tensor 是 view(带 offset 或非平凡 stride)时,新 tensor 的 storage 会被错误地按视图形状重新计算,与原 storage 不一致。修复方式:基于原 tensor 的完整 `storage().mutable_data()` 与 `storage().nbytes() / element_size()` 调用 `from_blob` 构造新 tensor(覆盖完整 storage),随后通过 `set_sizes_and_strides` 与 `set_storage_offset` 还原原 tensor 的视图信息,确保弱引用 tensor 的 storage、sizes、strides、offset 与原 tensor 完全一致。

3. 测试用例重构与新增:
   - 将原本散落在 `test/cpp_extensions/extension.cpp` 中的 from_blob 相关测试(`check_from_blob`/`check_from_blob_strides`/`check_from_blob_delete`)迁移到独立的 `test/cpp_extensions/test_from_blob.cpp`,按 `at_npu::native::from_blob` 接口能力分门别类组织。
   - `test/cpp_extensions/setup.py` 注册新的扩展模块 `torch_test_cpp_extension.npu_from_blob`。
   - `test/cpp_extensions/test/test_cpp_extensions_aot.py` 新增 `TestFromBlob` 测试类,覆盖 basic / deleter / strides / storage_offset / storage_offset_2d / storage_offset_dtype / storage_offset_contiguous / non_owning / clone 等场景;`test_storage_sizes` 增加 `@SupportedDevices(['Ascend910B', 'Ascend910C'])` 限制。
   - `test/npu/test_npu_format.py` 新增 `test_weak_ref_tensor_with_storage_offset` 用例,构造带非平凡 stride 与 storage_offset 的 view,验证 `_weak_ref_tensor` 返回的 tensor 在 size、stride、storage_offset、storage().nbytes() 与数值上都与原 tensor 一致。

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

不涉及

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

不涉及

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

1. C++ 扩展用例 `test/cpp_extensions/test/test_cpp_extensions_aot.py::TestFromBlob`:覆盖 `at_npu::native::from_blob` 在 basic、自定义 deleter、显式 strides、带 storage_offset、二维带 offset、不同 dtype、contiguous 标志、non-owning 语义、clone 后数据正确性等场景,验证修复后 storage 计算正确。
2. Python 用例 `test/npu/test_npu_format.py::TestNPUFormat::test_weak_ref_tensor_with_storage_offset`:构造 `view_shape=[2,1,8,64]`、`view_strides=[1536,0,192,1]`、`view_offset=128` 的 strided view,验证 `_weak_ref_tensor` 保持 size/stride/offset/storage 字节数一致且数值相等。
3. UT 已随 PR 一同提交,本地自验证通过。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33195
2026-04-14 17:43:48 +08:00
pta-robot 65fdea5228 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33626 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-13 21:02:06.

See merge request: Ascend/pytorch!33626
2026-04-13 21:49:43 +08:00
pta-robot 2570dfcc82 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33597 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-13 16:03:44.

See merge request: Ascend/pytorch!33597
2026-04-13 18:27:00 +08:00
pta-robot 1176f25c4a Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33579 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-13 15:56:09.

See merge request: Ascend/pytorch!33579
2026-04-13 17:20:28 +08:00
zhangguoguang a675017ef5 fixing review comments on v2.10.0-26.0.0
Co-authored-by: zhangguoguang<zhangguoguang2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32779 merge fix_review_210-260 into v2.10.0-26.0.0

fixing review comments on v2.10.0-26.0.0

Created-by: zhangguoguang
Commit-by: zhangguoguang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
增加代码可读性和完整性

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8fcf51a4-ef98-4bbe-a952-1c41fb9c97f2/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32779
2026-04-13 17:14:18 +08:00
yule100 39b9d521e2 【fix】transfer_to_npu adapt pg_nccl
Co-authored-by: yule100<chenyukun11@h-partners.com>



# message auto-generated for no-merge-commit merge:
!33561 merge cherry-pick-mr-33390-1776047037880-auto into v2.10.0-26.0.0

【fix】transfer_to_npu adapt pg_nccl

Created-by: yule100
Commit-by: yule100
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

  在transfer_to_npu.py将ProcessGroupNCCL替换成ProcessGroupHCCL

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

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

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

已新增测试用例 门禁已过
本地验证issue场景:pass
![image.png](https://raw.gitcode.com/user-images/assets/7404318/0d8f9bc4-6fcc-42b8-a3ad-a0fcffc934aa/image.png 'image.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33561
2026-04-13 15:43:22 +08:00
pta-robot 0cfa028a89 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33516 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-10 17:07:37.

See merge request: Ascend/pytorch!33516
2026-04-13 10:13:20 +08:00
LiNuohang 181648703f [fix] patch torch._C._host_emptyCache
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!33326 merge ec-26-10 into v2.10.0-26.0.0

[fix] patch torch._C._host_emptyCache

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
npu支持torch._C._host_emptyCache,patch成torch_npu._C._npu_hostEmptyCache

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33326
2026-04-11 14:27:50 +08:00
yu_liangbin 92a64451c4 [torch_2.10.0_26.0.0]修复profiler解析完成标志报错问题
Co-authored-by: yuliangbin<y1416490440@163.com>



# message auto-generated for no-merge-commit merge:
!33298 merge fix_export_2.10.0_26.0.0 into v2.10.0-26.0.0

[torch_2.10.0_26.0.0]修复profiler解析完成标志报错问题

Created-by: yu_liangbin
Commit-by: yuliangbin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
	[Bug]: 修复profiler解析完成标志报错问题
- [ ] 重构优化
- [ ] 资料更新

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

一、问题原因:
profiler有4种导出方式:tensorboard_trace_handler、export_chrome_trace、export_stack、export_memory_timeline,其中后三者传入路径为json文件,生成解析完成标志的动作在4中导出方式中都会调用,而该动作会在指定路径下生成一个analyse.done文件,但是后3种导出方式中指定路径为文件,在创建文件的时候会报错。

二、问题解决:
只有在tensorboard_trace_handler导出方式中才进行解析完成标志的动作。

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

不涉及

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

不涉及

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

修改前日志截图:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/005994ee-80b9-4240-b849-231dd219d7bc/image.png 'image.png')
会报创建不了json文件ERROR
修改后日志截图:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/bcf5256e-6924-449d-8002-bde46a60a3d8/image.png 'image.png')
无创建不了json文件ERROR
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33298
2026-04-11 11:30:32 +08:00
pta-robot c58362475e Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33533 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-10 21:02:06.

See merge request: Ascend/pytorch!33533
2026-04-10 23:43:04 +08:00
louyujing 2ee171c3a7 [bugfix]Dealing with the issue of torch.cuda.amp.autocast_mode patch failure
Co-authored-by: l30044004<louyujing@huawei.com>



# message auto-generated for no-merge-commit merge:
!33332 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[bugfix]Dealing with the issue of torch.cuda.amp.autocast_mode patch failure

Created-by: louyujing
Commit-by: l30044004
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1. torch.cuda.amp.autocast_mode接口patch失效,导致现存ut用例失败,需要重新patch
2. 与transfer_to_npu无关的若干线上ut失败,先进行屏蔽处理,已提单给责任人处理

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33332
2026-04-10 17:05:59 +08:00
Lu_G 3c6e2b5789 【fix】 env control acc-check during tune
Co-authored-by: Lu_G<luguang6@huawei.com>



# message auto-generated for no-merge-commit merge:
!32832 merge acc_check_during_tune_v2.10-26 into v2.10.0-26.0.0

【fix】 env control acc-check during tune

Created-by: Lu_G
Commit-by: Lu_G
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
> 为mlir图模式后端增加特性:已知不同配置的mlir算子存在精度问题,修改了mlir在对融合算子最优配置的选择逻辑,修改后会在精度ok的范围内选择最快的配置作为best-kernel,如果所有配置的融合算子精度都不ok会fallback
同时,考虑到大模型场景如果在运行时进行精度校验存在爆显存风险,增加一个环境变量对该特性进行控制
修复动态shape下精度校验失败的bug
为“所有mlir算子精度校验均不通过”的场景添加报错日志

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32832
2026-04-10 14:10:59 +08:00
pta-robot 742bbbbf9a Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33460 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-09 22:02:05.

See merge request: Ascend/pytorch!33460
2026-04-10 10:09:38 +08:00
ascend-robot 6822f1bdef fix coredump in ~ProcessGroupHCCL
Co-authored-by: dinghongzou<zoudinghong3@huawei.com>



# message auto-generated for no-merge-commit merge:
!33097 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix coredump in ~ProcessGroupHCCL

Created-by: Windwindzzz
Commit-by: dinghongzou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

ProcessGroupHCCL不调用shutdown中的流同步操作,退回0302的析构函数实现
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

![image.png](https://raw.gitcode.com/user-images/assets/7404318/19e52cf9-ce84-4b88-82d7-cff0ce686098/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33097
2026-04-10 10:06:16 +08:00
LucciC 4eebc1255b Revert "[fix] keep npu tensor strides for empty_like"
Co-authored-by: LucciC<cuiliangcheng2@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!33423 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Revert "[fix] keep npu tensor strides for empty_like"

Created-by: LucciC
Commit-by: LucciC
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33423
2026-04-10 08:57:02 +08:00
LucciC dfcdb2ee4e Revert "[fix] tensor.clone support uncontiguous tensor"
Co-authored-by: LucciC<cuiliangcheng2@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!33418 merge revert-tensor-clone-v2.10.0 into v2.10.0-26.0.0

Revert "[fix] tensor.clone support uncontiguous tensor"

Created-by: LucciC
Commit-by: LucciC
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33418
2026-04-10 08:55:49 +08:00
pta-robot 2985d687e7 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33450 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-09 21:02:12.

See merge request: Ascend/pytorch!33450
2026-04-09 22:07:07 +08:00
hulida 1c9af4f876 [refactor] 初始化external_event malloc内存
Co-authored-by: hulida<hulida@huawei.com>



# message auto-generated for no-merge-commit merge:
!33133 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[refactor] 初始化external_event malloc内存

Created-by: hulida
Commit-by: hulida
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

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

externel_event的malloc从record改成创建externel_event时malloc,并且使用memset初始化malloc内存;当裸aclgraph开启auto_dispatch_capture=True时,也会在capture阶段创建externel_event,从而触发memset报错,所以用aclmdlRICaptureThreadExchangeMode切换捕获模式,memset之后再切回来

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33133
2026-04-09 20:34:28 +08:00
Dring c507aef066 [doc][v2.10.0-26.0.0]modify doc date
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!33380 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[doc][v2.10.0-26.0.0]modify doc date

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [✓ ] 资料更新

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

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
修改中英文README文档,将PyTorch 2.9.0版本的“发布时间”从2025/10/15调整为2026/01/15,并将“预计进入维护状态的日期”相应从2026/03/15调整为2026/07/15

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33380
2026-04-09 19:43:27 +08:00
pta-robot 663b69a71e Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33360 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-09 10:01:31.

See merge request: Ascend/pytorch!33360
2026-04-09 10:45:53 +08:00
weixin_47897441 730aba7d4b fix(hccl): rename HCCL_COMM_HCCL_QOS_CONFIG_NOT_SET to HCCL_COMM_QOS_CONFIG_NOT_SET
Co-authored-by: weixin_47897441<wuyouqi1@h-partners.com>



# message auto-generated for no-merge-commit merge:
!33138 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix(hccl): rename HCCL_COMM_HCCL_QOS_CONFIG_NOT_SET to HCCL_COMM_QOS_CONFIG_NOT_SET

Created-by: weixin_47897441
Commit-by: weixin_47897441
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

- Rename constant HCCL_COMM_HCCL_QOS_CONFIG_NOT_SET to HCCL_COMM_QOS_CONFIG_NOT_SET
- Remove redundant HCCL prefix for consistency with other config constants

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

不涉及

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

不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33138
2026-04-09 09:22:17 +08:00
pta-robot 7196e99280 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33322 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-08 16:02:30.

See merge request: Ascend/pytorch!33322
2026-04-08 21:56:44 +08:00
kkjocker 21545acd88 [Inductor] fix kernel driver with newest triton-ascend
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!33287 merge v2.10.0_26 into v2.10.0-26.0.0

[Inductor] fix kernel driver with newest triton-ascend

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
[Inductor] fix kernel driver with newest triton-ascend
# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33287
2026-04-08 19:13:47 +08:00
SCh_zx 6596bb2c9e fix storage when aclgraph need an empty allocater
Co-authored-by: SCh_zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!33121 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix storage when aclgraph need an empty allocater

Created-by: SCh_zx
Commit-by: SCh_zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33121
2026-04-08 17:36:40 +08:00
cuiduo 0835bfb73f [fix]tiling_expr
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!33219 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[fix]tiling_expr

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 1.修复tiling逻辑中的在处理axis_dtype过程中出现的报错,原有的处理逻辑将expr类当做symbol类处理,对其进行修改,取出其中的symbol进行校验
```
File "/home/cuiduo/miniconda3/envs/py311/lib/python3.11/site-packages/torch_npu/_inductor/codegen/scheduling.py", line 670, in decide_cod
ims_in_kernel
split_tiling.select_no_loop_axis()
File "/home/cuiduo/miniconda3/envs/py311/lib/python3.11/site-packages/torch_npu/_inductor/codegen/split_tiling.py", line 209, in select_n
axis
axis_dtype = self.kernel.get_axis_dtype(self.kernel.split_axis[0])

File "/home/cuiduo/miniconda3/envs/py311/lib/python3.11/site-packages/torch_npu/_inductor/codegen/triton.py", line 790, in get_axis_dtype
dim = self.range_tree_nodes_removed[key]

torch. dynamo. exc. BackendCompilerFailed: backend='inductor' raised:
KeyError: x2 + 512*y1 + 2048*z0
```

>2.修改storge文件,增加faketensor的处理逻辑,确保其逻辑与GPU一致
# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 本地验证通过

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33219
2026-04-08 16:53:33 +08:00
pta-robot 08870f973c Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33266 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-07 22:18:18.

See merge request: Ascend/pytorch!33266
2026-04-08 11:24:10 +08:00
pta-robot 3e8ad315c7 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33175 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-07 10:03:28.

See merge request: Ascend/pytorch!33175
2026-04-07 21:48:10 +08:00
limuan 4f01ef4aec Apply backend patch from testing.__init__ to test_schedule
Co-authored-by: limuan<liyijie16@huawei.com>



# message auto-generated for no-merge-commit merge:
!33212 merge dts_lyj/v2.10.0-26.0.0 into v2.10.0-26.0.0

Apply backend patch from testing.__init__ to test_schedule

Created-by: limuan
Commit-by: limuan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】


- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、import torch_npu.testing 引入 fake backend 的patch

# 【资料变更】

不涉及

# 【接口变更】

不涉及

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8aac0034-224e-4b39-97b4-0506d85c249d/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33212
2026-04-07 20:52:48 +08:00
HandsoemLemon 3a40fd8221 fix mlir dynamic launch args error
Co-authored-by: zhangafei<zhangafei@huawei.com>



# message auto-generated for no-merge-commit merge:
!33216 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix mlir dynamic launch args error

Created-by: HandsoemLemon
Commit-by: zhangafei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
运行mlir的动态shape模式时,出现torch.Size对象与tuple拼接时,出现类型报错。修改方式直接显式的进行类型转换,避免隐式转换出现的类型错误

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33216
2026-04-07 20:05:37 +08:00
limuan 3eedcf4e27 ADD NCCL with HCCL in allgather_base backward
Co-authored-by: limuan<liyijie16@huawei.com>



# message auto-generated for no-merge-commit merge:
!32994 merge issue_lyj/v2.10.0 into v2.10.0-26.0.0

ADD NCCL with HCCL in allgather_base backward

Created-by: limuan
Commit-by: limuan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】


- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
运行torch社区用例,test/distributed/test_c10d_wpawn_nccl.py -v -k test_all_gather_base 报Backend not supported!错误,
原因:allgather base 的backward中if dist.get_backend(group=ctx.group) is dist.Backend.NCCL: 为false 则直接raise RuntimeError("Backend not supported!")
修改:在torch_npu的init中 对allgather base的backward函数进行替换
if dist.get_backend(group=ctx.group) is dist.Backend.NCCL:  改为 if dist.get_backend(group=ctx.group) in (dist.Backend.NCCL, dist.Backend.HCCL): 其他不变

# 【资料变更】
不涉及
# 【接口变更】
不涉及
# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
![image.png](https://raw.gitcode.com/user-images/assets/7404318/935b1769-e9a7-4b29-8309-8e1b6c362acb/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32994
2026-04-07 16:18:36 +08:00
liwei386 7deab3a5e4 revert removing the libhccl dependency
Co-authored-by: liwei386<liwei386@huawei.com>



# message auto-generated for no-merge-commit merge:
!33067 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

revert removing the libhccl dependency

Created-by: liwei386
Commit-by: liwei386
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [X] 重构优化
- [ ] 资料更新

# 【修改方案】
> 恢复对libhccl的依赖,解决上层应用通过libtorch_npu.so间接依赖libhccl.so时引入的兼容性问题,如
liba.so -> libtorch_npu.so -> libhccl.so
删除libtorch_npu.so对libhccl.so的依赖,会导致liba.so找不到libhccl.so中的符号

# 【资料变更】
> “不涉及”

# 【接口变更】
> “不涉及”

# 【功能验证】
>依赖关系恢复
![1775141588982.png](https://raw.gitcode.com/user-images/assets/7404318/41c2fd27-7824-4e23-a381-075ba664cc1f/1775141588982.png '1775141588982.png')

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

- [X] 代码注释完备,正确记录错误日志
- [X] 代码实现进行了返回值、空指针等校验
- [X] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [X] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33067
2026-04-07 11:26:33 +08:00
luochao60 680435630e fix: fix task queue aclgraph bug
Co-authored-by: luochao60<luochao60@huawei.com>



# message auto-generated for no-merge-commit merge:
!32811 merge Pynative_fix_task_queue_aclgraph_bug_add_wait_stream_status_20260327_v2.10.0-26.0.0 into v2.10.0-26.0.0

fix: fix task queue aclgraph bug

Created-by: luochao60
Commit-by: luochao60
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接
for i, out in enumerate(current_node.cached_tensor_outputs):
    if out is not None:
        cnt = torch_npu._C._storage_Use_Count(out.untyped_storage()._weak_ref())
        if cnt > 1:
            print(f"[ALIVE] output[{i}] storage_count={cnt} grad_fn={out.grad_fn}")
- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. **NPUCachingAllocator.h/cpp**:新增 `hasCapturesUnderway(device)` 接口,用于查询当前设备是否有正在进行的 ACLGraph capture。在 `DeviceCachingAllocator` 中加锁读取 `captures_underway` 容器是否为空;在 `NpuCachingAllocator` 顶层类中实现 override 并转发到对应 device allocator;在头文件中新增 inline 辅助函数 `hasCapturesUnderway(device)` 供外部调用。
2. **NPUEvent.cpp**:在 `NPUEvent::block()` 函数中,`LaunchWaitEventTask` 之后增加判断:若当前设备处于 ACLGraph capture 状态(`hasCapturesUnderway` 返回 true),则调用 `emptyAllNPUStream()` 刷新 task queue。修复了多流场景下(主流与旁路流通过 wait_stream 交互时)capture replay 结果不正确的问题。
3. **test/npu/test_aclgraph_multi_stream.py**:新增多流 ACLGraph 正确性测试,覆盖两种场景:shared-expert 旁路流 fork/join 模式、并行分支 fork/join 模式,验证 replay 后数值结果与 eager 模式一致。

# 【资料变更】
不涉及

# 【接口变更】
新增内部接口 `NPUCachingAllocator::hasCapturesUnderway(c10::DeviceIndex device)`,为 NPU allocator 虚函数扩展,不属于对外客户面 API,不涉及跨仓接口变更。

# 【功能验证】
新增测试文件 `test/npu/test_aclgraph_multi_stream.py`,包含以下用例:
- `test_shared_expert_stream_capture_replay`:验证 shared-expert 旁路流模式下 capture/replay 数值正确性
- `test_parallel_branch_capture_replay`:验证并行分支 fork-join 模式下 capture/replay 数值正确性

# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!32811
2026-04-07 10:22:44 +08:00
senzhen-town a8761cda69 修复测试用例使用fake后端但是不支持npu
Co-authored-by: senzhen-town<zhangsenzhen1@huawei.com>



# message auto-generated for no-merge-commit merge:
!33085 merge issue_76_fake_backend_support_npu_v2.10.0-26.0.0 into v2.10.0-26.0.0

修复测试用例使用fake后端但是不支持npu

Created-by: senzhen-town
Commit-by: senzhen-town
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
只针对fake后端添加NPU支持

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证使用'fake'后端的社区原生测试用例通过
![a8d55912-f77f-4bb9-8ada-33ffd0fc8cb4.png](https://raw.gitcode.com/user-images/assets/7404318/092a8217-5c8e-4193-859b-eb5211183852/a8d55912-f77f-4bb9-8ada-33ffd0fc8cb4.png 'a8d55912-f77f-4bb9-8ada-33ffd0fc8cb4.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33085
2026-04-07 10:21:59 +08:00
LucciC 2187245455 acl.h move acl.h content to acl_rt.h for namespace confilict
Co-authored-by: LucciC<cuiliangcheng2@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!33091 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

acl.h move acl.h content to acl_rt.h for namespace confilict

Created-by: LucciC
Commit-by: LucciC
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33091
2026-04-05 12:59:40 +08:00
pta-robot 1290805295 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33158 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-03 21:02:01.

See merge request: Ascend/pytorch!33158
2026-04-05 10:49:22 +08:00
Dring 048efeeeed [v2.10.0-26.0.0][bugfix]GetDeviceInfo do not support A5
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!32973 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[v2.10.0-26.0.0][bugfix]GetDeviceInfo do not support A5

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
暂时规避A5调用GetDeviceInfo接口,使用以前的GetMenInfo接口
报错:
[ERROR] - initDeviceProperty:../torch_npu/csrc/npu/Module.cpp:207 NPU function error: aclrtGetDeviceInfo(static_cast<uint32_t>(deviceid), ACL_DEV_ATTR_TOTAL_GLOBAL_MEM_SIZE, &tmp_d total), error code is 507899
[ERROR] 2026-04-01-18:09:19 (PID:7228, Device:1, RankID:-1) ERR00100 PTA call acl api failed

[Error]: An internal error occurs in the Driver module.
Rectify the fault based on the error information in the ascend log.
EE9999: Inner Error!
EE9999[PID: 7228] 2026-04-01-18:09:19.810.555 (EE9999): rtsDeviceGetInfo execution failed, reason=driver error:internal error[FUNC:FuncErrorReason][FILE:error_message_manage.cc][L 5]
TraceBack (most recent call last):
call rtsDeviceGetInfo failed, runtime result = 507899.[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:148]

plog首报错:
[ERROR] RUNTIME(16038,python3.10):2026-04-02-11:39:56.553.432 [npu_driver_mem.cc:1754]16038 MemGetInfo:[drv api] halMemGetInfo failed: device_id=0, drvRetCode=62!
[ERROR] RUNTIME(16038,python3.10):2026-04-02-11:39:56.553.441 [api_c_standard_soc.cc:540]16038 rtsDeviceGetInfo:ErrCode=507899, desc=[driver error:internal error], InnerCode=0x7020010
[ERROR] RUNTIME(16038,python3.10):2026-04-02-11:39:56.553.446 [error_message_manage.cc:65]16038 FuncErrorReason:rtsDeviceGetInfo execution failed, reason=driver 
error:internal error

原因:
drv在A2和A5行为不一致需要rts后续修复

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32973
2026-04-03 20:45:10 +08:00
LiNuohang 9cea7a3dc0 [fix] tensor.clone support uncontiguous tensor
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!33084 merge cl-26-10 into v2.10.0-26.0.0

[fix] tensor.clone support uncontiguous tensor

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
clone对齐原生行为,默认保持原格式。而不是只创建连续tensor。

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

# 【接口变更】
tensor.clone对非连续tensor,输出从连续更改为非连续

# 【功能验证】
对非连续tensor clone后输出仍然为非连续tensor
pytorch/test/test_maskedtensor.py::test_contiguous
PASS

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33084
2026-04-03 17:40:03 +08:00
zhaoyu65 1ecbc9f3eb torch_npu not support affinity cpu format a-b,c-d when set npu_affine:1
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!33047 merge v2.10.0-26.0.0-affinity into v2.10.0-26.0.0

torch_npu not support affinity cpu format a-b,c-d when set npu_affine:1

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

A5标卡,torch_npu.utils.set_thread_affinity()报错RuntimeError:affinity cpu 0-63,128-91 is error。

# 【修改方案】
修改为记录warning基本plog日志,表示torch_npu不支持同一个NPU亲和CPU多个分段

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证通过

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!33047
2026-04-03 17:14:16 +08:00
pta-robot 46e1534b16 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33037 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-02 22:02:14.

See merge request: Ascend/pytorch!33037
2026-04-03 14:53:33 +08:00
zhaoyu65 2e91ea6745 do not check error when check_uce_in_memory()
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!32939 merge v2.10.0-26.0.0-force-stop into v2.10.0-26.0.0

do not check error when check_uce_in_memory()

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单 
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

N秒故障快恢过程中,pta在执行check_uce_in_memory时,调用emptyCache,抛出FORCE_STOP导致快恢流程中断。
# 【修改方案】
增加need_check_error变量,根据emptyCache函数接收到的check_error值进行处理,对于check_error为False的场景不抛异常。
# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证通过。在2台910C双机环境上验证通过。N秒快恢测试用例正常执行。
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32939
2026-04-03 11:12:08 +08:00
nomiz c33d1b59d3 fix empty_like output contiguous tensor in copy h2d/d2h
Co-authored-by: nomiz<1606135114@qq.com>



# message auto-generated for no-merge-commit merge:
!32951 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix empty_like output contiguous tensor in copy h2d/d2h

Created-by: nomiz
Commit-by: nomiz
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

empty_like修改支持非连续输出后,h2d和d2h中调用empty_like时指定输出连续tensor,保证非连续输入场景下精度正确

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

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

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

验证非连续输入时,h2d和d2h之后结果同cpu一致
![image.png](https://raw.gitcode.com/user-images/assets/7404318/2e93b051-84b4-4926-8c87-afa606858e56/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32951
2026-04-03 10:22:57 +08:00
pta-robot dc9ae14f9f Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!33061 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-02 23:02:04.

See merge request: Ascend/pytorch!33061
2026-04-03 00:04:00 +08:00
pta-robot 28b5592b4f Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32911 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-04-01 21:03:23.

See merge request: Ascend/pytorch!32911
2026-04-02 22:35:31 +08:00
liwei386 8c44b95131 [refactor] remove needed of libhccl.so for _C.cpython.sogit
Co-authored-by: liwei386<liwei386@huawei.com>



# message auto-generated for no-merge-commit merge:
!32880 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[refactor] remove needed of libhccl.so for _C.cpython.sogit

Created-by: liwei386
Commit-by: liwei386
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
>  解决部分编译环境_C.cpython动态库对libhccl.so依赖问题

# 【资料变更】
>  不涉及

# 【接口变更】
>  不涉及

# 【功能验证】
> 未安装cann包场景,导入torch_npu时不报找不到libhccl.so错误
> ![1774948789413.png](https://raw.gitcode.com/user-images/assets/7404318/a40ea438-d424-4eab-8f94-ecfc93fa1aa1/1774948789413.png '1774948789413.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32880
2026-04-02 22:02:30 +08:00
yangch0324 747d940382 [fix][v2.10.0-26.0.0]fix OrderedSet scope and missing argument
Co-authored-by: y30062407<handsome0324@163.com>



# message auto-generated for no-merge-commit merge:
!32976 merge v2.10.0-26.0.0-reduse into v2.10.0-26.0.0

[fix][v2.10.0-26.0.0]fix OrderedSet scope and missing argument

Created-by: yangch0324
Commit-by: y30062407
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
问题单
- [ ] 需求
- [√] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改参考torch._inductor.compile_fx.py中cudagraphify_impl对align_inputs_from_check_idxs函数的调用传参。
![image.png](https://raw.gitcode.com/user-images/assets/7404318/91f71ebc-73ee-4637-a9dd-d430065521b4/image.png 'image.png')
由于pytorch/torch_npu/utils/_graph_tree.py 中npugraphify_impl函数对align_inputs_from_check_idxs函数的调用少参数mutated_input_idxs,报错:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e6f2d620-e46e-415b-8794-038d737f13b2/image.png 'image.png')
# 【资料变更】
不涉及
# 【接口变更】
不涉及
# 【功能验证】
修改后用例跑通,
![image.png](https://raw.gitcode.com/user-images/assets/7404318/09c16212-fef6-49a8-b99d-04b2610a19e4/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32976
2026-04-02 20:05:22 +08:00
SCh_zx 5034e00f58 fix torch.UntypedStorage with empty tensor on npu
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!32955 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

fix torch.UntypedStorage with empty tensor on npu

Created-by: SCh_zx
Commit-by: SCh-zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

在save/load的处理过程中,对于空tensor,会调用torch.UntypedStorage(self.size(), device=device)来创建storage,当device为cuda时,storage会正确保留cuda信息,但当device为npu时,storage则会将其保存为cpu。
![image.png](https://raw.gitcode.com/user-images/assets/7404318/3ef0ab87-be9b-4937-9c40-e046d0581068/image.png 'image.png')
原先allocate不能处理data_ptr和size同时为0的情况,现已修复。
修改storage中allocate的条件,使其能正确处理NPU上空tensor的情况。

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32955
2026-04-02 19:44:12 +08:00
qq_37868325 4223e7b616 [test]fix _test_alltoall_2p_size test_mgr.load
Co-authored-by: ACAES<liuyan7892@163.com>



# message auto-generated for no-merge-commit merge:
!32674 merge v2.10.0 into v2.10.0-26.0.0

[test]fix _test_alltoall_2p_size test_mgr.load

Created-by: AACAES
Commit-by: ACAES
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1. ci只提交分布式用例文件时,会被跳过导致ci跑不到,删除对应逻辑
2. https://gitcode.com/Ascend/pytorch/pull/31821
allow_internal_format默认值被改为False,_test_alltoall_2p_size 用例需手动设为True
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

本pr只修一个分布式用例,ci跑到了
![image.png](https://raw.gitcode.com/user-images/assets/7404318/f52c03d6-fc70-4ded-9ed8-9ed86a278c10/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32674
2026-04-02 19:15:00 +08:00
kkjocker 8826eda65a 【fix】fix A3 inductor flags bug
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!32866 merge v2.10.0_26 into v2.10.0-26.0.0

【fix】fix A3 inductor flags bug

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
gcc13识别不了A3机器的编译选项flagm,因此该patch把此处删除,其他版本已经合入
# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32866
2026-04-02 10:39:19 +08:00
pta-robot 5815a5673b Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32669 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-30 14:47:01.

See merge request: Ascend/pytorch!32669
2026-04-02 09:08:48 +08:00
ffmh aba73bd6be [v2.10.0-26.0.0][fix] fix shmem init by setting ACLSHMEMX_INIT_WITH_UNIQUEID
Co-authored-by: ffmh<fengminghao2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32750 merge cherry-pick-fix_shmemv2.10.0-26.0.0-9d370bd into v2.10.0-26.0.0

[v2.10.0-26.0.0][fix] fix shmem init by setting ACLSHMEMX_INIT_WITH_UNIQUEID

Created-by: ffmh
Commit-by: ffmh
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

shmem >= v1.0.1时报错:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/797b5dc5-1739-4c05-ba23-92f597000848/image.png 'image.png')

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

shmem uid流程,版本>=1.0.1时,初始化传入flag由 ACLSHMEMX_INIT_WITH_DEFAULT 改为 ACLSHMEMX_INIT_WITH_UNIQUEID

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

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

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

用例跑通无报错:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d552dbf9-e244-4815-a413-cadf16b6de3b/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32750
2026-04-01 20:36:23 +08:00
Dring d78d50b305 [v2.10.0-26.0.0][bugfix]fix undefined symbol aclrtGetDeviceInfo with dlopen
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!32760 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

[v2.10.0-26.0.0][bugfix]fix undefined symbol aclrtGetDeviceInfo with dlopen

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ✓] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
原本报错:
ImportError: /data/env_common/miniconda3/envs/py311_pt271/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so: undefined symbol: aclrtGetDeviceInfo
修改后:
![aclrtgetdeviceinfo.png](https://raw.gitcode.com/user-images/assets/7404318/ce272ba2-3359-4d64-bece-951e3c6c939f/aclrtgetdeviceinfo.png 'aclrtgetdeviceinfo.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32760
2026-04-01 11:23:55 +08:00
pta-robot 20199e391e Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32761 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-31 10:01:35.

See merge request: Ascend/pytorch!32761
2026-03-31 23:45:20 +08:00
kkjocker aa73dac55f 【inductor】fix static kernel bug
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!32688 merge v2.10.0_26 into v2.10.0-26.0.0

【inductor】fix static kernel bug

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
修复静态编译的缩进问题
# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32688
2026-03-31 21:28:11 +08:00
zhangguoguang 20beb0fec0 fix npu_fusion_attention_grad sharding strategy on v2.10.0-26.0.0
Co-authored-by: zhangguoguang<zhangguoguang2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32729 merge fix_fa_dtensor_210-260 into v2.10.0-26.0.0

fix npu_fusion_attention_grad sharding strategy on v2.10.0-26.0.0

Created-by: zhangguoguang
Commit-by: zhangguoguang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当pse为None时,反向计算pse的梯度也为None,不需要为其设置分片方式

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
问题单测试脚本执行结果:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/3fdb3aa8-c3a3-4839-a9e1-acb4ff33644e/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32729
2026-03-31 20:16:02 +08:00
sunyu-xuan fc65f3b6f0 add hccl exception msg and adjust status for CleanUponly Mode
Co-authored-by: sunyu-xuan<sunyuxuan4@huawei.com>



# message auto-generated for no-merge-commit merge:
!32701 merge bugfix/add_hccl_exception_msg_v2.10.0-26.0.0 into v2.10.0-26.0.0

add hccl exception msg and adjust status for CleanUponly Mode

Created-by: sunyu-xuan
Commit-by: sunyu-xuan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1.HCCL_ASYNC_ERROR_HANDLING=2(CleanUpOnly模式)下新增HCCL日志具体exception信息。
2.HCCL_ASYNC_ERROR_HANDLING=2(CleanUpOnly模式)下,根据实际exception记录work status 为start/end(原逻辑统一处理成end,与设计不符)

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

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

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

异常验证通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/3bcadff0-1fe5-4376-923d-52d33e465506/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32701
2026-03-31 19:42:33 +08:00
pta-robot eddc20d704 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32746 merge v2.10.0-26.0.0 into v2.10.0-26.0.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-30 21:02:58.

See merge request: Ascend/pytorch!32746
2026-03-30 23:14:22 +08:00
fft1374 69cc70d626 add branch = 26.0.0 for op-plugin and torchair submodules
Co-authored-by: fft1374<liwen120@huawei.com>



# message auto-generated for no-merge-commit merge:
!32707 merge 2100_2600_submodule into v2.10.0-26.0.0

add branch = 26.0.0 for op-plugin and torchair submodules

Created-by: fft1374
Commit-by: fft1374
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32707
2026-03-30 21:34:04 +08:00
ascend-robot 759c56eb9d test: add test for multiprocessing
Co-authored-by: HeYang<heyang88@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32045 merge v2.10.0 into v2.10.0

test: add test for multiprocessing

Created-by: VnOcean
Commit-by: HeYang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
[[Usage]: test 目录下 torch.multiprocessing 的 Array、get_start_method、set_start_method等测试用例缺失。](https://gitcode.com/Ascend/pytorch/issues/1584?ref=&did=3810729#tid-3810729)
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] issue/工单

# 【修改方案】
## 设计原则
该测试用例的设计遵循了三个核心原则:聚焦核心、贴合场景、轻量化。

## 核心思路
测试用例的核心思路围绕跨进程数据共享与通信展开,通过五个典型场景验证多进程编程的正确性:

1. 共享内存模式测试Value和Array时,创建子进程对共享数据进行修改,主进程验证修改结果,直观展示了多进程间数据共享的基本原理——共享内存在不同进程地址空间中的可见性。

2. 管道通信模式测试Pipe时,构建了双向通信场景:子进程发送多种类型数据(字符串、整数、列表),父进程接收验证;随后测试请求-响应模式,验证了管道作为双向通信通道的可靠性。

3. 管理器模式测试展示了比共享内存更高级的抽象,通过Manager创建共享列表、字典和命名空间,子进程的修改自动同步到主进程,体现了管理器服务进程作为代理的同步机制。

4. 张量规约测试特别针对NPU场景,验证了PyTorch张量在多进程环境下的序列化与反序列化能力,确保深度学习模型中的张量数据可以跨进程高效传递。

5. 多进程编程的核心本质是在独立进程地址空间之间,通过序列化、共享内存或代理服务等方式,建立安全可靠的数据交换通道,同时保持进程的独立性和并发执行能力。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
用例验证结果:


```
python test_multiprocessing_api.py -v
test_array (\__main__.TestMultiprocessingAPIs.test_array)
Test Array API ... ok
test_get_set_start_method (__main__.TestMultiprocessingAPIs.test_get_set_start_method)
Test get_start_method and set_start_method APIs ... ok
test_manager (__main__.TestMultiprocessingAPIs.test_manager)
Test Manager API ... ok
test_pipe (__main__.TestMultiprocessingAPIs.test_pipe)
Test Pipe API ... ok
test_reductions (__main__.TestMultiprocessingAPIs.test_reductions)
Test reductions API ... ok
test_value (__main__.TestMultiprocessingAPIs.test_value)
Test Value API ... ok

----------------------------------------------------------------------
Ran 6 tests in 1.304s

OK
```

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32045
2026-03-30 09:19:02 +08:00
Nice_try 9ca0f50843 test(distributed): add test for FileStore,Store,TCPStore
Co-authored-by: Nice_try<nicetryzzw@163.com>
Co-authored-by: Nice_try<1849404617@qq.com>



# message auto-generated for no-merge-commit merge:
!31914 merge v2.10.0-apt into v2.10.0

test(distributed): add test for FileStore,Store,TCPStore

Created-by: Nice_try
Commit-by: Nice_try
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**[Usage: test目录下torch.distributed.FileStore,torch.distributed.Store, torch.distributed.TCPStore API的测试用例缺失](https://gitcode.com/Ascend/pytorch/issues/1580)**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

基于 “最小化、核心化、针对性” 原则,设计独立 NPU 测试用例,核心思路:
1.剥离无关耦合:仅使用 PyTorch 原生基础层(Linear、BatchNorm、Conv2d)构建测试对象,避免算子适配干扰;
2.聚焦核心功能:仅验证 API 基础能力,不涉及边缘场景与复杂计算,确保结果反映 API 本身适配状态;
3.贴合 NPU 特性:重点校验设备一致性、跨设备状态迁移等 NPU 核心关注点;
4.轻量化设计:单个方法验证一个核心功能点,逻辑清晰、执行高效。

在 NPU(npu:0)环境下,覆盖原生测试用例中没有直接测试用例的API,包括:
```python
torch.distributed.FileStore.path
torch.distributed.Store.__init__
torch.distributed.Store.add
torch.distributed.Store.timeout
torch.distributed.TCPStore.host
torch.distributed.TCPStore.port
```
根据设计原则将对应的自定义测试用例进行补充。

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
不涉及
# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
不涉及
# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

```bash
root@56991725ea5f:/workspace/test_store_api# python test_store_api_v2-10-0.py 
.....
----------------------------------------------------------------------
Ran 5 tests in 0.327s

OK
```
![image.png](https://raw.gitcode.com/user-images/assets/7404318/342904b3-a0c2-4a51-9e75-108e742fcff2/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31914
2026-03-30 09:17:48 +08:00
pta-robot acc188d0e4 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32634 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-28 21:02:01.

See merge request: Ascend/pytorch!32634
2026-03-28 23:49:04 +08:00
zhukkk f0a99cf2fd [bugfix]自定义scope_begin/end修改为显式注册
Co-authored-by: zhukkk<zhuke11@huawei.com>



# message auto-generated for no-merge-commit merge:
!32606 merge v2.10.0 into v2.10.0

[bugfix]自定义scope_begin/end修改为显式注册

Created-by: zhukkk
Commit-by: zhukkk
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
通过lib def显式注册scope_begin\end的schema,避免通过custom_op注册schema存在的隐性错误

# 【资料变更】
不涉及
# 【接口变更】
不涉及
# 【功能验证】
不涉及接口内容变更,CI用例已通过
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32606
2026-03-28 20:52:29 +08:00
ascend-robot 13d8427f6b fix: add rethrow in ProcessGroupHCCL destructor to coredump on shutdown failure
Co-authored-by: dinghongzou<zoudinghong3@huawei.com>



# message auto-generated for no-merge-commit merge:
!32580 merge v2.10.0 into v2.10.0

fix: add rethrow in ProcessGroupHCCL destructor to coredump on shutdown failure

Created-by: Windwindzzz
Commit-by: dinghongzou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

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

在ProcessGroupHCCL的析构函数捕获异常并打印对应错误

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

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

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

库上现有用例可看护
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32580
2026-03-28 19:36:49 +08:00
zhangguoguang 02059ff3de add register sharding on v2.10.0
Co-authored-by: zhangguoguang<zhangguoguang2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32341 merge add_register_sharding/7th_210 into v2.10.0

add register sharding on v2.10.0

Created-by: zhangguoguang
Commit-by: zhangguoguang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
增加kl_div_loss正反向的分片策略

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证kl_div正反向
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e130337c-3390-46f1-a8e7-fd3c146a322f/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32341
2026-03-28 17:47:55 +08:00
pta-robot ee366e6e8a Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32613 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-28 16:02:02.

See merge request: Ascend/pytorch!32613
2026-03-28 17:07:10 +08:00
adelaideliu 85fcfa9844 [fix] reduce memory usage in alltoall via compatible mode
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!32511 merge v2.10.0_alltoall into v2.10.0

[fix] reduce memory usage in alltoall via compatible mode

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
alltoall算子的显存问题单

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改了兼容模式的输入变量处理,去掉了默认模式的flatten tensor从而降低显存,实现了显存对齐

# 【资料变更】
“不涉及”

# 【接口变更】
“不涉及”

# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/ed466ddc-15c1-4f9b-a4c6-3a3d87ed6fbb/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32511
2026-03-28 16:08:09 +08:00
pta-robot c2c78b0020 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32533 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-27 16:05:58.

See merge request: Ascend/pytorch!32533
2026-03-28 14:11:01 +08:00
kita-ikuyo 273e153eda [fix] fix call of UseStreamInCurrentThread in hccl process
Co-authored-by: Chukun Wang<wangchukun@huawei.com>



# message auto-generated for no-merge-commit merge:
!32240 merge v2.10.0 into v2.10.0

[fix] fix call of UseStreamInCurrentThread in hccl process

Created-by: kita-ikuyo
Commit-by: Chukun Wang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

问题背景:在使用旧版本cann包+主线pta时,因为is_enable_core_control判断有误,hccl算子中的useStreamRes总是被错误调用,导致获取不到接口报错。

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

修复is_enable_core_control的判断。

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

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

不涉及

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

验证hccl算子用例,在8.2的cann+主线代码的情况下,不带修改报错,带上修改可以正常运行。

不带修改:
![Untitled.jpg](https://raw.gitcode.com/user-images/assets/7404318/121e71e3-00b9-4498-b251-eece92e68146/Untitled.jpg 'Untitled.jpg')

带修改:
![ok.jpg](https://raw.gitcode.com/user-images/assets/7404318/42b7603b-d5a6-4402-81dd-84addaf76bfc/ok.jpg 'ok.jpg')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32240
2026-03-28 09:18:38 +08:00
LiNuohang 51eaa5cbae [fix] Revert "[fix] tensor clone api consistency"
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!32553 merge r-c-10 into v2.10.0

[fix]  Revert "[fix] tensor clone api consistency"

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
matmul冒烟精度失败,先回退对应commit

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32553
2026-03-28 09:13:38 +08:00
pta-robot 9525f88efc Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32560 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-27 21:02:06.

See merge request: Ascend/pytorch!32560
2026-03-27 21:58:32 +08:00
pta-robot ca37e539fd Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32527 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-27 15:47:33.

See merge request: Ascend/pytorch!32527
2026-03-27 18:11:11 +08:00
weixin_47897441 4a3351baed [fix]add torch_npu._C._npu_hasPrimaryContext
Co-authored-by: weixin_47897441<wuyouqi1@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32451 merge v2.10.0 into v2.10.0

[fix]add torch_npu._C._npu_hasPrimaryContext

Created-by: weixin_47897441
Commit-by: weixin_47897441
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
- [ ] 需求
- [ ] 问题单
- [x] issue/工单 社区issue需适配_npu_hasPrimaryContext
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、 新增hasPrimaryContext接口,用于查询指定设备的主上下文是否已激活,对齐CUDA能力,支持上下文状态感知的资源管理。
2、在ACL接口层封装aclrtGetPrimaryCtxState,C++层实现hasPrimaryContext函数,并通过Python扩展暴露_npu_hasPrimaryContext,同时注册到Dynamo跟踪规则以支持图模式调用。

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
python test_cuda_primary_ctx.py -v -k test_copy 自验证通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/b33b6582-f6bc-4373-93c2-468d65fc1335/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32451
2026-03-27 17:34:40 +08:00
zyb_230 488ad3ccfc bugfix:step_trace_time计算时出现负数
Co-authored-by: xfeng<zchlcw663@163.com>



# message auto-generated for no-merge-commit merge:
!32437 merge v2.10.0 into v2.10.0

bugfix:step_trace_time计算时出现负数

Created-by: zyb_230
Commit-by: xfeng
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修复性能分析模块中计算“未重叠通信时间(排除接收时间)”字段时可能产生负值的问题。如果是负数,置0.,表示不具备参考性

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

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

# 【功能验证】
修复前是负数
修复后
![image.png](https://raw.gitcode.com/user-images/assets/7404318/42668438-2854-48a3-8a6f-01590f04422c/image.png 'image.png')
![image.png](https://raw.gitcode.com/user-images/assets/7404318/47bd5de8-d034-4950-b02c-8607b3aea1db/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32437
2026-03-27 16:36:10 +08:00
pta-robot 8bd0b753b8 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32491 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-27 10:12:29.

See merge request: Ascend/pytorch!32491
2026-03-27 16:02:17 +08:00
ascend-robot 36a2f423d9 fix(nn): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load
Co-authored-by: dinglaiping<1016581171@qq.com>



# message auto-generated for no-merge-commit merge:
!32400 merge fixtest-jit-api-2.10.0 into v2.10.0

fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load

Created-by: dinglaiping
Commit-by: dinglaiping
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1597**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] issue/工单

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

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()。


# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

整体结论:
本次验证基于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 场景下模型编译优化、序列化部署、跨设备迁移、推理执行的实际业务需求。
1.	torch.jit.script:官方用例中函数重复脚本化操作正常,脚本化模型的序列化 / 反序列化无数据丢失,NPU 设备下编译后模型的参数、设备属性与原模型保持一致,编译优化逻辑正常生效;
2.	torch.jit.trace:官方用例中追踪化过程可完整保留模型的 train/eval 状态,字典类型可正常作为示例输入完成追踪,NPU 设备下追踪化模型的前向传播执行正常,输出结果与原模型一致;
3.	torch.jit.save:官方用例中模型可成功保存至 zip 压缩包格式,保存过程中可完整保留 NPU 设备信息与模型全状态(参数、缓冲区、计算图),序列化过程无数据遗漏或损坏;
4.	torch.jit.load:官方用例中可成功还原模型保存时的 NPU 设备信息,模型中自定义方法可正常导入并调用,zip 压缩包格式的模型可正确解析,加载后模型可直接在 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】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!32400
2026-03-27 15:17:29 +08:00
pta-robot c828a49bac Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32485 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-27 10:01:25.

See merge request: Ascend/pytorch!32485
2026-03-27 10:53:45 +08:00
pta-robot 45959bf67c Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32405 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-26 10:01:32.

See merge request: Ascend/pytorch!32405
2026-03-26 22:28:21 +08:00
wanlinan 848f46fc90 [feat]asynchronous batch send/recv via coalescing_manager context manager
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!31729 merge v2.10.0_pg into v2.10.0

[feat]asynchronous batch send/recv via coalescing_manager context manager

Created-by: wanlinan
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改_batch_isend_irecv函数,通过调用_coalescing_manager上下文管理器,在调用op(send/recv)前后分别调用groupstart/groupend

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 验证新功能要求cann版本>=9.0.0,涉及用例test_batch_isend_irecv.py、test_avoid_record_stream.py
执行结果:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/9253b0d9-0a92-4b78-a533-9d9e559f0f80/image.png 'image.png')

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31729
2026-03-26 20:58:09 +08:00
pta-robot 48c377395a Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32430 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-26 15:46:33.

See merge request: Ascend/pytorch!32430
2026-03-26 20:04:50 +08:00
ascend-robot f200c71917 [fix] batch_isend_irecv oom
Co-authored-by: pengqi<pengqi33@huawei.com>



# message auto-generated for no-merge-commit merge:
!32361 merge v2.10.0 into v2.10.0

[fix] batch_isend_irecv oom

Created-by: pengqihw
Commit-by: pengqi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
问题根因:tensor做register_work后storage被register列表持有。原生work类的wait方法中做了unregister_work, WorkHCCL继承后override了此方法,但未加unregister,导致被持有的内存在wait时没有释放。
修改方案:在wait和synchronize方法中加上unregister_work

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
已由实际场景验证

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32361
2026-03-26 19:42:57 +08:00
MrMC- ce1bebeeb4 del 91095
Co-authored-by: MrMC-<shiqunze@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32413 merge 2.10-del into v2.10.0

del 91095

Created-by: MrMC-
Commit-by: MrMC-
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32413
2026-03-26 19:00:29 +08:00
jizewei 8ba9f9ff3e refactor fsdp patch and add torch_npu.distributed.fsdp.fully_shard
Co-authored-by: jizewei<jizewei@huawei.com>



# message auto-generated for no-merge-commit merge:
!32148 merge v2.10.0_fsdp_patch into v2.10.0

refactor fsdp patch and add torch_npu.distributed.fsdp.fully_shard

Created-by: jizewei
Commit-by: jizewei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

fsdp patch整理:
1. 基本功能类patch:保证FSDP2在npu可运行,始终替换
2. 性能增强类patch:提升FSDP2显存、性能,按需替换,将脚本中的`torch.distributed.fsdp.fully_shard`改为`torch_npu.distributed.fsdp.fully_shard`启用

新增`torch_npu.distributed.fsdp.fully_shard`接口,签名与原生接口一致:
1. 首次调用时,替换增强类patch
2. 透传参数调用原生`fully_shard`

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

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

新接口训练拉起正常
![image.png](https://raw.gitcode.com/user-images/assets/7404318/39ab1c30-98a3-4a9d-834f-94736ea7b1a8/image.png 'image.png')

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32148
2026-03-26 11:26:16 +08:00
huangyunlong2022 a8a20b5360 test update ut
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32257 merge 2.10ut into v2.10.0

test update ut

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

更新ut

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32257
2026-03-26 11:20:02 +08:00
adelaideliu d23118fbeb [fix] reduce memory usage in scatter/gather via compatible mode
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!32263 merge v2.10.0_promote_scatter into v2.10.0

[fix] reduce memory usage in scatter/gather via compatible mode

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
scatter,gather算子的性能问题单
- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改了兼容模式的输入变量处理,去掉了默认模式的flatten tensor从而降低显存,实现了显存对齐
# 【资料变更】
“不涉及”

# 【接口变更】
“不涉及”

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
已经通过问题单用例测试和显存,验证性能
api 执行命令 gpu结果 npu结果 NPU驱动占用总内存 NPU框架持有总内存 NPU最大激活内存 GPU驱动占用总内存 GPU框架持有总内存 GPU最大激活内存
torch.distributed.all_to_all python3 -m unittest test_all_to_all.py -v -k test_alltoall_2p_dist 0.41G 0.0019G 6.86e-05G 1.046G 0.0019G 0.0019G
torch.distributed.gather_new python3 -m unittest test_gather.py -v -k test_gather_dist 1.57G 1.11G 1.11G 2.36G 1.11G 1.11G
torch.distributed.gather python3 -m unittest test_gather.py -v -k test_gather_dist 2.27G/2.28G 1.86G 1.86G 2.36G 1.11G 1.11G
torch.distributed.scatter_new 2.83G 2.41G 2.41G 3.27G 2.41G 2.41G
torch.distributed.scatter python3 -m unittest test_scatter.py -v -k test_scatter 4.44G/4.43G 4.02G 4.02G 3.27G 2.41G 2.41G
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32263
2026-03-26 10:10:27 +08:00
MrMC- 4a31804dbc del 910_95
Co-authored-by: MrMC-<shiqunze@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30640 merge 2.10.0-del-91095 into v2.10.0

del 910_95

Created-by: MrMC-
Commit-by: MrMC-
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> A5改名需求

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
删除910_95

# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30640
2026-03-26 09:14:14 +08:00
pta-robot cd6baed2bb Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32330 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-24 23:01:38.

See merge request: Ascend/pytorch!32330
2026-03-26 00:02:00 +08:00
liangsongwei 5defd4ef00 [fix]add TORCH_NPU_API api
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!32306 merge cherry-pick-mr-32305-1774352441549-auto into v2.10.0

[fix]add TORCH_NPU_API api

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
apply_tensor_without_format接口对外

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
PR门禁pass

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32306
2026-03-25 15:42:22 +08:00
zqwenn 9886a2ddbb [fix] keep npu tensor strides for empty_like
Co-authored-by: zqwenn<zhangqiongwen@huawei.com>



# message auto-generated for no-merge-commit merge:
!31961 merge v2.10.0_empty_like_npu_fix_new into v2.10.0

[fix] keep npu tensor strides for empty_like

Created-by: zqwenn
Commit-by: zqwenn
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

新增empty_stride分支,和原生对齐
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

新增ut

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31961
2026-03-25 15:18:12 +08:00
chenweiheng 2ed861f4e3 [bugfix]fix rts invalid params
Co-authored-by: chenweiheng<chenweiheng1@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!32301 merge cherry-pick-mr-32278-1774350901233-auto into v2.10.0

[bugfix]fix rts invalid params

Created-by: chenweiheng
Commit-by: chenweiheng
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

- [ ] 问题单

# 【修改方案】
在C25以下的cann版本不调用此接口

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
用C25以下的CANN测试

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32301
2026-03-25 14:30:55 +08:00
ascend-robot f9e6c3c6c3 fix(nn): fix test for nn api: torch.nn.ParameterDict, torch.nn.ParameterList, torch.nn.Sequential
Co-authored-by: dinglaiping<1016581171@qq.com>



# message auto-generated for no-merge-commit merge:
!32059 merge fixtest-nn-api-2.10.0 into v2.10.0

fix(nn): fix test for nn api: torch.nn.ParameterDict, torch.nn.ParameterList, torch.nn.Sequential

Created-by: dinglaiping
Commit-by: dinglaiping
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1585**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] issue/工单

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

1.   2.6.0版本提示skipIfMps找不到,要换成skipIfMPS。
2.   2.7及以上版本skipIfMps找不到,换成skipIfMPS;new_module_tests找不到,需要把导入new_module_tests改成导入get_new_module_tests并在调用的地方换成get_new_module_tests();tf32_on_and_off找不到,删掉导入,并在调用tf32_is_not_fp32()的地方换成调用torch.cuda.is_tf32_supported()


# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

整体结论:
本次验证通过修复官网test_nn.py用例文件,验证3个API,功能正常:
ParameterDict:官方用例中键值对索引、新增、删除、遍历等操作均正常,容器内所有参数设备统一为npu:0,无设备漂移问题;
ParameterList:官方用例中数字索引、append新增、遍历等操作均正常,参数设备一致性与长度校验均通过,有序管理能力正常;
Sequential:官方用例中getitem/setitem/delitem/append/insert/extend/pop等所有核心操作均正常执行,操作后子模块设备均保持为npu:0,动态扩展与元素管理能力完整。


运行日志:
[root@hostname-fqv42 torchnpuapi]# docker exec -it test210 bash
root@hostname-fqv42:/home# cd /root/torchnpuapi
root@hostname-fqv42:~/torchnpuapi# python -m unittest test_nn_npu27.TestNN.test_ParameterList test_nn_npu27.TestNN.test_ParameterDict test_nn_npu27.TestNN.test_Sequential_getitem test_nn_npu27.TestNN.test_Sequential_setitem test_nn_npu27.TestNN.test_Sequential_delitem test_nn_npu27.TestNN.test_Sequential_append test_nn_npu27.TestNN.test_Sequential_insert test_nn_npu27.TestNN.test_Sequential_extend test_nn_npu27.TestNN.test_Sequential_pop -v
test_ParameterList (test_nn_npu27.TestNN.test_ParameterList) ... ok
test_ParameterDict (test_nn_npu27.TestNN.test_ParameterDict) ... ok
test_Sequential_getitem (test_nn_npu27.TestNN.test_Sequential_getitem) ... ok
test_Sequential_setitem (test_nn_npu27.TestNN.test_Sequential_setitem) ... ok
test_Sequential_delitem (test_nn_npu27.TestNN.test_Sequential_delitem) ... ok
test_Sequential_append (test_nn_npu27.TestNN.test_Sequential_append) ... ok
test_Sequential_insert (test_nn_npu27.TestNN.test_Sequential_insert) ... ok
test_Sequential_extend (test_nn_npu27.TestNN.test_Sequential_extend) ... ok
test_Sequential_pop (test_nn_npu27.TestNN.test_Sequential_pop) ... ok

----------------------------------------------------------------------
Ran 9 tests in 0.057s

OK
root@hostname-fqv42:~/torchnpuapi# 



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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!32059
2026-03-25 14:29:52 +08:00
pengjingyou 5cd23b3666 feat: add get_p2p_stream_id interface for HCCL backend
Co-authored-by: pengjingyou<pengjingyou@huawei.com>



# message auto-generated for no-merge-commit merge:
!32202 merge p2p_stream_v2.10.0 into v2.10.0

feat: add get_p2p_stream_id interface for HCCL backend

Created-by: pengjingyou
Commit-by: pengjingyou
Merged-by: ascend-robot
Description: 

<!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

为 HCCL 后端新增 get_p2p_stream_id 接口,用于获取 P2P 通信的 NPU stream ID,方便用户在分布式训练场景下进行 stream 级别的同步和管理。

# 【修改方案】

1. 新增 C++ 方法 getP2PStreamId
   在 ProcessGroupHCCL 类中新增 getP2PStreamId 方法,支持两种模式:

- 批量模式 (is_batched=1) :使用 getKeyFromDevices 生成 key,适用于 batch_isend_irecv 场景
- 非批量模式 (is_batched=0) :使用 getKeySendRecv 生成 key,适用于单独的 send/recv 场景

2. 新增 Python 绑定
   在 Init.cpp 中添加 Python 绑定,暴露 get_p2p_stream_id 接口到 Python 层

# 【资料变更】

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

# 【接口变更】

| 接口名称                           | 参数                                                         | 返回值                           | 说明                      |
| ---------------------------------- | ------------------------------------------------------------ | -------------------------------- | ------------------------- |
| ProcessGroupHCCL.get_p2p_stream_id | device: torch.device - NPU <br>设备 peer: int - 对端 rank <br>is_batched: int - 是否批量模式 (1=批量, 0=非批量) | int - stream ID,不存在时返回 -1 | 获取 P2P 通信的 stream ID |

# 【功能验证】

1. ut验证
新增测试文件 test/distributed/test_get_p2p_stream_id.py ,包含以下测试场景:

| 测试用例                       | 说明                                           |
| ------------------------------ | ---------------------------------------------- |
| test_p2p_stream_id_batched     | 测试批量模式 (is_batched=1) 下获取 stream ID   |
| test_p2p_stream_id_non_batched | 测试非批量模式 (is_batched=0) 下获取 stream ID |
| test_p2p_stream_id_invalid | 测试未构造p2p stream场景下获取 stream ID 非法值-1 |

python -m pytest test/distributed/test_get_p2p_stream_id.py
![image.png](https://raw.gitcode.com/user-images/assets/7404318/14839078-206e-4b78-b173-f2310839a8c1/image.png 'image.png')

2. 业务场景验证
调用dist.send/recv方法进行p2p通信后,通过该新增接口get_p2p_stream_id()获取p2p stream id,拿到id对应的Stream实例,指定在该Stream上进行计算操作。
通过profiling文件可以看到计算在p2p stream上进行
![image.png](https://raw.gitcode.com/user-images/assets/7404318/24aeaefb-7abf-4af4-bdbe-59e528defbed/image.png 'image.png')

# 【CheckList】

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!32202
2026-03-25 10:11:58 +08:00
pta-robot e2a0417ba1 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32320 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-24 21:01:26.

See merge request: Ascend/pytorch!32320
2026-03-24 22:56:31 +08:00
mihudan 3cd91e6b11 修改npugraph_ex.compile_fx接口签名
Co-authored-by: wangkai<wangkai579@huawei.com>



# message auto-generated for no-merge-commit merge:
!32082 merge v2.10.0 into v2.10.0

修改npugraph_ex.compile_fx接口签名

Created-by: mihudan
Commit-by: wangkai
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [x] 资料更新

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

修改npugraph_ex.compile_fx接口 compile_fx(gm, example_inputs=None, options=None)

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
资料已对应修改:https://gitcode.com/Ascend/torchair/pull/2744
# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
资料已对应修改:https://gitcode.com/Ascend/torchair/pull/2744

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
对应用例也已同步修改
![image.png](https://raw.gitcode.com/user-images/assets/7404318/15fe052e-28f3-435a-81eb-d330f9f6c461/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x]  代码注释完备,正确记录错误日志
- [x]  代码实现进行了返回值、空指针等校验
- [x]  PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x]  PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32082
2026-03-24 20:20:37 +08:00
qq_37868325 82ebfdf51f migrate nlohmann-json from gitee to gitcode due to repository instability
Co-authored-by: ACAES<liuyan7892@163.com>



# message auto-generated for no-merge-commit merge:
!32207 merge v2.10.0 into v2.10.0

migrate nlohmann-json from gitee to gitcode due to repository instability

Created-by: AACAES
Commit-by: ACAES
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32207
2026-03-24 20:11:12 +08:00
cuiduo fe8d11b240 [fix]pickle_local_object_error
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31831 merge v2.10.0 into v2.10.0

[fix]pickle_local_object_error

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 修复闭包问题,pickle无法追踪闭包函数,迁移为公共函数

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 已增加UT,torchair测试通过

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31831
2026-03-24 20:04:25 +08:00
pta-robot bcd20db582 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32280 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-24 16:01:32.

See merge request: Ascend/pytorch!32280
2026-03-24 17:29:29 +08:00
ascend-robot de754b2246 Fixed IsGteCANNVersion
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!32185 merge cherry-pick-mr-32184-1774236181523-auto into v2.10.0

Fixed IsGteCANNVersion

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. 背景:
新格式(比如beta版本)的版本号需要用VersionV2ToNum转换为数字。
2. 问题:
判断分支 (major1 >= 8 && minor1 >= 5 && major2 >= 8 && minor2 >= 5) 这个逻辑有误,导致9.0.0 和9.0.0.beta1不能走入这个分支,进而导致不能调用VersionV2ToNum转换为数字。
3. 修改前的现象是:
当环境的版本号是9.0.0.beta1时,调用torch_npu.npu.utils.\_is_gte_cann_version("9.0.0", model="CANN") 时,返回的是True。
4. 修改后:
当环境的版本号是9.0.0.beta1时,调用torch_npu.npu.utils.\_is_gte_cann_version("9.0.0", model="CANN") 时,返回的是False。

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32185
2026-03-24 16:12:26 +08:00
adelaideliu 3756b48a5b [fix] group only supports in A2, A3 for all2all, scatter and gather
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!32106 merge v2.10.0_fix_scatter into v2.10.0

[fix] group only supports in A2, A3 for all2all, scatter and gather

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
来源是调用了同样group下发需求的问题单
- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
因为group目前只支持A2,A3机器,增加了对机型的判断
# 【资料变更】
“不涉及”

# 【接口变更】
“不涉及”

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
/home/l00939996/pytorch/test/distributed/test_scatter.py
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d2a9a92a-e248-4e0f-8887-1e8ca7cae2fe/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32106
2026-03-24 11:24:00 +08:00
ascend-robot 0b9d277227 [fix] Synchronize HCCL streams instead of device in ProcessGroupHCCL shutdown
Co-authored-by: dinghongzou<zoudinghong3@huawei.com>



# message auto-generated for no-merge-commit merge:
!32155 merge v2.10.0 into v2.10.0

[fix] Synchronize HCCL streams instead of device in ProcessGroupHCCL shutdown

Created-by: Windwindzzz
Commit-by: dinghongzou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

将设备同步改为流同步,同时新增判断,在不使用流的情况下不进行流的同步
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

test_zero_redundancy_optimizer.py中的test_add_param_group
已自验证,问题单报错消失
![image.png](https://raw.gitcode.com/user-images/assets/7404318/671ae89e-833f-48c5-829e-e2c9fc099a40/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32155
2026-03-24 11:00:20 +08:00
pta-robot 16db5456cf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32232 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-24 10:01:30.

See merge request: Ascend/pytorch!32232
2026-03-24 10:46:51 +08:00
moyuu2025 65fd39a25c fix: custom_fwd and custom_bwd lags behind the target torch version
Co-authored-by: dongxinwen<xwdong1998@163.com>



# message auto-generated for no-merge-commit merge:
!31772 merge v2.10.0 into v2.10.0

fix: custom_fwd and custom_bwd lags behind the target torch version

Created-by: moyuu2025
Commit-by: dongxinwen
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
**现象**
- 用例`test_cuda.py::test_autocast_custom_deprecated_warning`失败
- 报错指向:custom_fwd和custom_bwd未抛出弃用警告

**责任模块**
- `torch_npu/npu/amp/autocast_mode.py`的custom_fwd和custom_bwd函数

**根因分析**
- torch自2.4.0版本更新了custom_fwd和custom_bwd函数和相应装饰器,torch_npu中代码落后于目标torch版本代码

**解决方案**
- 更新torch_npu代码至目标torch版本代码

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
重跑已有测试用例

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31772
2026-03-24 10:43:18 +08:00
zhangguoguang 761cff2845 fix dropout sharding strategy on v2.10.0
Co-authored-by: zhangguoguang<zhangguoguang2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32179 merge fix_dropout_sharding_strategy_210 into v2.10.0

fix dropout sharding strategy on v2.10.0

Created-by: zhangguoguang
Commit-by: zhangguoguang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
npu上dropout算子的mask和原生社区不同,不能沿用原生的sharding strategy,重写dropout正反向的sharding strategy。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32179
2026-03-24 09:44:27 +08:00
pta-robot 984348e217 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32211 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-23 21:01:23.

See merge request: Ascend/pytorch!32211
2026-03-23 22:21:39 +08:00
pta-robot 11dd77cee9 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32191 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-23 16:01:23.

See merge request: Ascend/pytorch!32191
2026-03-23 17:17:15 +08:00
yu_liangbin e506bcb471 [fix_torch_profiler_2.10.0]修复profiler L0级别kernel_details.csv无shape信息问题
Co-authored-by: yuliangbin<y1416490440@163.com>



# message auto-generated for no-merge-commit merge:
!32102 merge fix_profiler_l1_2.10 into v2.10.0

[fix_torch_profiler_2.10.0]修复profiler L0级别kernel_details.csv无shape信息问题

Created-by: yu_liangbin
Commit-by: yuliangbin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
关联issue号:https://gitcode.com/Ascend/pytorch/issues/1586
- [ ] 重构优化
- [ ] 资料更新

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

1.功能:解析得时候会根据是否为aicore_none进行kernel_details.csv的表头过滤,但是在l1、aicore_metrics非aicore_none场景下会导致kernel_details.csv表头缺失shape字段,实际上只有l0场景下kernel_details.csv的表头比较少,l1场景下不应该缺失表头,因此过滤逻辑应当是是否为l0,若是l0场景,则过滤,反之不过滤;
2.UT:UT适配

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

不涉及

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

不涉及

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

验证结果:离线解析一份l1+aicore_none场景的数据,kernel_details.csv的表头与op_summary.csv的表头一致,未被过滤

![image.png](https://raw.gitcode.com/user-images/assets/7404318/9195d8a7-a49c-49ae-8894-2a0adc4c7239/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32102
2026-03-23 17:10:31 +08:00
pta-robot 3d566158fa Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32126 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-20 22:01:23.

See merge request: Ascend/pytorch!32126
2026-03-23 16:30:16 +08:00
xiaoqi-zhou 57414ce67f 【bug-fix】修复torch_npu2.10.0版本分布式用例未适配torch2.10.0的问题
Co-authored-by: xiaoqi-zhou<zhouxiaoqi9@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32012 merge distributed_test_v2.10.0 into v2.10.0

【bug-fix】修复torch_npu2.10.0版本分布式用例未适配torch2.10.0的问题

Created-by: xiaoqi-zhou
Commit-by: xiaoqi-zhou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
UT脚本未适配PT2.10版本,导致失败

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
报错用例同步PT2.10.0版本社区用例。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
本地验证测试用例正常跑通:
python test_schedule_multiproc.py:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/61df3c16-74cf-44a8-bdf4-8b01dfab5ee3/image.png 'image.png')

python test_stage.py
![image.png](https://raw.gitcode.com/user-images/assets/7404318/280e64b6-e978-466d-8ae7-0faa0268e0ea/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32012
2026-03-23 16:05:35 +08:00
gleaming-spark b56a42282d [fix]Perform driver version check prior to invoking interface aclrtPointerGetAttributes
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!32175 merge cherry-pick-mr-32173-1774232232617-auto into v2.10.0

[fix]Perform driver version check prior to invoking interface `aclrtPointerGetAttributes`

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
调用aclrtPointerGetAttributes接口前增加对驱动版本判断

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32175
2026-03-23 16:02:24 +08:00
zhenyu10 642313d63c bugfix:kSynchronizeBusyWaitMillis
Co-authored-by: zhenyu10<shizhenyu5@huawei.com>



# message auto-generated for no-merge-commit merge:
!31379 merge v2.10.0 into v2.10.0

bugfix:kSynchronizeBusyWaitMillis

Created-by: zhenyu10
Commit-by: zhenyu10
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
torch历史版本如2.1.0kSynchronizeBusyWaitMillis是10ms,客户使用的2.7.1和之后的版本都是1ms,此处对齐torch目标版本,更改值为1ms。

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
不涉及。环境变量对齐torch,非新增。

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
非新增功能,只是对齐torch变量值,不涉及用例。
测试未提供用例,构造用例的实验结果:
其中两次实验median的差值是9ms左右,可以生效。
kSynchronizeBusyWaitMillis为1ms:
HCCL_BLOCKING_WAIT=1,小 tensor all_reduce + async_op + wait() 单次耗时 (ms):
  rank 1: n=75  mean=1.105ms  median=1.076ms  p90=1.080ms  max=2.145ms
  rank 0: n=75  mean=1.064ms  median=1.077ms  p90=1.080ms  max=1.089ms
kSynchronizeBusyWaitMillis为10ms:
HCCL_BLOCKING_WAIT=1,小 tensor all_reduce + async_op + wait() 单次耗时 (ms):
  rank 0: n=75  mean=10.079ms  median=10.078ms  p90=10.082ms  max=10.099ms
  rank 1: n=75  mean=10.087ms  median=10.086ms  p90=10.093ms  max=10.122ms

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31379
2026-03-23 11:28:50 +08:00
pta-robot 14b5e1662b Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32168 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-23 10:01:29.

See merge request: Ascend/pytorch!32168
2026-03-23 10:49:26 +08:00
yangch0324 f4e5747fb8 [fix][v2.10.0]Fix the core dump issue of the COW feature.
Co-authored-by: y30062407<handsome0324@163.com>



# message auto-generated for no-merge-commit merge:
!32073 merge v2.10.0_cow into v2.10.0

[fix][v2.10.0]Fix the core dump issue of the COW feature.

Created-by: yangch0324
Commit-by: y30062407
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
适配 _lazy_clone 算子(TensorFactories.cpp)

调用 PyTorch 核心 c10::impl::COW::lazy_clone_storage() 创建共享存储的 Tensor 副本
通过 StorageDescHelper::CopyDesc() 同步 NPU 特有的存储描述符
修改内存分配器 copy_data 实现(NPUCachingAllocator.cpp)

将 default_copy_data(CPU memcpy)替换为 aclrtMemcpy(ACL_MEMCPY_DEVICE_TO_DEVICE)
实现 NPU 设备间直接内存拷贝,避免 PCIe 传输开销
修改存储创建逻辑(NPUStorageImpl.cpp)

支持外部传入已分配的 data_ptr,配合 COW 懒克隆场景
# 【资料变更】
不涉及
# 【接口变更】
不涉及
# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/a68135a4-c5aa-4ae8-be93-a9af0ab1c966/image.png 'image.png')
python3 test_ops.py -v TestCompositeCompliancePRIVATEUSE1.test_cow_input_remainder_npu_float32

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32073
2026-03-23 10:47:31 +08:00
pta-robot 7b2cefae5e Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32163 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-21 21:01:28.

See merge request: Ascend/pytorch!32163
2026-03-21 21:44:24 +08:00
liangsongwei d2406c660e [fix]add empty_with_swapped_memory ut
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!32131 merge v2.10.0 into v2.10.0

[fix]add empty_with_swapped_memory ut

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
https://gitcode.com/Ascend/pytorch/issues/1406

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
补充empty_with_swapped_memory接口预期计算值比对

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32131
2026-03-21 17:45:45 +08:00
pta-robot bf8c00aa60 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32146 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-21 16:04:14.

See merge request: Ascend/pytorch!32146
2026-03-21 17:07:43 +08:00
pta-robot 6cac822eb0 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32119 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-20 21:01:25.

See merge request: Ascend/pytorch!32119
2026-03-21 10:46:49 +08:00
pta-robot 61fa472e1d Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32062 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-19 19:36:10.

See merge request: Ascend/pytorch!32062
2026-03-20 17:46:47 +08:00
zhukkk e242eb7764 [feature]aclgraph支持superkernel
Co-authored-by: zhukkk<zhuke11@huawei.com>



# message auto-generated for no-merge-commit merge:
!32042 merge v2.10.0 into v2.10.0

[feature]aclgraph支持superkernel

Created-by: zhukkk
Commit-by: zhukkk
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
SuperKernel是一种算子的二进制融合技术,与源码融合不同,它聚焦于内核函数 (Kernel) 的二进制的调度方案,展开深度优化,于已编译的二进制代码基础上融合创建一个超级Kernel函数(SuperKernel),以调用子函数的方式调用多个其他内核函数,也就是子Kernel。相对于单算子下发,SuperKernel技术可以减少任务调度等待时间和调度开销,同时利用Task间隙资源进一步优化算子头开销。SuperKernel的参数中融合多个子kernel,在Superkernel内部直接调用算子,仅需一次stars调度后便可执行多个kernel。由于kernel内的调用路径比stars更短,性能更好,尤其是大量连续的aicore算子时,一个Superkernel可以融合上千个子算子,调用收益可达15%以上,为了获得该收益AclGraph需要支持Superkernel。
1、提供def super_kernel_optimize(self, optimize_options = None, debug_options = None)
2、提供def super_kernel_scope_begin/end(scope_name)接口标记superkernel融合范围做compile封装;
3、对optimize_options 、debug_options dict python入参类型做校验并转为sk_options;
# 【资料变更】
def super_kernel_scope_begin/end(scope_name):标记superkernel融合范围,如果graph中不存在scope_begin/end标签表示整个aclgraph做superkernel融合;
参数说明:scope_name为None或非空字符串;
使用示例:表示融合sk1范围内的matmul、relu算子


    with torch.npu.graph(g):
            torch_npu.npu.super_kernel_scope_begin("sk1")
            z = torch.matmul(x, y)
            w = torch.relu(z)
            torch_npu.npu.super_kernel_scope_end("sk1")  
 

def super_kernel_optimize(self, optimize_options = None, debug_options = None):aclgraph capture后触发superkernel融合;
参数说明:
optimize_options:支持preload_code、split_mode、stream_fusion;
preload_code、:  kernel执行前做指令的预加载,可选值:[0, 1, 2],0:按最大可能的预取size进行加载,1(默认值):按函数体大小进行加载,2:不进行预加载。
split_mode: 代码拆分的分数,可选值:[1,2,3,4]; 
stream_fusion:  是否是多流融合,可选值:[0, 1];

debug_options:支持debug_dcci_disable_on_kernel、debug_sync_aLL;
debug_dcci_disable_on_kernel: opX算子结束后不使能dcci,可选值:["op1", "op2",...];
debug_sync_all: debug模式是否每个算子后面插入全核同步,可选值:[0, 1];

使用示例:

       with torch.npu.graph(g):
            z = torch.matmul(x, y)
            w = torch.relu(z)

        optimize_options = {
            'preload_code': 1,
            'stream_fusion': 1
        }
        debug_options = {
            'debug_synn_alll':1
        }
        g.super_kernel_optimize(optimize_options=optimize_options, debug_options=None)
        g.replay()



# 【接口变更】
1、提供def super_kernel_optimize(self, optimize_options = None, debug_options = None)
2、提供def super_kernel_scope_begin/end(scope_name)接口标记superkernel融合范围做compile封装;
# 【功能验证】
已新增UT用例看护,test/npu/test_aclgraph_super_kernel.py,流水线CI已通过
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32042
2026-03-20 17:44:03 +08:00
cuiduo 2c194e8af7 [fix]user_autotune_npu
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!32038 merge v2.10.0 into v2.10.0

[fix]user_autotune_npu

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 为NPU增加自定义算子接口user_autotune_npu,以替代原本的user_autotune包装器,同时增加FixedGridNpu与PrecomputedGridNpu适配,确保自定义算子正常运行

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 以增加UT

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32038
2026-03-20 17:21:54 +08:00
xftxyz a6d3cd134e test(npu): add SupportedDevices decorator for test_fault_mode
Co-authored-by: xftxyz<pangxiaoyu@h-partners.com>



# message auto-generated for no-merge-commit merge:
!32022 merge v2.10.0-2603180 into v2.10.0

test(npu): add SupportedDevices decorator for test_fault_mode

Created-by: xftxyz
Commit-by: xftxyz
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

test/npu/test_fault_mode.py:Ascend950不支持aclop,为test_aclopCompile、test_ascyn这两个用例添加@SupportedDevices(['Ascend910A', 'Ascend910B', 'Ascend910_93'])装饰器
test/distributed/test_fault_mode.py:Ascend950日志字符串改变,为test_hccl_timeout用例添加@SupportedDevices(['Ascend910A', 'Ascend910B', 'Ascend910_93'])装饰器,并新增test_hccl_timeout_950,将断言修改为task timeout

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32022
2026-03-20 17:05:56 +08:00
liangsongwei 0bbadebc73 [fix] memory leak
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!32089 merge v2.10.0 into v2.10.0

[fix] memory leak

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
https://gitcode.com/Ascend/pytorch/issues/1406
- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
在 svm_deleter 函数中实现了交换内存的释放流程。首先检查传入指针是否为空,然后通过全局映射表 memBlocks 查找对应的原始主机内存指针。找到后,依次执行以下操作:1)调用 AclrtHostUnregister 注销设备对主机内存的映射;2)调用 aclrtFreeHost 释放原始主机内存;3)从映射表中移除对应条目。该实现确保了内存管理的正确性,并与现有清理逻辑保持一致。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e40e3b1b-2b4a-42c4-afbf-327961c758c3/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32089
2026-03-20 17:05:03 +08:00
liwei386 b9df9c0a5e [refactor] eliminate the dependency on libhccl and libopapi when import torch_npu
Co-authored-by: liwei386<liwei386@huawei.com>



# message auto-generated for no-merge-commit merge:
!31908 merge v2.10.0 into v2.10.0

[refactor] eliminate the dependency on libhccl and libopapi when import torch_npu

Created-by: liwei386
Commit-by: liwei386
Merged-by: ascend-robot
Description: # 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
> 1、将hccl接口改成运行时加载,消除import torch_npu时对libhccl的依赖
> 2、优化asd初始化逻辑,避免import torch_npu时依赖libopapi算子库

# 【资料变更】
> “不涉及”

# 【接口变更】
> “不涉及”

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31908
2026-03-20 15:33:49 +08:00
zhaoyu65 1c060467a8 record filename in plog and delete unused macros
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!31693 merge v2.10.0-plog into v2.10.0

record filename in plog and delete unused macros

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单   [#1568](https://gitcode.com/Ascend/pytorch/issues/1568) 
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、删除CMakeLists.txt文件中关于`__FILENAME__`和`__FILE__`的定义,以及其他2处使用到的地方:torch_npu/csrc/profiler/feature_mgr.cpp和torch_npu/csrc/profiler/profiler_mgr.cpp
2、在CMakeLists.txt文件中添加编译选项add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
3、修改调用到aclAppLog的地方;
4、将日志模块宏从torch_npu\csrc\logging\LogContext.h文件中挪到各模块的头文件中;
5、删除没有用到的宏;

打印效果:
1、日志模块宏的打印效果
```text
[223916] [2026-03-12 10:47:24:086] torch_npu.memory: [DEBUG] [223916] Allocating memory: size=64, device=6
[223916] [2026-03-12 10:47:24:086] torch_npu.memory: [DEBUG] [223916] Rounded size: 512, alloc size: 2097152, using small pool on device 6
[223916] [2026-03-12 10:47:24:086] torch_npu.memory: [DEBUG] [223916] Searching for free block: size=512, stream=0x22e309a0, device=6
```
2、plog日志打印效果
```text
[DEBUG] APP(223916,python):2026-03-12-10:47:28.033.940 [log_inner.cpp:87]223916 free:NPUCachingAllocator.cpp:1441: "[PTA]:"Freeing memory block: size=512, ptr=0x12c041200000, device=6""
[DEBUG] APP(223916,python):2026-03-12-10:47:28.033.973 [log_inner.cpp:87]223916 free_block:NPUCachingAllocator.cpp:2307: "[PTA]:"Freeing block to cache: size=512, ptr=0x12c041200000, device=6""
[DEBUG] APP(223916,python):2026-03-12-10:47:28.033.993 [log_inner.cpp:87]223916 free:NPUCachingAllocator.cpp:1479: "[PTA]:"PTA CachingAllocator free: free = 512, cached = 2097152, allocated = 1024""
[DEBUG] APP(223916,python):2026-03-12-10:47:28.289.574 [log_inner.cpp:87]223916 free:NPUCachingAllocator.cpp:1441: "[PTA]:"Freeing memory block: size=512, ptr=0x12c041200200, device=6""
```
# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
验证Ok

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31693
2026-03-20 10:20:39 +08:00
ascend-robot ddbfedff4b Fixed IsGteCANNVersion
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!31804 merge cherry-pick-mr-31803-1773390242371-auto into v2.10.0

Fixed IsGteCANNVersion

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31804
2026-03-20 09:40:45 +08:00
pta-robot a061407abf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32075 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-19 21:01:28.

See merge request: Ascend/pytorch!32075
2026-03-19 21:39:39 +08:00
SCh_zx 4eed1a77a6 change dispatch timeout log level
Co-authored-by: SCh_zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!32010 merge v2.10.0 into v2.10.0

change dispatch timeout log level

Created-by: SCh_zx
Commit-by: SCh_zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当下存在功能正常但日志报错情况,经评估,该报错日志不影响正常功能
将该error改为warning

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32010
2026-03-19 21:10:47 +08:00
qq_37868325 668c13e781 [inductor]精度工具分支合并
Co-authored-by: ACAES<liuyan7892@163.com>



# message auto-generated for no-merge-commit merge:
!31817 merge v2.10.0 into v2.10.0

[inductor]精度工具分支合并

Created-by: AACAES
Commit-by: ACAES
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

重构后,生成的图一致
![image.png](https://raw.gitcode.com/user-images/assets/7404318/1387b75d-0a91-444a-a71e-8fcd5f15b3c8/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31817
2026-03-19 19:54:49 +08:00
sunhaolun ffca004859 add_guard
Co-authored-by: sunhaolun<sunhaolun3@huawei.com>



# message auto-generated for no-merge-commit merge:
!31899 merge v2.10.0 into v2.10.0

add_guard

Created-by: sunhaolun
Commit-by: sunhaolun
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
https://codehub-y.huawei.com/c00502729/PTA_56_testing/issues/105
将torch.npu.current_device添加进guard列表中,触发重编译。
https://codehub-y.huawei.com/c00502729/PTA_56_testing/issues/82
添加trace_rule避免断图
# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
社区用例验证

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31899
2026-03-19 18:57:00 +08:00
cuiduo 841207b005 [fix]mlir_enable
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31964 merge v2.10.0 into v2.10.0

[fix]mlir_enable

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请修改MLIR使能方式,新增MLIR测试用例进行维护

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及”

# 【功能验证】
> 已包含UT

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31964
2026-03-19 17:38:38 +08:00
bigprestigee1 768d3c4e9a fix: create inv_scale_factor on same NPU as qkv in FA pattern example
Co-authored-by: bigprestigee1<zhangyican@huawei.com>



# message auto-generated for no-merge-commit merge:
!31923 merge v2.10.0 into v2.10.0

fix: create inv_scale_factor on same NPU as qkv in FA pattern example

Created-by: bigprestigee1
Commit-by: bigprestigee1
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31923
2026-03-19 17:23:30 +08:00
pta-robot d84744407d Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32050 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-19 16:01:27.

See merge request: Ascend/pytorch!32050
2026-03-19 16:50:55 +08:00
pta-robot bd0b3a7585 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32014 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-18 22:01:27.

See merge request: Ascend/pytorch!32014
2026-03-19 15:43:31 +08:00
mengmeizi05 0f694231d8 docs:Fix readme link issue
Co-authored-by: 50057208<shiyunhan1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31983 merge v2.10.0_link into v2.10.0

docs:Fix readme link issue

Created-by: mengmeizi05
Commit-by: 50057208
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改README的链接

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
不涉及

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31983
2026-03-19 15:42:20 +08:00
renyujin d2ac930431 [fix][test] fix test_schedule ut
Co-authored-by: renyujin<renyujin1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31988 merge test_ut_pipelining into v2.10.0

[fix][test] fix test_schedule ut

Created-by: renyujin
Commit-by: renyujin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

2.10版本test_schedule用例执行失败,报错如下
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e5db192e-69f8-4622-b8a5-be22cd7066ad/image.png 'image.png')

# 【修改方案】
报错1:Pytorch 2.10版本内部接口变更,测试用例需要同步。将 test_schedule.py 中的 _load_actions 调用替换为 _prepare_schedule_with_comms
报错2:PyTorch 的分布式进程组是全局状态,在同一个 Python 进程中只能初始化一次。test_schedule_with_single_stage 由于使用了 @parametrize 会运行多次。如果某次运行抛出异常,destroy_process_group() 不会被调用,后续的 test_grad_with_v_schedule 再次调用 init_process_group() 时就会报错。因此对齐 Pytorch 原生用例,在可能抛出异常的方法中使用 try...finally 兜底

# 【资料变更】
只修改UT用例,不涉及

# 【接口变更】
只修改UT用例,不涉及

# 【功能验证】
test_schedule用例验证通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/53aa96cb-d606-436b-be65-57b19bbbbc2b/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31988
2026-03-19 15:37:57 +08:00
shi-jiaxin9 21039cff3d [onnx] fix group_norm_silu and rotary_mul onnx api.
Co-authored-by: shi-jiaxin9<shijiaxin10@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31963 merge v2.10.0 into v2.10.0

[onnx] fix group_norm_silu and rotary_mul onnx api.

Created-by: shi-jiaxin9
Commit-by: shi-jiaxin9
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
- [ ] 问题单


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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31963
2026-03-19 14:54:55 +08:00
ltcs11 372692b479 add graph api extension for pluggable allocator
Co-authored-by: ltcs11<litangshengsheng@huawei.com>



# message auto-generated for no-merge-commit merge:
!31796 merge v2.10.0 into v2.10.0

add graph api extension for pluggable allocator

Created-by: ltcs11
Commit-by: ltcs11
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
https://gitcode.com/Ascend/pytorch/issues/1574

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
新增pluggable allocator自定义函数注册(已有自定义函数接口,仅新增注册功能,原调用会报错,新增后如有已注册接口则调用接口,未注册继续报错)
1. begin_allocate_to_pool_fn_
2. end_allocate_to_pool_fn_
3. release_pool_fn_

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
不涉及,CUDA Pluggable Allocator并无此类测试

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31796
2026-03-19 14:18:00 +08:00
pta-robot 760f8e0737 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!32024 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-19 10:01:27.

See merge request: Ascend/pytorch!32024
2026-03-19 11:22:19 +08:00
ascend-robot 63a06f7ce8 test(nn): add test for models api:torch.nn.Module, torch.nn.Module.state_dict, torch.nn.ModuleDict, torch.nn.ModuleList
Co-authored-by: dinglaiping<1016581171@qq.com>



# message auto-generated for no-merge-commit merge:
!31790 merge addtest-models-api-2.10.0 into v2.10.0

test(nn): add test for models api:torch.nn.Module, torch.nn.Module.state_dict, torch.nn.ModuleDict, torch.nn.ModuleList

Created-by: dinglaiping
Commit-by: dinglaiping
Merged-by: ascend-robot
Description: PR描述
<!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1575**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] issue/工单

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

自定义用例设计原则
基于 “最小化、核心化、针对性” 原则,设计独立 NPU 测试用例,核心思路:
1.	剥离无关耦合:仅使用 PyTorch 原生基础层(Linear、BatchNorm、Conv2d)构建测试对象,避免算子适配干扰;
2.	聚焦核心功能:仅验证 API 基础能力,不涉及边缘场景与复杂计算,确保结果反映 API 本身适配状态;
3.	贴合 NPU 特性:重点校验设备一致性、跨设备状态迁移等 NPU 核心关注点;
4.	轻量化设计:单个方法验证一个核心功能点,逻辑清晰、执行高效。

自定义用例核心验证点,在 NPU(npu:0)环境下,覆盖四个 API 核心功能及协同场景:
1.	Module:验证to(npu:0)迁移后,参数 / 缓冲区的设备一致性;
2.	state_dict:验证状态提取的完整性、设备一致性,及保存 / 加载后的参数值一致性;
3.	ModuleDict:验证键值对索引、新增、删除、遍历功能,及子模块设备一致性;
4.	ModuleList:验证数字索引、新增、插入、删除、遍历功能,及子模块设备一致性;
5.	四者协同:构建嵌套复合模块,验证state_dict对复合模块的状态提取 / 加载及设备一致性。


# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

整体结论
自定义测试用例在 NPU(npu:0)环境下全部执行成功,四个核心 API 的 NPU 适配验证完成核心功能全覆盖,基础能力与协同逻辑均正常可用,满足 NPU 场景下神经网络构建、状态管理、容器管理的实际需求。

核心功能验证结果
1.	Module设备管理:to(npu:0)可将模块及子模块的参数 / 缓冲区正确迁移至 NPU,无设备漂移;
2.	state_dict状态管理:状态提取完整、设备一致,保存 / 加载后参数值无丢失、无偏差;
3.	ModuleDict容器操作:键值对管理功能正常,容器内子模块与主模块设备一致;
4.	ModuleList容器操作:列表式管理功能正常,容器内子模块与主模块设备一致;
5.	四者协同:嵌套复合模块可实现设备统一迁移、状态完整提取与加载,无兼容性问题。

用例合理性说明
自定义用例虽简洁,但具备充分有效性与合理性:
1.	聚焦核心能力,剥离算子、精度等无关耦合,验证结果直接反映 API 本身适配状态;
2.	覆盖 API 所有核心功能点及协同场景,与实际业务使用方式高度贴合;
3.	基于 PyTorch 官方测试框架开发,使用原生断言方法,符合官方规范;
4.	适配 NPU 异步性、设备标识规则,避免 “假失败”,验证结果准确可靠。

运行日志
[root@hostname-fqv42 ~]# docker exec -it test210 bash
root@hostname-fqv42:/home# python /root/torchnpuapi/newtest.py
....
----------------------------------------------------------------------
Ran 4 tests in 1.708s

OK
root@hostname-fqv42:/home#


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31790
2026-03-19 09:03:32 +08:00
pta-robot 61a2ec4ce6 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31655 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-11 16:01:27.

See merge request: Ascend/pytorch!31655
2026-03-18 20:21:46 +08:00
pta-robot b4810259df Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31945 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-17 22:01:28.

See merge request: Ascend/pytorch!31945
2026-03-18 18:05:09 +08:00
luochao60 3f5607af6e fix: fix storage weakref wrapper
Co-authored-by: luochao60<luochao60@huawei.com>



# message auto-generated for no-merge-commit merge:
!31642 merge Pynative_fix_storage_wrapper_20260311_v2.10 into v2.10.0

fix: fix storage weakref wrapper

Created-by: luochao60
Commit-by: luochao60
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1. 修改 `torch_npu/npu/_graph_tree.py` 中 `StorageWeakRefWrapper.expired()` 方法,将 `torch_npu._C._storage_Use_Count` 替换为 PyTorch 原生的 `torch._C._storage_Use_Count`,修正 storage 引用计数判断逻辑,当存在 `extra_ref_check` 时额外减去 2(Python storage 对象引用 + cached Tensor 引用)
2. 修改 `torch_npu/npu/_graph_tree.py` 中 `StorageWeakRefWrapper.__init__` 的类型校验,将 `if not isinstance` + `raise RuntimeError` 简化为 `assert`;修正 `from_weakref_and_data_ptr` 的类型标注从 `Type[S]` 改为 `type[StorageWeakRefWrapper]`
3. 移除 `torch_npu/csrc/npu/Module.cpp` 中自定义的 `_storage_Use_Count` C++ 绑定函数,改用 PyTorch 原生实现
4. 增强 `test/npu/test_graph_tree.py` 中 `TestStorageWeakRefWrapper` 测试类,新增多个测试用例覆盖:从 Tensor/UntypedStorage 初始化、过期检测、`__call__` 返回值、`data_ptr` 持久性、`from_weakref_and_data_ptr`、`extra_ref_check`、`remove_extra_reference`、`__repr__` 等场景

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

不涉及

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

不涉及(移除的 `_storage_Use_Count` 为内部实现,改用 PyTorch 原生接口替代)

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

已在 `test/npu/test_graph_tree.py` 的 `TestStorageWeakRefWrapper` 类中新增以下测试用例:
- `test_init_from_tensor`: 验证从 Tensor 初始化 wrapper
- `test_init_from_untyped_storage`: 验证从 UntypedStorage 初始化 wrapper
- `test_expired_after_delete`: 验证 Tensor 释放后 wrapper 正确过期
- `test_call_returns_cdata_when_alive`: 验证存活时 `__call__` 返回 cdata
- `test_call_returns_none_when_expired`: 验证过期后 `__call__` 返回 None
- `test_data_ptr_persists_after_expiry`: 验证过期后 `data_ptr()` 仍返回原始指针
- `test_from_weakref_and_data_ptr`: 验证类方法构造 wrapper
- `test_extra_ref_check_prevents_expiry`: 验证 extra_ref_check 机制
- `test_remove_extra_reference`: 验证移除额外引用
- `test_repr_alive` / `test_repr_dead`: 验证 repr 输出

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31642
2026-03-18 16:35:37 +08:00
Dring ee2ccd7fb3 [v2.10.0][bugfix]get_device_properties报错NN processes exceeds the limit
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!31800 merge v2.10.0 into v2.10.0

[v2.10.0][bugfix]get_device_properties报错NN processes exceeds the limit

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
除ACL_DEV_ATTR_TOTAL_GLOBAL_MEM_SIZE = 301,同步了cann头文件的其它枚举变量,当前修改暂未用到

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

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

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

验证:同时fork 1000个进程,每个进程都去调用get_device_properties
修改前报错:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8c842f10-aabf-40bb-b80c-cf11003afcec/image.png 'image.png')
修改后:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d7d479d1-05ca-472b-afee-10dba47fb685/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31800
2026-03-18 16:26:26 +08:00
ascend-robot 5ac180ce02 test(nn): add test for nn api: torch.nn.Parameter, torch.nn.Buffer
Co-authored-by: dinglaiping<1016581171@qq.com>



# message auto-generated for no-merge-commit merge:
!31890 merge addtest-nn-api-2.10.0 into v2.10.0

test(nn): add test for nn api: torch.nn.Parameter, torch.nn.Buffer

Created-by: dinglaiping
Commit-by: dinglaiping
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1579**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] issue/工单

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

用例设计原则
本次验证结合官方用例复用与自定义用例补充的方式,遵循 “最小化、核心化、针对性” 原则,核心思路为:
1.	补充缺失用例:针对Parameter、Buffer两个无官方单独用例的 API,自定义极简测试用例,覆盖核心功能;
2.	聚焦核心功能:仅验证每个 API 的基础操作与 NPU 适配核心点,不涉及边缘场景与复杂计算,确保结果反映 API 本身适配状态;
3.	贴合 NPU 特性:所有用例均重点校验设备迁移一致性、容器操作有效性、属性正确性等 NPU 场景关键需求;
4.	轻量化设计:单个测试方法仅验证一个核心功能点,逻辑清晰、执行高效,便于问题定位。
验证用例核心验证点
在 NPU(npu:0)环境下,覆盖 2 个 API 的核心功能及实际使用场景,Parameter、Buffer通过自定义用例补充验证点,整体验证点如下:
1.	Parameter:验证直接在 NPU 上创建、核心属性(requires_grad)修改、data数据操作、设备一致性校验;
2.	Buffer:验证直接在 NPU 上创建、persistent双属性配置、模块注册后在state_dict中的存在性、设备一致性校验;


# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

整体结论:
本次验证通过 补充自定义用例的方式,在 NPU(npu:0)环境下完成 2 个核心 API 的全量验证,用例均执行成功,核心功能全覆盖,基础能力与操作逻辑均正常可用。

核心功能验证结果:
1.	Parameter:支持直接在 NPU 创建设备对象,requires_grad属性可灵活修改,data数据操作正常,设备一致性校验通过,核心属性与操作均符合预期;
2.	Buffer:支持直接在 NPU 创建设备对象,persistent=True/False双属性配置生效,模块注册后在state_dict中的存在性符合规则,设备一致性校验通过;


用例合理性说明:自定义用例虽简洁,但具备充分有效性与合理性。
1.	自定义用例精准补全:Parameter、Buffer的自定义用例聚焦无官方用例覆盖的核心功能,贴合实际业务使用方式,验证结果具备业务参考价值;
2.	适配操作最小化:对自定义用例仅做设备指定的最小化适配,确保验证结果能真实反映 API 本身的 NPU 适配状态;
3.	符合官方规范:自定义用例基于 PyTorch 官方测试框架开发,使用原生断言方法,与官方用例测试标准保持一致;


运行日志
[root@hostname-fqv42:~/torchnpuapi# python /root/torchnpuapi/test_nn_api.py
..
----------------------------------------------------------------------
Ran 2 tests in 5.263s

OK
root@hostname-fqv42:~/torchnpuapi#


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31890
2026-03-18 16:01:33 +08:00
huangyunlong2022 c6f2bcc523 fix ignore it when device_index < 0 on with device
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31937 merge 2.10wt into v2.10.0

fix ignore it when device_index < 0 on with device

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

修复with torch.npu.deivice,传-1时,会set device 0的问题,当前对于传入异常参数(小于0)不做处理

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

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

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

![image.png](https://raw.gitcode.com/user-images/assets/7404318/ca521bab-2fc6-4629-8c88-1058c7c2726e/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31937
2026-03-18 15:12:42 +08:00
zzhongmin 6c55230943 guard as_strided format inference on non-base-format tensors
Co-authored-by: zzhongmin<zhongmin23@huawei.com>



# message auto-generated for no-merge-commit merge:
!31864 merge v2.10.0_fix_strided into v2.10.0

guard as_strided format inference on non-base-format tensors

Created-by: zzhongmin
Commit-by: zzhongmin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
  --composite compliance相关用例会使用 CompositeCompliantTensor 这类 wrapper tensor 对前向、反向以及 view replay 过程进行检查。这类 tensor 会保留 device、size、stride、storage offset 等元数据,但其底层 storage 不一定是 NPUStorageImpl。现有 NPU 部分 metadata 和 view 路径默认假设输入一定持有原生 NPUStorageImpl,并直接读取 NPUStorageDesc 和 format 信息。当 wrapped args 或 wrapped grads 进入这些路径时,就可能将非法内存误解释为 format,从而触发 unknown format type 一类异常。
  --修改方案:将 internal format 相关判断严格限制在原生 NPU tensor 范围内,避免对 composite wrapper tensor 误读 backend specific storage。优先判断 format 格式是否合法,再进入 internal format 分支判断。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
test_ops.py -v -k test_operator_nn_functional_scaled_dot_product_attention_npu_float32用例通过
test_ops.py  -v -k test_backward_H_npu_float32用例通过
# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31864
2026-03-18 14:50:36 +08:00
glf2016 b6a28ca9d4 update register_replacement infer args
Co-authored-by: glf2016<13739288457@163.com>



# message auto-generated for no-merge-commit merge:
!31754 merge cherry-pick-mr-31590-1773363997784-auto into v2.10.0

update register_replacement infer args

Created-by: glf2016
Commit-by: glf2016
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31754
2026-03-18 11:47:52 +08:00
xuzhenhua2025 993ce9488b fix: restore limit_core_num implemented by the scope
Co-authored-by: xuzhenhua2025<xuzhenhua4@huawei.com>



# message auto-generated for no-merge-commit merge:
!31879 merge v2.10.0 into v2.10.0

fix: restore limit_core_num implemented by the scope

Created-by: xuzhenhua2025
Commit-by: xuzhenhua2025
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. 恢复limit_core_num接口调用;
增加接口签名校验和测试用例.

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
参考同时提交的测试用例代码:test_npugraph_ex.py中test_limit_core_num用例

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31879
2026-03-18 11:42:00 +08:00
ascend-robot 158aa46397 Can load the UT from the op warehouse separately.
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!31904 merge cherry-pick-mr-31859-1773734520940-auto into v2.10.0

Can load the UT from the op warehouse separately.

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31904
2026-03-18 09:42:31 +08:00
gleaming-spark b15480b1a1 [fix]Perform driver version check prior to invoking interface aclrtMallocHostWithCfg
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!31777 merge cherry-pick-mr-31775-1773373959401-auto into v2.10.0

[fix]Perform driver version check prior to invoking interface `aclrtMallocHostWithCfg`

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
接口存在性判断增加对驱动版本的判断

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
https://gitcode.com/Ascend/pytorch/pull/31776

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e2ee9a20-1410-4edb-b68a-b59e5bf9b2c6/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31777
2026-03-18 09:13:58 +08:00
chuboning 30d7606e42 [fix]Modify customize_dtype to keyword argument
Co-authored-by: chuboning<chuboning1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31519 merge v2.10.0 into v2.10.0

[fix]Modify customize_dtype to keyword argument

Created-by: chuboning
Commit-by: chuboning
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31519
2026-03-17 20:53:46 +08:00
wangzhenwu cf25b793c8 [fix] Solve recursivly initialize device
Co-authored-by: wangzhenwu7<5ge@live.com>
Co-authored-by: wangzhenwu<wangzhenwu7@huawei.com>



# message auto-generated for no-merge-commit merge:
!31876 merge v2.10.0 into v2.10.0

[fix] Solve recursivly initialize device

Created-by: wangzhenwu
Commit-by: wangzhenwu;wangzhenwu7
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
新增cacheDeviceErrorVerboseMsg函数对Device未初始化的检查,解决当前Device未初始化时,循环初始化问题
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31876
2026-03-17 20:31:42 +08:00
pta-robot cf0cb710f3 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31751 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-12 22:01:39.

See merge request: Ascend/pytorch!31751
2026-03-17 20:23:24 +08:00
ascend-robot 972e304016 [fix]fix profiler warn when cann path does not exist
Co-authored-by: hehongzhe<935062458@qq.com>



# message auto-generated for no-merge-commit merge:
!31495 merge wr10 into v2.10.0

[fix]fix profiler warn when cann path does not exist

Created-by: hhz0
Commit-by: hehongzhe
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

解析过程中多次调用load_info导致重复打印路径校验报错,修改为只在第一次调用时校验,并优化提示
在profiler_config的load_info中处理无PROF_XXX文件,且配置了NPU的情况,如果是此类情况则把activities中NPU去掉,不走NPU的解析流程;
判断是否已经调用过load_info,避免重复调用多次打印

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

不涉及

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

不涉及

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

对删除PROF文件夹的数据进行解析

修改前

![image.png](https://raw.gitcode.com/user-images/assets/7404318/7c542ca9-0b57-45fa-8284-5c40544aa118/image.png 'image.png')

修改后

![image.png](https://raw.gitcode.com/user-images/assets/7404318/78a4d4cb-1599-4a19-a5de-eaf1bea32700/image.png 'image.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31495
2026-03-17 17:49:32 +08:00
xiaoqi-zhou 197908353b 【bug-fix】DeviceProperty属性中multi_processor_count设置默认值
Co-authored-by: xiaoqi-zhou<zhouxiaoqi9@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31541 merge multi_processor_count_v2.10.0 into v2.10.0

【bug-fix】DeviceProperty属性中multi_processor_count设置默认值

Created-by: xiaoqi-zhou
Commit-by: xiaoqi-zhou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
分布式社区issue
torch.nn.DataParallel初始化时,会调用_check_balance方法对设备进行check,这个方法里面会使用设备的multi_processor_count属性,该属性npu上没有。
- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
torch.nn.DataParallel初始化时,会调用_check_balance方法对设备进行check,这个方法里面会使用设备的multi_processor_count属性,该属性npu上没有。
解决方案是获取multi_processor_count的值时使用vector_core_num或cube_core_num给其赋默认值。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
本地用例验证通过:
python /home/z30062846/test_stateless.py -v -k test_functional_call_with_data_parallel_error_stateless
![image.png](https://raw.gitcode.com/user-images/assets/7404318/fa787a7e-8efc-4028-8522-cdbf67a5a716/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31541
2026-03-17 15:29:31 +08:00
xiaoqi-zhou 4b042a40b9 【fix】修复assertError类型报错的问题
Co-authored-by: xiaoqi-zhou<zhouxiaoqi9@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31686 merge assert_v2.10.0 into v2.10.0

【fix】修复assertError类型报错的问题

Created-by: xiaoqi-zhou
Commit-by: xiaoqi-zhou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
问题单

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
在torch2.9.0及以后的版本中,运行test/distributed/checkpoint/test_checkpoint.py中的_test_dist_failure方法,错误场景从ValueError 扩展为ValueError 和 AssertionError。
使用assert判断时需要将错误场景扩大,与开源对齐。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
本地用例通过:
python test_checkpoint.py -v -k test_load_error_handling
![image.png](https://raw.gitcode.com/user-images/assets/7404318/0e5d8ca9-2175-416d-87aa-93359ad94fe4/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31686
2026-03-17 14:12:14 +08:00
chengpeng25 a86e0549aa [feat][v2.10.0] set allow_internal_format default value False in Atlas A2
Co-authored-by: chengpeng25<chengpeng9@huawei.com>



# message auto-generated for no-merge-commit merge:
!31606 merge v2.10.0 into v2.10.0

[feat][v2.10.0] set allow_internal_format default value False in Atlas A2

Created-by: chengpeng25
Commit-by: chengpeng25
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> A2代际的torch.npu.config.allow_internal_format的默认值修改为False

# 【资料变更】
> 涉及资料变更,PR:https://gitcode.com/Ascend/op-plugin/pull/4421

# 【接口变更】
> 不涉及

# 【功能验证】
> ![image.png](https://raw.gitcode.com/user-images/assets/7404318/5a1ca963-6adb-45e1-9a74-2f2f90e14885/image.png 'image.png')
> 对比验证
> A3:默认'disable'
> A2修改前:默认空'',等价于enable的效果(代码中处理)
> A2修改后:默认'disable',同A3一致

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31606
2026-03-17 14:11:18 +08:00
huangjingwei 6744f15df7 [master][bugfix] update Tensorpipe
Co-authored-by: JingweiHuang<huangjingwei4@huawei.com>



# message auto-generated for no-merge-commit merge:
!31851 merge v2.10.0-tensorpipe into v2.10.0

[master][bugfix] update Tensorpipe

Created-by: huangjingwei
Commit-by: JingweiHuang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单 
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

流水线失败

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

流水线失败。

原因:
`Tensorpipe` 依赖的 `https://gitee.com/mirrors/libuv.git` 转为需要认证的仓库,提供换gitcode的同步仓。
Ascend/pytorch 更新 `Tensorpipe` 依赖。

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

不涉及

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

不涉及

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

流水线通过。

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31851
2026-03-16 19:05:19 +08:00
zzhongmin c858228296 fix serialization offset filelike bug
Co-authored-by: zzhongmin<zhongmin23@huawei.com>



# message auto-generated for no-merge-commit merge:
!31612 merge v2.10.0__fix_serialization_offset_filelike into v2.10.0

fix serialization offset filelike bug

Created-by: zzhongmin
Commit-by: zzhongmin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
torch.serialization.save函数按调用方的入参执行,而不是写死为true

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
test_serialization.py中test_serialization_offset_filelike_weights_only_False用例通过

# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31612
2026-03-16 16:28:03 +08:00
yangch0324 9eaf2f3bd9 [fix][v2.10.0]aclgraph testcase add 910C support
Co-authored-by: y30062407<handsome0324@163.com>



# message auto-generated for no-merge-commit merge:
!31721 merge v2.10.0_acltest into v2.10.0

[fix][v2.10.0]aclgraph testcase add 910C support

Created-by: yangch0324
Commit-by: y30062407
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31721
2026-03-14 16:08:33 +08:00
kuhn7 cfd5b412f3 feat(libtorch_npu): add HCCL test case for libtorch_npu
Co-authored-by: chenkun<chenkun82@huawei.com>



# message auto-generated for no-merge-commit merge:
!31743 merge v2.10.0_libtorch_ut_for_hccl into v2.10.0

feat(libtorch_npu): add HCCL test case for libtorch_npu

Created-by: kuhn7
Commit-by: chenkun
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31743
2026-03-14 11:00:06 +08:00
LiNuohang d43940c8e0 [fix] load api consistency
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!31697 merge load-2.10 into v2.10.0

[fix] load api consistency

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
load在mmap时,从允许str改为允许path,对齐原生行为

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31697
2026-03-13 16:06:01 +08:00
LiNuohang a260b24481 [fix] tensor clone api consistency
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!31692 merge clone-2.10 into v2.10.0

[fix] tensor clone api consistency

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
clone在src为不连续tensor时,不clone strided属性,与CPU不对齐。
在Preserve|none时修改为empty_strided。

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31692
2026-03-13 16:04:40 +08:00
LiNuohang 7492ad614e [fix] as_strided consistency
Co-authored-by: LiNuohang<linuohang@huawei.com>



# message auto-generated for no-merge-commit merge:
!31668 merge strided-2.10.0 into v2.10.0

[fix] as_strided consistency

Created-by: LiNuohang
Commit-by: LiNuohang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
问题1:checkInBoundsForStorage未同步原生overflow检测,不能正确拦截overflow场景
2:if (self_->sizes() == size && self_->strides() == stride) 提前返回未能触发update_contiguous,后续判断is_contiguous会失败

修改方案:改为调用原生setStrided接口解决

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31668
2026-03-13 16:03:26 +08:00
kisnwang 6b4394105c [fix] cast stridedshard error
Co-authored-by: kisnwang<wangkaisheng2@huawei.com>



# message auto-generated for no-merge-commit merge:
!31646 merge v2.10.0 into v2.10.0

[fix] cast stridedshard error

Created-by: kisnwang
Commit-by: kisnwang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31646
2026-03-13 15:40:52 +08:00
wangzhenwu 272393d39e [feat] PTA supports retrying after a network failure step.
Co-authored-by: wangzhenwu7<5ge@live.com>



# message auto-generated for no-merge-commit merge:
!29897 merge v2.10.0 into v2.10.0

[feat] PTA supports retrying after a network failure step.

Created-by: wangzhenwu
Commit-by: wangzhenwu7
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
为 A5 增加 device error verbose 与 repair 能力;非 A5 保持原逻辑。
接口变更:
错误消息入口
旧:NPU_CHECK_ERROR -> handleDeviceError(int)
新:NPU_CHECK_ERROR -> getDeviceErrorMessage(int)(内部再调用 handleDeviceError,并在 A5 上追加 verbose)
ACL 适配层
旧:无设备错误 verbose/repair 接口
新:IsExistAclrtGetErrorVerbose/AclrtGetErrorVerbose、IsExistAclrtRepairError/AclrtRepairErrorACL 
数据结构
旧:无 aclrtErrorInfo 相关定义
新:新增 aclrtErrorType/aclrtErrorInfo 等结构与声明(含 third_party stub)
恢复流程旧:restart_device 仅清理 mem UCE 信息
新:A5机型额外执行 repair_device_error() + clear_device_error_info()
报错内容
旧:链路错误固定 HCCS LINK ERROR(分布式侧识别词同步增加)

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

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
在 Python 侧调用 torch_npu._C._npu_inject_device_error_for_test("uce"),可走通 NPU_CHECK_ERROR -> getDeviceErrorMessage -> formatDeviceErrorVerbose 报错链路,用于验证 A5 场景下设备错误打印格式
![image.png](https://raw.gitcode.com/user-images/assets/7404318/c0c712b3-e23c-455b-bd5d-5b387697a290/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常




See merge request: Ascend/pytorch!29897
2026-03-13 10:19:56 +08:00
weixin_47897441 2a110a7b88 [fix][2.10.0]add getMemoryFraction attribute for torch._C
Co-authored-by: weixin_47897441<wuyouqi1@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30795 merge v2.10.0 into v2.10.0

[fix][2.10.0]add getMemoryFraction attribute for torch._C

Created-by: weixin_47897441
Commit-by: weixin_47897441
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [x] issue/工单 : torch._C不支持_npu_getMemoryFraction
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、NPUCachingAllocator中新增getMemoryFraction方法及虚函数声明,Module中注册_npu_getMemoryFraction绑定;
2、在torch_npu.npu和torch_npu.npu.memory中实现并暴露get_per_process_memory_fraction接口,支持指定设备,调用底层 C++ 接口;
3、新增该接口的测试用例;
4、将该接口及底层Cpp绑定加入Dynamo追踪规则,完成适配。

# 【资料变更】
>  不涉及

# 【接口变更】
> 否

# 【功能验证】
> UT用例测试通过:python test_npu.py -v -k test_get_per_process_memory_fraction
![image.png](https://raw.gitcode.com/user-images/assets/7404318/dd7cc124-b3b1-47d1-ab15-ad3798b33115/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!30795
2026-03-12 19:46:22 +08:00
zzhongmin fc04b3e18f fix flight recorder dump file name bug
Co-authored-by: zzhongmin<zhongmin23@huawei.com>



# message auto-generated for no-merge-commit merge:
!31298 merge v2.10.0_fix_flightrecorder_bug into v2.10.0

fix flight recorder dump file name bug

Created-by: zzhongmin
Commit-by: zzhongmin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
全局通信域初始化时调用globalRank,解决FlightRecorder做dump的时候,文件名命名没有使用global rank的问题

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
FlightRecorder做dump的时候,文件名命名使用正确的global rank

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31298
2026-03-12 16:48:03 +08:00
jjt_3 7dc2cb7873 expose LogContext for extension
Co-authored-by: jjt_3<1926550527@qq.com>



# message auto-generated for no-merge-commit merge:
!31607 merge logcontext-v2.10.0 into v2.10.0

expose LogContext for extension

Created-by: jjt_3
Commit-by: jjt_3
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
由于修改log相关文件,导致extension中找不到符号:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/ee93fe81-8fdc-4289-a8c1-712d9bd23cf1/image.png 'image.png')
因此需要对外暴露LogContext,保证extension可以用到
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
不涉及”

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
用例已跑通:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/6d2e8f3c-1da0-40de-a45b-d163cc9e1ee3/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31607
2026-03-12 15:06:00 +08:00
bigprestigee1 13651d3929 add torch mlir ut case
Co-authored-by: bigprestigee1<zhangyican@huawei.com>



# message auto-generated for no-merge-commit merge:
!31639 merge v2.10.0 into v2.10.0

add torch mlir ut case

Created-by: bigprestigee1
Commit-by: bigprestigee1
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31639
2026-03-12 14:21:18 +08:00
xiaoqi-zhou c258f92781 【bug-fix】在torch_npu注册后同步更新rpc模块的BackendType引用
Co-authored-by: xiaoqi-zhou<zhouxiaoqi9@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31460 merge backend_v2.10.0 into v2.10.0

【bug-fix】在torch_npu注册后同步更新rpc模块的BackendType引用

Created-by: xiaoqi-zhou
Commit-by: xiaoqi-zhou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
分布式社区issue


- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
torch_npu 在注册 "NPU_TENSORPIPE" 时,backend_registry.register_backend 会重建并替换 backend_registry.BackendType,但 torch.distributed.rpc.init 在导入时已通过 from .backend_registry import BackendType 持有了旧的 BackendType 引用。因此推断出的 backend 是旧枚举的 TENSORPIPE,而 _validate_rpc_args 用新的 backend_registry.BackendType 做 isinstance 检查,导致失败。
解决方案:
在 torch_npu 注册后同步更新 rpc 模块的 BackendType 引用。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
本地用例通过:
python test_store.py -v -k test_init_pg_and_rpc_with_same_socket
![image.png](https://raw.gitcode.com/user-images/assets/7404318/ea062dd7-6c18-46ba-852d-5f1a28df8221/image.png 'image.png')
python test_store.py -v -k test_init_pg_and_rpc_with_same_file
![image.png](https://raw.gitcode.com/user-images/assets/7404318/a614992e-cc17-46e3-ba6c-4f7aa30499b7/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31460
2026-03-12 09:39:51 +08:00
mengmeizi05 9329c8c55f docs: Modifying the README file,Modified the CONTRIBUTING file.
Co-authored-by: s50057208<shiyunhan1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31672 merge mme2.10.0 into v2.10.0

docs: Modifying the README file,Modified the CONTRIBUTING file.

Created-by: mengmeizi05
Commit-by: s50057208
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改了README.md和CONTRIBUTING.md的内容

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
不涉及

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31672
2026-03-11 23:25:26 +08:00
pta-robot 73f22b8147 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31659 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-11 16:32:32.

See merge request: Ascend/pytorch!31659
2026-03-11 17:51:22 +08:00
dilililiwhy cd8d624882 Fix Dockerfile (2.10)
Co-authored-by: dilililiwhy<why.wuhuanyu@huawei.com>



# message auto-generated for no-merge-commit merge:
!31610 merge fix_dockerfile_2100 into v2.10.0

Fix Dockerfile (2.10)

Created-by: dilililiwhy
Commit-by: dilililiwhy
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
镜像增量制作时使用正确的基础镜像cpython版本创建软链接,同步替换rc版本基础镜像

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

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

# 【功能验证】
![image.png](https://raw.gitcode.com/user-images/assets/7404318/6b844cc9-4b8f-4d91-a2e4-9d74e412002f/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31610
2026-03-11 17:34:59 +08:00
pta-robot 4b46f4b123 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31621 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-10 22:01:22.

See merge request: Ascend/pytorch!31621
2026-03-11 16:14:19 +08:00
pta-robot 6a57dde224 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31633 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-11 10:01:53.

See merge request: Ascend/pytorch!31633
2026-03-11 11:10:18 +08:00
sunhaolun 638106a644 fix_device_dynamo_trace
Co-authored-by: sunhaolun<sunhaolun3@huawei.com>



# message auto-generated for no-merge-commit merge:
!31560 merge v2.10.0 into v2.10.0

fix_device_dynamo_trace

Created-by: sunhaolun
Commit-by: sunhaolun
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
现场问题
torch.device在原生中为skipVariable  而pta把他归为TorchInGraphFunctionVariable,在dynamo阶段会出现trcae失败的问题。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
社区issue测试,以及现场问题反馈的用例

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31560
2026-03-11 09:45:10 +08:00
adelaideliu f4d3ce3550 add native group send/recv collectives (gather, alltoall, scatter)
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!30956 merge v2.10.0-group into v2.10.0

add native group send/recv collectives (gather, alltoall, scatter)

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30956
2026-03-11 09:34:40 +08:00
pta-robot cc5fba043d Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31618 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-10 21:01:27.

See merge request: Ascend/pytorch!31618
2026-03-10 23:48:40 +08:00
yangch0324 0ab0ca0dec [feat][v2.10.0]Begin Allocate Current Thread To Pool
Co-authored-by: y30062407<handsome0324@163.com>



# message auto-generated for no-merge-commit merge:
!31570 merge v2.10.0_dropout into v2.10.0

[feat][v2.10.0]Begin Allocate Current Thread To Pool

Created-by: yangch0324
Commit-by: y30062407
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31570
2026-03-10 20:44:52 +08:00
ascend-robot 0d330429d7 [fix]profiler export_type warning mod
Co-authored-by: hehongzhe<935062458@qq.com>



# message auto-generated for no-merge-commit merge:
!31449 merge ex10 into v2.10.0

[fix]profiler export_type warning mod

Created-by: hhz0
Commit-by: hehongzhe
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

export_type在资料中写了默认值为text,但是在不设置的情况下默认为None,然后校验成text,会打印一个WARNING造成误解,因此修正其默认值

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

不涉及,资料中本来就说明了export_type默认值为text

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

不涉及

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

修改前

![image.png](https://raw.gitcode.com/user-images/assets/7404318/9201f424-7a5c-47c7-8e78-28ba307c7876/image.png 'image.png')

修改后,export_type的WARNING消失

![image.png](https://raw.gitcode.com/user-images/assets/7404318/949313b2-d125-4855-bcee-b1f7b6ebf140/image.png 'image.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31449
2026-03-10 20:20:46 +08:00
pta-robot 074854ec01 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31600 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-10 16:01:30.

See merge request: Ascend/pytorch!31600
2026-03-10 16:50:47 +08:00
wangzili121 3491b1bf15 [feat][Inductor] Add MLIR support for v2.10.0
Co-authored-by: wangzili<wangzili14@huawei.com>



# message auto-generated for no-merge-commit merge:
!31450 merge feature/mlir2.10 into v2.10.0

[feat][Inductor] Add MLIR support for v2.10.0

Created-by: wangzili121
Commit-by: wangzili
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
- 新增ascend_npu_ir模块,实现MLIR后端的编译入口、算子映射和代码生成,提供三种启用方式:配置项、环境变量、torch.compile参数
- 在C++层实现MLIR绑定,新增torch_npu._C.mlir子模块提供核心接口
- 新增README文档,说明MLIR引入背景、使用方式和示例

# 【资料变更】
新增torch_npu/_inductor/ascend_npu_ir/README.md简要说明mlir的基本信息与使用方法

# 【接口变更】
新增以下客户面可见接口,详细使用方法已在 torch_npu/_inductor/ascend_npu_ir/README.md 中说明。
- 配置项:torch._inductor.config.npu_backend = "mlir"
- 环境变量:TORCHINDUCTOR_NPU_BACKEND='mlir'
- torch.compile参数:options={"npu_backend":"mlir"}

# 【功能验证】
已运行din/dcn/hllm/hf_Albert/BERT_pytorch五张网络验证能跑通精度没问题

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31450
2026-03-10 15:36:07 +08:00
fu-hao-huawei 367ebd18fa [feat] 支持多流api 入图
Co-authored-by: fu-hao-huawei<fuhao16@huawei.com>



# message auto-generated for no-merge-commit merge:
!30605 merge v2.10.0 into v2.10.0

[feat] 支持多流api 入图

Created-by: fu-hao-huawei
Commit-by: fu-hao-huawei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1、将dynamo中对原生stream、event、record_event的实现逻辑patch给npu,使npu多流相关的api可以被dynamo追踪入图
2、新增NpuStreamContextVariable类继承自原生的StreamContextVariable,与原生相比多出的逻辑为切流时在图上添加set_stream节点,从而在图上保留切流的信息

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

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

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

已新增st看护
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30605
2026-03-10 15:25:51 +08:00
pta-robot e8c4bc879e Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31581 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-09 23:01:32.

See merge request: Ascend/pytorch!31581
2026-03-10 11:22:06 +08:00
pta-robot de91cd3911 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31578 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-09 22:01:28.

See merge request: Ascend/pytorch!31578
2026-03-10 10:38:18 +08:00
pta-robot 1e461c2603 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31551 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-09 16:01:25.

See merge request: Ascend/pytorch!31551
2026-03-09 22:23:46 +08:00
adelaideliu 9335691fe2 undo supprot coalescing send/recv
Co-authored-by: adelaideliu<adelaideliu@163.com>



# message auto-generated for no-merge-commit merge:
!31472 merge v2.10.0 into v2.10.0

undo supprot coalescing send/recv

Created-by: adelaideliu
Commit-by: adelaideliu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>
上一个pr:https://gitcode.com/Ascend/pytorch/pull/30547
- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31472
2026-03-09 21:07:46 +08:00
zhanw_coding 3db79daba4 fix: skip test_index_put_accumulate_large_tensor
Co-authored-by: zhanw_coding<zhanwang@huawei.com>



# message auto-generated for no-merge-commit merge:
!31419 merge v2.10.0 into v2.10.0

fix: skip test_index_put_accumulate_large_tensor

Created-by: zhanw_coding
Commit-by: zhanw_coding
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
门禁A1机器cann8.5.0 AsStrided124 算子报错

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31419
2026-03-09 19:19:05 +08:00
Dring 924517bb95 [v2.10.0][bugfix]code Rollback
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!31525 merge v2.10.0 into v2.10.0

[v2.10.0][bugfix]code Rollback

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31525
2026-03-08 20:56:31 +08:00
pta-robot 510c33ad9c Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31530 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-07 21:01:31.

See merge request: Ascend/pytorch!31530
2026-03-07 21:45:38 +08:00
culechan 6558f3c3ee [feat] add nestedtensor backend
Co-authored-by: culechan<chenshuai81@huawei.com>



# message auto-generated for no-merge-commit merge:
!30981 merge cherry-pick-mr-30980-1771989801135-auto into v2.10.0

[feat] add nestedtensor backend

Created-by: culechan
Commit-by: culechan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 创建Nestedtensor相关的后端,参考quantized后端的实现,因为二者较为类似,因此在文件代码自动生成逻辑部分做了合并重构。

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增已适配UT测试用例看护,并补充测试自验证截图
![image.png](https://raw.gitcode.com/user-images/assets/7404318/2a752de0-200f-41f4-b2f7-40bb54b8b7e6/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30981
2026-03-07 17:55:53 +08:00
liwei386 dd06f35ae8 Fix Tensor.empty deterministic bug.
Co-authored-by: liwei386<liwei386@huawei.com>



# message auto-generated for no-merge-commit merge:
!31486 merge revert-mr-31352-1772788394636-auto into v2.10.0

Fix Tensor.empty deterministic bug.

Created-by: liwei386
Commit-by: liwei386
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31486
2026-03-07 11:14:36 +08:00
pta-robot 25f59e08d2 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31508 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-06 22:02:49.

See merge request: Ascend/pytorch!31508
2026-03-07 04:21:18 +08:00
pta-robot af4e67cd49 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31497 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-06 21:01:25.

See merge request: Ascend/pytorch!31497
2026-03-06 22:28:01 +08:00
pta-robot 832743e6ba Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31262 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-03 10:01:28.

See merge request: Ascend/pytorch!31262
2026-03-06 20:11:08 +08:00
SCh_zx a0482a065d skip ci error
Co-authored-by: SCh_zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!31492 merge v2.10.0 into v2.10.0

skip ci error

Created-by: SCh_zx
Commit-by: SCh_zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31492
2026-03-06 19:34:45 +08:00
ascend-robot a3831fccd4 Register custom meta function for _to_copy to handle NPU-specific tensor conversions
Co-authored-by: dujinhang<15990042527@163.com>



# message auto-generated for no-merge-commit merge:
!31452 merge v2.10.0-inductor into v2.10.0

Register custom meta function for _to_copy to handle NPU-specific tensor conversions

Created-by: du-jin-hang
Commit-by: dujinhang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31452
2026-03-06 19:10:06 +08:00
cuiduo 8fd7f72b6f [fix]trace_fix
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31329 merge v2.10.0 into v2.10.0

[fix]trace_fix

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 修改trace_rule,解决部分API入图不一致问题

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 本地验证通过

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31329
2026-03-06 17:19:20 +08:00
kkjocker 54273eef40 【inductor】fix generate valid config
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31373 merge v2.10.0 into v2.10.0

【inductor】fix generate valid config

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
在部分昇腾产品中,核数为20,vector_core为40,会导致tiling之后得到不合理的block,从而生成错误的config,本pr用于修复这个bug,保证能够tune到符合要求的config,算法将继续执行后续逻辑。
# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 移除了descend_one_axis的一个用于提前结束循环的break语句,该语句会导致inductor在vector_core为40时生成不合理的config,从而超UB

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> Qwen2.5和llama3自验证通过

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

- [x]代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31373
2026-03-06 17:09:30 +08:00
Dring 42da1f41a8 [v2.10.0][bugfix]get_device_properties报错NN processes exceeds the limit
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!31282 merge v2.10.0 into v2.10.0

[v2.10.0][bugfix]get_device_properties报错NN processes exceeds the limit

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
除ACL_DEV_ATTR_TOTAL_GLOBAL_MEM_SIZE = 301,同步了cann头文件的其它枚举变量,当前修改暂未用到

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

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

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

验证:同时fork 1000个进程,每个进程都去调用get_device_properties
修改前报错:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8c842f10-aabf-40bb-b80c-cf11003afcec/image.png 'image.png')
修改后:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d7d479d1-05ca-472b-afee-10dba47fb685/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31282
2026-03-06 14:22:44 +08:00
LucciC 7411df6d64 add meta
Co-authored-by: LucciC<cuiliangcheng2@hisilicon.com>



# message auto-generated for no-merge-commit merge:
!31420 merge v2.10.0 into v2.10.0

add meta

Created-by: LucciC
Commit-by: LucciC
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31420
2026-03-06 11:48:26 +08:00
pta-robot 268b356f27 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31436 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-05 22:01:34.

See merge request: Ascend/pytorch!31436
2026-03-06 04:17:29 +08:00
kuhn7 105223d0f8 libtorch_npu.so support hccl api
Co-authored-by: kuhn7<chenkun82@huawei.com>



# message auto-generated for no-merge-commit merge:
!31404 merge v2.10.0_hccl_libtorch into v2.10.0

libtorch_npu.so support hccl api

Created-by: kuhn7
Commit-by: kuhn7
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31404
2026-03-05 22:49:31 +08:00
culechan 65869d4caa [feat] exposed customed api
Co-authored-by: chenshuai<chenshuai81@huawei.com>



# message auto-generated for no-merge-commit merge:
!31389 merge cherry-pick-mr-31388-1772627936681-auto into v2.10.0

[feat] exposed customed api

Created-by: culechan
Commit-by: chenshuai
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
对自定义算子做暴露处理

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

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

# 【功能验证】


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31389
2026-03-05 21:11:10 +08:00
jizewei 805f5bddfd FSDP memory cache
Co-authored-by: jizewei<jizewei@huawei.com>



# message auto-generated for no-merge-commit merge:
!31332 merge v2.10.0_fsdp_mem_cache into v2.10.0

FSDP memory cache

Created-by: jizewei
Commit-by: jizewei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. 支持对FSDP2的all_gather输出、reduce_scatter输入使用缓存,减少内存申请释放、降低内存碎片
2. 重计算FSDP2冗余allgather消除

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

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

# 【功能验证】
环境:A3,套件:MindSpeed-LLM,模型:Qwen3-Next-80B-A3B-Instruct(4层,16k)
1. 精度一致:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/0ad376f0-7419-42c5-99e3-79ed06443480/image.png 'image.png')
2. 显存变化:
基线:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/90dc1b04-2915-41ad-8c7b-2113fc72b21d/image.png 'image.png')
transformer层启用缓存:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/bdd26a25-3906-49af-8484-453043ad18e4/image.png 'image.png')
3. 性能变化:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/06635bd2-fccb-48b4-8103-4962d371e88e/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31332
2026-03-05 20:52:05 +08:00
liangchenghui 2a0266cf02 Fix Tensor.empty deterministic bug.
Co-authored-by: liangchenghui<liangchenghui@huawei.com>



# message auto-generated for no-merge-commit merge:
!31352 merge fix_empty_deterministic_2.10.0 into v2.10.0

Fix Tensor.empty deterministic bug.

Created-by: liangchenghui
Commit-by: liangchenghui
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
在 `DeterministicGuard(True, fill_uninitialized_memory=True)` 场景下,`test_deterministic_empty_npu_bool` 失败。  
现象是:`torch.empty(..., dtype=torch.bool, device="npu")` 生成结果与预期不一致,断言 `res.eq(True).all()` 失败。

`test_deterministic_resize_npu_bfloat16` 等用例在 NPU 上失败。  
失败原因是 `resize_` 扩容后,新增 storage 区间没有按 deterministic 语义填充为 `NaN/MAX_INT`,导致测试断言与上游行为不一致。

排查发现:
- 问题出在 NPU `empty` 相关工厂路径未完整覆盖 deterministic 填充逻辑;
- 部分路径(尤其 `empty_like` 的 NPU 分支)绕过了 `at::empty` 默认分支,导致没有执行 `fill_empty_deterministic_`。

## 根因

`torch_npu` 的 `empty`/`empty_like`/`empty_strided`/`empty_out` 多个入口中,存在路径直接走 NPU 自定义分配(如 `OpPreparation::ApplyTensorWithFormat`)而未补充 deterministic 填充,造成返回张量内容不符合 deterministic 语义。

NPU 的 `resize_` 实现仅执行了:

1. 存储扩容(`resize_impl_npu_`)
2. 旧数据拷贝

但缺少上游 `ATen` 在 deterministic 场景下的关键步骤:  对“新增 storage 区域”调用 `fill_resize_deterministic_`。

因此在 `torch.use_deterministic_algorithms(True)` 且 `fill_uninitialized_memory=True` 时,NPU 与 CPU/CUDA 语义不一致。

## 修改内容

文件:`torch_npu/csrc/aten/common/TensorFactories.cpp`
文件:`torch_npu/csrc/aten/common/ResizeNpu.cpp`

1. 引入 `#include <ATen/native/TensorFactories.h>`,以复用上游 `at::native::fill_empty_deterministic_`。
2. 新增公共判断函数:
   - `should_fill_empty_deterministic()`
   - 条件:`deterministicAlgorithms && deterministicFillUninitializedMemory`
3. 在以下 NPU empty 入口补齐 deterministic 填充:
   - `NPUNativeFunctions::empty`
   - `empty_like_npu`(NPU 分支 `ApplyTensorWithFormat` 后)
   - `NPUNativeFunctions::empty_strided`(`resize_impl_npu_` 后)
   - `empty_out_npu`(`resize_` 后)
4. 在 `NPUNativeFunctions::resize_` 中补齐 deterministic 填充逻辑
- resize 前记录 `old_storage_nbytes`
- resize 后在 deterministic 条件满足时调用:
  - `at::native::fill_resize_deterministic_(self, old_storage_nbytes)`

# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31352
2026-03-05 19:51:05 +08:00
zhaoyu65 0d9f051a54 log info when createHCCLCommEx switch to original interface
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!31365 merge v2.10.0-roll into v2.10.0

log info when createHCCLCommEx switch to original interface

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当rank_table_file为空或不可读时,记录成info日志。

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

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

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

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

- [x]  代码注释完备,正确记录错误日志
- [x]  代码实现进行了返回值、空指针等校验
- [x]  PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x]  PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31365
2026-03-05 19:38:26 +08:00
pta-robot d93e071469 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31311 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-03 19:12:49.

See merge request: Ascend/pytorch!31311
2026-03-05 19:07:06 +08:00
zqwenn d13ce29efd [feat]add TORCH_NPU_USE_COMPATIBLE_IMPL for over-adapted api
Co-authored-by: zqwenn<zhangqiongwen@huawei.com>



# message auto-generated for no-merge-commit merge:
!31366 merge v2.10.0_add_env_var_for_matmul into v2.10.0

[feat]add TORCH_NPU_USE_COMPATIBLE_IMPL for over-adapted api

Created-by: zqwenn
Commit-by: zqwenn
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

使用TORCH_NPU_USE_COMPATIBLE_IMPL环境变量控制mamtul过适配是否生效,过适配涉及算子注册、dtensor策略注册、meta策略注册
其中算子注册逻辑修改自动生成代码,在mdef之前新增环境变量条件判断,生成代码如下:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/c13230af-600b-40a2-b589-70fe7191a1da/image.png 'image.png')
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

涉及,资料单独提PR合入

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

不涉及

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

原有用例看护

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31366
2026-03-05 17:38:25 +08:00
gleaming-spark 5660d5196f [fix]Enhanced the interface with null pointer validation for is_pinned
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!31381 merge cherry-pick-mr-31380-1772627220237-auto into v2.10.0

[fix]Enhanced the interface with null pointer validation for is_pinned

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
python test_sparse.py -v -k test_generate_simple_inputs_npu
![image.png](https://raw.gitcode.com/user-images/assets/7404318/f2ae1895-6a9e-4eb9-8be2-501c7adb64d4/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31381
2026-03-05 17:00:45 +08:00
SCh_zx 7fe7a471a2 remove aclnn except A5
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!31203 merge v2.10.0 into v2.10.0

remove aclnn except A5

Created-by: SCh_zx
Commit-by: SCh_zx;SCh-zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当前,NpuFormatCast的aclnn接口调用存在问题,暂时规避调用aclnn接口
非A5环境下,回退调用aclnn接口

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31203
2026-03-05 15:13:31 +08:00
xuzhenhua2025 1045ceeef4 feat: Support independent packaging and deployment of npugraph_ex
Co-authored-by: xuzhenhua2025<xuzhenhua4@huawei.com>



# message auto-generated for no-merge-commit merge:
!31406 merge v2.10.0 into v2.10.0

feat: Support independent packaging and deployment of npugraph_ex

Created-by: xuzhenhua2025
Commit-by: xuzhenhua2025
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. torch_npu/dynamo 新增npugraph_ex独立包目录,实现npugraph_ex backend功能,不依赖torchair包
npugraph_ex后端注册方法使用import npugraph_ex, 并支持lazy import
2. npugraph_ex multi-stream已支持原生接口,删除torch.npu.npugraph_ex.scope/ops/experimental目录接口引用

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
使用/test/dynamo/test_npugraph_ex.py内unittest用例测试;
无新增内容,无需新增用例/变更内容是否已适配UT测试用例看护.

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31406
2026-03-05 14:51:48 +08:00
ascend-robot b519ba699d [feat] custom hccl api with dispatch
Co-authored-by: pengqi<pengqi33@huawei.com>



# message auto-generated for no-merge-commit merge:
!31343 merge v2.10.0 into v2.10.0

[feat] custom hccl api with dispatch

Created-by: pengqihw
Commit-by: pengqi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
为自定义HCCL分布式API添加AsyncCollectiveTensor支持,实现自动wait触发机制。

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】

1. 新增文件

- test/distributed/test_async_collective_tensor.py - 新增测试用例,验证三个API对AsyncCollectiveTensor的支持
- torch_npu/csrc/distributed/HcclOps.cpp - 新增HCCL操作实现
2. 核心修改

- ProcessGroupHCCL.cpp/hpp - 为以下API添加dispatch机制,支持AsyncCollectiveTensor自动触发wait:
  - batch_isend_irecv
  - reduce_scatter_tensor_uneven
  - all_gather_into_tensor_uneven
3. 其他修改

- test/distributed/test_reduce_scatter_tensor.py - 测试用例调整
- torch_npu_schema.json - schema更新
- Init.cpp - 初始化相关调整

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
新增测试用例覆盖:

- AsyncCollectiveTensor类型验证
- completed状态验证(初始False,调用后True)
- 结果一致性验证(与普通Tensor结果对比)
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8d82b911-24d6-4d26-8d12-20adcc56e4dc/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31343
2026-03-05 14:32:58 +08:00
donglinzhuo ae64b9a850 [feat]Torch_npu aclgraph basic interface modification alignment pytorch
Co-authored-by: 董林卓<donglinzhuo@huawei.com>



# message auto-generated for no-merge-commit merge:
!31304 merge v2.10.0 into v2.10.0

[feat]Torch_npu aclgraph basic interface modification alignment pytorch

Created-by: donglinzhuo
Commit-by: 董林卓
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
1、随机数生成器构造函数处增加非捕获状态的校验。
2、对齐pytorch原生代码,set_philox_offset_per_thread与philox_offset_per_thread在捕获状态下设置值或者取值为图内偏移量
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

# 【资料变更】
> “不涉及”

# 【接口变更】
>“不涉及”

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
在图捕获期间,创建随机数生成器查看是否能触发校验。符合预期
![image.png](https://raw.gitcode.com/user-images/assets/7404318/8fdfaf0a-67dd-4b95-88e5-0b9f937122f7/image.png 'image.png')
两种场景下set值后去读philox_offset_per_thread,查看其取到的是全局偏移还是图内偏移,是否符合预期。
![image.png](https://raw.gitcode.com/user-images/assets/7404318/87042d29-a34c-4bca-a94b-5a98c5baa10e/image.png 'image.png')
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31304
2026-03-05 10:32:47 +08:00
zhukkk 9c205684ad [fix]rollback del 32 allocator
Co-authored-by: zhukkk<zhuke11@huawei.com>



# message auto-generated for no-merge-commit merge:
!31397 merge v2.10.0 into v2.10.0

[fix]rollback del 32 allocator

Created-by: zhukkk
Commit-by: zhukkk
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31397
2026-03-05 10:31:34 +08:00
kkjocker ada7f96e2c 【inductor】 fix invoke_subgraph fallback bug
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31098 merge v2.10.0 into v2.10.0

【inductor】 fix invoke_subgraph fallback bug

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
修复了社区用例test_invoke_subgraph.py报错,让invoke_subgraph不走fallback流程,pta的patch会让higher_ops默认走fallback,而这个op应该正常走lowering
# 【合入来源】
> (如有)请关联需求文档/issue链接

-  [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31098
2026-03-04 17:01:38 +08:00
chaijinwei cb3cea51a2 adapt dcmi interface for A5
Co-authored-by: chaijinwei<chaijinwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!31338 merge npu_id_2.10 into v2.10.0

adapt dcmi interface for A5

Created-by: chaijinwei
Commit-by: chaijinwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
旧接口:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d1898e7b-c6fb-4a61-be65-256010e6ce48/image.png 'image.png')
新接口:
1、dcmiv2_get_affinity_cpu_info_by_device_id 2、dcmiv2_init 3、dcmiv2_get_device_list

A5机器对上面新的dcmi接口进行适配,同时兼容A2功能不回退

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

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

# 【功能验证】
验证方法:
1、设置环境变量:
     export ASCEND_SLOG_PRINT_TO_STDOUT=1
     export ASCEND_GLOBAL_LOG_LEVEL=0
     export CPU_AFFINITY_CONF=1,npu_affine:1
 2、运行调用aclnn算子的用例
 3、保存的日志中搜索affinity
 ![image.png](https://raw.gitcode.com/user-images/assets/7404318/64d23c05-0445-4df0-88be-b39260b95a62/image.png 'image.png')
 表示验证成功

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31338
2026-03-04 16:48:40 +08:00
yvjc bb496d27ab feat: Support environment variable to control fallback all ops in inductor
Co-authored-by: yvjc<yujincheng7@huawei.com>



# message auto-generated for no-merge-commit merge:
!31214 merge fallback210 into v2.10.0

feat: Support environment variable to control fallback all ops in inductor

Created-by: yvjc
Commit-by: yvjc
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
通过环境变量 NPU_INDUCTOR_FALLBACK_ALL 控制inductor的fallback行为,支持对所有算子进行fallback,具体实现如下:

  1. 新增 _fallback_ops_with_meta()
  函数:遍历所有torch算子名称,对具有Meta实现或CompositeImplicitAutograd实现的算子进行fallback注册
  2. 新增 _register_npu_custom_lowerings()
  函数:将原有的自定义lowering注册逻辑(如reduction算子、各种aten算子的lowering)独立封装,便于代码维护
  3. 重构 _register_npu_inductor_fallbacks() 函数:
    - 当环境变量 NPU_INDUCTOR_FALLBACK_ALL=1 时,启用全量fallback模式:
        - 对 lowerings 中所有算子进行fallback(排除decompositions中的算子和TritonKernelWrapperMutation类型)
      - 调用 _fallback_ops_with_meta() 对Meta实现算子进行fallback
    - 当环境变量未设置或为其他值时,保持原有逻辑不变(基于白名单的fallback机制)

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

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
  1. 测试场景:
    - 设置环境变量 NPU_INDUCTOR_FALLBACK_ALL=1,验证inductor能够对所有算子进行fallback
    - 不设置该环境变量或设置为其他值,验证原有fallback逻辑正常工作
  2. 测试方法:
    - 通过设置/不设置环境变量运行包含多种算子的模型,验证fallback行为是否符合预期
    - 检查 FALLBACK_LIST 中是否正确添加了相应的算子
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31214
2026-03-04 16:45:33 +08:00
suhaibo 5545692e6d refactor: replace hard-coded dispatch with Registry + Template Method for NPU Graph op handlers
Co-authored-by: suhaibo<suhaibo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31273 merge v2.10.0 into v2.10.0

refactor: replace hard-coded dispatch with Registry + Template Method for NPU Graph op handlers

Created-by: suhaibo
Commit-by: suhaibo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
1. 拓展aclgraph update功能,支持自定义算子注册update能力,避免侵入式修改pta源码

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

# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
<span style="color:#0066cc;">新增register_npu_graph_handler和NpuGraphOpHandler对外接口</span>

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31273
2026-03-04 16:33:31 +08:00
zhaoyu65 2777992475 define log macros and add memory, hccl log
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!31043 merge v2.10.0-log into v2.10.0

define log macros and add memory, hccl log

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: # 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求  增加内存相关日志和分布式相关日志
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

说明:由于npu_logging::Logger.log()中调用了ASCEND_LOG,**存在以下2个问题**:
1、当前TORCH_NPU_LOGS的值影响到了plog记录,即plog日志为debug,TORCH_NPU_LOGS为warning时,不能记录plog的info、debug级别的日志。
2、通过npu_logging::Logger.log()记录的plog日志中,无法有效显示日志所在文件、函数、行。显示的是log函数调用ASCEND_LOG所在的行。

# 【修改方案】
1、实现npu_logging::Logger和plog解耦,**删除npu_logging::Logger.log()中调用ASCEND_LOG的地方;**
2、基于现有日志能力,增加**TORCH_NPU_LOGX**日志公共宏,增加hccl的日志模块宏**TORCH_NPU_HCCL_LOGX**,增加memory的日志模块宏**TORCH_NPU_MEMORY_LOGX**。在两个日志模块宏中先调用TORCH_NPU_LOGX,再调用ASCEND_LOGX;
3、在关键函数中增加日志打印。

增加日志原则说明:
1、info记录关键信息、debug记录一般信息,**对于高性能场景将info调整为debug,避免影响性能**;

# 【资料变更】
> 不涉及

# 【接口变更】
>不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31043
2026-03-04 16:08:29 +08:00
xubinglin f0b5566583 feat: npu_format_cast support input_dtype
Co-authored-by: x00444734<xubinglin@huawei.com>



# message auto-generated for no-merge-commit merge:
!31066 merge v2.10.0 into v2.10.0

feat: npu_format_cast support input_dtype

Created-by: yuanshuai000
Commit-by: x00444734
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
https://gitcode.com/Ascend/pytorch/issues/1551

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. npu_format_cast新增input_dtype入参,根据输入的数据类型推断输出NZ格式的C0值

# 【资料变更】
不涉及

# 【接口变更】
npu_format_cast新增可选入参:https://gitcode.com/cann/ops-math/pull/1239

# 【功能验证】
自验证fp4_e2m1类型的数据ND2NZ转换,流程及精度均正常。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31066
2026-03-04 15:21:00 +08:00
wanlinan fa22c6d8e8 support coalescing send/recv
Co-authored-by: wanlinan<wanlinan@huawei.com>



# message auto-generated for no-merge-commit merge:
!30553 merge v2.10.0_dev into v2.10.0

support coalescing send/recv

Created-by: adelaideliu
Commit-by: wanlinan
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30553
2026-03-04 14:20:14 +08:00
liubuyu1 2f63ecaa9a fix test case
Co-authored-by: lby<liubuyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31323 merge v2.10.0 into v2.10.0

fix test case

Created-by: liubuyu1
Commit-by: lby
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

测试用例TestMultiStreamLazyReclaim在x86环境上,profiling工具统计信息与预期不符,暂时跳过x86

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

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

不涉及

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31323
2026-03-04 11:19:49 +08:00
liubuyu1 b47fc616f3 lazy query events
Co-authored-by: lby<liubuyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!31025 merge v2.10.0 into v2.10.0

lazy query events

Created-by: liubuyu1
Commit-by: lby
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

内存申请流程中,将原来的每次申请即查询event,修改为event数量达到上限后再查询,降低查询次数,提升host性能。

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

文档中新增环境变量`PYTORCH_NPU_ALLOC_CONF=multi_stream_lazy_reclaim:True`说明。

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

新增环境变量`export PYTORCH_NPU_ALLOC_CONF=multi_stream_lazy_reclaim:True`,控制event延迟查询功能开启。

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

新增测试用例,使用profiling功能对比功能开启前后event查询次数
![image.png](https://raw.atomgit.com/user-images/assets/7404318/fb9aaf99-517b-4960-9f88-e8e3305f652c/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31025
2026-03-03 19:44:22 +08:00
zhangguoguang f56d1746ee update matmul sharding strategy
Co-authored-by: zhangguoguang<zhangguoguang2@huawei.com>



# message auto-generated for no-merge-commit merge:
!31146 merge update_matmul_sharding_strategy_2100 into v2.10.0

update matmul sharding strategy

Created-by: zhangguoguang
Commit-by: zhangguoguang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
补齐matmul正向和反向sharding strategy,根据输入shape,列出所有可能的sharding方式

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
新增7个UT用例看护,自验通过
![image.png](https://raw.gitcode.com/user-images/assets/7404318/5db434a7-e2f7-42e2-9a5d-094191d78a06/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31146
2026-03-03 16:30:53 +08:00
mihudan edb94d7f64 【bugfix】patch_event_variable_python_type for profiling bugs
Co-authored-by: wangkai<wangkai579@huawei.com>



# message auto-generated for no-merge-commit merge:
!31173 merge v2.10.0 into v2.10.0

【bugfix】patch_event_variable_python_type for profiling bugs

Created-by: mihudan
Commit-by: wangkai
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

适配fullgraph=false的验证时,发现event在with中断图时,profiling存在报错,需要patch补充EventVariable的python_type

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
报错信息:
    raise NotImplementedError(f"{self} has no type") from None
torch._dynamo.exc.InternalTorchDynamoError: NotImplementedError: EventVariable() has no type
```
 def patch_event_variable_python_type():
 	     """
 	     Add the 'python_type' method to the EventVariable class.
 	     """
 	     def python_type(self):
 	         return type(self.value)
 	 
 	     if "python_type" not in torch._dynamo.variables.streams.EventVariable.__dict__:
 	         torch._dynamo.variables.streams.EventVariable.python_type = (
 	             python_type
 	         )
```
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
不涉及
# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
不涉及
# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
bugfix,已有st覆盖看护,自验证通过

![image.png](https://raw.gitcode.com/user-images/assets/7404318/9339d093-345d-4c47-9256-d9437dd226b3/image.png 'image.png')
patch后验证结果:profiling成功
[2026-02-28 17:21:42] [INFO] [926516] profiler.py: All profiling data parsed in a total time of 0:00:12.097939

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31173
2026-03-03 16:02:43 +08:00
ascend-robot 6c5a8e3755 Add PREMUL_SUM support in ProcessGroupHCCL for ReduceOp
Co-authored-by: dairenjie<dairenjie@huawei.com>



# message auto-generated for no-merge-commit merge:
!31239 merge v2.10.0_0303 into v2.10.0

Add PREMUL_SUM support in ProcessGroupHCCL for ReduceOp

Created-by: dairenjie
Commit-by: dairenjie
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. 修改ProcessGroupHCCL内reduce类接口的实现,在pre函数添加input.mul_(factor)的调用(9处)
2. 修改getHcclReduceOp内处理premul_sum场景为sum

# 【资料变更】
不涉及

# 【接口变更】
增加torch.distributed._make_hccl_premul_sum
和PT原生接口_make_nccl_premul_sum保持对等,已评审。

# 【功能验证】
修改/新增reduce算子premul_sum场景测试用例。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31239
2026-03-03 15:17:29 +08:00
ascend-robot 735d8e3bcd refactor shutdown and destructor to match torch behavior
Co-authored-by: dinghong_zou<zoudinghong3@huawei.com>



# message auto-generated for no-merge-commit merge:
!30626 merge v2.10.0 into v2.10.0

refactor shutdown and destructor to match torch behavior

Created-by: Windwindzzz
Commit-by: dinghong_zou
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

将关闭通信域从ProcessGroupHCCL类析构函数前移到shutdown()函数
去除shutdown()的参数,从而能够正确继承基类的shutdown()
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

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

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

单元测试:无新增 UT 测试用例,该功能可用库上现有UT用例覆盖
回归测试:执行 torch_npu/testing 模块下的所有现有 UT 测试套件,确认本次修改未影响其他功能;
手动验证:在测试环境中导入 torch_npu.testing 模块,调用destory_process_group方法,通过日志确认通信域在shutdown()方法中关闭。
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30626
2026-03-03 14:30:53 +08:00
pta-robot 4c5fcb179e Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31242 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-03 09:18:16.

See merge request: Ascend/pytorch!31242
2026-03-03 14:20:17 +08:00
qq_37868325 b97bf547c2 skip test_index_put_accumulate_large_tensor
Co-authored-by: ACAES<liuyan7892@163.com>



# message auto-generated for no-merge-commit merge:
!31118 merge v2.10.0 into v2.10.0

skip test_index_put_accumulate_large_tensor

Created-by: AACAES
Commit-by: ACAES
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31118
2026-03-03 11:45:03 +08:00
ascend-robot c83bac42c6 [bugfix] The issue of tensor lifecycle being too long and the stride validation problem.
Co-authored-by: dujinhang<15990042527@163.com>



# message auto-generated for no-merge-commit merge:
!31209 merge v2.10.0-inductor into v2.10.0

[bugfix] The issue of tensor lifecycle being too long and the stride validation problem.

Created-by: du-jin-hang
Commit-by: dujinhang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31209
2026-03-03 09:24:19 +08:00
pta-robot cd63b24625 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31237 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-02 22:01:31.

See merge request: Ascend/pytorch!31237
2026-03-03 09:12:25 +08:00
liujunzhu 4a1a28bd97 [feat] add eventpool for d2d copy
Co-authored-by: liujunzhu<liujunzhu@huawei.com>



# message auto-generated for no-merge-commit merge:
!29901 merge v2.10.0_2 into v2.10.0

[feat] add eventpool for d2d copy

Created-by: liujunzhu
Commit-by: liujunzhu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

单进程多卡场景跨设备拷贝device时,拷贝前后的Event使用了IPC Event,IPC Event一次创建300微秒左右,频繁的Event创建对性能影响很大,希望对跨设备的Event进行池化管理,从而提升性能。

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

不涉及

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

不涉及

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

本PR是对已有功能的重构,门禁已有用例看护。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!29901
2026-03-03 09:10:38 +08:00
pta-robot c530c5eba6 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31220 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-02 21:01:23.

See merge request: Ascend/pytorch!31220
2026-03-02 22:14:16 +08:00
huangyunlong2022 090d91f0e3 fix hostmemory leak, release it after aclCreateTensor
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!31171 merge 2.10format into v2.10.0

fix hostmemory leak, release it after aclCreateTensor

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

ConvertType会创建acltensor,使用后调用Release释放

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31171
2026-03-02 15:06:59 +08:00
pta-robot 8c82c02b68 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31182 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-28 22:01:29.

See merge request: Ascend/pytorch!31182
2026-03-02 14:04:16 +08:00
pta-robot 98d5f467c3 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31190 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-03-02 10:01:27.

See merge request: Ascend/pytorch!31190
2026-03-02 11:09:05 +08:00
moyuu2025 d404451f1c fix: copy_ bug for negative view
Co-authored-by: dongxinwen<xwdong1998@163.com>



# message auto-generated for no-merge-commit merge:
!31110 merge v2.10.0 into v2.10.0

fix: copy_ bug for negative view

Created-by: moyuu2025
Commit-by: dongxinwen
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
**现象**
- 用例`test_torch.py::test_copy_transpose_math_view_npu_int64`失败
- 报错指向:`copy_`未正确处理负视图情况

**责任模块**
- `torch_npu/csrc/aten/ops/op_api/CopyKernelOpApi.cpp`的负视图处理逻辑(NPU侧)

**根因分析**
- NPU侧对负视图的判断局限于`src.is_neg()`,未考虑self.is_neg()及self和src之间的负视图关系

**解决方案**
- 增加了copy_中负视图场景,当self与src的is_neg状态不一致时,通过neg_()对物理内存进行一次取反操作,补偿逻辑上的负号差异
- 具体修改:`src.is_neg()` -> `self.is_neg() != src.is_neg()`

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
重跑已有测试用例

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!31110
2026-03-02 10:35:51 +08:00
daifu1234567 e98ca39a4e [2.10.0]support aclnn extension
Co-authored-by: DaiFu<daifu2@huawei.com>



# message auto-generated for no-merge-commit merge:
!31150 merge v2.10.0 into v2.10.0

[2.10.0]support aclnn extension

Created-by: daifu1234567
Commit-by: DaiFu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

1、get_npu_data_unsafe_flag等函数加TORCH_NPU_API对外暴露,extension中可以从libtorch_npu.so中获取对应函数
2、修改CustomRegisterSchema.cpp生成逻辑,extension场景用TORCH_LIBRARY_FRAGMENT代替TORCH_LIBRARY
3、修复bug,extension场景下无需获取VERSION_PART

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

不涉及

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

不涉及

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

1、extension可以正常获取所需函数
![image.png](https://raw.gitcode.com/user-images/assets/7404318/37de6f85-f1c3-4de4-bb75-fe9715df96bc/image.png 'image.png')

2、extension中生成的CustomRegisterSchema.cpp中使用TORCH_LIBRARY_FRAGMENT
![image.png](https://raw.gitcode.com/user-images/assets/7404318/73f39b9e-e9d2-47b7-8d5f-e53ccac92f70/image.png 'image.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31150
2026-03-02 09:48:33 +08:00
pta-robot cd5346eb25 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31135 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-28 10:01:28.

See merge request: Ascend/pytorch!31135
2026-03-02 09:13:49 +08:00
pta-robot 789d22a885 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31125 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-27 17:32:06.

See merge request: Ascend/pytorch!31125
2026-02-28 09:21:27 +08:00
pta-robot df00332fa7 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31090 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-27 10:01:31.

See merge request: Ascend/pytorch!31090
2026-02-28 09:14:43 +08:00
pta-robot b2d71d79e9 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31083 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-26 22:01:27.

See merge request: Ascend/pytorch!31083
2026-02-27 14:15:17 +08:00
kkjocker d69f2f0608 fix v2.10.0 aoti bug
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30978 merge aoti_master into v2.10.0

fix v2.10.0 aoti bug

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

# 【资料变更】
>“不涉及”

# 【接口变更】
>“不涉及”

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30978
2026-02-27 09:59:44 +08:00
pta-robot 2ab2b08abf Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31081 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-26 21:02:30.

See merge request: Ascend/pytorch!31081
2026-02-26 22:02:48 +08:00
pta-robot 8295857b21 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31045 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-26 10:01:28.

See merge request: Ascend/pytorch!31045
2026-02-26 21:00:06 +08:00
pta-robot 62514c331b Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31076 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-26 19:13:04.

See merge request: Ascend/pytorch!31076
2026-02-26 20:24:38 +08:00
pta-robot 79da80dfd8 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31028 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-25 22:01:27.

See merge request: Ascend/pytorch!31028
2026-02-26 14:47:57 +08:00
liangsongwei e904e77fbe [feature] fix utils path not found
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!31011 merge cherry-pick-mr-30935-1772021479712-auto into v2.10.0

[feature] fix utils path not found

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31011
2026-02-26 10:34:22 +08:00
liangsongwei e488a65ce2 [feat]gen_backend_stubs code generation adap
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!31012 merge cherry-pick-mr-31007-1772021640712-auto into v2.10.0

[feat]gen_backend_stubs code generation adap

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
在生成C++原生函数注册代码时,通过读取环境变量 ACLNN_EXTENSION_SWITCH 的值,动态决定是否将 "torch_npu/csrc/framework/FormatHelper.h" 头文件包含到生成的代码头部列表中。该修改使得代码生成逻辑能够依据外部环境配置进行自适应调整,无需改动核心业务逻辑。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!31012
2026-02-26 09:49:58 +08:00
pta-robot 4ca5106057 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!31017 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-25 21:01:33.

See merge request: Ascend/pytorch!31017
2026-02-26 09:05:26 +08:00
yashi999 9f930a5c8f [feat]modifications for aclnn extension
Co-authored-by: yashi999<guyashi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30938 merge cherry-pick-mr-30809-1771055600402-auto into v2.10.0

[feat]modifications for aclnn extension

Created-by: yashi999
Commit-by: yashi999
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 基于aclnn_extension需求的需要,对pytorch仓库的部分依赖进行解耦。

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 测试方法:配合op_plugin仓的aclnn_extension,在aclnn_extension文件夹下执行gen.sh npu_fast_gelu.yaml npu_fast_gelu_derivatives.yaml
可成功运行,并生成相关输出件到当前文件夹:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/19fbaa44-23b1-4181-a8a7-76c4fb8e8e01/image.png 'image.png')
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d29633d5-4b5e-4c13-9820-a15cd99803b5/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30938
2026-02-25 20:10:52 +08:00
daifu1234567 8bc3f2f30a [2.10.0]add .h in utils
Co-authored-by: DaiFu<daifu2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30952 merge v2.10.0 into v2.10.0

[2.10.0]add .h in utils

Created-by: daifu1234567
Commit-by: DaiFu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

安装whl时,op_plugin/utils内的.h也安装至site-packages下的torch_npu内

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

不涉及

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

不涉及

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

site-packages中包含utils路径,且包含预期.h文件
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e7a92d5a-a507-4bfe-a390-f31ce8db74c4/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30952
2026-02-25 19:57:37 +08:00
pta-robot ae276a8967 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30995 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-25 16:01:28.

See merge request: Ascend/pytorch!30995
2026-02-25 17:22:41 +08:00
pta-robot e7c93f9b02 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30915 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-13 18:12:24.

See merge request: Ascend/pytorch!30915
2026-02-25 15:49:32 +08:00
liujunzhu e67de1bbd0 [feat] add env TORCH_TRANSFER_TO_NPU
Co-authored-by: liujunzhu<liujunzhu@huawei.com>



# message auto-generated for no-merge-commit merge:
!30825 merge v2.10.0 into v2.10.0

[feat] add env TORCH_TRANSFER_TO_NPU

Created-by: liujunzhu
Commit-by: liujunzhu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

支持通过环境变量`TORCH_TRANSFER_TO_NPU`使能transfer_to_npu。
设置环境变量`TORCH_TRANSFER_TO_NPU`为1时(取值为0或1),在`import torch_npu`时自动执行`from torch_npu.contrib import transfer_to_npu`,方便Torch CUDA脚本无缝迁移到NPU。

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

涉及资料变更,资料中需描述`TORCH_TRANSFER_TO_NPU`的功能和用法,本pr不涉及资料修改,后续单独提交资料修改的pr。

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

新增环境变量`TORCH_TRANSFER_TO_NPU`,取值为0或1,默认为0,设置为1时支持cuda接口到npu的转换。

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

PR已附带大量验证用例。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30825
2026-02-25 14:29:20 +08:00
pta-robot f46a421696 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30971 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-25 09:45:49.

See merge request: Ascend/pytorch!30971
2026-02-25 14:28:21 +08:00
qq_37868325 ccf4ef110b skip test_npu_lazy_init
Co-authored-by: acaes<liuyan7892@163.com>



# message auto-generated for no-merge-commit merge:
!30948 merge v2.10.0 into v2.10.0

skip test_npu_lazy_init

Created-by: AACAES
Commit-by: acaes
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30948
2026-02-24 14:16:10 +08:00
wangchao430 6a6089524c [fa_v3]skip cpu check, register_sharding for npu_fusion_attention_v3
Co-authored-by: wangchao430<wangchao430@huawei.com>



# message auto-generated for no-merge-commit merge:
!30861 merge v2.10.0_fav3 into v2.10.0

[fa_v3]skip cpu check, register_sharding for npu_fusion_attention_v3

Created-by: wangchao430
Commit-by: wangchao430
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1. torch_npu.npu_fusion_attention_v3适配支持DTensor策略注册。
2. graph_tree中支持根据torch_npu.\_inductor.config.npugraph_trees.disable_cpu_input_check配置开启时跳过cpu Tensor的相关检测,从而支持torch_npu.npu_fusion_attention_v3入graph_tree

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
新增DTensor测试用例

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30861
2026-02-14 15:14:38 +08:00
zzhongmin 6d7d33c5c0 fix as_strided bug
Co-authored-by: zzhongmin<zhongmin23@huawei.com>



# message auto-generated for no-merge-commit merge:
!30891 merge v2.10.0_fix_as_strided_bug into v2.10.0

fix as_strided bug

Created-by: zzhongmin
Commit-by: zzhongmin
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
调整as_strided校验逻辑,解决stride设置时报错不一致问题

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
as_strided校验逻辑对齐cuda、cpu
# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30891
2026-02-14 11:02:18 +08:00
liangchenghui 5bc5d6f011 Fix __rmod__ testcase.
Co-authored-by: liangchenghui<liangchenghui@huawei.com>



# message auto-generated for no-merge-commit merge:
!30905 merge fix___rmod___testcase_2.10.0 into v2.10.0

Fix __rmod__ testcase.

Created-by: liangchenghui
Commit-by: liangchenghui
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
## 现象
- 用例 `test_ops.py::test_dtypes___rmod___npu` 失败。
- 报错指向:前向实际可用的 dtype(`torch.int32`, `torch.int64`)未在 OpInfo 中登记。

## 责任模块
- 主要:`torch_npu.testing` 的 OpInfo 适配/注册逻辑(NPU 测试基础设施)
- 关联:上游 PyTorch 的 OpInfo dtype 定义(`__rmod__` 的默认 dtype 列表)

## 根因分析
- NPU 侧 `__rmod__` 前向对 `int32/int64` 实际可用,但测试侧 OpInfo 仍沿用上游默认 dtype 列表,未包含这两种整型。
- NPU 测试适配层对 OpInfo 的 `supported_dtypes()` 直接透传 `self.dtypes`,导致前向实际能力与登记信息不一致。

## 解决方案
### 已实施(配置驱动)
- 在 `torch_npu/testing/__init__.py` 中引入配置驱动的 dtype 扩展:
  - 新增 `torch_npu/testing/npu_opinfo_dtypes.py`,按 op 维护额外 dtype。
  - `supported_dtypes()` 读取配置并合并,避免硬编码。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
修改已有测试用例。

# 【CheckList】

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30905
2026-02-13 18:01:46 +08:00
pta-robot 9450663576 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30880 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-12 23:01:26.

See merge request: Ascend/pytorch!30880
2026-02-13 14:09:40 +08:00
pta-robot 8d84100366 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30872 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-12 22:01:42.

See merge request: Ascend/pytorch!30872
2026-02-13 11:02:08 +08:00
huangyunlong2022 c7ea32e796 fix zero copy set device
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30773 merge 2.10zero into v2.10.0

fix zero copy set device

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

修复zero copy特性init_process_group前没有set device报错问题

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30773
2026-02-12 21:50:11 +08:00
pta-robot 66d8a55767 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30848 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-12 16:01:34.

See merge request: Ascend/pytorch!30848
2026-02-12 19:55:47 +08:00
pta-robot fabb83d95e Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30822 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-11 22:01:32.

See merge request: Ascend/pytorch!30822
2026-02-12 16:02:12 +08:00
SCh_zx 663b21efac fix mem_get_info
Co-authored-by: SCh_zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!30839 merge v2.10.0 into v2.10.0

fix mem_get_info

Created-by: SCh_zx
Commit-by: SCh_zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [x] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改在mem_get_info中对_get_device_index调用,使其对齐原生PyTorch

# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30839
2026-02-12 15:52:52 +08:00
xuzhenhua2025 cef9936cff fix: process compile_fx options
Co-authored-by: xuzhenhua2025<xuzhenhua4@huawei.com>



# message auto-generated for no-merge-commit merge:
!30805 merge v2.10.0 into v2.10.0

fix: process compile_fx options

Created-by: xuzhenhua2025
Commit-by: xuzhenhua2025
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
对compile_fx接口options字典参数空值进行处理,并补充用例。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
在test/dynamo/test_npugraph_ex.py中test_compile_fx用例增加options传参测试方法并用ut验证
```
[2026/02/11 20:49:48.865 GMT+08:00] ***** Total result:
[2026/02/11 20:49:48.865 GMT+08:00] exec ut dynamo/test_npugraph_ex success.
```

# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30805
2026-02-12 15:23:12 +08:00
kita-ikuyo 68c4ec1ec5 [fix] set core num to hccl thread when calling hccl operators
Co-authored-by: Chukun Wang<wangchukun@huawei.com>



# message auto-generated for no-merge-commit merge:
!30747 merge v2.10.0 into v2.10.0

[fix] set core num to hccl thread when calling hccl operators

Created-by: kita-ikuyo
Commit-by: Chukun Wang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

问题背景:当前使用单算子控核接口存在hccl算子调用无法控住核的情况。原理是hccl算子依赖从线程变量中取出核数,而只有计算算子会触发线程变量刷新。如果hccl算子调用前没有前置的计算算子,单算子控核api下发的核数并不会在hccl算子上实际生效。

问题修改:在hccl算子下发过程中新增对线程变量的更新。

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

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

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

hccl算子无前置计算算子场景,核数可以正确配置,hccl获取的核数正确。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30747
2026-02-12 14:12:02 +08:00
pta-robot 1c62433530 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30813 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-11 21:01:31.

See merge request: Ascend/pytorch!30813
2026-02-12 09:11:10 +08:00
pta-robot 81ca42df4c Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30789 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-11 16:01:35.

See merge request: Ascend/pytorch!30789
2026-02-11 19:18:01 +08:00
huangyunlong2022 5e8157bc18 remove over-adaptation for to
Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30357 merge 2.10to into v2.10.0

remove over-adaptation for to

Created-by: huangyunlong2022
Commit-by: huangyunlong2022
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:
删除to过适配,对于to.dtype中double转float在_to_copy提通过判断dtype不为空,device,layout为空进行类型转换,之前_npu_dtype_cast通过_to_copy中empty,copy_实现

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30357
2026-02-11 18:18:18 +08:00
gleaming-spark cd5f447d54 [fix]add socversion check for aclrtMallocHostWithCfg
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30727 merge v2.10.0_soc_version into v2.10.0

[fix]add socversion check for aclrtMallocHostWithCfg

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
Ascend910_95 soc暂不支持通过aclrtMallocHostWithCfg接口实现va一致性,故添加soc version约束

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30727
2026-02-11 17:42:40 +08:00
fu-hao-huawei 373433d62a patch call_id for EventVariable
Co-authored-by: fu-hao-huawei<fuhao16@huawei.com>



# message auto-generated for no-merge-commit merge:
!30757 merge v2.10.0_id_event into v2.10.0

patch call_id for EventVariable

Created-by: fu-hao-huawei
Commit-by: fu-hao-huawei
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

event被继承为torch的event对象后,后续对在compile流程中event对象会变为EventVariable,而EventVariable没有id函数,后续使用id(Event)的地方会报错,
此次修改为EventVariable patch了id函数

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

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

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

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30757
2026-02-11 17:31:24 +08:00
pta-robot 8590a67cec Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30720 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-10 12:01:41.

See merge request: Ascend/pytorch!30720
2026-02-11 11:43:40 +08:00
SCh_zx 8325d5cb79 add err for set_deterministic_level
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!30710 merge v2.10.0 into v2.10.0

add err for set_deterministic_level

Created-by: SCh_zx
Commit-by: SCh-zx
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改torch_npu.npu.set_deterministic_level配置为非预期值时的行为,从输出warning级日志,改为报错

# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30710
2026-02-11 10:25:10 +08:00
gleaming-spark 75fb22448d [test] pin_memory support PCIE_through HVA UT
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30724 merge cherry-pick-mr-30721-1770704836796-auto into v2.10.0

[test] pin_memory support PCIE_through HVA UT

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
环境变量设置为os.environ["PYTORCH_NPU_ALLOC_CONF"] = "pinned_mem_register:True"后,测试pin_memory功能是否正常

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30724
2026-02-10 17:43:44 +08:00
kita-ikuyo c167f69aa6 Revert "[fix] set core num to hccl thread when calling hccl operators"
Co-authored-by: Chukun Wang<wangchukun@huawei.com>



# message auto-generated for no-merge-commit merge:
!30704 merge v2.10.0 into v2.10.0

Revert "[fix] set core num to hccl thread when calling hccl operators"

Created-by: kita-ikuyo
Commit-by: Chukun Wang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30704
2026-02-10 15:33:23 +08:00
pta-robot b563427447 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30696 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-10 11:28:55.

See merge request: Ascend/pytorch!30696
2026-02-10 15:20:00 +08:00
kongdeshuo ea50bbcaf1 del unstable case
Co-authored-by: kongdeshuo<1670690897@qq.com>



# message auto-generated for no-merge-commit merge:
!30689 merge v2.10.0 into v2.10.0

del unstable case

Created-by: kongdeshuo
Commit-by: kongdeshuo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

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

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

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

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30689
2026-02-10 15:14:54 +08:00
pta-robot 927fde64a9 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30577 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-06 12:01:40.

See merge request: Ascend/pytorch!30577
2026-02-10 11:17:27 +08:00
pta-robot b626897b91 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30673 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-09 22:01:22.

See merge request: Ascend/pytorch!30673
2026-02-10 10:17:04 +08:00
sunhaolun 90a01d6334 add_random_op
Co-authored-by: sunhaolun<sunhaolun3@huawei.com>



# message auto-generated for no-merge-commit merge:
!30655 merge v2.10.0 into v2.10.0

add_random_op

Created-by: sunhaolun
Commit-by: sunhaolun
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
通过对原生rng实现代码打patch的方法注册npu设备的实现。主要主要针对\torch\_prims\rng_prims.py 中的philox_rand_offset,philox_rand_offset_meta,register_philox_rand,register_run_and_save_rng_state_op,register_run_with_rng_state_op这些代码。其中_philox_rand 此函数原生调用中不传入设备类型,修改为传入设备npu。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
编写UT进行测试,可以保证在固定随机种子的情况下eager,inductor可以得到相同的结果(如有需要可提供截图)

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30655
2026-02-10 10:05:21 +08:00
ascend-robot 678efd8107 [fix]profiler db analyse optimize
Co-authored-by: hehongzhe<935062458@qq.com>



# message auto-generated for no-merge-commit merge:
!30649 merge jx10 into v2.10.0

[fix]profiler db analyse optimize

Created-by: hhz0
Commit-by: hehongzhe
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

在db解析的情况下node_launch与enqueue匹配或是torchop与enqueue匹配的时候,进行双指针匹配,但是匹配过程中,没有对未匹配上的场景进行判断,导致双指针失效。

本pr新增了对未匹配场景的指针更新与break逻辑。

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

不涉及

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

不涉及

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

对于同一份数据,修改前后,db解析的时长有明显变短

![image.png](https://raw.gitcode.com/user-images/assets/7404318/a64f8ba9-eb79-4a94-91c4-237034ac9343/image.png 'image.png')

![image.png](https://raw.gitcode.com/user-images/assets/7404318/bd8d9cf1-c642-4f85-8df7-099faf22369d/image.png 'image.png')


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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30649
2026-02-10 10:04:38 +08:00
zhujiaxing1029 6e80df47ff Suppress error printing for the pta in the python interactive environment.
Co-authored-by: zhujiaxing<zhujiaxing2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30381 merge v2.10.0 into v2.10.0

Suppress error printing for the pta in the python interactive environment.

Created-by: zhujiaxing1029
Commit-by: zhujiaxing
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
/kind feature


**What does this PR do / why do we need it**:
Suppress error printing for the pta in the python interactive environment.

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30381
2026-02-10 10:04:20 +08:00
kongdeshuo 005262c8aa add_acl_cal_log
Co-authored-by: kongdeshuo<1670690897@qq.com>



# message auto-generated for no-merge-commit merge:
!30592 merge v2.10.0 into v2.10.0

add_acl_cal_log

Created-by: kongdeshuo
Commit-by: kongdeshuo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

增加对acl接口调用入参的打印
根据黑白名单,对指定接口进行打印;
不指定黑白名单,默认 屏蔽 Query、Event类接口

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

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

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

不设置黑白名单,默认打印除 Query、Event的接口
![image.png](https://raw.gitcode.com/user-images/assets/7404318/84aa3ea9-5cd3-402a-9db6-4b4b4be48ae8/image.png 'image.png')

设置黑白名单:export TORCH_NPU_LOGS_FILTER="+aclmdlRICaptureGetInfo”,只打印该接口调用:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/4548a274-f8d0-4c8f-8892-8267309249d9/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30592
2026-02-09 21:37:45 +08:00
ascend-robot 5956d16323 [feat]msmonitor support async_mode
Co-authored-by: hehongzhe<935062458@qq.com>



# message auto-generated for no-merge-commit merge:
!30633 merge xq110 into v2.10.0

[feat]msmonitor support async_mode

Created-by: hhz0
Commit-by: hehongzhe
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

动态profiling获取async_mode时判断场景,支持dyno场景

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

不涉及,在msmonitor资料中体现

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

不涉及

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

![image.png](https://raw.gitcode.com/user-images/assets/7404318/f600f223-2739-42c8-9bca-ddb6c224f0e3/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30633
2026-02-09 16:42:06 +08:00
nomiz 16247cae4a add TORCH_NPU_LOGS_FILTER
Co-authored-by: nomiz<1606135114@qq.com>



# message auto-generated for no-merge-commit merge:
!30583 merge v2.10.0 into v2.10.0

add TORCH_NPU_LOGS_FILTER

Created-by: nomiz
Commit-by: nomiz
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新


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

新增环境变量TORCH_NPU_LOGS_FILTER,对日志进行过滤
实现黑白名单功能 “+”: 只打印白名单内容;“-”:不打印黑名单内容,其他保留; 无该环境变量:全部打印
LogContext.cpp 
新增环境变量解析和过滤逻辑
Logger.cpp
日志打印前实现过滤

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

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

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

新增环境变量已新增UT测试用例
![image.png](https://raw.gitcode.com/user-images/assets/7404318/642aa3c7-e7f9-42d9-8e96-14b8b451044f/image.png 'image.png')

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30583
2026-02-09 15:29:54 +08:00
pta-robot 962c2ef367 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30611 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-06 22:01:37.

See merge request: Ascend/pytorch!30611
2026-02-09 14:40:49 +08:00
kita-ikuyo f0dd33414d [fix] set core num to hccl thread when calling hccl operators
Co-authored-by: Chukun Wang<wangchukun@huawei.com>



# message auto-generated for no-merge-commit merge:
!30569 merge v2.10.0 into v2.10.0

[fix] set core num to hccl thread when calling hccl operators

Created-by: kita-ikuyo
Commit-by: Chukun Wang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

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

问题背景:当前使用单算子控核接口存在hccl算子调用无法控住核的情况。原理是hccl算子依赖从线程变量中取出核数,而只有计算算子会触发线程变量刷新。如果hccl算子调用前没有前置的计算算子,单算子控核api下发的核数并不会在hccl算子上实际生效。

问题修改:在hccl算子下发过程中新增对线程变量的更新。

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

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

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

hccl算子无前置计算算子场景,核数可以正确配置,hccl获取的核数正确。

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30569
2026-02-09 12:35:17 +08:00
cuiduo 9eb7b28094 API Conflict Fix
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30597 merge v2.10.0 into v2.10.0

API Conflict Fix

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> API问题修复,修改trace_rule文件

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 变更内容已适配看护

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30597
2026-02-07 21:40:21 +08:00
gleaming-spark 47dc37ca9b pin_memory support PCIE_through HVA
Co-authored-by: geyi<geyi2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30209 merge v2.10.0_pin_pcie into v2.10.0

[feat] pin_memory support PCIE_through HVA

Created-by: gleaming-spark
Commit-by: geyi
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
1、将内存申请接口从aclrtMallocHost改为aclrtMallocHostWithCfg,并通过开关控制是否进行host register
2、对接口功能进行版本兼容性处理,保证向下兼容。

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
涉及,pr中已修改https://gitcode.com/Ascend/pytorch/pull/30210

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

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
使用现有的pin_memory()接口用例覆盖即可,即:
1、创建普通的cpu tensor,调用pin_memory()接口无异常;
2、调用is_pinned()接口:普通cpu tensor返回False;pin tensor返回True
![image.png](https://raw.gitcode.com/user-images/assets/7404318/f37dc07b-5730-472f-8828-93e02b57b57f/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30209
2026-02-06 17:28:54 +08:00
pta-robot 4b36b00495 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30522 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-04 22:01:37.

See merge request: Ascend/pytorch!30522
2026-02-06 17:23:07 +08:00
gcw_Dgfy2aKk b460dfb95c request for hccl qos
Co-authored-by: gcw_Dgfy2aKk<dujunjie2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30435 merge Hccl_Qos_v2.10.0 into v2.10.0

request for hccl qos

Created-by: gcw_Dgfy2aKk
Commit-by: gcw_Dgfy2aKk
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接
SR20260122924103
https://portal.libing.huawei.com/apps/21/6900108a-78fd-4741-bd29-39eae2207009?otherQuery=%257B%2522designerDesktopPath%2522%253A%2522featureRequirement%2522%252C%2522featureRequirementCon%2522%253A%257B%2522SF%2522%253A%257B%2522fields%2522%253A%257B%257D%252C%2522filterData%2522%253A%257B%257D%257D%252C%2522All%2522%253A%257B%2522fields%2522%253A%257B%257D%252C%2522filterData%2522%253A%257B%257D%257D%252C%2522searchValue%2522%253A%2522SR20260122924103%2522%257D%252C%2522rid%2522%253A%25222096456495%2522%257D
- [x] 需求

# 【修改方案】
透传hccl qos参数给HCCL

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
执行 python test/distributed/test_options.py  -k test_options_hccl_sdma_qos_wrong_type
执行结果:
	执行通过, 无报错

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30435
2026-02-06 17:20:49 +08:00
pta-robot b75c9d85f2 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30450 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-03 16:01:28.

See merge request: Ascend/pytorch!30450
2026-02-06 11:55:26 +08:00
Dring fae0ce9815 [2.10.0][feature]support Lazy aclsetcompileopt
Co-authored-by: Dring<17737727613@163.com>



# message auto-generated for no-merge-commit merge:
!30472 merge v2.10.0 into v2.10.0

[2.10.0][feature]support Lazy aclsetcompileopt

Created-by: Dring
Commit-by: Dring
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [✓ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、	在PTA中新增LazyAclopSet 管理类,用于实现ACL编译选项的延迟设置与批量提交。具体修改包括:
1)在新类中提供 LazyAclSetCompileopt 方法,用于在初始化阶段暂存所有环境变量解析出的编译选项;
2)在算子实际运行前(OpCommand::Run 中)调用 SetCompileopt 方法,将暂存的选项一次性设置到ACL运行时环境;
2、	将 EnvVariables.cpp 中所有通过 REGISTER_OPTION_HOOK 注册的ACL选项设置调用,从直接调用 AclSetCompileopt 统一替换为调用 LazyAclSetCompileopt
3、	通过互斥锁保证线程安全,并仅在特定初始化模式下启用,以兼容现有行为
![image.png](https://raw.gitcode.com/user-images/assets/7404318/4b98bf46-dd55-473e-bda3-81843d06e528/image.png 'image.png')
# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
1、算子编译选项设置后,算子实际调用前,进入lazyinit---对应观察,日志里没有aclsetcompileopt调用,后台没有算子编译多进程
2、算子编译时,默认算子编译选项也生效,设置的算子编译选项为设置的值而非默认值---手动配置可以覆盖默认值,也可以新增,同时可以多次配置,日志里在aclop调用前最后的配置项一定要和手动配置的一样,同时要保证配置的顺序和脚本手动配置的顺序一致,另外观察下默认配置值和手动配置值的顺序和修改之前一致
3、aclop算子调用后,配置选项立即生效
4、第一次算子调用后,再次设置算子编译选项,算子直接编译且为设置值

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

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30472
2026-02-06 11:51:56 +08:00
leland17 3527f87468 feat(autocast): 支持float32作为自动混合精度计算的数据类型
Co-authored-by: leland17<lileliao@foxmail.com>



# message auto-generated for no-merge-commit merge:
!30560 merge v2.10.0 into v2.10.0

feat(autocast): 支持float32作为自动混合精度计算的数据类型

Created-by: leland17
Commit-by: leland17
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

issue:[支持float32作为自动混合精度计算的数据类型](https://gitcode.com/Ascend/pytorch/issues/1537)

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
当前现状with autocast(device="npu", dtype=torch.float32)暂时不支持按照float32的精度获取结果。同liwei有过详细的讨论方案,并且确定了如下的支持思路
在autocast_utils.py中支持float32的数据类型支持。

# 【资料变更】
>  不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
```bash
cd ${pytorch}/test &&  python -m unittest test_autocast.TestAutocastNPUfp32
```
新增4个用例场景,验证暂无问题	
![image.png](https://raw.gitcode.com/user-images/assets/7404318/ae524921-b8cd-4790-b2c2-6ef636ca7229/image.png 'image.png')

整体test_autocast.py的用例执行结果
![image.png](https://raw.gitcode.com/user-images/assets/7404318/c4ba297d-8d9d-446a-93d7-f6031525dde3/image.png 'image.png')

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30560
2026-02-06 10:59:11 +08:00
mihudan 1a76e355e1 [docs] 增加npugraph_ex.register_replacement的scalar_workaround和skip_duplicates参数
Co-authored-by: wangkai<wangkai579@huawei.com>



# message auto-generated for no-merge-commit merge:
!30530 merge v2.10.0 into v2.10.0

[docs] 增加npugraph_ex.register_replacement的scalar_workaround和skip_duplicates参数

Created-by: mihudan
Commit-by: wangkai
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求


# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
```
def register_replacement(search_fn, replace_fn, example_inputs, trace_fn=fwd_only, extra_check=_return_true,
 	                          search_fn_pattern=None, scalar_workaround=None, skip_duplicates=False):
 	     import torchair
 	     return torchair.patterns.pattern_pass_manager.register_replacement(search_fn, replace_fn, example_inputs,
 	                                                                        trace_fn=trace_fn, extra_check=extra_check,
 	                                                                        search_fn_pattern=search_fn_pattern,
 	                                                                        scalar_workaround=scalar_workaround, 
 	                                                                        skip_duplicates=skip_duplicates)
```
                                                                            
torchair已增加参数,同步修改即可

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

# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
增加npugraph_ex.register_replacament的scalar_workaround和skip_duplicates参数口

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
新增接口在torchair有用例看护,PR:https://gitcode.com/Ascend/torchair/pull/2551
```
Ran 30 tests in 82.839s
OK (skipped=1)
```
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常



See merge request: Ascend/pytorch!30530
2026-02-06 09:13:48 +08:00
sunhaolun 8bf8dbfce0 api_trace_rule_changes
Co-authored-by: sunhaolun<sunhaolun3@huawei.com>



# message auto-generated for no-merge-commit merge:
!30546 merge v2.10.0 into v2.10.0

api_trace_rule_changes

Created-by: sunhaolun
Commit-by: sunhaolun
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
修改trace_rule.py文件,确保NPU部分API在图模式下,入图行为与标杆一致。修改set-rng_state函数处理多余算子以及torch.npu.current_device白名单处理以确保算子生成fx图与标杆一致。

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
新增测试文件test/_inductor/test_npu_current_device.py,参与ut看护

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30546
2026-02-05 19:54:44 +08:00
zhaoyu65 a32bcd50a0 torch_npu.npu.Event inherits torch.Event, add GetPerStreamQueue in NPUGuardImpl's function
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!30506 merge v2.10.0-event_stream into v2.10.0

torch_npu.npu.Event inherits torch.Event, add GetPerStreamQueue in NPUGuardImpl's function

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: # 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求 event/stream等接口对齐社区接入逻辑
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
1、将torch_npu.npu.Event修改为torch.Event的子类,和pytorch原生代码行为保持一致;
2、实现NPUGuardImpl::uncheckedGetDevice();
3、NPUGuardImpl::block()、destroyEvent()支持PerStreamQueue,参考NPUEvent;
4、优化NPUGuardImpl::synchronizeEvent();

# 【资料变更】
不涉及

# 【接口变更】
不涉及

# 【功能验证】
1、使用isinstance、issubclass方法校验torch_npu.npu.Event和torch.Event的关系;
2、验证单流单queue场景是否正常;

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30506
2026-02-05 17:11:17 +08:00
cuiduo 0d69dddcd3 meta_check
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30461 merge v2.10.0 into v2.10.0

meta_check

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
>1. 修复resize_as_和squeeze_算子的unknow format type问题,新增fake tensor校验以绕过过适配流程。
>2.BaseSchedulerNode新增校验,避免非标准节点错误。

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 新增测试文件test/_inductor/test_resize_as和test_squeeze_.py,参与ut看护

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30461
2026-02-05 14:21:02 +08:00
liujunzhu 654ccd8399 add page size check for ipc event
Co-authored-by: liujunzhu<liujunzhu@huawei.com>



# message auto-generated for no-merge-commit merge:
!30493 merge v2.10.0 into v2.10.0

add page size check for ipc event

Created-by: liujunzhu
Commit-by: liujunzhu
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
IPC Event当前不支持页表大小(PageSize)为64K的环境(驱动会报错),需要CANN和HDK适配。当前先在torch_npu规避,PageSize为64K的环境不使用IPC Event。
页表大小确认:执行`getconf PAGE_SIZE`命令,4K环境返回4096,64K环境返回65536。
PR的具体实现:调用`sysconf(_SC_PAGE_SIZE)`,如果返回4096则认为支持IPC Event,否则认为不支持。


# 【资料变更】
不涉及

# 【接口变更】
不涉及

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

测试方法:执行已有IPC Event跨进程用例。
预期结果:4K和64K环境执行正常,4K环境打印`IsSupportIpcEvent return true.`日志,64K环境打印`IsSupportIpcEvent return false because page size %ld is not supported.`日志。

4K环境自验:
```
# grep IsSupportIpcEvent run.log 
[DEBUG] APP(7748,python):2026-02-04-14:11:29.932.995 [log_inner.cpp:87]7748 build/CMakeFiles/torch_npu.dir/compiler_depend.ts:operator():396: "[PTA]:"IsSupportIpcEvent return true.""
[DEBUG] APP(7815,python):2026-02-04-14:11:35.437.574 [log_inner.cpp:87]7815 build/CMakeFiles/torch_npu.dir/compiler_depend.ts:operator():396: "[PTA]:"IsSupportIpcEvent return true.""
```

64K环境自验:
```
# python test_share_npu1.py
发送方发送 tensor = tensor([1., 1., 1., 1., 1.], device='npu:0')
接收方收到 tensor = tensor([1., 1., 1., 1., 1.], device='npu:0')
```
64K环境Debug日志:
```
# grep IsSupportIpcEvent run.log 
[DEBUG] APP(428000,python):2026-02-04-20:20:20.125.537 [log_inner.cpp:87]428000 build/CMakeFiles/torch_npu.dir/compiler_depend.ts:operator():369: "[PTA]:"IsSupportIpcEvent return false because page size 65536 is not supported.""
```

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30493
2026-02-05 11:43:46 +08:00
cuiduo f6ede4254f API_trace_relu changes
Co-authored-by: cuiduo<cuiduo1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30395 merge v2.10.0 into v2.10.0

API_trace_relu changes

Created-by: cuiduo
Commit-by: cuiduo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [x] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 修改trace_rule.py文件,确保NPU部分API在图模式下,入图行为与标杆一致。修改set-rng_state函数处理多余算子以及torch.npu.current_device白名单处理以确保算子生成fx图与标杆一致。

# 【资料变更】
> 不涉及

# 【接口变更】
> 不涉及

# 【功能验证】
> 新增测试文件test/_inductor/test_npu_current_device.py,参与ut看护

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

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!30395
2026-02-05 10:27:41 +08:00
xuzhenhua2025 137e48a4c1 Provides npugraph_ex APIs for user-defined backends and passes
Co-authored-by: xuzhenhua2025<xuzhenhua4@huawei.com>



# message auto-generated for no-merge-commit merge:
!30367 merge v2.10.0 into v2.10.0

fix: npugraph_ex补充用户自定义backend和自定义pass缺失的接口

Created-by: xuzhenhua2025
Commit-by: xuzhenhua2025
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> (如有)请关联需求文档/issue链接

- [ ] 需求
- [x] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
1. npugraph_ex补充用户自定义backends接口
2. npugraph_ex补充用户自定义passes相关接口
	2.1 补充注册replacement接口
    2.2 补充自定义pass流record接口

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

已在新版本资料中补充接口说明,资料配套发布。

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

1. 补充user-defined backends接口
```python
def my_backend(gm: torch.fx.GraphModule, example_inputs):
    compiler = torch.npu.npugraph_ex.compile_fx()
    return aot_module_simplified(gm, example_inputs, fw_compiler=compiler)
 ```
2. 补充user-defined passes接口
```python
torch.npu.npugraph_ex.register_replacement(
    search_fn=search_fn,
    replace_fn=replace_fn,
    example_inputs=(input_tensor(), input_tensor(), kwargs_tensor()),
    extra_check=extra_check
)
```
```python
# record and wait should be used in pairs
with torch.npu.npugraph_ex.scope.npu_stream_switch('1'):
    # ...
    record = torch.npu.npugraph_ex.ops.record()
    # ...
torch.npu.npugraph_ex.ops.wait([record])
```
# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

新增测试用例看护:
1. compile_fx接口用例:
/test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_compile_fx
2. 自定义pass接口用例:
/test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_register_replacement
/test/dynamo/test_npugraph_ex.TestNpuGraphEx.test_record_and_wait
![image.png](https://raw.gitcode.com/user-images/assets/7404318/d383d445-2324-4b7f-9b4b-1c1935a64f81/image.png 'image.png')
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常

See merge request: Ascend/pytorch!30367
2026-02-04 14:36:39 +08:00
pta-robot 197dc8fa1a Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30486 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-03 22:01:39.

See merge request: Ascend/pytorch!30486
2026-02-04 09:19:36 +08:00
pta-robot 43eb90f964 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30167 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-01-28 22:01:29.

See merge request: Ascend/pytorch!30167
2026-02-03 20:06:20 +08:00
SCh_zx 8b5edbd706 add set_deterministic_level
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!30385 merge v2.10.0 into v2.10.0

add set_deterministic_level

Created-by: SCh_zx
Commit-by: SCh-zx
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:
新增接口用于配置强一致性

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30385
2026-02-03 17:34:09 +08:00
SoraAzzz 345d6400e0 [v2.10.0][Profiler]rename block dim to block num
Co-authored-by: xieanran<694099604@qq.com>



# message auto-generated for no-merge-commit merge:
!30412 merge v2.10.0 into v2.10.0

[v2.10.0][Profiler]rename block dim to block num

Created-by: SoraAzzz
Commit-by: xieanran
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task

/kind feature

**What does this PR do / why do we need it**:

rename blockdim to blocknum to adapte msprof revise
**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30412
2026-02-03 16:49:23 +08:00
liangsongwei 216dd00b2c [docs] add pull request template
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!30429 merge v2.10.0 into v2.10.0

[docs] add pull request template

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30429
2026-02-03 15:27:17 +08:00
pta-robot 977f4f35f4 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30425 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-03 12:01:34.

See merge request: Ascend/pytorch!30425
2026-02-03 15:18:15 +08:00
pta-robot f7a8ec31c7 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30406 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-02 21:01:27.

See merge request: Ascend/pytorch!30406
2026-02-02 22:34:58 +08:00
pta-robot d5614c95f8 Update op_plugin commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30366 merge v2.10.0 into v2.10.0

Update op_plugin commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-02-02 15:54:40.

See merge request: Ascend/pytorch!30366
2026-02-02 19:26:21 +08:00
zhaoyu65 22cbb72de5 record query event error and add device_capability cache
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!30266 merge v2.10.0-issue into v2.10.0

record query event error and add device_capability cache

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes [#1523](https://gitcode.com/Ascend/pytorch/issues/1523) 

**Special notes for your reviewers**:
1、torch_npu/csrc/distributed/ProcessGroupHCCL.cpp中currentLoopErrors变量名表达不准确,修改成checkErrors的;
2、torch_npu.npu.get_device_capability的告警信息拼写错误,cann->cann。
3、torch_npu.npu.get_device_capability把匹配成功的信息保存下来,提高性能。
4、torch_npu/csrc/core/npu/CachingHostAllocator.cpp,增加注释说明通过try、catch捕获event query失败的原因;
5、torch_npu/csrc/core/npu/CachingHostAllocator.cpp,catch的runtime错误信息补充到plog日志里;

See merge request: Ascend/pytorch!30266
2026-02-02 17:42:42 +08:00
daifu1234567 b097738135 [2.10.0]fix dropout
Co-authored-by: DaiFu<daifu2@huawei.com>



# message auto-generated for no-merge-commit merge:
!30280 merge v2.10.0 into v2.10.0

[2.10.0]fix dropout

Created-by: daifu1234567
Commit-by: DaiFu
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30280
2026-02-02 14:39:58 +08:00
kkjocker 9ec2d2c1d0 【inductor】Temporarily close some inductor ci tests, accelarate ci access control
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30305 merge v2.10.0 into v2.10.0

【inductor】Temporarily close some inductor ci tests, accelarate ci access control

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30305
2026-01-31 16:36:54 +08:00
glf2016 24a2c556a0 del 32 allocator
Co-authored-by: guanlongfeng<guanlongfeng1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30262 merge cherry-pick-mr-30020-1769753724017-auto into v2.10.0

del 32 allocator

Created-by: glf2016
Commit-by: guanlongfeng
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30262
2026-01-31 09:36:12 +08:00
SCh_zx b67ee27932 change compatible impl name
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!30208 merge v2.10.0 into v2.10.0

change compatible impl name

Created-by: SCh_zx
Commit-by: SCh-zx
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30208
2026-01-30 18:06:58 +08:00
wangzhenwu eeb6827ae3 add datatypes for HCCLUtils
Co-authored-by: wangzhenwu7<5ge@live.com>



# message auto-generated for no-merge-commit merge:
!30222 merge v2.10.0_type into v2.10.0

add datatypes for HCCLUtils

Created-by: wangzhenwu
Commit-by: wangzhenwu7
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30222
2026-01-30 16:26:34 +08:00
zqwenn 401dfddfb6 [fix] fsdp patch fix all_gather_copy_in.default unsupported issue
Co-authored-by: zqwenn<zhangqiongwen@huawei.com>



# message auto-generated for no-merge-commit merge:
!30155 merge v2.10.0_fsdp_patch_fix into v2.10.0

[fix] fsdp patch fix all_gather_copy_in.default unsupported issue

Created-by: zqwenn
Commit-by: zqwenn
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30155
2026-01-30 14:20:17 +08:00
culechan 6fa0524c56 pta supports to create nested tensor
Co-authored-by: chenshuai<chenshuai81@huawei.com>



# message auto-generated for no-merge-commit merge:
!30227 merge cherry-pick-mr-30193-1769685797182-auto into v2.10.0

pta supports to create nested tensor

Created-by: culechan
Commit-by: chenshuai
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30227
2026-01-30 09:38:38 +08:00
kkjocker dd84d7f26a 【inductor】fix inductor ci bug
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30175 merge v2.10.0_main into v2.10.0

【inductor】fix inductor ci bug

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:
修复inductor ci问题

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30175
2026-01-29 20:55:46 +08:00
yu_liangbin a007d587cc [profiler-2.10]profiler添加解析完成标志文件&level1场景支持aicore_none开关
Co-authored-by: yu-liang-bin<y1416490440@163.com>



# message auto-generated for no-merge-commit merge:
!30124 merge feature-profiler-2.10 into v2.10.0

[profiler-2.10]profiler添加解析完成标志文件&level1场景支持aicore_none开关

Created-by: yu_liangbin
Commit-by: yu-liang-bin
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:
1. profiler解析完成后只有日志打屏,华为云用户需要一个解析完成的文件来确定是否解析完成;
2. profiler level1/level2场景下aicore_metrics默认值为pipeutilization, level1/level2场景下也应该支持不采集aicore_metrics数据;

**Which issue(s) this PR fixes**:
1. 添加profiler解析完成标志文件;
2. profiler level1/level2场景下aicore_metrics能支持不采集aicore_metrics数据;
3. 补充生成解析完成标志文件的UT

验证结果:
测试用例全部通过:
![image.png](https://raw.gitcode.com/user-images/assets/7404318/e593cd86-018b-4007-a02c-8f6fb9a59e3b/image.png 'image.png')

<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30124
2026-01-29 20:13:24 +08:00
lihui488 07d3542cba fix head path
Co-authored-by: lihui<lihui488@huawei.com>



# message auto-generated for no-merge-commit merge:
!30118 merge v2.10.0 into v2.10.0

fix head path

Created-by: lihui488
Commit-by: lihui
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug


**What does this PR do / why do we need it**:
修改rt.h的路径

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30118
2026-01-29 17:01:16 +08:00
liangsongwei 207b67a58c [feature] setup.py add torchnpugen
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!30104 merge v2.10.0 into v2.10.0

[feature] setup.py add torchnpugen

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30104
2026-01-29 14:31:28 +08:00
SCh_zx 48250ff21c support STRONG_CONSISTENCY
Co-authored-by: SCh-zx<1325467101@qq.com>



# message auto-generated for no-merge-commit merge:
!29889 merge master into v2.10.0

support STRONG_CONSISTENCY

Created-by: SCh_zx
Commit-by: SCh_zx;SCh-zx
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29889
2026-01-29 09:10:50 +08:00
ascend-robot 0017cbd2be Skip when device name is Ascend910B4
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>
Co-authored-by: yuhaiyan<yuhaiyan8@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30130 merge cherry-pick-mr-30129-1769583178326-auto into v2.10.0

Skip when device name is Ascend910B4

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30130
2026-01-28 18:00:33 +08:00
kkjocker e52a8a79df fix bug in transfer_to_npu
Co-authored-by: kkjocker<hexuanyu1@huawei.com>



# message auto-generated for no-merge-commit merge:
!30005 merge v2.10.0 into v2.10.0

fix bug in transfer_to_npu

Created-by: kkjocker
Commit-by: kkjocker
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:
原本有些代码和torch.jit.script不适配,使用try except方式使能torch.jit.script后会引入别的bug,本pr通过use_jit_script的方式来使能torch.jit.script
> import torch_npu
> from torch_npu.utils import _dynamo
> _dynamo.use_jit_script = True
> from torch_npu.contrib import transfer_to_npu



**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30005
2026-01-28 17:34:57 +08:00
pta-robot d1a7b5ff63 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!30089 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-01-27 22:01:29.

See merge request: Ascend/pytorch!30089
2026-01-28 14:41:10 +08:00
liujunzhu d55db5dd2d add torch_npu._C._npu_getCurrentRawStreamNoWait()
Co-authored-by: liujunzhu<liujunzhu@huawei.com>



# message auto-generated for no-merge-commit merge:
!29900 merge v2.10.0 into v2.10.0

add torch_npu._C._npu_getCurrentRawStreamNoWait()

Created-by: liujunzhu
Commit-by: liujunzhu
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task

/kind feature


**What does this PR do / why do we need it**:
现有的`torch_npu._C._npu_getCurrentRawStream()`由于清空taskqueue导致性能比较差,所以添加不清空taskqueue的`torch_npu._C._npu_getCurrentRawStreamNoWait()`接口。
由于新增的`torch_npu._C._npu_getCurrentRawStreamNoWait(device)`接口不清空taskqueue,如果既使用返回的`aclrtStream`下发任务又使用torch_npu的taskqueue下发任务,则会引起保序问题,需由用户确保只使用其中的一种下发方式(如果混用需确保无数据依赖且性能不敏感)。


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29900
2026-01-28 10:23:43 +08:00
MrMC- 85e9a333fb rename 910_95->950
Co-authored-by: MrMC-<shiqunze@h-partners.com>



# message auto-generated for no-merge-commit merge:
!30029 merge add950 into v2.10.0

rename 910_95->950

Created-by: MrMC-
Commit-by: MrMC-
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30029
2026-01-27 15:16:14 +08:00
pta-robot 3a30714dc1 Update torchair commit id
Co-authored-by: pta-robot<pta_robot@163.com>



# message auto-generated for no-merge-commit merge:
!29958 merge v2.10.0 into v2.10.0

Update torchair commit id

Created-by: pta-robot
Commit-by: pta-robot
Merged-by: ascend-robot
Description: Commited by @pta-robot at 2026-01-23 10:14:53.

See merge request: Ascend/pytorch!29958
2026-01-27 14:12:15 +08:00
liangsongwei 0861f1374c [feature] add torchnpugen packages
Co-authored-by: liangsongwei<liangsongwei@huawei.com>



# message auto-generated for no-merge-commit merge:
!30033 merge v2.10.0 into v2.10.0

[feature] add torchnpugen packages

Created-by: liangsongwei
Commit-by: liangsongwei
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!30033
2026-01-26 22:08:41 +08:00
tongleicom a9186d5c86 check the size of tensors for alltoall
Co-authored-by: tonglei<tonglei10@huawei.com>



# message auto-generated for no-merge-commit merge:
!29942 merge v2.10.0 into v2.10.0

check the size of tensors for alltoall

Created-by: tongleicom
Commit-by: tonglei
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29942
2026-01-26 19:11:59 +08:00
ascend-robot a01560d77c Fixed test_modules_can_be_imported
Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com>



# message auto-generated for no-merge-commit merge:
!29975 merge v2.10.0 into v2.10.0

Fixed test_modules_can_be_imported

Created-by: yuhaiyan
Commit-by: yuhaiyan
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature


**What does this PR do / why do we need it**:


**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29975
2026-01-26 09:29:07 +08:00
zhaoyu65 d6010cffed implement torch_npu.npu.get_device_capability()
Co-authored-by: zhaoyu<nanzhaogang@qq.com>



# message auto-generated for no-merge-commit merge:
!29918 merge v2.10.0-capability into v2.10.0

implement torch_npu.npu.get_device_capability()

Created-by: zhaoyu65
Commit-by: zhaoyu
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
/kind feature


**What does this PR do / why do we need it**:
支持环境变量配置设备capability,用于和特定版本cuda对标。该配置不提供默认值,用户未配置情况下仍返回None,在告警信息中说明可通过对应环境变量配置。

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29918
2026-01-23 18:13:10 +08:00
xuzhenhua2025 04d917ad1b Decouple npugraph_ex and torchair-ge
Co-authored-by: xuzhenhua2025<xuzhenhua4@huawei.com>



# message auto-generated for no-merge-commit merge:
!29934 merge v2.10.0 into v2.10.0

Decouple npugraph_ex and torchair-ge

Created-by: xuzhenhua2025
Commit-by: xuzhenhua2025
Merged-by: ascend-robot
Description: <!--  Thanks for sending a pull request! 
-->

**What type of PR is this?**
/kind feature


**What does this PR do / why do we need it**:
The cache compile function supports decoupling of npugraph_ex and torchair-ge.
Use an independent configuration parameter to enable the cache compile function of npugraph_ex.

**Which issue(s) this PR fixes**:
<!-- 
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewers**:




See merge request: Ascend/pytorch!29934
2026-01-23 15:06:04 +08:00
kuhn7 00b182dd89 Release 2.10.0rc2
Co-authored-by: chenkun<chenkun82@huawei.com>



# message auto-generated for no-merge-commit merge:
!29940 merge v2.10.0rc2 into v2.10.0

Release 2.10.0rc2

Created-by: kuhn7
Commit-by: chenkun
Merged-by: ascend-robot
Description: **What type of PR is this?**
bug

**What does this PR do / why do we need it**:
- Align installation/dependency docs with the new release

**Which issue(s) this PR fixes**:
- Fix torch_npu-2.10.0rc1 undefined symbol error caused by torch-2.10.0 package update


**Special notes for your reviewers**:
https://github.com/pytorch/pytorch/pull/171821



See merge request: Ascend/pytorch!29940
2026-01-22 21:03:47 +08:00
kuhn7 7e7336e3db Release 2.10.0rc1
Co-authored-by: chenkun<chenkun82@huawei.com>



# message auto-generated for no-merge-commit merge:
!29905 merge v2.10.0rc1 into v2.10.0

Release 2.10.0rc1

Created-by: kuhn7
Commit-by: chenkun
Merged-by: ascend-robot
Description: **What type of PR is this?**
task

**What does this PR do / why do we need it**:
Release 2.10.0rc1
- Bump version to 2.10.0rc1
- Update release notes / build metadata






See merge request: Ascend/pytorch!29905
2026-01-22 16:40:01 +08:00
370 changed files with 31284 additions and 4769 deletions
+34
View File
@@ -0,0 +1,34 @@
<!--
PR描述模板更新日期:20260203
-->
# 【合入来源】
> (如有)请关联需求文档/issue链接
- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [ ] 重构优化
- [ ] 资料更新
# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)
# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”
# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”
# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图
# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]
- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常
-24
View File
@@ -1,24 +0,0 @@
<!-- Thanks for sending a pull request!
-->
**What type of PR is this?**
> Uncomment only one ` /kind <>` line, hit enter to put that in a new line, and remove leading whitespaces from that line:
>
> /kind bug
> /kind task
> /kind feature
**What does this PR do / why do we need it**:
**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #
**Special notes for your reviewers**:
+3 -1
View File
@@ -2,12 +2,14 @@
path = third_party/op-plugin
url = https://gitcode.com/ascend/op-plugin.git
ignore = dirty
branch = 26.0.0
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/mirrors/googletest.git
[submodule "third_party/torchair/torchair"]
path = third_party/torchair/torchair
url = https://gitcode.com/ascend/torchair.git
branch = 26.0.0
[submodule "third_party/Tensorpipe"]
path = third_party/Tensorpipe
url = https://gitcode.com/ascend/Tensorpipe.git
@@ -16,7 +18,7 @@
url = https://gitee.com/mirrors/fmt.git
[submodule "third_party/nlohmann"]
path = third_party/nlohmann
url = https://gitee.com/mirrors/nlohmann-json.git
url = https://gitcode.com/GitHub_Trending/js/json
[submodule "third_party/torch-mlir"]
path = third_party/torch-mlir
url = https://gitee.com/mirrors_llvm/torch-mlir.git
+4 -5
View File
@@ -11,6 +11,7 @@ else()
endif()
project(TORCHNPU CXX C)
add_compile_options(-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/=)
set(LINUX TRUE)
set(CMAKE_INSTALL_MESSAGE NEVER)
@@ -119,8 +120,6 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=redundant-decls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined -D__FILE__='\"$(subst $(realpath ${CMAKE_SOURCE_DIR})/,,$(abspath $<))\"'")
# These flags are not available in GCC-4.8.5. Set only when using clang.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
@@ -231,9 +230,9 @@ set(CORE_SRCS)
set(FRAMEWORK_SRCS)
set(LOGGING_SRCS)
set(INDUCTOR_SRCS)
set(DIST_SRCS)
if (NOT DEFINED BUILD_LIBTORCH)
set(DIST_SRCS)
set(FLOP_SRCS)
set(NPU_SRCS)
set(PROF_SRCS)
@@ -254,9 +253,9 @@ add_subdirectory(${TORCHNPU_ROOT}/flopcount)
add_subdirectory(${TORCHNPU_ROOT}/logging)
add_subdirectory(${TORCHNPU_ROOT}/custom_dtype)
add_subdirectory(${TORCHNPU_ROOT}/inductor)
add_subdirectory(${TORCHNPU_ROOT}/distributed)
if (NOT DEFINED BUILD_LIBTORCH)
add_subdirectory(${TORCHNPU_ROOT}/distributed)
add_subdirectory(${TORCHNPU_ROOT}/npu)
add_subdirectory(${TORCHNPU_ROOT}/profiler)
add_subdirectory(${TORCHNPU_ROOT}/ipc)
@@ -289,7 +288,7 @@ if (DEFINED BUILD_TENSORPIPE)
endif()
if (DEFINED BUILD_LIBTORCH)
set(CPP_SRCS ${ATEN_SRCS} ${INDUCTOR_SRCS} ${CORE_SRCS} ${OPS_PLUGIN_SRCS} ${FLOP_SRCS} ${CUS_DTYPE_SRCS} ${FRAMEWORK_SRCS} ${LOGGING_SRCS} ${NPU_CPP_LIBS_SRCS})
set(CPP_SRCS ${ATEN_SRCS} ${INDUCTOR_SRCS} ${CORE_SRCS} ${OPS_PLUGIN_SRCS} ${DIST_SRCS} ${FLOP_SRCS} ${CUS_DTYPE_SRCS} ${FRAMEWORK_SRCS} ${LOGGING_SRCS} ${NPU_CPP_LIBS_SRCS} )
else()
# Compile code with pybind11
set(CPP_SRCS ${ATEN_SRCS} ${INDUCTOR_SRCS} ${CORE_SRCS} ${OPS_PLUGIN_SRCS} ${DIST_SRCS} ${FLOP_SRCS} ${CUS_DTYPE_SRCS} ${LOGGING_SRCS} ${FRAMEWORK_SRCS} ${NPU_SRCS} ${PROF_SRCS} ${IPC_SRCS} ${UTILS_SRCS} ${SAN_SRCS} ${AFD_SRCS})
+154
View File
@@ -0,0 +1,154 @@
# PyTorch贡献指南
感谢您考虑为 PyTorch做出贡献!我们欢迎任何形式的贡献,包括错误修复、功能增强、文档改进等,甚至只是反馈。无论您是经验丰富的开发者还是第一次参与开源项目,您的帮助都是非常宝贵的。
您可以通过多种方式支持本项目:
- 通过[Issues](https://gitcode.com/Ascend/pytorch/issues)反馈问题。
- 建议或实现新功能。
- 改进或扩展文档。
- 审查Pull Request并协助其他贡献者。
- 传播项目:在博客文章、社交媒体上分享PyTorch,或给仓库点个⭐。
## 寻找可贡献的问题
您可以通过查看[Issues列表](https://gitcode.com/Ascend/pytorch/issues)了解项目的发展计划和路线图。
## 贡献流程
- [贡献者许可协议](#贡献者许可协议)
- [开发与测试](#开发与测试)
### 贡献者许可协议
在您第一次向 PyTorch 社区提交代码之前,需要签署 CLA。
对于个人贡献者,详细信息请参考[ICLA 在线文档](https://www.mindspore.cn/icla)。
### 开发与测试
1. 先在GitCode平台点击仓库右上角"Fork"按钮,将仓库克隆到个人账户
2. 克隆到本地:
```bash
git clone https://gitcode.com/<your-username>/pytorch.git
cd pytorch
```
3. 在个人仓库进行代码开发
代码开发请遵循 **[代码规范](#代码规范)**
4. 代码测试
参见 **[代码测试](https://gitcode.com/Ascend/pytorch/blob/master/test/README.md)**
5. **[门禁异常处理](#门禁异常处理)**
6. **[提交Pull Request](#提交Pull-Request)**
7. **[报告问题](#报告问题)**
#### 代码规范
请遵循这些风格,以使 PyTorch 易于开发、审查和维护。
- 编码指南
请在PyTorch社区使用规统一的编码分格,python建议的编码风格是[PEP 8编码样式](https://pep8.org/),C++编码所建议的风格是 [Google C++编码指南](http://google.github.io/styleguide/cppguide.html) 。可以使用[CppLint](https://github.com/cpplint/cpplint),[CppCheck](http://cppcheck.sourceforge.net/),[CMakeLint](https://github.com/cmake-lint/cmake-lint),[CodeSpell](https://github.com/codespell-project/codespell), [Lizard](http://www.lizard.ws/),[ShellCheck](https://github.com/koalaman/shellcheck)和[pylint](https://pylint.org/)检查代码的格式,建议在您的IDE中安装这些插件。
- 单元测试指南
请在PyTorch社区使用统一的单元测试风格, Python中建议的单元测试风格是[pytest](http://www.pytest.org/en/latest/),C++单元测试所建议的风格是 [Googletest Primer](#https://github.com/google/googletest/blob/master/docs/primer.md) 。测试用例的设计意图应该通过它的注释名称来反映。
- 重构指南
我们鼓励开发人员重构我们的代码以消除[代码异味](https://en.wikipedia.org/wiki/Code_smell)。所有的代码都应该符合编码风格和测试风格的需求,重构代码也不例外。当您收到警告时,您必须重构要合并的代码。
#### 门禁异常处理
门禁异常主要包含如下几种,请根据相关提示解决异常问题。
- 编译异常
请检查代码编译失败的原因,解决问题后重新编译即可。
- 静态检查异常(代码Bug、代码漏洞、代码异味)
请依照提示查找代码中的异常并解决。
- UT测试未通过
请根据提示,查找测试用例不通过项并检查原因,解决后再测试。
#### 提交Pull Request
1. 本地创建分支。
为了避免多个分支之间的不一致,建议创建新的分支进行开发:
```
git checkout -b {new_branch_name} origin/master
```
以master分支为例,PyTorch可能会根据需要创建版本分支和下游开发分支,请先修复上游的bug。然后就可以随意更改代码了。
2. 将代码推送到远程仓库。
更新代码后,您需要以正式的方式推送更新:
```
git add .
git status # Check the update status
git commit -m "Your commit title"
git commit -s --amend #Add the concrete description of your commit
git push origin {new_branch_name}
```
3. 创建Pull Request
在GitCode上创建Pull Request
根据`.gitcode/PULL_REQUEST_TEMPLATE.md`中的规范模板,完整填写:
- 合入来源
- 修改方案
- 资料变更
- 接口变更
- 功能验证
- CheckList
确认信息完整准确后提交Pull Request,等待代码审查
#### 报告问题
为项目做出贡献的一个好方法是在遇到问题时发送详细报告。我们总是很感激写得很好、彻底的错误报告,并会由此感谢您!
报告问题时,请参考以下格式:
- 您使用的是什么版本的环境 (pytorch、os、python 等)?
- 这是错误报告还是功能请求?
- 什么样的问题,添加标签以在问题仪表板上突出显示。
- 发生了什么?
- 您预计会发生什么?
- 如何重现它?(尽可能最小和精确。)
- 给审稿人的特别说明?
问题咨询:
- 如果您发现一个未解决的问题,而这正是您要解决的问题,请对该问题发表一些评论,告诉其他人您将负责它。
- 如果问题已打开一段时间,建议贡献者在解决该问题之前进行预检查。
- 如果您解决了自己报告的问题,则还需要在关闭该问题之前让其他人知道。
## 社区准则
### 行为准则
我们致力于为所有参与者提供一个友好、安全和包容的环境。参与本项目即表示您同意:
- 尊重不同的观点和经验
- 接受建设性的批评
- 关注对社区最有利的事情
- 对其他社区成员表示同理心
### 沟通渠道
- **Issues**:用于报告Bug、提出功能建议和讨论技术问题
- **Pull Requests**:用于代码审查和讨论具体实现
-226
View File
@@ -1,226 +0,0 @@
# PyTorch贡献指南
- [贡献者许可协议](#贡献者许可协议.md)
- [入门](#入门.md)
- [开发指导](#开发指导.md)
- [测试用例](#测试用例.md)
- [代码风格](#代码风格.md)
- [门禁异常处理](#门禁异常处理.md)
- [Fork-Pull开发模式](#Fork-Pull开发模式.md)
- [报告问题](#报告问题.md)
- [提出PR](#提出PR.md)
<h2 id="贡献者许可协议.md">贡献者许可协议</h2>
在您第一次向 PyTorch 社区提交代码之前,需要签署 CLA。
对于个人贡献者,详细信息请参考[ICLA 在线文档](https://www.mindspore.cn/icla)。
<h2 id="入门.md">入门</h2>
- 在[GitCode](https://gitcode.com/ascend/pytorch)上Fork存储库。
- 阅读[README.md](#https://gitcode.com/ascend/pytorch/blob/master/README.zh.md)以获取项目信息和构建说明。
<h2 id="开发指导.md">开发指导</h2>
- **[测试用例](#测试用例.md)**
- **[代码风格](#代码风格.md)**
- **[门禁异常处理](#门禁异常处理.md)**
- **[Fork-Pull开发模式](#Fork-Pull开发模式.md)**
- **[报告问题](#报告问题.md)**
- **[提出PR](#提出PR.md)**
<h2 id="测试用例.md">测试用例</h2>
通过具体示例,完成PyTorch的功能测试。
1. 编写测试脚本。
以add运算为例,在“pytorch/test/test\_network\_ops“路径下编写测试脚本文件: test\_add.py。
以下示例仅为一个简单的用例实现,供用户参考。具体测试用例的实现,需要根据运算定义进行完整的覆盖才能保证功能的基本正确。
```
# 引入依赖库
import sys
import torch
import torch_npu
import numpy as np
from torch_npu.testing.testcase import TestCase, run_tests
from torch_npu.testing.common_utils import create_common_tensor
# 定义add测试用例类
class TestAdd(TestCase):
# 定义CPU的add执行函数
def cpu_op_exec(self, input1, input2):
output = torch.add(input1, input2, alpha = 1)
output = output.numpy()
return output
# 定义NPU的add执行函数
def npu_op_exec_new(self, input1, input2):
output = torch.add(input1, input2, alpha = 1)
output = output.to("cpu")
output = output.numpy()
return output
# 定义add对应场景通用函数,该函数中负责场景对应输入数据和对比CPU和NPU返回结果
def add_result(self, shape_format):
for item in shape_format:
cpu_input1, npu_input1 = create_common_tensor(item, 0, 100)
cpu_input2, npu_input2 = create_common_tensor(item, 0, 100)
if cpu_input1.dtype == torch.float16:
cpu_input1 = cpu_input1.to(torch.float32)
cpu_input2 = cpu_input2.to(torch.float32)
cpu_output = self.cpu_op_exec(cpu_input1, cpu_input2)
npu_output = self.npu_op_exec_new(npu_input1, npu_input2)
cpu_output = cpu_output.astype(npu_output.dtype)
self.assertRtolEqual(cpu_output, npu_output)
# 定义具体add场景的测试用例,用例函数需要以test_开头
def test_add_shape_format_fp32_2d(self):
format_list = [0, 3, 29]
shape_format = [
[np.float32, i, [5, 256]] for i in format_list
]
self.add_result(shape_format)
if __name__ == "__main__":
run_tests()
```
2. 设置环境变量。
进入"pytorch"根目录,并执行env.sh脚本。
```
bash env.sh
```
3. 执行测试用例脚本。
进入“test\_add.py“所在的目录,执行:
```
python3.7 test_add.py
```
<h2 id="代码风格.md">代码风格</h2>
请遵循这些风格,以使 PyTorch 易于开发、审查和维护。
- 编码指南
请在PyTorch社区使用规统一的编码分格,python建议的编码风格是[PEP 8编码样式](https://pep8.org/),C++编码所建议的风格是 [Google C++编码指南](http://google.github.io/styleguide/cppguide.html) 。可以使用[CppLint](https://github.com/cpplint/cpplint),[CppCheck](http://cppcheck.sourceforge.net/),[CMakeLint](https://github.com/cmake-lint/cmake-lint),[CodeSpell](https://github.com/codespell-project/codespell), [Lizard](http://www.lizard.ws/),[ShellCheck](https://github.com/koalaman/shellcheck)和[pylint](https://pylint.org/)检查代码的格式,建议在您的IDE中安装这些插件。
- 单元测试指南
请在PyTorch社区使用统一的单元测试风格, Python中建议的单元测试风格是[pytest](http://www.pytest.org/en/latest/),C++单元测试所建议的风格是 [Googletest Primer](#https://github.com/google/googletest/blob/master/docs/primer.md) 。测试用例的设计意图应该通过它的注释名称来反映。
- 重构指南
我们鼓励开发人员重构我们的代码以消除[代码异味](https://en.wikipedia.org/wiki/Code_smell)。所有的代码都应该符合编码风格和测试风格的需求,重构代码也不例外。当您收到警告时,您必须重构要合并的代码。
<h2 id="门禁异常处理.md">门禁异常处理</h2>
门禁异常主要包含如下几种,请根据相关提示解决异常问题。
- 编译异常
请检查代码编译失败的原因,解决问题后重新编译即可。
- 静态检查异常(代码Bug、代码漏洞、代码异味)
请依照提示查找代码中的异常并解决。
- UT测试未通过
请根据提示,查找测试用例不通过项并检查原因,解决后再测试。
<h2 id="Fork-Pull开发模式.md">Fork-Pull开发模式</h2>
1. Fork PyTorch存储库。
在向PyTorch项目提交代码之前,请确保该项目已经Fork到您自己的存储库。这意味着PyTorch存储库和您自己的存储库之间将存在并行开发,因此请注意避免存储库之间的不一致。
2. 克隆远程仓库。
如果要将代码下载到本地环境,git是很好的方法:
```
# For GitCode
git clone https://gitcode.com/{insert_your_forked_repo}/pytorch.git
git remote add upstream https://gitcode.com/pytorch/pytorch.git
```
3. 本地开发代码。
为了避免多个分支之间的不一致,建议创建新的分支进行开发:
```
git checkout -b {new_branch_name} origin/master
```
以master分支为例,PyTorch可能会根据需要创建版本分支和下游开发分支,请先修复上游的bug。然后就可以随意更改代码了。
4. 将代码推送到远程仓库。
更新代码后,您需要以正式的方式推送更新:
```
git add .
git status # Check the update status
git commit -m "Your commit title"
git commit -s --amend #Add the concrete description of your commit
git push origin {new_branch_name}
```
5. 向 PyTorch存储库拉取请求。
在最后一步中,您需要在新分支和“PyTorch master“分支之间拉取比较请求。完成拉取请求后,“Jenkins CI“将自动设置为构建测试。您的pull request应该尽快合并到上游 master 分支,以降低合并的风险。
<h2 id="报告问题.md">报告问题</h2>
为项目做出贡献的一个好方法是在遇到问题时发送详细报告。我们总是很感激写得很好、彻底的错误报告,并会由此感谢您!
报告问题时,请参考以下格式:
- 您使用的是什么版本的环境 (pytorch、os、python 等)?
- 这是错误报告还是功能请求?
- 什么样的问题,添加标签以在问题仪表板上突出显示。
- 发生了什么?
- 您预计会发生什么?
- 如何重现它?(尽可能最小和精确。)
- 给审稿人的特别说明?
问题咨询:
- 如果您发现一个未解决的问题,而这正是您要解决的问题,请对该问题发表一些评论,告诉其他人您将负责它。
- 如果问题已打开一段时间,建议贡献者在解决该问题之前进行预检查。
- 如果您解决了自己报告的问题,则还需要在关闭该问题之前让其他人知道。
<h2 id="提出PR.md">提出PR</h2>
- 在[GitCode](https://gitcode.com/ascend/pytorch/issues)上提出您的想法作为_问题_。
- 如果是需要大量设计细节的新功能,还应提交设计方案。
- 在问题讨论和设计提案审查中达成共识后,完成分叉回购的开发并提交 PR(Pull Request)。
- 在从批准者那里收到2+ LGTM(Looks Good To Me)之前,不允许任何PR 。请注意,审批人不允许在自己的 PR 上添加LGTM。
- 在 PR 被充分讨论后,它将根据讨论的结果被合并、放弃或拒绝。
公关咨询:
- 应避免任何不相关的更改。
- 确保你的提交历史被排序。
- 始终将您的分支与主分支保持一致。
- 对于错误修复 PR,请确保链接所有相关问题。
+28 -25
View File
@@ -19,13 +19,13 @@ Install **PyTorch** through pip.
**For Aarch64:**
```bash
pip3 install torch==2.1.0
pip3 install torch==2.10.0
```
**For x86:**
```bash
pip3 install torch==2.1.0+cpu --index-url https://download.pytorch.org/whl/cpu
pip3 install torch==2.10.0+cpu --index-url https://download.pytorch.org/whl/cpu
```
2. **Install torch-npu dependencies**
@@ -39,31 +39,29 @@ pip3 install setuptools
If the installation fails, use the download link or visit the [PyTorch official website](https://pytorch.org/) to download the installation package of the corresponding version.
| OS arch | Python version | link |
|---------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| x86 | Python3.8 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp38-cp38-linux_x86_64.whl#sha256=9e5cfd931a65b38d222755a45dabb53b836be31bc620532bc66fee77e3ff67dc) |
| x86 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp39-cp39-linux_x86_64.whl#sha256=86cc28df491fa84738affe752f9870791026565342f69e4ab63e5b935f00a495) |
| x86 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=5077921fc2b54e69a534f3a9c0b98493c79a5547c49d46f5e77e42da3610e011) |
| x86 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp311-cp311-linux_x86_64.whl#sha256=5954924ce74bc7e6a6c811e3fa4bdda9936d9889f6369fd068420c444bfd1cae) |
| aarch64 | Python3.8 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=761822761fffaa1c18a62c5deb13abaa780862577d3eadc428f1daa632536905) |
| aarch64 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=de7d63c6ecece118684415a3dbd4805af4a4c1ee1490cccf7405d8c240a481b4) |
| aarch64 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=a04a0296d47f28960f51c18c5489a8c3472f624ec3b5bcc8e2096314df8c3342) |
| aarch64 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=8132efb782cd181cc2dcca5e58effbe4217cdb2581206ac71466d535bf778867) |
| OS arch | Python version | link |
|---------|----------------|-------------------------------------------|
| x86 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp310-cp310-manylinux_2_28_x86_64.whl) |
| x86 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp311-cp311-manylinux_2_28_x86_64.whl) |
| x86 | Python3.12 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp312-cp312-manylinux_2_28_x86_64.whl) |
| aarch64 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp310-cp310-manylinux_2_28_aarch64.whl) |
| aarch64 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp311-cp311-manylinux_2_28_aarch64.whl) |
| aarch64 | Python3.12 | [link](https://download.pytorch.org/whl/cpu/torch-2.10.0%2Bcpu-cp312-cp312-manylinux_2_28_aarch64.whl) |
3. **Install torch-npu**
```
pip3 install torch-npu==2.1.0.post17
pip3 install torch-npu==2.10.0rc2
```
### From Source
In some special scenarios, users may need to compile **torch-npu** by themselves.Select a branch in table [Ascend Auxiliary Software](#ascend-auxiliary-software) and a Python version in table [PyTorch and Python Version Matching Table](#pytorch-and-python-version-matching-table) first. The docker image is recommended for compiling torch-npu through the following steps(It is recommended to mount the working path only and avoid the system path to reduce security risks.), the generated .whl file path is ./dist/. Note that gcc version has the following constraints if you try to compile without using docker image: we recommend to use gcc 10.2 for ARM and gcc 9.3.1 for X86.
In some special scenarios, users may need to compile **torch-npu** by themselves.Select a branch in table [Ascend Auxiliary Software](#ascend-auxiliary-software) and a Python version in table [PyTorch and Python Version Matching Table](#pytorch-and-python-version-matching-table) first. The docker image is recommended for compiling torch-npu through the following steps(It is recommended to mount the working path only and avoid the system path to reduce security risks.), the generated .whl file path is ./dist/. Note that gcc version has the following constraints if you try to compile without using docker image: we recommend to use gcc 13.3 for both ARM and X86.
1. **Clone torch-npu**
```
git clone https://github.com/ascend/pytorch.git -b 2.1.0-7.2.0 --depth 1
git clone https://gitcode.com/ascend/pytorch.git -b v2.10.0 --depth 1
```
2. **Build Docker Image**
@@ -82,16 +80,16 @@ In some special scenarios, users may need to compile **torch-npu** by themselves
4. **Compile torch-npu**
Take **Python 3.8** as an example.
Take **Python 3.10** as an example.
```
cd /home/pytorch
bash ci/build.sh --python=3.8
bash ci/build.sh --python=3.10
```
**Tips**
If you would like to compile with new C++ ABI, then first run this command, at this point, the recommended compilation environment is same to community torch package: glibc 2.28, gcc 11.2.1
If you would like to compile with new C++ ABI, then first run this command, at this point, the recommended compilation environment is same to community torch package: glibc 2.28, gcc 13.3
```
export _GLIBCXX_USE_CXX11_ABI=1
@@ -100,7 +98,7 @@ In some special scenarios, users may need to compile **torch-npu** by themselves
Meanwhile, we support configuring -fabi-version using the following variables,require consistency with the community torch package
```
export _ABI_VERSION=16
export _ABI_VERSION=18
```
## Getting Started
@@ -146,6 +144,8 @@ Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for m
| PyTorch2.6.0 | Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.7.1 | Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.8.0 | Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.9.0 | Python3.10.x,Python3.11.x,Python3.12.x |
| PyTorch2.10.0 | Python3.10.x,Python3.11.x,Python3.12.x |
## Ascend Auxiliary Software
@@ -153,7 +153,8 @@ Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for m
| CANN Version | Supported PyTorch Version | Supported Extension Version | Github Branch |
|-----------------------|---------------------------|-----------------------------|-------------------|
| CANN 8.5.0 | 2.9.0 | 2.9.0 | v2.9.0-7.3.0 |
| CANN 8.5.0 | 2.10.0 | 2.10.0rc2 | v2.10.0 |
| | 2.9.0 | 2.9.0 | v2.9.0-7.3.0 |
| | 2.8.0 | 2.8.0.post2 | v2.8.0-7.3.0 |
| | 2.7.1 | 2.7.1.post2 | v2.7.1-7.3.0 |
| | 2.6.0 | 2.6.0.post5 | v2.6.0-7.3.0 |
@@ -255,7 +256,8 @@ The version branches of AscendPyTorch have the following maintenance phases:
| **PyTorch** | **Maintenance Policies** | **Status** | **Launch Date** | **Subsequent Status** | **EOL Date** |
|-------------|--------------------------|-------------|-----------------|-------------------------------------------------------------------|--------------|
| 2.9.0 | Regular Release | Development | 2025/10/15 | Expected to enter maintenance status from March 15, 2026 | - |
| 2.10.0 | Regular Release | Development | 2026/01/22 | Expected to enter maintenance status from July 22, 2026 | - |
| 2.9.0 | Regular Release | Development | 2026/01/15 | Expected to enter maintenance status from July 15, 2026 | - |
| 2.8.0 | Regular Release | Development | 2025/10/15 | Expected to enter maintenance status from March 15, 2026 | - |
| 2.7.1 | Long Term Support | Development | 2025/10/15 | Expected to enter maintenance status from October 15, 2026 | |
| 2.6.0 | Regular Release | Development | 2025/07/25 | Expected to enter maintenance status from January 15, 2026 | - |
@@ -275,10 +277,11 @@ For more detailed information on installation guides, model migration, training/
| Document Name | Document Link |
|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| Installation Guide | [link](https://www.hiascend.com/document/detail/zh/Pytorch/720/configandinstg/instg/insg_0001.html) |
| Network Model Migration and Training | [link](https://www.hiascend.com/document/detail/zh/Pytorch/720/ptmoddevg/trainingmigrguide/PT_LMTMOG_0003.html) |
| Operator Adaptation | [link](https://www.hiascend.com/document/detail/zh/canncommercial/81RC1/operatordev/tbeaicpudevg/atlasopdev_10_0086.html) |
| API List (PyTorch and Custom Interfaces) | [link](https://www.hiascend.com/document/detail/zh/Pytorch/720/apiref/apilist/ptaoplist_000002.html) |
| Installation Guide | [link](https://www.hiascend.com/document/detail/zh/Pytorch/730/configandinstg/instg/docs/zh/installation_guide/installation_description.md) |
| Network Model Migration and Training | [link](https://www.hiascend.com/document/detail/zh/Pytorch/730/ptmoddevg/trainingmigrguide/PT_LMTMOG_0003.html) |
| Operator Adaptation | [link](https://www.hiascend.com/document/detail/zh/Pytorch/730/ptmoddevg/Frameworkfeatures/docs/zh/framework_feature_guide_pytorch/adaptation_description_opplugin.md) |
| PyTorch Native API | [link](https://www.hiascend.com/document/detail/zh/Pytorch/730/apiref/PyTorchNativeapi/docs/zh/native_apis/pytorch_2-9-0/overview.md) |
| Ascend Extension for PyTorch (Custom Interfaces) | [link](https://www.hiascend.com/document/detail/zh/Pytorch/730/apiref/apilist/ptaoplist_000002.html) |
## License
+58 -262
View File
@@ -1,269 +1,54 @@
# Ascend Extension for PyTorch插件
## 简介
本项目开发了名为**torch_npu**的**Ascend Extension for PyTorch**插件,使昇腾NPU可以适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。
昇腾为基于华为昇腾处理器和软件的行业应用及服务提供全栈AI计算基础设施。您可以通过访问[昇腾社区](https://www.hiascend.com/zh/),了解关于昇腾的更多信息。
## 目录结构
关键目录如下:
```ColdFusion
├─ci # 持续集成脚本目录
├─cmake # CMake构建配置目录
├─torch_npu # 核心适配目录
│ ├─csrc/ # 底层核心目录
│ ├─npu/ # NPU接口目录
│ ├─distributed/ # 分布式训练适配目录
│ ├─asd/ # Ascend Debug工具目录
├─docs # 项目文档目录
├─examples # 示例目录
├─torchnpugen/ # 代码生成模块目录
└─test # 测试目录
```
## 版本说明
### PyTorch与Python版本配套表
| PyTorch版本 | Python版本 |
|---------------|:-------------------------------------------------------------|
| PyTorch1.11.0 | Python3.7.x(>=3.7.5), Python3.8.x, Python3.9.x, Python3.10.x |
| PyTorch2.1.0 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.2.0 | Python3.8.x, Python3.9.x, Python3.10.x |
| PyTorch2.3.1 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.4.0 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.5.1 | Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.6.0 | Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.7.1 | Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.8.0 | Python3.9.x, Python3.10.x, Python 3.11.x |
### 昇腾辅助软件
**Ascend Extension for PyTorch**的分支名称采用`{PyTorch版本}-{昇腾版本}`命名规则,前者为**Ascend Extension for PyTorch**匹配的PyTorch版本,后者为**Ascend Extension for PyTorch**版本号,详细匹配如下:
| CANN版本 | 支持的PyTorch版本 | 支持的Extension版本 | GitCode分支 |
|-----------------------|--------------|------------------|-------------------|
| CANN 8.5.0 | 2.9.0 | 2.9.0 | v2.9.0-7.3.0 |
| | 2.8.0 | 2.8.0.post2 | v2.8.0-7.3.0 |
| | 2.7.1 | 2.7.1.post2 | v2.7.1-7.3.0 |
| | 2.6.0 | 2.6.0.post5 | v2.6.0-7.3.0 |
| CANN 8.3.RC1 | 2.8.0 | 2.8.0 | v2.8.0-7.2.0 |
| | 2.7.1 | 2.7.1 | v2.7.1-7.2.0 |
| | 2.6.0 | 2.6.0.post3 | v2.6.0-7.2.0 |
| | 2.1.0 | 2.1.0.post17 | v2.1.0-7.2.0 |
| CANN 8.2.RC1 | 2.6.0 | 2.6.0 | v2.6.0-7.1.0 |
| | 2.5.1 | 2.5.1.post1 | v2.5.1-7.1.0 |
| | 2.1.0 | 2.1.0.post13 | v2.1.0-7.1.0 |
| CANN 8.1.RC1 | 2.5.1 | 2.5.1 | v2.5.1-7.0.0 |
| | 2.4.0 | 2.4.0.post4 | v2.4.0-7.0.0 |
| | 2.3.1 | 2.3.1.post6 | v2.3.1-7.0.0 |
| | 2.1.0 | 2.1.0.post12 | v2.1.0-7.0.0 |
| CANN 8.0.0 | 2.4.0 | 2.4.0.post2 | v2.4.0-6.0.0 |
| | 2.3.1 | 2.3.1.post4 | v2.3.1-6.0.0 |
| | 2.1.0 | 2.1.0.post10 | v2.1.0-6.0.0 |
| CANN 8.0.RC3 | 2.4.0 | 2.4.0 | v2.4.0-6.0.rc3 |
| | 2.3.1 | 2.3.1.post2 | v2.3.1-6.0.rc3 |
| | 2.1.0 | 2.1.0.post8 | v2.1.0-6.0.rc3 |
| CANN 8.0.RC2 | 2.3.1 | 2.3.1 | v2.3.1-6.0.rc2 |
| | 2.2.0 | 2.2.0.post2 | v2.2.0-6.0.rc2 |
| | 2.1.0 | 2.1.0.post6 | v2.1.0-6.0.rc2 |
| | 1.11.0 | 1.11.0.post14 | v1.11.0-6.0.rc2 |
| CANN 8.0.RC1 | 2.2.0 | 2.2.0 | v2.2.0-6.0.rc1 |
| | 2.1.0 | 2.1.0.post4 | v2.1.0-6.0.rc1 |
| | 1.11.0 | 1.11.0.post11 | v1.11.0-6.0.rc1 |
| CANN 7.0.0 | 2.1.0 | 2.1.0 | v2.1.0-5.0.0 |
| | 2.0.1 | 2.0.1.post1 | v2.0.1-5.0.0 |
| | 1.11.0 | 1.11.0.post8 | v1.11.0-5.0.0 |
| CANN 7.0.RC1 | 2.1.0 | 2.1.0.rc1 | v2.1.0-5.0.rc3 |
| | 2.0.1 | 2.0.1 | v2.0.1-5.0.rc3 |
| | 1.11.0 | 1.11.0.post4 | v1.11.0-5.0.rc3 |
| CANN 6.3.RC3.1 | 1.11.0 | 1.11.0.post3 | v1.11.0-5.0.rc2.2 |
| CANN 6.3.RC3 | 1.11.0 | 1.11.0.post2 | v1.11.0-5.0.rc2.1 |
| CANN 6.3.RC2 | 2.0.1 | 2.0.1.rc1 | v2.0.1-5.0.rc2 |
| | 1.11.0 | 1.11.0.post1 | v1.11.0-5.0.rc2 |
| | 1.8.1 | 1.8.1.post2 | v1.8.1-5.0.rc2 |
| CANN 6.3.RC1 | 1.11.0 | 1.11.0 | v1.11.0-5.0.rc1 |
| | 1.8.1 | 1.8.1.post1 | v1.8.1-5.0.rc1 |
| CANN 6.0.1 | 1.5.0 | 1.5.0.post8 | v1.5.0-3.0.0 |
| | 1.8.1 | 1.8.1 | v1.8.1-3.0.0 |
| | 1.11.0 | 1.11.0.rc2(beta) | v1.11.0-3.0.0 |
| CANN 6.0.RC1 | 1.5.0 | 1.5.0.post7 | v1.5.0-3.0.rc3 |
| | 1.8.1 | 1.8.1.rc3 | v1.8.1-3.0.rc3 |
| | 1.11.0 | 1.11.0.rc1(beta) | v1.11.0-3.0.rc3 |
| CANN 5.1.RC2 | 1.5.0 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| | 1.8.1 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
| CANN 5.1.RC1 | 1.5.0 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| | 1.8.1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| CANN 5.0.4 | 1.5.0 | 1.5.0.post4 | 2.0.4.tr5 |
| CANN 5.0.3 | 1.8.1 | 1.5.0.post3 | 2.0.3.tr5 |
| CANN 5.0.2 | 1.5.0 | 1.5.0.post2 | 2.0.2.tr5 |
## 快速入门
基于CNN模型识别手写数字的脚本,对在GPU上训练的该脚本代码进行修改,使其可以迁移到昇腾NPU上进行训练。具体操作请参见[Ascend Extension for PyTorch 快速入门](https://www.hiascend.com/document/detail/zh/Pytorch/710/fastexperience/fastexperience_0001.html)。
Ascend Extension for PyTorch的版本说明包含版本配套说明、版本兼容性说明和更新说明等,具体请参见《[Ascend Extension for PyTorch 版本说明](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/zh/release_notes/release_notes.md)》。
## 环境部署
### 使用二进制文件进行安装
Ascend Extension for PyTorch插件的安装操作,具体请参见《[Ascend Extension for PyTorch 软件安装](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/zh/installation_guide/menu_installation_guide.md)》。
我们为用户提供可以快速安装**torch_npu**的whl安装包。在安装**torch_npu**之前,您需要先安装**CANN**软件。[昇腾辅助软件](#昇腾辅助软件)中有更多关于CANN的版本信息。请参考[CANN安装指南](https://www.hiascend.com/cann)获取**CANN**安装包。
## 快速入门
1. **安装PyTorch**
以CNN模型为例,介绍将其迁移至昇腾NPU上进行训练的方法,具体操作请参见《[Ascend Extension for PyTorch 快速入门](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/zh/quick_start/quick_start.md)》。
通过 pip 安装 PyTorch。
## 特性介绍
**aarch64:**
Ascend Extension for PyTorch插件从内存资源优化、通信性能优化、计算性能优化、辅助报错定位等方面精心打造了一系列独特的特性,具体特性指导请参见《[PyTorch 框架特性指南](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/zh/framework_feature_guide_pytorch/menu_framework_feature.md)》。
```bash
pip3 install torch==2.1.0
```
## API参考
**x86:**
```bash
pip3 install torch==2.1.0+cpu --index-url https://download.pytorch.org/whl/cpu
```
若使用pip命令安装失败,请使用下载链接或进入[PyTorch官方网站](https://pytorch.org/)进行查询下载对应版本。
| 架构 | Python版本 | 下载链接 |
|---------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| x86 | Python3.8 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp38-cp38-linux_x86_64.whl#sha256=9e5cfd931a65b38d222755a45dabb53b836be31bc620532bc66fee77e3ff67dc) |
| x86 | Python3.9 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp39-cp39-linux_x86_64.whl#sha256=86cc28df491fa84738affe752f9870791026565342f69e4ab63e5b935f00a495) |
| x86 | Python3.10 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=5077921fc2b54e69a534f3a9c0b98493c79a5547c49d46f5e77e42da3610e011) |
| x86 | Python3.11 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0%2Bcpu-cp311-cp311-linux_x86_64.whl#sha256=5954924ce74bc7e6a6c811e3fa4bdda9936d9889f6369fd068420c444bfd1cae) |
| aarch64 | Python3.8 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=761822761fffaa1c18a62c5deb13abaa780862577d3eadc428f1daa632536905) |
| aarch64 | Python3.9 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=de7d63c6ecece118684415a3dbd4805af4a4c1ee1490cccf7405d8c240a481b4) |
| aarch64 | Python3.10 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=a04a0296d47f28960f51c18c5489a8c3472f624ec3b5bcc8e2096314df8c3342) |
| aarch64 | Python3.11 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=8132efb782cd181cc2dcca5e58effbe4217cdb2581206ac71466d535bf778867) |
2. **安装torch_npu依赖**
运行以下命令安装依赖。
```bash
pip3 install pyyaml
pip3 install setuptools
```
3. **安装torch_npu**
```bash
pip3 install torch-npu==2.1.0.post17
```
如需要保存安装日志,可在pip3 install命令后面加上参数 `--log <PATH>`,并对您指定的目录`<PATH>`做好权限管控。
### 使用源代码进行安装
某些特殊场景下,用户可能需要自行编译**torch_npu**。可以根据[昇腾辅助软件表](#昇腾辅助软件)和[PyTorch与Python版本配套表](#pytorch与python版本配套表)选择合适的分支。
推荐使用Docker镜像编译**torch_npu**,可以通过以下步骤获取(建议只挂载工作路径,并避开系统路径,以降低安全风险), 生成的.whl文件路径为./dist/。
>**须知:**<br>
>如果不使用镜像,编译时请注意gcc版本遵循如下约束。
> - ARM架构下推荐使用gcc 10.2版本
> - X86架构下推荐使用gcc 9.3.1
1. **克隆torch_npu代码仓**
```
git clone https://gitcode.com/ascend/pytorch.git -b v2.1.0-7.2.0 --depth 1
```
2. **构建镜像**
```
cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
docker build -t manylinux-builder:v1 .
```
3. **进入Docker容器**
```
docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
# {code_path} is the torch_npu source code path
```
4. **编译torch_npu**
以**Python 3.8** 为例。
```
cd /home/pytorch
bash ci/build.sh --python=3.8
```
**提示**
如果想使用新的C++ ABI编译,请首先运行如下命令,此时推荐和社区torch包相同的编译环境:glibc 2.28, gcc 11.2.1。
```
export _GLIBCXX_USE_CXX11_ABI=1
```
同时,我们支持使用如下变量配置-fabi-version,要求和社区torch包ABI版本一致
```
export _ABI_VERSION=16
```
### 安装后验证
#### 前提
运行以下命令初始化**CANN**环境变量。
```Shell
# Default path, change it if needed.
source /usr/local/Ascend/ascend-toolkit/set_env.sh
```
#### 快速验证
可以通过以下样例快速体验**昇腾NPU**。
```diff
import torch
- import torch_npu # torch_npu2.5.1及以后版本可以不用手动导包
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)
```
## 卸载
Pytorch框架训练环境的卸载可以参考[昇腾官方文档](https://www.hiascend.com/document/detail/zh/ModelZoo/pytorchframework/ptes/ptes_00032.html)。
torch_npu的卸载只需执行命令:
```bash
pip3 uninstall torch_npu
```
如需要保存卸载日志,可在pip3 uninstall命令后面加上参数 `--log <PATH>`,并对您指定的目录`<PATH>`做好权限管控。
## 硬件配套
昇腾训练设备包含以下型号,都可作为PyTorch模型的训练环境。
| 产品系列 | 产品型号 |
|-----------------------|----------------------------------|
| Atlas 训练系列产品 | Atlas 800 训练服务器(型号:9000) |
| | Atlas 800 训练服务器(型号:9010) |
| | Atlas 900 PoD(型号:9000) |
| | Atlas 300T 训练卡(型号:9000) |
| | Atlas 300T Pro 训练卡(型号:9000)|
| Atlas A2 训练系列产品 | Atlas 800T A2 训练服务器 |
| | Atlas 900 A2 PoD 集群基础单元 |
| | Atlas 200T A2 Box16 异构子框 |
| Atlas A3 训练系列产品 | Atlas 800T A3 训练服务器 |
| | Atlas 900 A3 SuperPoD 超节点 |
昇腾推理设备包含以下型号,都可作为大模型的推理环境。
| 产品系列 | 产品型号 |
|-----------------------|----------------------------------|
| Atlas 800I A2推理产品 | Atlas 800I A2 推理服务器 |
## 建议与交流
欢迎大家为社区做贡献。如果有任何疑问或建议,请提交[GitCode Issues](https://gitcode.com/Ascend/pytorch/issues),我们会尽快回复。感谢您的支持。
- 原生PyTorch API在昇腾NPU设备上的支持情况请参见《[PyTorch 原生API支持度](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/zh/native_apis/menu_pt_native_apis.md)》。
- Ascend Extension for PyTorch插件提供了部分自定义API接口,具体使用请参见《[Ascend Extension for PyTorch自定义API](https://gitcode.com/Ascend/op-plugin/blob/26.0.0/docs/zh/custom_APIs/menu_Pytorch_API.md)》。
## 分支维护策略
Ascend Extension for PyTorch版本分支的维护阶段如下:
| **状态** | **时间** | **说明** |
| ------------------- | -------- | ------------------------------------------------ |
| 计划 | 1—3 个月 | 计划特性 |
@@ -273,14 +58,15 @@ Ascend Extension for PyTorch版本分支的维护阶段如下:
## PyTorch版本维护策略
| **PyTorch版本** | **维护策略** | **当前状态** | **发布时间** | **后续状态** | **EOL日期** |
|---------------|----------|----------|------------|----------------------|-----------|
| 2.9.0 | 常规分支 | 开发 | 2025/10/15| 预计2026/03/15起进入维护状态 | - |
| 2.8.0 | 常规分支 | 开发 | 2025/10/15| 预计2026/03/15起进入维护状态 | - |
| 2.7.1 | 长期分支 | 开发 | 2025/10/15| 预计2026/10/15起进入维护状态 | - |
| 2.6.0 | 常规分支 | 开发 | 2025/07/25 | 预计2026/01/25起进入维护状态 | - |
| 2.5.1 | 常规分支 | 维护 | 2024/11/08 | 预计2026/08/08起进入无维护状态 | - |
| 2.4.0 | 常规分支 | 维护 | 2024/10/15 | 预计2026/06/15起进入无维护状态 | - |
| **PyTorch版本** | **维护策略** | **当前状态** | **发布时间** | **后续状态** | **EOL日期** |
|---------------|-------------|------------|------------|----------------------------------|------------|
| 2.10.0 | 常规分支 | 开发 | 2026/04/15| 预计2026/10/15起进入维护状态 | - |
| 2.9.0 | 常规分支 | 开发 | 2026/01/15 | 预计2026/07/15起进入维护状态 | - |
| 2.8.0 | 常规分支 | 开发 | 2025/10/15 | 预计2026/03/15起进入维护状态 | - |
| 2.7.1 | 长期分支 | 开发 | 2025/10/15 | 预计2026/10/15起进入维护状态 | - |
| 2.6.0 | 常规分支 | 维护 | 2025/07/25 | 预计2026/01/25起进入维护状态 | - |
| 2.5.1 | 常规分支 | 维护 | 2024/11/08 | 预计2026/08/08起进入无维护状态 | - |
| 2.4.0 | 常规分支 | 维护 | 2024/10/15 | 预计2026/06/15起进入无维护状态 | - |
| 2.3.1 | 常规分支 | 维护 | 2024/06/06 | 预计2026/06/07起进入无维护状态 | |
| 2.2.0 | 常规分支 | EOL | 2024/04/01 | | 2025/10/14 |
| 2.1.0 | 长期支持 | 维护 | 2023/10/15 | 预计2026/12/30起进入无维护状态 | |
@@ -289,23 +75,33 @@ Ascend Extension for PyTorch版本分支的维护阶段如下:
| 1.8.1 | 长期支持 | EOL | 2022/4/10 | | 2023/4/10 |
| 1.5.0 | 长期支持 | EOL | 2021/7/29 | | 2022/7/29 |
## 贡献指导
介绍如何向Ascend Extension for PyTorch插件库贡献代码,具体请参见[Ascend Extension for PyTorch插件 贡献指南](CONTRIBUTING.md)。
## 联系我们
欢迎大家为社区做贡献。如果有任何疑问或建议,请提交[GitCode Issues](https://gitcode.com/Ascend/pytorch/issues),我们会尽快回复。感谢您的支持。
## 安全声明
[Ascend Extension for PyTorch插件 安全声明](./SECURITYNOTE.md)
Ascend Extension for PyTorch的系统安全加固、运行用户建议和文件权限控制等内容,请参见[Ascend Extension for PyTorch插件 安全声明](SECURITYNOTE.md)。
## 参考文档
## 免责声明
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[昇腾社区Ascend Extension for PyTorch](https://www.hiascend.com/software/ai-frameworks?framework=pytorch)。
致Ascend Extension for PyTorch插件使用者
| 文档名称 | 文档链接 |
| -------------------------- | ------------------------------------------------------------ |
| 软件安装指南 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/720/configandinstg/instg/insg_0001.html) |
| 网络模型迁移和训练 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/720/ptmoddevg/trainingmigrguide/PT_LMTMOG_0002.html) |
| 算子适配 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/720/ptmoddevg/Frameworkfeatures/featuresguide_00021.html) |
| PyTorch原生接口清单 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/720/apiref/PyTorchNativeapi/ptaoplist_000003.html) |
| Ascend Extension for PyTorch自定义API参考 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/720/apiref/torchnpuCustomsapi/context/%E6%A6%82%E8%BF%B0.md) |
- 本插件仅供调试和开发使用,使用者需自行承担使用风险,并理解以下内容:
- 数据处理及删除:用户在使用本插件过程中产生的数据属于用户责任范畴。建议用户在使用完毕后及时删除相关数据,以防信息泄露。
- 数据保密与传播:使用者了解并同意不得将通过本插件产生的数据随意外发或传播。对于由此产生的信息泄露、数据泄露或其他不良后果,本插件及其开发者概不负责。
- 用户输入安全性:用户需自行保证输入的命令行的安全性,并承担因输入不当而导致的任何安全风险或损失。对于输入命令行不当所导致的问题,本插件及其开发者概不负责。
- 免责声明范围:本免责声明适用于所有使用本插件的个人或实体。使用本插件即表示您同意并接受本声明的内容,并愿意承担因使用该功能而产生的风险和责任,如有异议请停止使用本插件。
- 在使用本工具之前,请谨慎阅读并理解以上免责声明的内容。对于使用本插件所产生的任何问题或疑问,请及时联系开发者。
## License
## 许可证
Ascend Extension for PyTorch插件的使用许可证,具体请参见[LICENSE](LICENSE)文件。
Ascend Extension for PyTorch插件使用BSD许可证。详见[LICENSE](LICENSE)文件。
## 致谢
感谢来自社区的每一个PR,欢迎贡献Ascend Extension for PyTorch插件!
+318
View File
@@ -0,0 +1,318 @@
# Ascend Extension for PyTorch Security Statement
## System Security Hardening
You are advised to enable address space layout randomization (ASLR) level 2 in the system. Run the following command to enable it:
echo 2 > /proc/sys/kernel/randomize_va_space
## Running User Recommendations
For security reasons and the principle of least privilege, do not use root or other privileged accounts to run torch_npu.
## File Permission Control
1. It is recommended that users implement appropriate access controls for sensitive files such as training data, intermediate saved files, personal private data, and commercial assets. For example, in multi-user dataset sharing scenarios, write permissions for dataset files should be restricted; permission controls should also be applied to files generated during profiling. For permission settings, refer to the [File Permission Reference](#file-permission-reference).
2. The torch_npu profiler generates performance record files with default permission `640` and directories with permission `750`. Users may adjust these permissions as needed.
3. Users should enforce permission controls during installation and usage. Refer to the [File Permission Reference](#file-permission-reference) for recommended settings. If you need to save installation/uninstallation logs, append `--log` to the installation/uninstallation command, and ensure proper permission management on the generated files and directories.
4. Files generated during PyTorch framework execution (for example, files saved via `torch.save`) inherit system‑default permissions. It is recommended that the user executing the script applies appropriate permission controls on output files as needed. Refer to the [File Permission Reference](#file-permission-reference) for guidance. The `umask` setting can be used to control default permissions and mitigate privilege escalation risks. It is recommended to set `umask` to `0027` or stricter on both hosts (including the host machine) and containers to enhance security.
### File Permission Reference
| Type | Maximum Linux Permission |
| --- | --- |
| Home directory | 750 (rwxr-x---) |
| Program files (including scripts and libraries) | 550 (r-xr-x---) |
| Program file directory | 550 (r-xr-x---) |
| Configuration files | 640 (rw-r-----) |
| Configuration file directory | 750 (rwxr-x---) |
| Log files (recorded or archived) | 440 (r--r-----) |
| Log files (being recorded) | 640 (rw-r-----) |
| Log file directory | 750 (rwxr-x---) |
| Debug files | 640 (rw-r-----) |
| Debug file directory | 750 (rwxr-x---) |
| Temporary file directory | 750 (rwxr-x---) |
| Maintenance and upgrade file directory | 770 (rwxrwx---) |
| Service data files | 640 (rw-r-----) |
| Service data file directory | 750 (rwxr-x---) |
| Key components, private keys, certificates, and ciphertext file directory | 700 (rwx------) |
| Key components, private keys, certificates, and ciphertext files | 600 (rw-------) |
| APIs and scripts for encryption and decryption | 500 (r-x------) |
## Debugging Tool Statement
The performance analysis tool profiler is integrated within torch_npu:
- Reason for integration: To align with PyTorch's native capabilities, provide performance analysis support for NPU-based PyTorch development, and accelerate the performance debugging process.
- Usage scenario: Data collection is disabled by default. When performance analysis is needed, users can add the Ascend Extension for PyTorch Profiler API to the model training script. Performance data is collected during training, and a visual performance data file is output after training completes.
- Risk notification: Using this feature generates performance data locally. Users are advised to take necessary precautions to protect this data. It is recommended to use the tool only when performance analysis is required and to disable it promptly after analysis is complete. For more details about the Profiler tool, please refer to the [PyTorch Performance Profiler](https://gitcode.com/Ascend/docs/blob/master/FrameworkPTAdapter/26.0.0/en/pytorch_model_migration_fine_tuning/introduction_to_performance_tuning_tools.md).
## Data Security Statement
1. PyTorch requires loading and saving data during its operation. Some interfaces rely on the pickle module, which may introduce security risks. Examples include torch.load, torch.jit.load, and torch.distributed.scatter_object_list. For more information on these risks, please refer to the [torch.load](https://pytorch.org/docs/main/generated/torch.load.html#torch.load) and [collective-functions](https://pytorch.org/docs/main/distributed.html#collective-functions) documentation.
2. The Ascend Extension for PyTorch relies on CANN's foundational capabilities to provide features such as AOE performance tuning, operator dumping, and logging. Users should carefully manage permission controls over files generated by these features and strengthen the protection of related data.
## Build Security Statement
torch_npu supports source code compilation and installation. During the build process, it downloads dependent third-party libraries and executes build shell scripts. Temporary program files and build directories are generated during compilation. Users may apply permission controls on files within the source code directory as needed to reduce security risks.
## Runtime Security Statement
1. You are advised to write training scripts that match the resource constraints of their runtime environment. Mismatches between the training script and available resources—such as loading a dataset that exceeds memory capacity or generating local data that exceeds disk space—may cause errors and unexpected process termination.
2. When runtime exceptions occur, PyTorch and torch_npu will terminate the process and print error messages, which is expected behavior. Users are advised to diagnose the root cause using the error messages, for example by enabling synchronous operator execution, inspecting CANN logs, or analyzing generated Core Dump files.
3. The distributed features of PyTorch and torch_npu are intended for internal communication only. For performance reasons, these features do not include any authentication protocol and may send unencrypted messages. For detailed documentation and security considerations regarding PyTorch's distributed capabilities, refer to [using-distributed-features](https://github.com/pytorch/pytorch/security#using-distributed-features).
## Public Network Address Statement
There are [public network addresses](#public-network-addresses) in the configuration files and scripts of torch_npu.
### Public Network Addresses
| Type | Open Source Code Address | Filename | Public IP Address/Public URL Address/Domain Name/Email Address | Usage Description |
| --- | --- | --- | --- | --- |
| Self-developed | Not applicable | .gitmodules | <https://gitcode.com/ascend/op-plugin.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitee.com/mirrors/googletest.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitee.com/ascend/torchair.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitcode.com/ascend/Tensorpipe.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitee.com/mirrors/fmt.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitee.com/mirrors_llvm/torch-mlir.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitee.com/mirrors/nlohmann-json.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitcode.com/cann/runtime.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitcode.com/cann/ge.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | .gitmodules | <https://gitcode.com/cann/graph-autofusion.git> | Dependent Open Source Repository |
| Self-developed | Not applicable | ci\docker\X86\Dockerfile | <https://mirrors.huaweicloud.com/repository/pypi/simple> | Docker Configuration File, used to configure pip source |
| Self-developed | Not applicable | ci\docker\X86\Dockerfile | <https://download.pytorch.org/whl/cpu> | Docker configuration source, used to configure torch Download Link |
| Self-developed | Not applicable | ci\docker\ARM\Dockerfile | <https://mirrors.huaweicloud.com/repository/pypi/simple> | Docker Configuration File, used to configure pip source |
| Self-developed | Not applicable | ci\docker\X86\Dockerfile | <https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo> | Docker Configuration File, used to configure yum source |
| Self-developed | Not applicable | ci\docker\ARM\Dockerfile | <https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo> | Docker Configuration File, used to configure yum source |
| Self-developed | Not applicable | .github\workflows\\_build-and-test.yml | <https://mirrors.huaweicloud.com/repository/pypi/simple> | Workflow Configuration File, used to configure pip source |
| Self-developed | Not applicable | setup.cfg | <https://gitcode.com/ascend/pytorch> | URL parameter for packaging whl |
| Self-developed | Not applicable | setup.cfg | <https://gitcode.com/ascend/pytorch/tags> | download_url parameter for packaging whl |
| Self-developed | Not applicable | third_party\op-plugin\ci\build.sh | <https://gitcode.com/ascend/pytorch.git> | Build script pulls code from torch_npu repository address for compilation |
| Self-developed | Not applicable | third_party\op-plugin\ci\exec_ut.sh | <https://gitcode.com/ascend/pytorch.git> | UT script pulls code from torch_npu repository address for UT testing |
| Open Source Introduction | <https://github.com/pytorch/pytorch/blob/v2.7.1/test/nn/test_convolution.py> <br> <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_mps.py> <br> <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_serialization.py> | test\url.ini | <https://download.pytorch.org/test_data/legacy_conv2d.pt> | Used for test Script Download of related pt files |
| Open Source Introduction | <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_serialization.py> | test\url.ini | <https://download.pytorch.org/test_data/legacy_serialized.pt> | Used for test Script Download of related pt files |
| Open Source Introduction | <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_serialization.py> | test\url.ini | <https://download.pytorch.org/test_data/gpu_tensors.pt> | Used for test Script Download of related pt files |
| Open Source Introduction | <https://github.com/pytorch/pytorch/blob/v2.7.1/test/onnx/test_utility_funs.py> | test\url.ini | <https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml> | Link to issue |
| Open Source Introduction | <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_nn.py> <br> <https://github.com/pytorch/pytorch/blob/v2.7.1/test/test_serialization.py> | test\url.ini | <https://download.pytorch.org/test_data/linear.pt> | Used for test Script Download of related pt files |
| Self-developed | Not applicable | torch_npu\npu\config.yaml | <https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl> | Flame graph Script Download path |
| Self-developed | Not applicable | test\requirements.txt | <https://download.pytorch.org/whl/nightly/cpu> | Download Link, used to download torch-cpu version |
| Self-developed | Not applicable | test\requirements.txt | <https://data.pyg.org/whl/torch-2.7.0+cpu.html> | Download Link, used to download torch-scatter cpu version |
| Self-developed | Not applicable | requirements.txt | <https://download.pytorch.org/whl/nightly/cpu> | Download Link, used to download torch-cpu version |
| Self-developed | Not applicable | test\get_synchronized_files.sh | <https://github.com/pytorch/pytorch.git> | Download Link, used to download PyTorch test cases |
## Public API Statement
The Ascend Extension for PyTorch is an adapter plugin for PyTorch that enables users to perform training and inference on Ascend devices using PyTorch. After adaptation, the extension allows users to use native PyTorch APIs. In addition to native PyTorch APIs, the Ascend Extension for PyTorch provides several custom APIs, including custom operators, affinity libraries, and other APIs, supporting integration between PyTorch APIs and custom ones. For details, refer to the [Ascend Extension for PyTorch Custom API Reference](https://gitcode.com/Ascend/op-plugin/blob/26.0.0/docs/en/custom_APIs/overview.md) and [PyTorch API List](https://gitcode.com/Ascend/pytorch/blob/v2.7.1-26.0.0/docs/en/native_apis/pytorch_2-10-0/overview.md).
Following the [PyTorch Community Public API Guidelines](https://github.com/pytorch/pytorch/wiki/Public-API-definition-and-documentation), the Ascend Extension for PyTorch provides external custom interfaces. If a function appears to meet the criteria for a public API and is documented as such, it is considered a public API. Otherwise, before using such a feature, you are encouraged to inquire with the community to confirm whether it is intentionally public or has been inadvertently exposed, as undocumented interfaces may be modified or removed in the future.
The Ascend Extension for PyTorch is developed using both C++ and Python. Except for Libtorch scenarios, the official APIs are currently provided only as Python APIs. The shared libraries within the torch_npu binary package do not provide direct services; any exposed interfaces are for internal use only and are not recommended for user adoption.
## Communication Security Hardening
PyTorch distributed training services require communication between devices. The ports opened for communication listen on 0.0.0.0 by default. To mitigate security risks, you are advised to harden the security for this scenario, for example, by configuring firewall rules using iptables to restrict external access to the ports used for distributed training before the training starts, and cleaning up the firewall rules after distributed training completes.
1. Firewall rule configuration and removal reference script template
- For firewall rule configuration, refer to the following script:
```bash
#!/bin/bash
set -x
# Port Number to be restricted
port={port_number}
# Clear old rules
iptables -D INPUT -p tcp -j {rule_name}
iptables -F {rule_name}
iptables -X {rule_name}
# Create a new rule chain
iptables -t filter -N {rule_name}
# In a multi-node scenario, configure a whitelist to allow other nodes to access the listening port of the master node.
# Add a rule to the rule chain that allows a specific IP address range.
iptables -t filter -A {rule_name} -i eno1 -p tcp --dport $port -s {IP allowed for external access} -j ACCEPT
# Block external addresses from accessing the distributed training port.
# Add a rule to the PORT-LIMIT-RULE chain to deny other IP addresses.
iptables -t filter -A {rule_name} -i {NIC to be restricted} -p tcp --dport $port -j DROP
# Pass traffic to the rule chain
iptables -I INPUT -p tcp -j {rule_name}
```
- To remove a firewall rule, refer to the following script:
```bash
#!/bin/bash
set -x
# Clear rules
iptables -D INPUT -p tcp -j {rule name}
iptables -F {rule name}
iptables -X {rule name}
```
2. Firewall rule configuration and removal reference script example
- Configure the firewall for a specific port. The port number in the script is the port to be restricted. For the port number in PyTorch distributed training, refer to [Communication Matrix Information](#communication-matrix-information). The network interface card name to be restricted is the NIC used by the server for distributed communication, and the allowed external access IP is the IP address of the distributed training server. The NIC and server IP can be viewed using ifconfig. In the following output, eth0 is the NIC name and 192.168.1.1 is the server IP address:
```bash
# ifconfig
eth0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::230:64ee:ef1a:c1a/64 Scope:Link
```
- Assume the server master node address is 192.168.1.1, another server that needs to perform distributed training is 192.168.1.2, and the training port is 29510.
- Firewall rule configuration, refer to the following script:
```bash
#!/bin/bash
set -x
# Set the listening port
port=29510
# Clear old rules
iptables -D INPUT -p tcp -j PORT-LIMIT-RULE
iptables -F PORT-LIMIT-RULE
iptables -X PORT-LIMIT-RULE
# Create a new PORT-LIMIT-RULE chain
iptables -t filter -N PORT-LIMIT-RULE
# Set a whitelist in a multi-node scenario to allow 192.168.1.2 to access the master node
# Add a rule in the PORT-LIMIT-RULE chain to allow a specific IP address range
iptables -t filter -A PORT-LIMIT-RULE -i eno1 -p tcp --dport $port -s 192.168.1.2 -j ACCEPT
# Block external addresses from accessing the distributed training port
# Add a rule in the PORT-LIMIT-RULE chain to deny other IP addresses
iptables -t filter -A PORT-LIMIT-RULE -i eth0 -p tcp --dport $port -j DROP
# Pass traffic to the PORT-LIMIT-RULE chain
iptables -I INPUT -p tcp -j PORT-LIMIT-RULE
```
- Firewall rule removal, refer to the following script:
```bash
#!/bin/bash
set -x
# Clear rules
iptables -D INPUT -p tcp -j PORT-LIMIT-RULE
iptables -F PORT-LIMIT-RULE
iptables -X PORT-LIMIT-RULE
```
## Communication Matrix
PyTorch provides distributed training capabilities and supports training in both single‑node and multi‑node scenarios, which requires network communication. Specifically, PyTorch communicates over TCP, while torch_npu uses HCCL from CANN for communication between NPU devices. For port details, refer to the [communication matrix](#communication-matrix-information). Users should pay attention to and ensure the security of inter‑node communication networks. Measures such as iptables can be used to mitigate security risks. For network security hardening, refer to the [Communication Security Hardening](#communication-security-hardening) section.
### Communication Matrix Information
| Component | PyTorch | HCCL |
| --------------------- | ------------------------------------ | ------------------------------------ |
| Source Device | Server running the torch_npu process | Server running the torch_npu process |
| Source IP | Device IP Address | Device IP Address |
| Source Port | Automatically assigned by the operating system. The assignment range is determined by the OS's own configuration. | Default value is 60000, Value Range [1024, 65520]. Users can specify the starting port number of the Host NIC via the HCCL_IF_BASE_PORT Environment Variable. After configuration, the system occupies 16 ports starting from this port by default. |
| Destination Device | Server running the torch_npu process | Server running the torch_npu process |
| Destination IP | Device IP Address | Device IP Address |
| Destination Port (Listening) | Default 29500/29400, users can set the Port Number | Default value is 60000, Value Range [1024, 65520]. Users can specify the starting port number of the Host NIC via the HCCL_IF_BASE_PORT Environment Variable. After configuration, the system occupies 16 ports starting from this port by default. |
| Protocol | TCP | TCP |
| Port Description | In distributed scenarios <br> 1. torchrun/torch.distributed.launch <br> (1) When backend is static (default), the destination port (default 29500) is used for receiving and sending data, and the source port is used for receiving and sending data. Use master-addr to specify the address and master-port to specify the port. <br> (2) When backend is c10d, the destination port (default 29400) is used for receiving and sending data, and the source port is used for receiving and sending data. Use rdzv_endpoint to specify the address and port number in the format "address:port number". <br> 2. torch_npu_run: The destination port (default 29500) is used for receiving and sending data, and the source port is used for receiving and sending data. Use master-addr to specify the address and master-port to specify the port. | Default value is 60000, Value Range [1024, 65520]. Users can specify the starting port number of the Host NIC via the HCCL_IF_BASE_PORT Environment Variable. After configuration, the system occupies 16 ports starting from this port by default. |
| Can Listening Port Be Changed | Yes | Yes |
| Authentication Method | No authentication | No authentication |
| Encryption Method | None | None |
| Belonging Plane | Not involved | Not involved |
| Version | All versions | All versions |
| Special Scenario | None | None |
| Remarks | This communication process is controlled by the open-source software PyTorch, configured with PyTorch native settings. Refer to the [PyTorch documentation](https://pytorch.org/docs/stable/distributed.html#launch-utility). The source port is automatically assigned by the operating system, and the assignment range is determined by the OS configuration. For example, on Ubuntu: it is specified by the /proc/sys/net/ipv4/ipv4_local_port_range file, which can be viewed via cat /proc/sys/net/ipv4/ipv4_local_port_range or sysctl net.ipv4.ip_local_port_range. | This communication process is controlled by the HCCL component in CANN; torch_npu does not control it. For the port range, refer to the "Execution Related > Collective Communication > HCCL_IF_BASE_PORT" section in the [Environment Variable Reference](https://www.hiascend.com/document/detail/zh/canncommercial/900/maintenref/envvar/envref_07_0001.html). |
## Vulnerability Security Statement
The Ascend Extension for PyTorch community highly values the security of community versions. Vulnerability management specialists are specifically designated to handle vulnerability-related matters. To build a more secure AI full-process toolchain, we look forward to your participation.
### Vulnerability Handling Procedure
For each security vulnerability, the MindStudio community assigns personnel to follow up and handle it. The end-to-end vulnerability handling process is shown in the following figure.
![vulnerability handling procedure](./figures/cve.png)
The following sections explain the vulnerability reporting, assessment, and disclosure processes.
### Vulnerability Reporting
You can contact the Ascend Extension for PyTorch community team by submitting an issue. We will arrange for a security vulnerability specialist to contact you promptly.
Note that to ensure security, do not include specific information about security privacy in the issue.
#### Response to Reports
1. The Ascend Extension for PyTorch community will confirm, analyze, and report security vulnerability issues within three working days, while initiating the security handling process.
2. The Ascend Extension for PyTorch security team will assign confirmed security vulnerability issues to dedicated personnel and follow up on them.
3. During the process of classifying, confirming, and fixing security vulnerabilities, as well as releasing patches, we will provide timely updates on the report.
### Vulnerability Assessment
The industry widely uses the CVSS standard to assess vulnerability severity. When using CVSS v3.1 for vulnerability assessment, Ascend Extension for PyTorch sets specific attack scenarios and performs assessments based on the actual impact within those scenarios. Vulnerability severity assessment involves assessing the difficulty of exploitation as well as the impact on confidentiality, integrity, and availability after exploitation, resulting in a numerical score.
#### Vulnerability Assessment Metrics
Ascend Extension for PyTorch assesses vulnerability severity levels by using the following vector metrics:
- Attack vector (AV): indicates the "remoteness" of an attack and how a vulnerability can be exploited.
- Attack complexity (AC): describes the difficulty of executing an attack and the factors required for a successful attack.
- User interaction (UI): determines whether the attack requires user participation.
- Privileges required (PR): records the level of user authentication required for a successful attack.
- Scope (S): determines whether an attack can affect components with different permission levels.
- Confidentiality (C): measures the impact resulting from information disclosure to unauthorized parties.
- Integrity (I): measures the impact resulting from information tampering.
- Availability (A): measures the impact on users' access to data or services when needed.
#### Assessment Principles
- Assess the severity level of the vulnerability, not the risk.
- The assessment must be based on an attack scenario where a successful attack can compromise the confidentiality, integrity, and availability of the system.
- When a security vulnerability has multiple attack scenarios, the attack scenario with the highest CVSS score (that is, with the greatest impact) shall prevail in the assessment.
- If a vulnerability exists in an embedded or invoked library, perform the assessment after determining the attack scenario based on how the library is used in the product.
- If a security defect cannot be triggered or does not affect confidentiality, integrity, or availability (CIA), the CVSS score is 0.
#### Assessment Procedure
To assess the severity level of a vulnerability, perform the following steps:
1. Set a possible attack scenario and score based on this attack scenario.
2. Identify the vulnerable component and affected components.
3. Select values for the base metrics.
- Select values for the exploitability metrics (attack vector, attack complexity, privileges required, user interaction, and scope) based on the vulnerable component.
- Ensure impact metrics (confidentiality, integrity, and availability) reflect the impact on either the vulnerable component or the affected components, whichever is more severe.
#### Severity Rating
| **Severity Rating** | **CVSS Score** | **Vulnerability Fix Time** |
| ------------------------------- | --------------------- | ---------------- |
| Critical | 9.0~10.0 | 7 days |
| High | 7.0~8.9 | 14 days |
| Medium | 4.0~6.9 | 30 days |
| Low | 0.1~3.9 | 30 days |
### Vulnerability Disclosure
After a security vulnerability is fixed, the Ascend Extension for PyTorch community will release a security advisory (SA) and security notice (SN). The SA includes technical details of the vulnerability, type, reporter, CVE ID, affected versions, and fixed versions.
To ensure security for Ascend Extension for PyTorch users, the Ascend Extension for PyTorch community will not publicly disclose, discuss, or confirm security issues until after investigation and fixing are complete and an SA has been released.
### Appendix
#### Security Advisory (SA)
Currently maintained versions have no security vulnerabilities.
#### Security Note (SN)
No vulnerability notices are currently available for third-party open-source components.
+28 -28
View File
@@ -70,35 +70,35 @@ torch_npu支持源码编译安装,在编译时会下载依赖第三方库并
##### 公网地址
| 类型 | 开源代码地址 | 文件名 | 公网IP地址/公网URL地址/域名/邮箱地址 | 用途说明 |
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|--------------------------------------------------------------------------------|--------------------------------|
| 自研 | 不涉及 | .gitmodules | https://gitcode.com/ascend/op-plugin.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/googletest.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/ascend/torchair.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitcode.com/ascend/Tensorpipe.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/fmt.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/nlohmann-json.git | 依赖的开源代码仓 |
| 类型 | 开源代码地址 | 文件名 | 公网IP地址/公网URL地址/域名/邮箱地址 | 用途说明 |
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|--------------------------------------------------------------------------------|--------------------------------|
| 自研 | 不涉及 | .gitmodules | https://gitcode.com/ascend/op-plugin.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/googletest.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/ascend/torchair.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitcode.com/ascend/Tensorpipe.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/fmt.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/nlohmann-json.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors_llvm/torch-mlir.git | 依赖的开源代码仓 | |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://download.pytorch.org/whl/cpu | docker配置源,用于配置torch下载连接 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | .github\workflows\\_build-and-test.yml | https://mirrors.huaweicloud.com/repository/pypi/simple | workflow配置文件,用于配置pip源 |
| 自研 | 不涉及 | setup.cfg | https://gitcode.com/ascend/pytorch | 用于打包whl的url入参 |
| 自研 | 不涉及 | setup.cfg | https://gitcode.com/ascend/pytorch/tags | 用于打包whl的download_url入参 |
| 自研 | 不涉及 | third_party\op-plugin\ci\build.sh | https://gitcode.com/ascend/pytorch.git | 编译脚本根据torch_npu仓库地址拉取代码进行编译 |
| 自研 | 不涉及 | third_party\op-plugin\ci\exec_ut.sh | https://gitcode.com/ascend/pytorch.git | UT脚本根据torch_npu仓库地址拉取代码进行UT测试 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/main/test/nn/test_convolution.py <br> https://github.com/pytorch/pytorch/blob/main/test/test_mps.py <br> https://github.com/pytorch/pytorch/blob/main/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_conv2d.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/main/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_serialized.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/main/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/gpu_tensors.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/main/test/onnx/test_utility_funs.py | test\url.ini | https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml | issue的链接 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/main/test/test_nn.py <br> https://github.com/pytorch/pytorch/blob/main/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/linear.pt | 用于test脚本下载相关pt文件 |
| 自研 | 不涉及 | torch_npu\npu\config.yaml | https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl | 火焰图脚本下载路径 |
| 自研 | 不涉及 | test\requirements.txt | https://download.pytorch.org/whl/nightly/cpu | 下载链接,用于下载torch-cpu版本 |
| 自研 | 不涉及 | test\requirements.txt | https://data.pyg.org/whl/torch-2.4.0+cpu.html | 下载链接,用于下载torch-scatter的cpu版本 |
| 自研 | 不涉及 | requirements.txt | https://download.pytorch.org/whl/nightly/cpu | 下载链接,用于下载torch-cpu版本 |
| 自研 | 不涉及 | test\get_synchronized_files.sh | https://github.com/pytorch/pytorch.git | 下载链接,用于下载PyTorch的测试用例 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://download.pytorch.org/whl/cpu | docker配置源,用于配置torch下载连接 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | .github\workflows\\_build-and-test.yml | https://mirrors.huaweicloud.com/repository/pypi/simple | workflow配置文件,用于配置pip源 |
| 自研 | 不涉及 | setup.cfg | https://gitcode.com/ascend/pytorch | 用于打包whl的url入参 |
| 自研 | 不涉及 | setup.cfg | https://gitcode.com/ascend/pytorch/tags | 用于打包whl的download_url入参 |
| 自研 | 不涉及 | third_party\op-plugin\ci\build.sh | https://gitcode.com/ascend/pytorch.git | 编译脚本根据torch_npu仓库地址拉取代码进行编译 |
| 自研 | 不涉及 | third_party\op-plugin\ci\exec_ut.sh | https://gitcode.com/ascend/pytorch.git | UT脚本根据torch_npu仓库地址拉取代码进行UT测试 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.8.0/test/nn/test_convolution.py <br> https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_mps.py <br> https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_conv2d.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_serialized.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/gpu_tensors.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.8.0/test/onnx/test_utility_funs.py | test\url.ini | https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml | issue的链接 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_nn.py <br> https://github.com/pytorch/pytorch/blob/v2.8.0/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/linear.pt | 用于test脚本下载相关pt文件 |
| 自研 | 不涉及 | torch_npu\npu\config.yaml | https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl | 火焰图脚本下载路径 |
| 自研 | 不涉及 | test\requirements.txt | https://download.pytorch.org/whl/cpu | 下载链接,用于下载torch-cpu版本 |
| 自研 | 不涉及 | test\requirements.txt | https://data.pyg.org/whl/torch-2.7.0+cpu.html | 下载链接,用于下载torch-scatter的cpu版本 |
| 自研 | 不涉及 | requirements.txt | https://download.pytorch.org/whl/cpu | 下载链接,用于下载torch-cpu版本 |
| 自研 | 不涉及 | test\get_synchronized_files.sh | https://github.com/pytorch/pytorch.git | 下载链接,用于下载PyTorch的测试用例 |
## 公开接口声明
+6 -1
View File
@@ -16,7 +16,7 @@ from distutils import file_util
# Disable autoloading before running 'import torch' to avoid circular dependencies
os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = "0"
from codegen.utils import PathManager
from torchnpugen.utils import PathManager
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
PathManager.check_directory_path_readable(os.path.join(BASE_DIR, "version.txt"))
@@ -227,6 +227,11 @@ def copy_hpp():
"torch_npu/csrc/framework/*/*/*.h",
"torch_npu/csrc/libs/*.h",
"torch_npu/csrc/inductor/**/*.h",
"torch_npu/csrc/distributed/*.h",
"torch_npu/csrc/distributed/*.hpp",
"third_party/acl/inc/*/*.h",
"third_party/acl/inc/*/*/*.h",
"third_party/hccl/inc/*/*.h",
]
glob_header_files = []
for regex_pattern in header_files:
+4 -5
View File
@@ -34,7 +34,7 @@ class TestMgr:
def load(self, modify_files, world_size):
with open(modify_files) as f:
for line in f:
if world_size != 0 and ("test/distributed/" in line or "test/_inductor/" in line):
if world_size != 0 and ("test/_inductor/" in line):
continue
line = line.strip()
self.modify_files.append(line)
@@ -67,6 +67,8 @@ class TestMgr:
self.test_files['ut_files'] += [str(i) for i in (BASE_DIR / 'test/_inductor').rglob('test_*.py')]
def load_op_plugin_ut(self):
if not os.path.exists(BASE_DIR / 'third_party/op-plugin/test'):
raise Exception("The path of op-plugin did not exist, check whether it had been pulled.")
version_path = get_test_torch_version_path()
file_hash = {}
for file_path in (BASE_DIR / 'third_party/op-plugin/test').rglob('test_*.py'):
@@ -87,10 +89,7 @@ class TestMgr:
if include_distributed_case:
self.load_distributed_ut()
if include_op_plugin_case:
if os.path.exists(BASE_DIR / 'third_party/op-plugin/test'):
self.load_op_plugin_ut()
else:
raise Exception("The path of op-plugin did not exist, check whether it had been pulled.")
self.load_op_plugin_ut()
def split_test_files(self, rank, world_size):
if rank > world_size:
+19 -2
View File
@@ -8,6 +8,7 @@ import queue
import argparse
from pathlib import Path
import random
import time
import psutil
from access_control import (
TestMgr,
@@ -97,12 +98,15 @@ def exec_ut(files):
ut_info = "test_ops " + ut_info
else:
cmd = cmd if 'op-plugin' in str(Path(ut_file)) else cmd + ["--init_method={}".format(init_method)]
t_start = time.time()
ret = run_cmd_with_timeout(cmd)
elapsed = time.time() - t_start
duration = "{:.1f}s".format(elapsed)
if ret:
has_failed = ret
test_infos.append("exec ut {} failed.".format(ut_info))
test_infos.append("exec ut {} failed. [{}]".format(ut_info, duration))
else:
test_infos.append("exec ut {} success.".format(ut_info))
test_infos.append("exec ut {} success. [{}]".format(ut_info, duration))
init_method = 2 if init_method == 1 else 1
return has_failed, test_infos
@@ -121,6 +125,7 @@ if __name__ == "__main__":
parser.add_argument('--inductor', action="store_true", help='Run inductor testcases')
parser.add_argument('--rank', default=0, type=int, help='Index of current ut nodes')
parser.add_argument('--world_size', default=0, type=int, help='Number of ut nodes')
parser.add_argument('--npu_core', help='Run core testcases in npu')
parser.add_argument('--network_ops', action="store_true", help='Run network_ops testcases in the op-plugin repo')
options = parser.parse_args()
print(f"options: {options}")
@@ -131,6 +136,8 @@ if __name__ == "__main__":
test_mgr.load_all_ut(options.distributed, options.network_ops)
elif options.distributed:
test_mgr.load_distributed_ut()
elif options.network_ops:
test_mgr.load_op_plugin_ut()
elif options.inductor:
test_mgr.load_inductor_ut()
elif os.path.exists(cur_modify_files):
@@ -144,6 +151,16 @@ if __name__ == "__main__":
test_mgr.split_test_files(options.rank, options.world_size)
cur_test_files = test_mgr.get_test_files()
if options.npu_core in ("yes", "no"):
npu_dir = str(TEST_DIR / "npu")
for ut_type in list(cur_test_files.keys()):
if options.npu_core == "yes":
cur_test_files[ut_type] = [f for f in cur_test_files[ut_type]
if str(Path(f)).startswith(npu_dir)]
else:
cur_test_files[ut_type] = [f for f in cur_test_files[ut_type]
if not str(Path(f)).startswith(npu_dir)]
test_mgr.print_modify_files()
test_mgr.print_ut_files()
test_mgr.print_op_ut_files()
+22 -14
View File
@@ -1,11 +1,19 @@
FROM quay.io/pypa/manylinux2014_aarch64:2023-10-07-c1e05d1
FROM pytorch/manylinux2_28_aarch64-builder:cpu-aarch64-v2.10.0-rc7
# Set pip
ENV PATH /usr/local/bin:$PATH
RUN echo "alias ll='ls -l --color=auto'" >> /root/.bashrc
# Set pip&python
RUN cd /usr/local/bin \
&& ln -s /opt/_internal/cpython-3.9.18/bin/pip3.9 pip3.9 \
&& ln -s /opt/_internal/cpython-3.10.13/bin/pip3.10 pip3.10 \
&& ln -s /opt/_internal/cpython-3.11.6/bin/pip3.11 pip3.11 \
&& ln -s python3.9 python3
&& ln -sf /opt/_internal/cpython-3.10.19/bin/pip3.10 pip3.10 \
&& ln -sf /opt/_internal/cpython-3.11.14/bin/pip3.11 pip3.11 \
&& ln -sf /opt/_internal/cpython-3.12.12/bin/pip3.12 pip3.12 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/pip3.10 pip3 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/python3.10 python3.10 \
&& ln -sf /opt/_internal/cpython-3.11.14/bin/python3.11 python3.11 \
&& ln -sf /opt/_internal/cpython-3.12.12/bin/python3.12 python3.12 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/python3.10 python3
# Set pip source
RUN mkdir /root/.pip \
@@ -32,16 +40,16 @@ RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
fi
# Install pip package(build)
RUN pip3.9 install pyyaml \
&& pip3.9 install torch==2.1.0 \
&& pip3.9 install numpy==1.21.3
RUN pip3.10 install pyyaml \
&& pip3.10 install torch==2.1.0 \
&& pip3.10 install numpy==1.21.3
&& pip3.10 install torch==2.10.0 \
&& pip3.10 install numpy==1.25.2
RUN pip3.11 install pyyaml \
&& pip3.11 install torch==2.1.0 \
&& pip3.11 install numpy==1.23.2
&& pip3.11 install torch==2.10.0 \
&& pip3.11 install numpy==1.25.2
RUN pip3.12 install pyyaml \
&& pip3.12 install torch==2.10.0 \
&& pip3.12 install numpy==1.25.2
WORKDIR /home
+22 -17
View File
@@ -1,14 +1,19 @@
FROM pytorch/manylinux-builder:cpu-2.1
FROM pytorch/manylinux2_28-builder:cpu-v2.10.0-rc7
# Install python
ENV PATH /usr/local/bin:$PATH
RUN echo "alias ll='ls -l --color=auto'" >> /root/.bashrc
# Set pip&python
RUN cd /usr/local/bin \
&& ln -s /opt/_internal/cpython-3.9.0/bin/pip3.9 pip3.9 \
&& ln -s /opt/_internal/cpython-3.10.1/bin/pip3.10 pip3.10 \
&& ln -s /opt/_internal/cpython-3.11.0/bin/pip3.11 pip3.11 \
&& ln -s /opt/_internal/cpython-3.9.0/bin/python3.9 python3.9 \
&& ln -s /opt/_internal/cpython-3.10.1/bin/python3.10 python3.10 \
&& ln -s /opt/_internal/cpython-3.11.0/bin/python3.11 python3.11 \
&& ln -s python3.9 python3
&& ln -sf /opt/_internal/cpython-3.10.19/bin/pip3.10 pip3.10 \
&& ln -sf /opt/_internal/cpython-3.11.14/bin/pip3.11 pip3.11 \
&& ln -sf /opt/_internal/cpython-3.12.12/bin/pip3.12 pip3.12 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/pip3.10 pip3 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/python3.10 python3.10 \
&& ln -sf /opt/_internal/cpython-3.11.14/bin/python3.11 python3.11 \
&& ln -sf /opt/_internal/cpython-3.12.12/bin/python3.12 python3.12 \
&& ln -sf /opt/_internal/cpython-3.10.19/bin/python3.10 python3
# Set pip source
RUN mkdir /root/.pip \
@@ -35,16 +40,16 @@ RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
fi
# Install pip package(build)
RUN pip3.9 install pyyaml \
&& pip3.9 install torch==2.1.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.9 install numpy==1.21.3
RUN pip3.10 install pyyaml \
&& pip3.10 install torch==2.1.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.10 install numpy==1.21.3
&& pip3.10 install torch==2.10.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.10 install numpy==1.25.2
RUN pip3.11 install pyyaml \
&& pip3.11 install torch==2.1.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.11 install numpy==1.23.2
&& pip3.11 install torch==2.10.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.11 install numpy==1.25.2
RUN pip3.12 install pyyaml \
&& pip3.12 install torch==2.10.0+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.12 install numpy==1.25.2
WORKDIR /home
+76
View File
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(HCCLAllreduceExample CXX C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
# 定义构建类型
IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug构建")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DEBUG")
ELSEIF(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message("RelWithDebInfo构建")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
ELSE()
message("Release构建")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
ENDIF()
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
# 自动查找libtorch路径
# 优先使用环境变量,如果未设置则自动从Python获取
if(DEFINED ENV{TORCH_INSTALL_DIR})
set(torch_path "$ENV{TORCH_INSTALL_DIR}")
else()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import torch; import os; print(os.path.dirname(torch.__file__))"
OUTPUT_VARIABLE torch_path
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
if(NOT EXISTS ${torch_path})
message(FATAL_ERROR "未找到libtorch安装目录,请设置环境变量TORCH_INSTALL_DIR或确保Python环境中已安装torch")
endif()
message(STATUS "libtorch路径: ${torch_path}")
include_directories(${torch_path}/include)
# c10d/ProcessGroup.hpp
include_directories(${torch_path}/include/torch/csrc/distributed)
# torch/torch.h
include_directories(${torch_path}/include/torch/csrc/api/include)
link_directories(${torch_path}/lib)
# 使用环境变量查找libtorch_npu路径
if(DEFINED ENV{TORCH_NPU_INSTALL_DIR})
set(torch_npu_path "$ENV{TORCH_NPU_INSTALL_DIR}")
endif()
if(NOT EXISTS ${torch_npu_path})
message(WARNING "未找到libtorch_npu安装目录,请设置环境变量TORCH_NPU_INSTALL_DIR")
else()
message(STATUS "libtorch_npu路径: ${torch_npu_path}")
include_directories(${torch_npu_path}/include)
link_directories(${torch_npu_path}/lib)
endif()
# arm环境构建依赖torch.libs/*.so库,需要手动加载
# link_directories(<python path>/site-packages/torch.libs)
# 添加可执行文件
add_executable(example_allreduce_hccl allreduce_hccl.cpp)
# 链接库
target_link_libraries(example_allreduce_hccl
-ltorch
-ltorch_cpu
-lc10
-ltorch_npu
)
+85
View File
@@ -0,0 +1,85 @@
# HCCL AllReduce 示例
这是一个独立的HCCL集合通信测试用例,用于验证NPU设备上的ProcessGroupHCCL功能。
## 文件说明
- `allreduce_hccl.cpp` - HCCL allreduce示例代码
- `CMakeLists.txt` - 独立的CMake构建文件
- `libtorch_hccl.sh` - 运行脚本
## 构建
### 1. 环境准备
CMakeLists.txt会自动从Python环境检测libtorch的安装路径。
**自动检测**(推荐):
- 确保Python环境中已安装torch
- CMake会自动从Python获取路径
**手动指定**(可选):
```bash
# 如果自动检测失败,可以手动设置环境变量
export TORCH_INSTALL_DIR=/path/to/torch # 通常在 site-packages/torch
export TORCH_NPU_INSTALL_DIR=/path/to/torch_npu
```
### 2. 构建示例
```bash
cd examples/libtorch_hccl
mkdir build && cd build
cmake ..
make
```
## 运行
### 方法:
```bash
cd examples/libtorch_hccl
chmod +x libtorch_hccl.sh
./libtorch_hccl.sh
```
自定义进程数:
```bash
NUM_PROCESSES=4 ./libtorch_hccl.sh
```
## 预期输出
```
启动HCCL allreduce示例: rank=0, size=2
NPU设备 0 初始化完成
在NPU设备 0 上创建了 10 个张量
已提交 10 个allreduce操作
所有操作已完成!
张量 0 第一个元素: 2.0
张量 1 第一个元素: 2.0
张量 2 第一个元素: 2.0
HCCL allreduce示例运行成功!
```
值 `2.0` 是2个进程对全1张量进行allreduce求和的结果 (1+1=2)。
## 代码说明
示例演示了以下关键步骤:
1. **NPU设备初始化**: 使用 `torch_npu::init_npu("npu:0")` 初始化设备
2. **创建ProcessGroupHCCL**: 用于NPU集合通信
3. **创建张量**: 在NPU设备上创建张量
4. **执行allreduce**: 对张量进行全局归约操作
5. **验证结果**: 检查归约结果是否正确
6. **资源清理**: 调用 `torch_npu::finalize_npu()` 释放资源
## 注意事项
- 确保NPU设备可用且CANN已正确安装
- 使用NPU设备结束后必须调用 `torch_npu::finalize_npu()` 释放资源
- 所有进程需要同时启动才能正常工作
- libtorch通常安装在Python的site-packages/torch目录下
- libtorch_npu通常使用build_libtorch_npu.py脚本构建安装
+87
View File
@@ -0,0 +1,87 @@
#include <iostream>
#include <cstdlib>
#include <string>
#include <c10/util/irange.h>
#include <torch/csrc/distributed/c10d/FileStore.hpp>
#include <torch_npu/csrc/distributed/ProcessGroupHCCL.hpp>
#include <torch/torch.h>
#include "torch_npu/torch_npu.h"
using namespace c10d;
using namespace c10d_npu;
const int g_rank = []() {
const char* env = std::getenv("RANK");
return env ? std::stoi(std::string(env)) : 0;
}();
const int g_size = []() {
const char* env = std::getenv("SIZE");
return env ? std::stoi(std::string(env)) : 1;
}();
int main(int argc, char** argv)
{
int rank = g_rank;
int size = g_size;
std::cout << "启动 HCCL allreduce 示例: rank=" << rank << ", size=" << size << std::endl;
// 初始化NPU设备 - 使用npu字符串格式
std::string device_str = "npu:" + std::to_string(rank);
torch_npu::init_npu(device_str);
std::cout << "NPU设备 " << rank << " 初始化完成" << std::endl;
// 创建FileStore用于进程间通信协调
auto store = c10::make_intrusive<FileStore>("/tmp/c10d_hccl_example", size);
// 创建ProcessGroupHCCL选项
auto options = ProcessGroupHCCL::Options::create();
// 创建ProcessGroupHCCL实例
auto pg = c10::make_intrusive<ProcessGroupHCCL>(store, rank, size, options);
// 通过传NPU字符串构造NPU设备
auto device = at::Device(device_str);
// 创建10个张量用于测试
const auto ntensors = 10;
std::vector<at::Tensor> tensors;
for (const auto i : c10::irange(ntensors)) {
// 在NPU设备上创建全1张量
auto x = at::ones({1000, 16 * (i + 1)}, at::TensorOptions(device).dtype(at::kFloat));
tensors.push_back(x);
}
std::cout << "在NPU设备 " << rank << " 上创建了 " << ntensors << " 个张量" << std::endl;
// 提交所有allreduce操作
std::vector<c10::intrusive_ptr<Work>> pending;
for (const auto i : c10::irange(ntensors)) {
std::vector<at::Tensor> tmp = {tensors[i]};
pending.push_back(pg->allreduce(tmp));
}
std::cout << "已提交 " << ntensors << " 个allreduce操作" << std::endl;
// 等待所有操作完成
for (auto& work : pending) {
work->wait();
}
std::cout << "所有操作已完成!" << std::endl;
// 验证结果 - 打印前3个张量的第一个元素
for (const auto i : c10::irange(std::min(ntensors, 3))) {
auto cpu_tensor = tensors[i].to(at::kCPU);
std::cout << "张量 " << i << " 第一个元素: " << cpu_tensor.data_ptr<float>()[0] << std::endl;
}
std::cout << "HCCL allreduce示例运行成功!" << std::endl;
// 使用NPU设备结束需进行反初始化
torch_npu::finalize_npu();
return 0;
}
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
set -e
# 默认使用2个进程
NUM_PROCESSES=${NUM_PROCESSES:-2}
# 获取脚本所在目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 检查二进制文件是否存在
if [ ! -f "${SCRIPT_DIR}/build/example_allreduce_hccl" ]; then
echo "错误: 未找到example_allreduce_hccl二进制文件"
echo "请先构建项目:"
echo " cd ${SCRIPT_DIR}"
echo " mkdir build && cd build"
echo " cmake .."
echo " make"
exit 1
fi
echo "运行HCCL allreduce示例,进程数: ${NUM_PROCESSES}"
echo "二进制文件: ${SCRIPT_DIR}/build/example_allreduce_hccl"
# 清理之前的临时文件
rm -f /tmp/c10d_hccl_example
# 启动多个进程
pids=()
for ((rank=0; rank<NUM_PROCESSES; rank++)); do
echo "启动进程 ${rank}"
RANK=${rank} SIZE=${NUM_PROCESSES} \
"${SCRIPT_DIR}/build/example_allreduce_hccl" &
pids+=($!)
done
# 等待所有进程完成
for pid in "${pids[@]}"; do
wait ${pid}
done
echo "所有进程已完成!"
# 清理临时文件
rm -f /tmp/c10d_hccl_example
+4 -4
View File
@@ -23,19 +23,19 @@ testing_source_yaml="$CDIR/test/ops_unsupport_list.yaml"
op_plugin_functions_yaml_path="$op_plugin_config_path/npu_native_functions.yaml"
${python_execute} -m codegen.gen_backend_stubs \
${python_execute} -m torchnpugen.gen_backend_stubs \
--output_dir="torch_npu/csrc/aten" \
--source_yaml="$source_yaml" \
--impl_path="$CDIR/torch_npu/csrc/aten" \
--op_plugin_impl_path="$CDIR/third_party/op-plugin/op_plugin/ops" \
--op_plugin_yaml_path="$op_plugin_config_path/op_plugin_functions.yaml"
${python_execute} -m codegen.autograd.gen_autograd \
${python_execute} -m torchnpugen.autograd.gen_autograd \
--out_dir="$CDIR/torch_npu/csrc/aten" \
--autograd_dir="$CDIR/codegen/autograd" \
--autograd_dir="$CDIR/torchnpugen/autograd" \
--npu_native_function_dir="$source_yaml"
${python_execute} -m codegen.codegen_ops_info
${python_execute} -m torchnpugen.codegen_ops_info
if [ -f $CDIR/third_party/op-plugin/codegen/templates/_op_plugin_docs.py ]; then
if [ -f $CDIR/torch_npu/_op_plugin_docs.py ]; then
+1 -1
View File
@@ -1,4 +1,4 @@
--extra-index-url https://download.pytorch.org/whl/test/cpu
--extra-index-url https://download.pytorch.org/whl/cpu
pyyaml
setuptools
+77 -5
View File
@@ -28,7 +28,7 @@ from wheel.bdist_wheel import bdist_wheel
# Disable autoloading before running 'import torch' to avoid circular dependencies
os.environ["TORCH_DEVICE_BACKEND_AUTOLOAD"] = "0"
from codegen.utils import PathManager
from torchnpugen.utils import PathManager
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
THIRD_PARTY_PATH = os.path.join(BASE_DIR, "third_party")
@@ -237,12 +237,15 @@ def generate_dbg_files_and_strip():
def patchelf_dynamic_library():
library_dir = Path(BASE_DIR).joinpath("build/packages/torch_npu/lib")
library_files = [str(i) for i in library_dir.rglob('*.so')]
for library_file in library_files:
# Process all .so files in lib directory
lib_dir = Path(BASE_DIR).joinpath("build/packages/torch_npu/lib")
lib_files = [str(i) for i in lib_dir.rglob('*.so')]
for library_file in lib_files:
subprocess.check_call(["patchelf", "--remove-needed", "libgomp.so.1", library_file], cwd=BASE_DIR) # Compliant
def CppExtension(name, sources, *args, **kwargs):
r'''
Creates a :class:`setuptools.Extension` for C++.
@@ -401,6 +404,9 @@ def add_ops_files(base_dir, file_list):
plugin_path = os.path.join(base_dir, 'third_party/op-plugin/op_plugin/include')
if os.path.exists(plugin_path):
file_list.append('third_party/op-plugin/op_plugin/include/*.h')
plugin_utils_path = os.path.join(base_dir, 'third_party/op-plugin/op_plugin/utils')
if os.path.exists(plugin_utils_path):
file_list.append('third_party/op-plugin/op_plugin/utils/*.h')
return
@@ -503,6 +509,62 @@ def get_src_py_and_dst():
os.makedirs(os.path.dirname(dst), exist_ok=True)
ret.append((src, dst))
def add_torch_npu_codegen(codegen_src_dir, codegen_dst_dir, exclude_root_init=None):
"""
复制codegen目录下的文件到目标路径
:param codegen_src_dir: 源codegen目录
:param codegen_dst_dir: 目标目录
:param exclude_root_init: 需要排除根目录__init__.py的源目录(仅过滤该目录下的__init__.py)
"""
# 匹配需要复制的文件类型
codegen_files = glob.glob(
os.path.join(codegen_src_dir, '**/*.py'), recursive=True
) + glob.glob(
os.path.join(codegen_src_dir, '**/*.yaml'), recursive=True
) + glob.glob(
os.path.join(codegen_src_dir, '**/*.json'), recursive=True
) + glob.glob(
os.path.join(codegen_src_dir, '**/*.cpp'), recursive=True
) + glob.glob(
os.path.join(codegen_src_dir, '**/*.h'), recursive=True
)
# 按原目录结构复制到目标路径
for src in codegen_files:
# 仅过滤指定目录下的根级__init__.py
if (exclude_root_init is not None and
os.path.basename(src) == '__init__.py' and
os.path.dirname(src) == exclude_root_init):
continue # 跳过op-plugin/codegen根目录的__init__.py
# 计算目标路径(保留原目录层级)
dst = os.path.join(
codegen_dst_dir,
os.path.relpath(src, codegen_src_dir) # 保留torchnpugen内部的目录层级
)
print(os.path.relpath(src, codegen_src_dir))
# 确保目标目录存在
os.makedirs(os.path.dirname(dst), exist_ok=True)
# 加入文件复制列表
ret.append((src, dst))
# 新增:提前创建 torchnpugen 根目录
torchnpugen_root = os.path.join(BASE_DIR, "build/packages/torchnpugen")
os.makedirs(torchnpugen_root, exist_ok=True)
# 将codegen复制到package路径
codegen_src_dir = os.path.join(BASE_DIR, "torchnpugen")
codegen_dst_dir = os.path.join(BASE_DIR, "build/packages/torchnpugen")
# 复制torch_npu的torchnpugen
add_torch_npu_codegen(codegen_src_dir, codegen_dst_dir)
# 复制op-plugin的torchnpugen(仅过滤其根目录的__init__.py)
op_plugin_codegen_src = os.path.join(BASE_DIR, "third_party/op-plugin/torchnpugen")
add_torch_npu_codegen(
op_plugin_codegen_src,
codegen_dst_dir,
exclude_root_init=op_plugin_codegen_src # 指定要过滤根目录__init__.py的源目录
)
return ret
@@ -643,8 +705,10 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requirements = ['torch==2.10.0+cpu' if platform.machine() == 'x86_64' else 'torch==2.10.0']
setup(
name=os.environ.get('TORCH_NPU_PACKAGE_NAME', 'torch_npu'),
@@ -654,7 +718,7 @@ setup(
long_description_content_type="text/markdown",
license="BSD License",
classifiers=classifiers,
packages=["torch_npu"],
packages=["torch_npu", "torchnpugen"],
libraries=[('torch_npu', {'sources': list()})],
package_dir={'': os.path.relpath(os.path.join(BASE_DIR, "build/packages"))},
ext_modules=[
@@ -669,12 +733,20 @@ setup(
define_macros=[('_GLIBCXX_USE_CXX11_ABI', '1' if USE_CXX11_ABI else '0'), ('GLIBCXX_USE_CXX11_ABI', '1' if USE_CXX11_ABI else '0')]
),
],
install_requires=requirements,
extras_require={
},
package_data={
'torch_npu': [
'*.so', 'lib/*.so*',
],
'torchnpugen': [
'*.py', '**/*.py',
'*.yaml', '**/*.yaml',
'*.json', '**/*.json',
'*.cpp', '**/*.cpp',
'*.h', '**/*.h',
],
},
cmdclass={
'build_clib': CPPLibBuild,
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -9,6 +10,7 @@ class TestAbs(TestUtils):
result = torch.abs(first_element)
return result
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', [(1024, 32), (256, 8)])
@parametrize('dtype', ['float16', 'float32', 'bfloat16'])
def test_pointwise_cases(self, shape, dtype):
+1
View File
@@ -10,6 +10,7 @@ from torch.testing._internal.common_utils import (
)
from testutils import TestUtils
import torch_npu
import torch_npu._inductor
class TestWrapTriton(TestUtils):
@@ -0,0 +1,39 @@
import torch
from torch._inductor.utils import run_and_get_code
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestNpuSetDeviceInGraph(TestUtils):
@parametrize("shape", [(2, 2)])
@parametrize("dtype", ["float32"])
def test_npu_set_device_in_graph(self, shape, dtype):
def op_calc(x, y):
x = x * y
# 保留你原来 graph 内的 NPU 调用
torch_npu._C._npu_getDefaultStream(0)
out = x + y
return out
x = self._generate_tensor(shape, dtype)
y = self._generate_tensor(shape, dtype)
compiled_fn = torch.compile(op_calc, backend="inductor")
out, codes = run_and_get_code(compiled_fn, x, y)
# 基本 sanity check:确保 Inductor kernel 生成
self.assertTrue(len(codes) > 0)
self.assertIn("triton", codes[0])
instantiate_parametrized_tests(TestNpuSetDeviceInGraph)
if __name__ == "__main__":
run_tests()
+52
View File
@@ -0,0 +1,52 @@
import os
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
import torch_npu
import torch_npu._inductor
class DeviceCheckFunc(torch.autograd.Function):
@staticmethod
def forward(ctx, x):
return x.clone()
@staticmethod
def backward(ctx, grad_output):
# 在 backward 中访问 device 对象
dev = torch.device("npu")
return grad_output
class TestCompiledAutograd(TestUtils):
@parametrize("input_dim", [10])
@parametrize("device", ["npu"])
def test_compiled_autograd(self, input_dim, device):
def model_fn(x):
return DeviceCheckFunc.apply(x).sum()
torch.manual_seed(42)
x = torch.randn(input_dim, requires_grad=True, device=device)
with torch._dynamo.utils.maybe_enable_compiled_autograd(True):
compiled_fn = torch.compile(
model_fn,
backend="inductor",
dynamic=False
)
loss = compiled_fn(x)
loss.backward()
grad = x.grad.detach().cpu().numpy()
print("grad:", grad)
instantiate_parametrized_tests(TestCompiledAutograd)
if __name__ == "__main__":
run_tests()
+33
View File
@@ -0,0 +1,33 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestCurrentDevice(TestUtils):
def test_npu_current_device(self):
def fn(x):
y = torch.empty(
(2, 3), dtype=torch.float32, device=torch.npu.current_device()
)
y.copy_(x)
return torch.sin(y + y.device.index)
counter = torch._dynamo.testing.CompileCounter()
opt_fn = torch.compile(backend=counter, fullgraph=True)(fn)
with torch.npu.device(0):
x = torch.randn(2, 3).to("npu")
self.assertEqual(opt_fn(x), fn(x))
self.assertEqual(counter.frame_count, 1)
instantiate_parametrized_tests(TestCurrentDevice)
if __name__ == "__main__":
run_tests()
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -9,6 +10,7 @@ class TestFloor(TestUtils):
result = torch.floor(first_element)
return result
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32', 'int64'])
def test_pointwise_cases(self, shape, dtype):
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -8,6 +9,7 @@ class TestGe(TestUtils):
def op_calc(self, first_element, second_element):
return torch.ge(first_element, second_element)
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32'])
def test_pointwise_cases(self, shape, dtype):
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -9,6 +10,7 @@ class TestGt(TestUtils):
result = torch.gt(first_element, second_element)
return result
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32'])
def test_pointwise_cases(self, shape, dtype):
+43
View File
@@ -0,0 +1,43 @@
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
from torch._inductor.utils import run_and_get_code
import torch_npu
import torch_npu._inductor
class TestAdd(TestUtils):
def op_calc(self, first_element, second_element):
result = first_element + second_element
return result
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float32', 'int64'])
def test_options_environ_cases(self, shape, dtype):
x = self._generate_tensor(shape, dtype)
y = self._generate_tensor(shape, dtype)
std_out = self.op_calc(x, y)
compile_func = torch.compile(self.op_calc, options={"npu_backend": "mlir"})
compile_out, codes = run_and_get_code(compile_func, x, y)
self.assertEqual(std_out, compile_out)
self.assertTrue("mlir_fused" in codes[0])
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float32', 'int64'])
def test_config_environ_cases(self, shape, dtype):
torch._inductor.config.npu_backend = "mlir"
x = self._generate_tensor(shape, dtype)
y = self._generate_tensor(shape, dtype)
std_out = self.op_calc(x, y)
compile_func = torch.compile(self.op_calc)
compile_out, codes = run_and_get_code(compile_func, x, y)
self.assertEqual(std_out, compile_out)
self.assertTrue("mlir_fused" in codes[0])
instantiate_parametrized_tests(TestAdd)
if __name__ == "__main__":
run_tests()
+36
View File
@@ -0,0 +1,36 @@
import torch
from torch._inductor.utils import run_and_get_code
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
class TestCurrentDevice(TestUtils):
@parametrize('shape', [(2, 2)])
@parametrize('dtype', ['float32'])
def test_current_device(self, shape, dtype):
def op_calc(x, y):
x = x * y
t = torch.empty(
size=x.shape,
dtype=x.dtype,
device=torch.npu.current_device(),
)
out = x + y
return out
x = self._generate_tensor(shape, dtype)
y = self._generate_tensor(shape, dtype)
compile_result, codes = run_and_get_code(torch.compile(op_calc, backend='inductor'), x, y)
self.assertTrue('triton_unk_fused_add_mul_0.run' in codes[0])
instantiate_parametrized_tests(TestCurrentDevice)
if __name__ == "__main__":
run_tests()
+1 -1
View File
@@ -36,7 +36,7 @@ class TestNpuDevice(TestCase):
self.assertIn("#include <sys/syscall.h>", result)
self.assertIn("#include <torch_npu/csrc/framework/OpCommand.h>", result)
self.assertIn("#include <torch_npu/csrc/core/npu/NPUStream.h>", result)
self.assertIn("#include \"experiment/runtime/runtime/rt.h\"", result)
self.assertIn("#include \"runtime/runtime/rt.h\"", result)
def test_cpp_aoti_stream_guard(self):
overrides = NewNPUDeviceOpOverrides()
+2
View File
@@ -1,5 +1,6 @@
import os
import random
import unittest
import numpy as np
import torch
@@ -11,6 +12,7 @@ import torch_npu
device_npu = 'npu'
@unittest.skip("This test is not supported yet")
class TestModel(TestUtils):
def test_opensora_cases_model_9_inference(self):
def forward(primals_1: "f32[1, 9600, 2304]"):
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -15,6 +16,7 @@ class TestReshape(TestUtils):
y = a + b
return y
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', [(1, 12, 256, 8)])
@parametrize('dtype', ['float32', 'int32', 'float16', 'bfloat16', 'int64'])
def test_view_cases(self, shape, dtype):
+30
View File
@@ -0,0 +1,30 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestResizeAs(TestUtils):
def op_calc(self, x, target, adder):
return torch.ops.aten.resize_as_.default(x, target) + adder
def test_default(self):
shape = (2, 8)
target_shape = (8, 2)
x = torch.randn(shape, dtype=torch.float16, device="npu")
target = torch.randn(target_shape, dtype=torch.float16, device="npu")
adder = torch.randn(target_shape, dtype=torch.float16, device="npu")
std_out = self.op_calc(x, target, adder)
compile_out = torch.compile(self.op_calc, backend='inductor')(x, target, adder)
self.assertEqual(std_out, compile_out, atol=1e-5, rtol=1e-5)
instantiate_parametrized_tests(TestResizeAs)
if __name__ == "__main__":
run_tests()
+30
View File
@@ -0,0 +1,30 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from torch._prims.rng_prims import register_run_and_save_rng_state_op, run_and_save_rng_state
from testutils import TestUtils
import torch_npu
import torch_npu._inductor
class TestRNGPrims(TestUtils):
def test_default(self):
register_run_and_save_rng_state_op()
x = torch.randn(4, 4).to("npu")
args = (x,)
kwargs = {}
expected_rng_state = torch_npu.npu.get_rng_state()
rng_state, out = run_and_save_rng_state(lambda x: x, *args, **kwargs)
self.assertEqual(out, x)
self.assertTrue(torch.equal(rng_state, expected_rng_state))
instantiate_parametrized_tests(TestRNGPrims)
if __name__ == "__main__":
run_tests()
@@ -0,0 +1,56 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestRngprimsPhiloxRand(TestUtils):
def op_calc(self, x):
size = list(x.shape)
seed = torch.tensor(1234, device=x.device, dtype=torch.int64)
offset = torch.tensor(0, device=x.device, dtype=torch.int64)
rand, new_offset = torch.ops.rngprims.philox_rand(
size, # SymInt[]
seed, # Tensor
offset, # Tensor
None, # stride
x.device, # device
x.dtype, # dtype
)
return rand * 2.0 + x
@parametrize("shape", [(2, 4)])
@parametrize("dtype", [torch.float32])
def test_philox_rand_eager_vs_inductor(self, shape, dtype):
device = "npu"
x = torch.ones(shape, device=device, dtype=dtype)
torch.manual_seed(0)
y1_eager = self.op_calc(x)
y2_eager = self.op_calc(x)
compiled_op = torch.compile(
self.op_calc,
backend="inductor",
fullgraph=True,
dynamic=False,
)
y1_ind = compiled_op(x)
y2_ind = compiled_op(x)
self.assertEqual(y1_eager, y2_eager)
self.assertEqual(y1_ind, y2_ind)
self.assertEqual(y1_eager, y1_ind)
instantiate_parametrized_tests(TestRngprimsPhiloxRand)
if __name__ == "__main__":
run_tests()
@@ -0,0 +1,56 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestRngprimsPhiloxRandDefault(TestUtils):
def op_calc(self, x):
size = list(x.shape)
seed = torch.tensor(1234, device=x.device, dtype=torch.int64)
offset = torch.tensor(0, device=x.device, dtype=torch.int64)
rand, new_offset = torch.ops.rngprims.philox_rand.default(
size, # SymInt[]
seed, # Tensor
offset, # Tensor
None, # stride
x.device, # device
x.dtype, # dtype
)
return rand * 2.0 + x
@parametrize("shape", [(2, 4)])
@parametrize("dtype", [torch.float32])
def test_philox_rand_eager_vs_inductor(self, shape, dtype):
device = "npu"
x = torch.ones(shape, device=device, dtype=dtype)
torch.manual_seed(0)
y1_eager = self.op_calc(x)
y2_eager = self.op_calc(x)
compiled_op = torch.compile(
self.op_calc,
backend="inductor",
fullgraph=True,
dynamic=False,
)
y1_ind = compiled_op(x)
y2_ind = compiled_op(x)
self.assertEqual(y1_eager, y2_eager)
self.assertEqual(y1_ind, y2_ind)
self.assertEqual(y1_eager, y1_ind)
instantiate_parametrized_tests(TestRngprimsPhiloxRandDefault)
if __name__ == "__main__":
run_tests()
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -9,6 +10,7 @@ class TestRsqrt(TestUtils):
result = torch.rsqrt(first_element)
return result
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32', 'int64'])
def test_pointwise_cases(self, shape, dtype):
@@ -0,0 +1,48 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestRunAndSaveRngState(TestUtils):
def op_calc(self, like, device, dtype):
rng_state1, res1 = torch._prims.rng_prims.run_and_save_rng_state(
torch.ops.aten.rand_like.default,
like,
device=device,
dtype=dtype,
)
torch_npu.npu.set_rng_state(rng_state1)
rng_state2, res2 = torch._prims.rng_prims.run_and_save_rng_state(
torch.ops.aten.rand_like.default,
like,
device=device,
dtype=dtype,
)
return rng_state1, res1, rng_state2, res2
@parametrize("shape", [(10,)])
@parametrize("dtype", [torch.float32])
def test_rng_state_with_compile(self, shape, dtype):
device = "npu"
like = torch.empty(shape, device=device, dtype=dtype)
# eager
rng_state1_eager, res1_eager, rng_state2_eager, res2_eager = \
self.op_calc(like, device, dtype)
self.assertEqual(res1_eager, res2_eager)
self.assertTrue(torch.equal(rng_state1_eager, rng_state2_eager))
instantiate_parametrized_tests(TestRunAndSaveRngState)
if __name__ == "__main__":
run_tests()
+55
View File
@@ -0,0 +1,55 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestRunWithRngState(TestUtils):
def op_calc(self, current_state, like, device, dtype):
res1 = torch._prims.rng_prims.run_with_rng_state(
current_state,
torch.ops.aten.rand_like.default,
like,
device=device,
dtype=dtype,
)
res2 = torch._prims.rng_prims.run_with_rng_state(
current_state,
torch.ops.aten.rand_like.default,
like,
device=device,
dtype=dtype,
)
return res1, res2
@parametrize("shape", [(10,)])
@parametrize("dtype", [torch.float32])
def test_rng_state_with_compile(self, shape, dtype):
device = "npu"
torch.manual_seed(0)
current_state = torch_npu.npu.get_rng_state()
like = torch.empty(shape, device=device, dtype=dtype)
# eager
res1_eager, res2_eager = \
self.op_calc(current_state, like, device, dtype)
# compiled
compiled_op_calc = torch.compile(self.op_calc, backend="inductor")
res1_ind, res2_ind = \
compiled_op_calc(current_state, like, device, dtype)
self.assertEqual(res1_eager, res2_eager)
self.assertEqual(res1_ind, res2_ind)
self.assertEqual(res1_ind, res1_eager)
instantiate_parametrized_tests(TestRunWithRngState)
if __name__ == "__main__":
run_tests()
+40
View File
@@ -0,0 +1,40 @@
import torch
from torch.testing._internal.common_utils import (
run_tests,
parametrize,
instantiate_parametrized_tests,
)
from testutils import TestUtils
import torch_npu
class TestSqueeze(TestUtils):
@parametrize('shape', [(1, 5)])
@parametrize('dtype', ['int32'])
def test_squeeze_cases(self, shape, dtype):
def op_calc(x):
return torch.ops.aten.squeeze_.default(x)
tensor = self._generate_tensor(shape, dtype)
std_result = op_calc(tensor)
compile_result = torch.compile(op_calc, backend='inductor')(tensor)
self.assertEqual(std_result, compile_result, atol=1e-5, rtol=1e-5)
@parametrize('shape', [(1, 5)])
@parametrize('dtype', ['int32'])
def test_squeeze_dims_cases(self, shape, dtype):
def op_calc(x):
return torch.ops.aten.squeeze_.dims(x, dim=[0])
tensor = self._generate_tensor(shape, dtype)
std_result = op_calc(tensor)
compile_result = torch.compile(op_calc, backend='inductor')(tensor)
self.assertEqual(std_result, compile_result, atol=1e-5, rtol=1e-5)
instantiate_parametrized_tests(TestSqueeze)
if __name__ == "__main__":
run_tests()
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -9,6 +10,7 @@ class TestSub(TestUtils):
result = first_element - second_element
return result
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32', 'int64'])
def test_pointwise_cases(self, shape, dtype):
+33
View File
@@ -0,0 +1,33 @@
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
import torch_npu
class TestAdd(TestUtils):
import os
os.environ['TORCHINDUCTOR_NPU_BACKEND'] = 'mlir'
def op_calc(self, first_element, second_element):
result = first_element + second_element
return result
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float32', 'int64'])
def test_pointwise_cases(self, shape, dtype):
first_element = self._generate_tensor(shape, dtype)
second_element = self._generate_tensor(shape, dtype)
std_sum = self.op_calc(first_element, second_element)
compiled_op_calc = torch.compile(self.op_calc)
inductor_sum = compiled_op_calc(first_element, second_element)
self.assertEqual(std_sum, inductor_sum)
instantiate_parametrized_tests(TestAdd)
if __name__ == "__main__":
run_tests()
+48
View File
@@ -0,0 +1,48 @@
import torch
import triton
import triton.language as tl
from torch.testing._internal.common_utils import run_tests, TestCase
import torch_npu
import torch_npu._inductor
class TestUserAutotuneNpu(TestCase):
def test_user_autotune_npu(self):
@triton.autotune(
configs=[
triton.Config({"BLOCK_SIZE": 64}),
triton.Config({"BLOCK_SIZE": 32}),
],
key=["n_elements"],
)
@triton.jit
def add_kernel(x_ptr, y_ptr, output_ptr, n_elements, BLOCK_SIZE: "tl.constexpr"):
pid = tl.program_id(axis=0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
mask = offsets < n_elements
x = tl.load(x_ptr + offsets, mask=mask)
y = tl.load(y_ptr + offsets, mask=mask)
tl.store(output_ptr + offsets, x + y, mask=mask)
def add(x, y):
output = torch.empty_like(x)
n_elements = output.numel()
def grid(meta):
return (triton.cdiv(n_elements, meta["BLOCK_SIZE"]),)
add_kernel[grid](x, y, output, n_elements)
return output
x = torch.randn(64, device="npu")
y = torch.randn(64, device="npu")
expected = x + y
compiled = torch.compile(add, backend="inductor")
result = compiled(x, y)
self.assertTrue(torch.allclose(result, expected, atol=1e-3))
if __name__ == "__main__":
run_tests()
+2
View File
@@ -1,3 +1,4 @@
import unittest
import torch
from torch.testing._internal.common_utils import run_tests, parametrize, instantiate_parametrized_tests
from testutils import TestUtils
@@ -8,6 +9,7 @@ class TestWhere(TestUtils):
def op_calc(self, condition, first_element, second_element):
return torch.where(condition, first_element, second_element)
@unittest.skip("it takes too long, not supported yet")
@parametrize('shape', TestUtils._pointwise_demo_shapes)
@parametrize('dtype', ['float16', 'float32', 'bfloat16', 'int32'])
def test_pointwise_cases(self, shape, dtype):
+3 -1
View File
@@ -2865,7 +2865,9 @@
"BFloat16Tensor",
"restart_device",
"stop_device",
"set_op_timeout_ms"
"set_op_timeout_ms",
"NpuGraphOpHandler",
"register_npu_graph_handler"
],
"torch_npu.profiler": [
"ProfilerActivity",
+1
View File
@@ -32,6 +32,7 @@ class NpuMNIST(nn.Module):
class TestEnsembleDropout(unittest.TestCase):
@unittest.skip("test_EnsembleDropout is not supported yet")
def test_EnsembleDropout(self):
model = NpuMNIST().to("npu")
x = torch.randn(2, 10, 16, 16).to("npu")
+1 -1
View File
@@ -72,7 +72,7 @@ class TestLinearWeightQuant(TestCase):
npu_out = npu_out.cpu()
self.assertRtolEqual(cpu_out, npu_out.numpy(), 0.01)
@SupportedDevices(['Ascend910_95'])
@SupportedDevices(['Ascend950'])
def test_npu_linear_weight_quant_weight_dtype_hif8(self):
m = 2
k = 64
+3
View File
@@ -1,3 +1,5 @@
import unittest
import torch
import torch_npu
@@ -27,6 +29,7 @@ class TestPsRoiPooling(TestCase):
output.sum().backward()
return output.detach().cpu(), cls_feat.grad.cpu()
@unittest.skip("test_npu_roi_align_1 is not supported yet")
def test_npu_roi_align_1(self):
cls_feat = torch.randn(4, 1078, 84, 84).float().npu()
rois_tensor = self.get_random_rois((4, 128, 5)).permute(0, 2, 1).float().npu()
+11
View File
@@ -387,6 +387,17 @@ class TestTransferToNpu(TestCase):
if torch.distributed.is_initialized():
torch.distributed.destroy_process_group()
def test_process_group_nccl(self):
from torch.distributed import ProcessGroupNCCL
pg_options = ProcessGroupNCCL.Options()
self.assertIsNotNone(pg_options)
from torch.distributed.distributed_c10d import ProcessGroupNCCL
pg_options = ProcessGroupNCCL.Options()
self.assertIsNotNone(pg_options)
def test_host_empty_cache_is_patched(self):
self.assertEqual(torch._C._host_emptyCache, torch_npu._C._npu_hostEmptyCache)
if __name__ == "__main__":
run_tests()
+221
View File
@@ -0,0 +1,221 @@
import os
os.environ["TORCH_TRANSFER_TO_NPU"] = "1"
import torch
from torch.nn.parameter import UninitializedTensorMixin
from torch.utils.data import TensorDataset
from torch.testing._internal.common_utils import TestCase, run_tests
import torch_npu
class TestTransferToNpuEnv(TestCase):
"""Test transfer_to_npu auto-import via environment variable"""
def test_cuda_replaced_with_env(self):
tensor = torch.randn(2, 3, device="cuda")
self.assertEqual(tensor.device.type, 'npu')
current_device = torch.cuda.current_device()
self.assertIsInstance(current_device, int)
stream = torch.cuda.current_stream()
self.assertTrue(hasattr(stream, 'device'))
stream = torch.cuda.Stream()
self.assertTrue(hasattr(stream, 'device'))
class TestTransferToNpu(TestCase):
def test_generator(self):
g0 = torch.Generator()
self.assertTrue(isinstance(g0, torch.Generator))
self.assertEqual(g0.device.type, 'cpu')
g1 = torch.Generator('cuda')
self.assertTrue(isinstance(g1, torch.Generator))
self.assertEqual(g1.device.type, 'npu')
g2 = torch.Generator(torch.device('cuda'))
self.assertTrue(isinstance(g2, torch.Generator))
self.assertEqual(g2.device.type, 'npu')
g3 = torch.Generator(device='cuda')
self.assertTrue(isinstance(g3, torch.Generator))
self.assertEqual(g3.device.type, 'npu')
g4 = torch.Generator(device=torch.device('cuda'))
self.assertTrue(isinstance(g4, torch.Generator))
self.assertEqual(g4.device.type, 'npu')
def test_amp_function(self):
self.assertEqual(torch.cuda.amp.autocast_mode, torch_npu.npu.amp.autocast_mode)
self.assertEqual(torch.cuda.amp.common, torch_npu.npu.amp.common)
self.assertEqual(torch.cuda.amp.grad_scaler, torch_npu.npu.amp.grad_scaler)
def test_wrap_device(self):
device = torch.device(f"cuda:{0}")
torch.cuda.set_device(device)
a = torch.randint(1, 5, (2, 3), device=device)
self.assertEqual(a.device.type, 'npu')
def test_wrap_device_int_type(self):
a = torch.rand(1)
device_id = torch.cuda.current_device()
b = a.to(device=device_id)
c = a.to(device_id)
d = torch.tensor(1, device=device_id)
def test_wrap_autocast(self):
a = torch.randn([3, 3], device='cuda')
b = torch.randn([3, 3], device='cuda')
c = a @ b
c_before_autocast = c.dtype
with torch.autocast('cuda'):
c = a @ b
c_after_autocast_args = c.dtype
with torch.autocast(device_type='cuda'):
c = a @ b
c_after_autocast_kwargs = c.dtype
self.assertNotEqual(c_before_autocast, c_after_autocast_args)
self.assertEqual(c_after_autocast_args, c_after_autocast_kwargs)
with torch.amp.autocast('cuda'):
c = a @ b
c_after_amp_autocast_args = c.dtype
with torch.amp.autocast(device_type='cuda'):
c = a @ b
c_after_amp_autocast_kwargs = c.dtype
self.assertNotEqual(c_before_autocast, c_after_amp_autocast_args)
self.assertEqual(c_after_amp_autocast_args, c_after_amp_autocast_kwargs)
def test_device_meta(self):
with torch.device('meta'):
out = torch.nn.Linear(32, 8)
device = out.weight.device
self.assertEqual(device.type, 'meta')
def test_set_default_device(self):
torch.set_default_device("cuda")
a = torch.tensor(1)
self.assertEqual(a.device.type, 'npu')
def test_device_context(self):
device = torch.device('cuda')
with device:
a = torch.tensor(1)
self.assertEqual(a.device.type, 'npu')
def test_data_loader_pin_memory(self):
images = torch.arange(10 * 5, dtype=torch.float32).view(10, 5)
labels = torch.arange(10 * 5, dtype=torch.float32).view(10, 5)
dataset = TensorDataset(images, labels)
data_loader = torch.utils.data.DataLoader(
dataset, num_workers=2, pin_memory=True, pin_memory_device='cuda')
data_iter = iter(data_loader)
images0, _ = next(data_iter)
self.assertTrue(images0.is_pinned())
def test_replace_to_method_in_allowed_methods(self):
for method in UninitializedTensorMixin._allowed_methods:
if method.__name__ == "to":
self.assertFalse(hasattr(method, "__self__")) # 替换后torch.Tensor.to变成普通函数,而不是原来的绑定方法
break
def test_torch_Event(self):
event = torch.Event(device='cuda:0', enable_timing=True)
self.assertEqual(str(event.device), 'npu')
self.assertEqual(isinstance(event, torch.Event), True)
event = torch.Event('cuda:0')
self.assertEqual(str(event.device), 'npu')
self.assertEqual(isinstance(event, torch.Event), True)
def test_torch_get_device_module(self):
device_module1 = torch.get_device_module(device='cuda:0')
device_module2 = torch.get_device_module(device=torch.device('cuda:0'))
npu_device_module = torch.get_device_module(device='npu:0')
self.assertEqual(device_module1, npu_device_module)
self.assertEqual(device_module2, npu_device_module)
def test_torch_cuda_current_stream(self):
cur_stream = torch.cuda.current_stream(0)
cur_npu_stream = torch.npu.current_stream(0)
self.assertEqual(cur_stream, cur_npu_stream)
cur_stream = torch.cuda.current_stream(torch.device('cuda:0'))
cur_npu_stream = torch.npu.current_stream(torch.device('npu:0'))
self.assertEqual(cur_stream, cur_npu_stream)
def test_torch_cuda_utilization(self):
# 获取device利用率
use = torch.cuda.utilization(0)
use = torch.cuda.utilization(torch.device('cuda:0'))
def test_torch_cuda_set_per_process_memory_fraction(self):
torch.cuda.set_per_process_memory_fraction(0.5, device=0)
torch.cuda.set_per_process_memory_fraction(1.0, device=torch.device('cuda:0'))
def test_torch_cuda_caching_allocator_alloc(self):
size = 1024 * 1024
ptr1 = torch.cuda.caching_allocator_alloc(size, 0)
ptr2 = torch.cuda.caching_allocator_alloc(size, torch.device('cuda:0'))
torch.cuda.caching_allocator_delete(ptr1)
torch.cuda.caching_allocator_delete(ptr2)
def test_torch_cuda_memory(self):
device = torch.device('cuda:0')
a = torch.randn((1000, 1000), device=device)
torch.cuda.memory._record_memory_history(device=device)
snapshot = torch.cuda.memory._snapshot(device=device)
def test_torch_fft(self):
freq_fft = torch.fft.fftfreq(5, device=torch.device('cuda:0'))
self.assertEqual(str(freq_fft.device), 'npu:0')
freq_rfft = torch.fft.rfftfreq(5, device=torch.device('cuda:0'))
self.assertEqual(str(freq_rfft.device), 'npu:0')
def test_torch_autograd_profiler_util_Kernel(self):
kernel = torch.autograd.profiler_util.Kernel("model_inference", 'cuda', 11)
self.assertEqual(kernel.device, 'npu')
def test_torch_utils_cpp_extension_include_paths(self):
torch.utils.cpp_extension.include_paths(device_type='cuda')
def test_init_process_group(self):
MASTER_ADDR = "127.0.0.1"
MASTER_PORT = "29500"
WORLD_SIZE = 1
RANK = 0
os.environ['MASTER_ADDR'] = MASTER_ADDR
os.environ['MASTER_PORT'] = MASTER_PORT
os.environ['RANK'] = str(RANK)
os.environ['WORLD_SIZE'] = str(WORLD_SIZE)
try:
torch.distributed.init_process_group(
backend='nccl',
init_method=f"tcp://{MASTER_ADDR}:{MASTER_PORT}",
world_size=WORLD_SIZE,
rank=RANK,
device_id=torch.device(f"cuda:{RANK}")
)
self.assertEqual(torch.distributed.get_backend(), 'hccl')
torch.distributed.barrier()
finally:
if torch.distributed.is_initialized():
torch.distributed.destroy_process_group()
if __name__ == "__main__":
run_tests()
-62
View File
@@ -2,7 +2,6 @@
#include <chrono>
#include <torch/extension.h>
#include "torch_npu/csrc/core/npu/NPUFormat.h"
#include "torch_npu/csrc/aten/common/from_blob.h"
#include "torch_npu/csrc/framework/OpCommand.h"
#include "torch_npu/csrc/framework/OpHook.h"
// test in .setup with relative path
@@ -33,64 +32,6 @@ bool check_storage_sizes(const Tensor &tensor, const c10::IntArrayRef &sizes)
return false;
}
bool check_from_blob()
{
auto data = torch::tensor({1.0, 2.0, 3.0}, torch::kFloat).to(at::Device("npu:0"));
auto tensor = at_npu::native::from_blob(data.data_ptr(), data.sizes(), torch::dtype(torch::kFloat));
bool dtype_same = (tensor.dtype() == torch::kFloat);
bool num_same = (tensor.numel() == 3);
bool pos1_same = (tensor[0].item<float>() == 1);
bool pos2_same = (tensor[1].item<float>() == 2);
bool pos3_same = (tensor[2].item<float>() == 3);
tensor = tensor -1;
bool sub_same = ((tensor[2].item<float>() == 2));
return dtype_same && num_same && pos1_same && pos2_same && pos3_same && sub_same;
}
bool check_from_blob_delete()
{
int isgone = 0;
{
auto data = torch::tensor({1.0, 2.0, 3.0}, torch::kFloat).to(at::Device("npu:0"));
auto res = at_npu::native::from_blob(data.data_ptr(), data.sizes(), [&](void*) { isgone++; });
}
bool is_deleted = (isgone == 1);
return is_deleted;
}
bool check_from_blob_strides()
{
auto data = torch::tensor({1, 2, 3, 4, 5, 6, 7, 8, 9}, torch::kInt32).to(at::Device("npu:0"));
auto tensor = at_npu::native::from_blob(data.data_ptr(), {3, 3}, {1, 3}, torch::kInt32); // sizes = {3,3}, strides = {1,3}
bool dtype_same = (tensor.dtype() == torch::kInt32);
bool num_same = (tensor.numel() == data.numel());
const std::vector<int64_t> expected_strides = {1, 3};
auto result_strides = tensor.strides();
bool stride_same = std::equal(result_strides.begin(), result_strides.end(), expected_strides.begin());
bool pos_same = true;
for (const auto i : c10::irange(tensor.size(0))) {
for (const auto j : c10::irange(tensor.size(1))) {
// NOTE: This is column major because the strides are swapped.
if (tensor[i][j].item<int32_t>() != (1 + (j * tensor.size(1)) + i))
pos_same = false;
}
}
auto tensor_clone = tensor.clone();
bool clone_same = at::equal(tensor_clone, tensor);
auto tensor_add = tensor + 1;
bool add_same = true;
for (const auto i : c10::irange(tensor_add.size(0))) {
for (const auto j : c10::irange(tensor_add.size(1))) {
// NOTE: This is column major because the strides are swapped.
if (tensor_add[i][j].item<int32_t>() != (2 + (j * tensor_add.size(1)) + i))
add_same = false;
}
}
return dtype_same && num_same && pos_same && stride_same && clone_same && add_same;
}
Tensor blocking_ops(Tensor x)
{
auto blocking_call = []() -> int {
@@ -140,9 +81,6 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
m.def("tanh_add", &tanh_add, "tanh(x) + tanh(y)");
m.def("npu_add", &npu_add, "x + y");
m.def("check_storage_sizes", &check_storage_sizes, "check_storage_sizes");
m.def("check_from_blob", &check_from_blob, "check_from_blob");
m.def("check_from_blob_strides", &check_from_blob_strides, "check_from_blob_strides");
m.def("check_from_blob_delete", &check_from_blob_delete, "check_from_blob_delete");
m.def("blocking_ops", &blocking_ops, "blocking_ops");
m.def("register_op_hook", &register_op_hook, "register_op_hook");
m.def("get_op_hook_call_count", &get_op_hook_call_count, "get_op_hook_call_count");
+3
View File
@@ -17,6 +17,9 @@ ext_modules = [
NpuExtension(
'torch_test_cpp_extension.npu', ['extension.cpp'],
extra_compile_args=CXX_FLAGS),
NpuExtension(
'torch_test_cpp_extension.npu_from_blob', ['test_from_blob.cpp'],
extra_compile_args=CXX_FLAGS),
]
setup(
@@ -15,12 +15,12 @@ from torch_npu.testing.common_utils import create_common_tensor
try:
import torch_test_cpp_extension.npu as npu_extension
import torch_test_cpp_extension.npu_from_blob as from_blob_ext
except ImportError as e:
raise RuntimeError(
"test_cpp_extensions_aot.py cannot be invoked directly. Run "
"`python run_cpp_test.py` instead.") from e
class TestCppExtensionAOT(TestCase):
"""Tests ahead-of-time cpp extensions
"""
@@ -39,22 +39,6 @@ class TestCppExtensionAOT(TestCase):
npu_z = npu_extension.npu_add(x.npu(), y.npu())
self.assertEqual(npu_z.cpu(), (x + y))
def test_storage_sizes(self):
t = torch_npu.npu_format_cast(torch.ones(128, 512, dtype=torch.int8).npu(), 29)
self.assertTrue(npu_extension.check_storage_sizes(t, (16, 8, 16, 32)))
t = torch_npu.npu_format_cast(torch.ones(31, 127, 511, dtype=torch.int8).npu(), 29)
self.assertTrue(npu_extension.check_storage_sizes(t, (31, 16, 8, 16, 32)))
t = torch_npu.npu_format_cast(torch.ones(128, 512, dtype=torch.float16).npu(), 29)
self.assertTrue(npu_extension.check_storage_sizes(t, (32, 8, 16, 16)))
# float32 will cast to float16 before calculate
t = torch_npu.npu_format_cast(torch.ones(128, 512, dtype=torch.float32).npu(), 29)
self.assertTrue(npu_extension.check_storage_sizes(t, (32, 8, 16, 16)))
def test_from_blob(self):
self.assertTrue(npu_extension.check_from_blob())
self.assertTrue(npu_extension.check_from_blob_strides())
self.assertTrue(npu_extension.check_from_blob_delete())
def test_dispatch_allreduce(self):
flags = os.O_WRONLY | os.O_RDONLY | os.O_CREAT
modes = stat.S_IWUSR | stat.S_IRUSR
@@ -65,7 +49,7 @@ class TestCppExtensionAOT(TestCase):
cmd = ["torchrun", "--nproc-per-node=1", code_file]
p = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=f)
p.wait()
timeout = 0
with open(log_pth, 'r', encoding='utf-8') as f:
tmp = f.readlines()
@@ -207,6 +191,35 @@ class TestCppExtensionAOT(TestCase):
os.remove(dump_pth)
os.remove(dump_pth + "_py_traceback")
class TestFromBlob(TestCase):
"""Tests for at_npu::native::from_blob interface"""
def test_from_blob_basic(self):
self.assertTrue(from_blob_ext.test_from_blob_basic())
def test_from_blob_deleter(self):
self.assertTrue(from_blob_ext.test_from_blob_deleter())
def test_from_blob_strides(self):
self.assertTrue(from_blob_ext.test_from_blob_strides())
def test_from_blob_storage_offset(self):
self.assertTrue(from_blob_ext.test_from_blob_storage_offset())
def test_from_blob_storage_offset_2d(self):
self.assertTrue(from_blob_ext.test_from_blob_storage_offset_2d())
def test_from_blob_storage_offset_dtype(self):
self.assertTrue(from_blob_ext.test_from_blob_storage_offset_dtype())
def test_from_blob_storage_offset_contiguous(self):
self.assertTrue(from_blob_ext.test_from_blob_storage_offset_contiguous())
def test_from_blob_non_owning(self):
self.assertTrue(from_blob_ext.test_from_blob_non_owning())
def test_from_blob_clone(self):
self.assertTrue(from_blob_ext.test_from_blob_clone())
if __name__ == "__main__":
run_tests()
+255
View File
@@ -0,0 +1,255 @@
#include <torch/extension.h>
#include <c10/util/irange.h>
#include "torch_npu/csrc/aten/common/from_blob.h"
using namespace at;
static const auto npu_device = at::Device("npu:0");
// Helper: create a 1D float tensor on NPU
static Tensor make_npu_float(std::vector<float> vals)
{
return torch::tensor(vals, torch::kFloat).to(npu_device);
}
// Helper: create a 1D int32 tensor on NPU
static Tensor make_npu_int(std::vector<int32_t> vals)
{
return torch::tensor(vals, torch::kInt32).to(npu_device);
}
// Test 1: Basic from_blob with sizes and dtype.
// Verifies: dtype, element count, per-element values match source,
// and storage context is null (non-owning, no deleter).
bool test_from_blob_basic()
{
auto data = make_npu_float({1.0, 2.0, 3.0});
auto tensor = at_npu::native::from_blob(
data.data_ptr(), data.sizes(), torch::dtype(torch::kFloat));
if (tensor.dtype() != torch::kFloat) return false;
if (tensor.numel() != data.numel()) return false;
for (const auto i : c10::irange(data.numel())) {
if (tensor[i].item<float>() != data[i].item<float>()) return false;
}
if (tensor.storage().data_ptr().get_context() != nullptr) return false;
return true;
}
// Test 2: Deleter is called exactly once when tensor goes out of scope.
bool test_from_blob_deleter()
{
int called = 0;
{
auto data = make_npu_float({1.0, 2.0, 3.0});
auto tensor = at_npu::native::from_blob(
data.data_ptr(), data.sizes(), [&](void*) { called++; });
}
return (called == 1);
}
// Test 3: from_blob with strides (column-major layout).
// sizes={3,3}, strides={1,3}: element [i][j] = 1 + j*cols + i (column major).
bool test_from_blob_strides()
{
auto data = make_npu_int({1, 2, 3, 4, 5, 6, 7, 8, 9});
auto tensor = at_npu::native::from_blob(
data.data_ptr(), {3, 3}, {1, 3}, torch::kInt32);
if (tensor.dtype() != torch::kInt32) return false;
if (tensor.numel() != data.numel()) return false;
const std::vector<int64_t> expected_strides = {1, 3};
auto result_strides = tensor.strides();
if (!std::equal(result_strides.begin(), result_strides.end(),
expected_strides.begin()))
return false;
for (const auto i : c10::irange(tensor.size(0))) {
for (const auto j : c10::irange(tensor.size(1))) {
if (tensor[i][j].item<int32_t>() != (1 + (j * tensor.size(1)) + i))
return false;
}
}
return true;
}
// Test 4: from_blob with storage_offset, verifies storage size is correct.
// This is the bug-fix test: storage_offset must be multiplied by itemsize.
// Base tensor: arange(kBaseSize) as float32 (4 bytes each).
// View: sizes=[kViewSize], strides=[kStride], offset=kOffset (simulates base[3:8]).
// Expected storage bytes = (kOffset + kStride + kStride*(kViewSize-1)) * sizeof(float)
// = (3 + 1 + 1*4) * 4 = 32 bytes.
// Before the fix: storage was computed in mixed units (bytes + elements), giving wrong result.
// Verified: element i of the view equals float(i + kOffset).
bool test_from_blob_storage_offset()
{
constexpr int64_t kBaseSize = 10;
constexpr int64_t kViewSize = 5;
constexpr int64_t kStride = 1;
constexpr int64_t kOffset = 3;
auto base = torch::arange(kBaseSize, torch::kFloat).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kViewSize},
{kStride},
kOffset,
torch::dtype(torch::kFloat));
if (tensor.storage_offset() != kOffset) return false;
for (int i = 0; i < kViewSize; i++) {
if (tensor[i].item<float>() != static_cast<float>(i + kOffset))
return false;
}
size_t expected_nbytes = (kOffset + kStride + kStride * (kViewSize - 1)) * sizeof(float);
if (tensor.storage().nbytes() != expected_nbytes) return false;
return true;
}
// Test 5: from_blob with storage_offset for 2D tensor.
// Base: arange(kBaseSize) float32. View: kRows x kCols submatrix of a 4x4 matrix.
// strides=[kRowStride, kColStride], offset=kOffset (row 1, col 1 of 4x4 -> offset=5).
// Expected values: [kOffset, kOffset+kColStride], [kOffset+kRowStride, kOffset+kRowStride+kColStride].
// Expected storage bytes = (kOffset + kColStride + kRowStride*(kRows-1) + kColStride*(kCols-1)) * sizeof(float)
// = (5 + 1 + 4*1 + 1*1) * 4 = 44 bytes.
bool test_from_blob_storage_offset_2d()
{
constexpr int64_t kBaseSize = 16;
constexpr int64_t kRows = 2;
constexpr int64_t kCols = 2;
constexpr int64_t kRowStride = 4;
constexpr int64_t kColStride = 1;
constexpr int64_t kOffset = 5;
auto base = torch::arange(kBaseSize, torch::kFloat).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kRows, kCols},
{kRowStride, kColStride},
kOffset,
torch::dtype(torch::kFloat));
if (tensor.storage_offset() != kOffset) return false;
if (tensor.sizes() != c10::IntArrayRef({kRows, kCols})) return false;
if (tensor.strides() != c10::IntArrayRef({kRowStride, kColStride})) return false;
if (tensor[0][0].item<float>() != static_cast<float>(kOffset)) return false;
if (tensor[0][1].item<float>() != static_cast<float>(kOffset + kColStride)) return false;
if (tensor[1][0].item<float>() != static_cast<float>(kOffset + kRowStride)) return false;
if (tensor[1][1].item<float>() != static_cast<float>(kOffset + kRowStride + kColStride)) return false;
size_t expected_nbytes =
(kOffset + kColStride + kRowStride * (kRows - 1) + kColStride * (kCols - 1)) * sizeof(float);
if (tensor.storage().nbytes() != expected_nbytes) return false;
return true;
}
// Test 6: from_blob with storage_offset for different dtypes.
// Verifies the itemsize multiplier is correct across float64, float16, and int32.
// All sub-tests: sizes=[kViewSize], strides=[kStride], offset=kDtypeOffset.
// float64 (8 bytes): expected = (kDtypeOffset+kStride+kStride*(kViewSize-1))*sizeof(double) = 56.
// float16 (2 bytes): expected = (kDtypeOffset+kStride+kStride*(kViewSize-1))*sizeof(at::Half) = 14.
// int32 (4 bytes): expected = (kDtypeOffset+kStride+kStride*(kViewSize-1))*sizeof(int32_t) = 28.
// The first element of each view should equal kDtypeOffset.
bool test_from_blob_storage_offset_dtype()
{
bool all_pass = true;
constexpr int64_t kBaseSize = 10;
constexpr int64_t kViewSize = 5;
constexpr int64_t kStride = 1;
constexpr int64_t kDtypeOffset = 2;
{
auto base = torch::arange(kBaseSize, torch::kFloat64).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kViewSize}, {kStride}, kDtypeOffset,
torch::dtype(torch::kFloat64));
size_t expected = (kDtypeOffset + kStride + kStride * (kViewSize - 1)) * sizeof(double);
if (tensor.storage().nbytes() != expected) all_pass = false;
if (tensor[0].item<double>() != static_cast<double>(kDtypeOffset)) all_pass = false;
}
{
auto base = torch::arange(kBaseSize, torch::kFloat16).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kViewSize}, {kStride}, kDtypeOffset,
torch::dtype(torch::kFloat16));
size_t expected = (kDtypeOffset + kStride + kStride * (kViewSize - 1)) * sizeof(at::Half);
if (tensor.storage().nbytes() != expected) all_pass = false;
}
{
auto base = torch::arange(kBaseSize, torch::kInt32).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kViewSize}, {kStride}, kDtypeOffset,
torch::dtype(torch::kInt32));
size_t expected = (kDtypeOffset + kStride + kStride * (kViewSize - 1)) * sizeof(int32_t);
if (tensor.storage().nbytes() != expected) all_pass = false;
if (tensor[0].item<int32_t>() != static_cast<int32_t>(kDtypeOffset)) all_pass = false;
}
return all_pass;
}
// Test 7: from_blob without explicit strides (contiguous) with storage_offset.
// Verifies storage_offset, element count, first and last element values.
bool test_from_blob_storage_offset_contiguous()
{
constexpr int64_t kBaseSize = 10;
constexpr int64_t kViewSize = 5;
constexpr int64_t kStride = 1;
constexpr int64_t kOffset = 3;
auto base = torch::arange(kBaseSize, torch::kFloat).to(npu_device);
auto tensor = at_npu::native::from_blob(
base.storage().mutable_data(),
{kViewSize},
{kStride},
kOffset,
torch::dtype(torch::kFloat));
if (tensor.storage_offset() != kOffset) return false;
if (tensor.numel() != kViewSize) return false;
if (tensor[0].item<float>() != static_cast<float>(kOffset)) return false;
if (tensor[kViewSize - 1].item<float>() != static_cast<float>(kOffset + kViewSize - 1)) return false;
return true;
}
// Test 8: from_blob produces a non-owning reference; original tensor stays valid after view is destroyed.
// data={10.0, 20.0, 30.0}. The view (weak) shares the same data pointer.
// After weak goes out of scope, data[0] and data[kLastDataIdx] must still be accessible.
bool test_from_blob_non_owning()
{
constexpr int64_t kLastDataIdx = 2;
auto data = make_npu_float({10.0, 20.0, 30.0});
void* original_ptr = data.data_ptr();
{
auto weak = at_npu::native::from_blob(
data.data_ptr(), data.sizes(), torch::dtype(torch::kFloat));
if (weak.data_ptr() != original_ptr) return false;
if (weak[1].item<float>() != 20.0f) return false;
}
if (data[0].item<float>() != 10.0f) return false;
if (data[kLastDataIdx].item<float>() != 30.0f) return false;
return true;
}
// Test 9: from_blob clone produces an independent copy.
// Cloned tensor must be equal in value but reside in different storage.
bool test_from_blob_clone()
{
auto data = make_npu_float({1.0, 2.0, 3.0});
auto tensor = at_npu::native::from_blob(
data.data_ptr(), data.sizes(), torch::dtype(torch::kFloat));
auto cloned = tensor.clone();
if (!at::equal(tensor, cloned)) return false;
if (cloned.data_ptr() == tensor.data_ptr()) return false;
return true;
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
{
m.def("test_from_blob_basic", &test_from_blob_basic);
m.def("test_from_blob_deleter", &test_from_blob_deleter);
m.def("test_from_blob_strides", &test_from_blob_strides);
m.def("test_from_blob_storage_offset", &test_from_blob_storage_offset);
m.def("test_from_blob_storage_offset_2d", &test_from_blob_storage_offset_2d);
m.def("test_from_blob_storage_offset_dtype", &test_from_blob_storage_offset_dtype);
m.def("test_from_blob_storage_offset_contiguous", &test_from_blob_storage_offset_contiguous);
m.def("test_from_blob_non_owning", &test_from_blob_non_owning);
m.def("test_from_blob_clone", &test_from_blob_clone);
}
@@ -116,5 +116,47 @@ class TestDTensorCustomOps(DTensorTestBase):
self.assertEqual(dist_res.to_local().shape, local_result.shape)
def exec_dropout_backward(self, p, train):
x = torch.randn(12, 5).npu()
x.requires_grad = True
output = torch.nn.functional.dropout(x, p=p, training=train).sum.backward()
x_grad = x.grad
device_mesh = DeviceMesh(self.device_type, list(range(self.world_size)))
x_dtensor = distribute_tensor(npu_input, device_mesh, [Shard(0)])
x_dtensor.requires_grad = True
dist_res = torch.nn.functional.dropout(x, p=p, training=train).sum.backward()
x_grad_dtensor = x_dtensor.grad.redistribute(device_mesh, [Replicate()])
self.assertEqual(x_grad_dtensor.to_local().shape, x_grad.shape)
@skipIfUnsupportMultiNPU(4)
@with_comms
def test_dtensor_dropout_backward(self):
p_list = [0, 0.2, 0.5, 0.7, 1]
train_list = [True, False]
for p in p_list:
for train in train_list:
self.exec_dropout_backward(p, train)
@skipIfUnsupportMultiNPU(4)
@with_comms
def test_dtensor_npu_transpose(self):
npu_input = torch.randn(5, 3, 6, 4).npu()
perm = [1, 0, 2, 3]
local_result = torch_npu.npu_transpose(npu_input, perm)
device_mesh = DeviceMesh(self.device_type, list(range(self.world_size)))
shard0_spec = Shard(0)
shard1_spec = Shard(1)
replica_spec = Replicate()
placement_specs = [shard0_spec, shard1_spec, replica_spec]
for spec in placement_specs:
dt_input = distribute_tensor(npu_input, device_mesh, [spec])
dist_res: DTensor = cast(DTensor, torch_npu.npu_transpose(dt_input, perm)).redistribute(
device_mesh, [replica_spec]
)
self.assertEqual(dist_res.to_local().shape, local_result.shape)
if __name__ == '__main__':
run_tests()
@@ -1,3 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
# Owner(s): ["oncall: distributed"]
from typing import Any, Callable, Dict, Optional, Sequence
from unittest import skip
@@ -243,6 +246,27 @@ class DistElementwiseOpsTest(DTensorTestBase):
self.assertEqual(input_tensor, dtensor.to_local())
self.assertEqual(expected, dt.to_local())
@skipIfUnsupportMultiNPU(4)
@with_comms
def test_cast_strided_shard(self):
from torch.distributed.device_mesh import init_device_mesh
from torch.distributed.tensor.placement_types import _StridedShard
npu_input = torch.randn((8, 8), dtype=torch.float32).npu()
dst_dtype = torch.float16
local_result = torch_npu.npu_dtype_cast(npu_input, dst_dtype)
# distributed tensor
device_mesh = init_device_mesh(self.device_type, [1, 4], mesh_dim_names=["dp", "tp"])
shard0_spec = Shard(0)
strided_shard0_spec = _StridedShard(0, split_factor=4)
replica_spec = Replicate()
dt_input = distribute_tensor(npu_input, device_mesh, [strided_shard0_spec, shard0_spec])
dist_res: DTensor = torch_npu.npu_dtype_cast(dt_input, dst_dtype).redistribute(
device_mesh, [replica_spec, replica_spec]
)
self.assertEqual(dist_res.to_local().dtype, dst_dtype)
self.assertEqual(dist_res.to_local(), local_result)
if __name__ == "__main__":
run_tests()
@@ -361,13 +361,13 @@ class TestDistributedFailure(ShardedTensorTestBase):
self._test_load(state_dict)
self._test_load(state_dict, fail_set_up_storage_reader=[0])
self._test_load(state_dict, fail_prepare_global_plan=[0])
self._test_load(state_dict, fail_read_metadata=[0])
self._test_load(state_dict, fail_read_metadata=[0], ignore_exception_type=True)
self._test_load(state_dict, fail_prepare_local_plan=[1])
self._test_load(state_dict, fail_read_data=[3])
self._test_load(state_dict, fail_read_data_async=[1])
self._test_load(state_dict, coordinator=3, fail_set_up_storage_reader=[0])
self._test_load(state_dict, coordinator=1, fail_read_metadata=[3])
self._test_load(state_dict, coordinator=1, fail_read_metadata=[3], ignore_exception_type=True)
self._test_load(state_dict, coordinator=2, fail_read_data=[0])
self._test_load(state_dict, coordinator=3, fail_read_data_async=[2])
self._test_load(state_dict, coordinator=1, fail_prepare_global_plan=[1])
@@ -376,7 +376,7 @@ class TestDistributedFailure(ShardedTensorTestBase):
state_dict = {"replicated": torch.rand(10, 10), "bytes": [1, 2, 3, 4]}
self._test_load(state_dict)
self._test_load(state_dict, fail_set_up_storage_reader=[0])
self._test_load(state_dict, fail_read_metadata=[0])
self._test_load(state_dict, fail_read_metadata=[0], ignore_exception_type=True)
self._test_load(state_dict, fail_prepare_local_plan=[0])
self._test_load(state_dict, fail_prepare_global_plan=[0])
self._test_load(state_dict, fail_read_data=[0])
+80 -1
View File
@@ -1,6 +1,18 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
# Owner(s): ["oncall: distributed"]
# This file is a model zoo for testing torch.distributed.pipelining.
# It includes schedules designed purely for testing purposes
# Licensed under the BSD 3-Clause License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/pytorch/pytorch/blob/main/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import torch
from torch.autograd import Function
from torch.distributed.pipelining import pipe_split, SplitPoint
@@ -33,12 +45,21 @@ class ModelWithKwargs(torch.nn.Module):
DEFAULT_DHID = 512
DEFAULT_BATCH_SIZE = 256
def __init__(self, d_hid: int = DEFAULT_DHID):
def __init__(self, d_hid: int = DEFAULT_DHID, splits=2):
if splits > 8:
raise ValueError(f"splits must be <= 8, got {splits}")
super().__init__()
self.splits = splits
self.mm_param0 = torch.nn.Parameter(torch.randn(d_hid, d_hid))
self.mm_param1 = torch.nn.Parameter(torch.randn(d_hid, d_hid))
self.lin0 = torch.nn.Linear(d_hid, d_hid)
self.lin1 = torch.nn.Linear(d_hid, d_hid)
self.lin2 = torch.nn.Linear(d_hid, d_hid)
self.lin3 = torch.nn.Linear(d_hid, d_hid)
self.lin4 = torch.nn.Linear(d_hid, d_hid)
self.lin5 = torch.nn.Linear(d_hid, d_hid)
self.lin6 = torch.nn.Linear(d_hid, d_hid)
self.lin7 = torch.nn.Linear(d_hid, d_hid)
def forward(self, x, y=torch.zeros(DEFAULT_BATCH_SIZE, DEFAULT_DHID)):
x = torch.mm(x, self.mm_param0)
@@ -49,6 +70,30 @@ class ModelWithKwargs(torch.nn.Module):
x = torch.mm(x, self.mm_param1)
x = self.lin1(x)
x = torch.relu(x)
if self.splits > 2:
pipe_split()
x = self.lin2(x)
x = torch.relu(x)
if self.splits > 3:
pipe_split()
x = self.lin3(x)
x = torch.relu(x)
if self.splits > 4:
pipe_split()
x = self.lin4(x)
x = torch.relu(x)
if self.splits > 5:
pipe_split()
x = self.lin5(x)
x = torch.relu(x)
if self.splits > 6:
pipe_split()
x = self.lin6(x)
x = torch.relu(x)
if self.splits > 7:
pipe_split()
x = self.lin7(x)
x = torch.relu(x)
return x
@@ -88,6 +133,22 @@ class MLPModule(torch.nn.Module):
return x
class MLPKWargModule(torch.nn.Module):
def __init__(self, d_hid: int, layer_num):
super().__init__()
self.net1 = torch.nn.Linear(d_hid, d_hid)
self.relu = torch.nn.ReLU()
self.net2 = torch.nn.Linear(d_hid, d_hid)
self.layer_num = layer_num
def forward(self, x, unused_kwarg: torch.Tensor = torch.zeros(1)):
x = self.net1(x)
x = self.relu(x)
x = self.net2(x)
# Test when only 1 module has extra outputs
return x
# Multi-MLP model
class MultiMLP(torch.nn.Module):
def __init__(self, d_hid: int, n_layers: int = 2):
@@ -102,6 +163,24 @@ class MultiMLP(torch.nn.Module):
return x
# Multi-MLP with kwargs model
class MultiMLPKwargs(torch.nn.Module):
def __init__(self, d_hid: int, n_layers: int = 2):
super().__init__()
self.layers = torch.nn.ModuleList(
[MLPKWargModule(d_hid, i) for i in range(n_layers)]
)
# For testing purpose only, this should be defined by user
self.split_spec = {
f"layers.{i}": SplitPoint.BEGINNING for i in range(1, n_layers)
}
def forward(self, x, unused_kwarg: torch.Tensor = torch.zeros(1)):
for layer in self.layers:
x = layer(x)
return x
class CustomLinearDx(Function):
@staticmethod
# pylint:disable=huawei-too-many-arguments
+10 -6
View File
@@ -8,6 +8,8 @@ import os
from model_registry import MultiMLP
import torch
import torch_npu.testing
from torch._dynamo import OptimizedModule
from torch.distributed.pipelining import (
Schedule1F1B,
ScheduleGPipe,
@@ -211,16 +213,18 @@ class ScheduleTest(TestCase):
model = MultiMLP(8, n_layers=n_stages)
# full_mod
compiled_model = torch.compile(model)
self.assertTrue(isinstance(compiled_model, OptimizedModule))
stage = PipelineStage(
compiled_model,
0,
n_stages,
device,
)
with self.assertRaises(RuntimeError):
ScheduleInterleavedZeroBubble([stage], 2)
torch.distributed.destroy_process_group()
try:
with self.assertRaises(RuntimeError):
ScheduleInterleavedZeroBubble([stage], 2)
finally:
torch.distributed.destroy_process_group()
instantiate_parametrized_tests(ScheduleTest)
@@ -714,7 +718,7 @@ class TestScheduleLowering(TestCase):
loss_fn=loss_fn,
scale_grads=False,
)
schedule._load_actions(
schedule._prepare_schedule_with_comms(
{
0: self._parse_actions(
[
@@ -825,7 +829,7 @@ class TestScheduleLowering(TestCase):
num_microbatches,
loss_fn=loss_fn,
)
schedule._load_actions(
schedule._prepare_schedule_with_comms(
{
0: self._parse_actions(
[
File diff suppressed because it is too large Load Diff
+170 -84
View File
@@ -1,8 +1,19 @@
# Copyright (c) Meta Platforms, Inc. and affiliates
# Owner(s): ["oncall: distributed"]
# This file is a Schedule zoo for testing torch.distributed.pipelining.
# It includes schedules designed purely for testing purposes
# Licensed under the BSD 3-Clause License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/pytorch/pytorch/blob/main/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import tempfile
from model_registry import ExampleCode, ModelWithKwargs, MultiMLP
@@ -15,22 +26,27 @@ from torch.distributed.pipelining import (
ScheduleGPipe,
)
from torch.distributed.pipelining._utils import PipeliningShapeError
from torch.testing._internal.common_cuda import TEST_MULTIGPU
from torch.testing._internal.common_distributed import (
MultiProcContinousTest,
requires_nccl,
MultiProcContinuousTest,
MultiProcessTestCase,
requires_accelerator_dist_backend,
)
from torch.testing._internal.common_utils import (
instantiate_parametrized_tests,
parametrize,
run_tests,
skip_but_pass_in_sandcastle_if,
TEST_MULTIACCELERATOR,
)
from torch.utils._pytree import tree_map_only
from torch_npu.testing.common_distributed import init_pg
d_hid = 512
batch_size = 256
chunks = 4
chunks = 8
device_type = "npu"
torch.manual_seed(0)
@@ -59,25 +75,28 @@ def get_flatten_hook():
return flatten_hook
class StageTest(MultiProcContinousTest):
class StageTest(MultiProcContinuousTest):
world_size = int(os.getenv("WORLD_SIZE", 2))
@classmethod
def backend_str(cls) -> str:
# Testing with HCCL backend
return "hccl"
@classmethod
def setUpClass(cls):
"""
Class-scope test fixture. Run once for entire test class, before any test starts.
Set up the device.
"""
super().setUpClass()
dev_id = cls.rank % torch.npu.device_count()
cls.device = torch.device(f"npu:{dev_id}")
def device_type(cls) -> str:
return device_type
@property
def device(self) -> torch.device:
return torch.device(device_type, self.rank)
@parametrize("ModelClass", [ExampleCode, MultiMLP])
def test_tracer(self, ModelClass):
mod = ModelClass(d_hid)
if ModelClass == ExampleCode:
mod = ModelClass(d_hid)
else:
mod = ModelClass(d_hid, n_layers=self.world_size)
mod.to(self.device)
x = torch.randn(batch_size, d_hid, device=self.device)
@@ -117,23 +136,6 @@ class StageTest(MultiProcContinousTest):
old_keys = mod.state_dict().keys()
assert all(k in old_keys for k in submod_keys)
if self.rank == 0:
# intended to run this code on all ranks, but the problem is if rank0 throws,
# it won't perform the send that unblocks rank 1.
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x.to(torch.int32))
# output of stage's mlp layer will be flattened by this hook, the stage should err
handle = stage.submod.register_forward_hook(get_flatten_hook())
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(x)
handle.remove()
stage.submod.register_forward_hook(get_dtype_change_hook(torch.bfloat16))
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x)
@parametrize("ModelClass", [ModelWithKwargs])
def test_tracer_kwargs(self, ModelClass):
mod = ModelClass(d_hid)
@@ -211,23 +213,6 @@ class StageTest(MultiProcContinousTest):
ref_out = full_mod(x)
torch.testing.assert_close(out, ref_out)
if self.rank == 0:
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(torch.randn(batch_size + 1, d_hid, device=self.device))
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x.to(torch.int32))
# output of stage's mlp layer will be flattened by this hook, the stage should err
handle = stage_mod.register_forward_hook(get_flatten_hook())
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(x)
handle.remove()
stage_mod.register_forward_hook(get_dtype_change_hook(torch.bfloat16))
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x)
def test_custom_dw_with_fb_schedule(self):
"""Tests that separate weight grad function 'dw_runner' gets run under a schedule that's only aware of F/B."""
full_mod = MultiMLP(d_hid, n_layers=self.world_size)
@@ -286,18 +271,146 @@ class StageTest(MultiProcContinousTest):
ref_out = full_mod(x)
torch.testing.assert_close(out, ref_out)
def test_output_chunks_memory_usage(self):
"""Test that output_chunks doesn't store memory for non-first stages."""
full_mod = MultiMLP(d_hid, n_layers=self.world_size)
full_mod.to(self.device)
stage_mod = full_mod.get_submodule(f"layers.{self.rank}")
x = torch.randn(batch_size, d_hid, device=self.device)
target = torch.randn(batch_size, d_hid, device=self.device)
stage = PipelineStage(
stage_mod,
self.rank,
self.world_size,
self.device,
)
self.assertEqual(
len(stage.output_chunks), 0, "output_chunks should be empty initially"
)
schedule = ScheduleGPipe(
stage, chunks, loss_fn=torch.nn.MSELoss(reduction="sum")
)
if self.rank == 0:
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(torch.randn(batch_size + 1, d_hid, device=self.device))
schedule.step(x)
elif self.rank == self.world_size - 1:
schedule.step(target=target)
else:
schedule.step()
# Verify fwd_cache is empty
self.assertEqual(len(stage.fwd_cache), 0, "fwd_cache should be cleared")
# Check output_chunks state after step
if self.rank == self.world_size - 1:
self.assertEqual(
len(stage.output_chunks),
chunks,
"Last stage should store output chunks",
)
else:
self.assertEqual(
len(stage.output_chunks),
0,
f"Non-last stage (rank {self.rank}) should not store output chunks",
)
# Clear the schedule and stage caches
stage.clear_runtime_states()
if self.rank == self.world_size - 1:
# Last stage should have output_chunks populated
self.assertEqual(
len(stage.output_chunks), 0, "Last stage should store output chunks"
)
instantiate_parametrized_tests(StageTest)
class StageNegativeTest(MultiProcessTestCase):
@property
def world_size(self) -> int:
return int(os.getenv("WORLD_SIZE", 2))
@property
def device(self) -> torch.device:
device = torch.device(device_type, self.rank)
return torch.device(device_type, self.rank)
def setUp(self):
super().setUp()
self._spawn_processes()
def tearDown(self):
super().tearDown()
try:
os.remove(self.file_name)
except OSError:
pass
def init_pg(self):
"""Initialize process group"""
init_pg(
backend="hccl",
world_size=self.world_size,
rank=self.rank,
file_name=self.file_name
)
def test_shape_prop_mismatch(self):
"""Tests shape prop errors are raised"""
self.init_pg()
def test_custom_dw_errors(self):
"""Tests expected errors are raised"""
full_mod = MultiMLP(d_hid, n_layers=self.world_size)
full_mod.to(self.device)
stage_mod = full_mod.get_submodule(f"layers.{self.rank}")
x = torch.randn(batch_size, d_hid, device=self.device)
target = torch.randn(batch_size, d_hid, device=self.device)
stage = PipelineStage(
stage_mod,
self.rank,
self.world_size,
self.device,
)
# Attach to a schedule
schedule = ScheduleGPipe(stage, chunks)
# Run
def _run_step(x):
if self.rank == 0:
schedule.step(x)
else:
schedule.step()
_run_step(x)
if self.rank == 0:
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(torch.randn(batch_size + 1, d_hid, device=self.device))
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x.to(torch.int32))
# output of stage's mlp layer will be flattened by this hook, the stage should err
handle = stage_mod.register_forward_hook(get_flatten_hook())
with self.assertRaisesRegex(PipeliningShapeError, "shape mismatch"):
_run_step(x)
handle.remove()
stage_mod.register_forward_hook(get_dtype_change_hook(torch.bfloat16))
with self.assertRaisesRegex(PipeliningShapeError, "dtype mismatch"):
_run_step(x)
def test_custom_dw_errors(self):
"""Tests expected errors are raised"""
self.init_pg()
full_mod = MultiMLP(d_hid, n_layers=self.world_size)
full_mod.to(self.device)
stage_mod = full_mod.get_submodule(f"layers.{self.rank}")
stage_with_dw_builder = PipelineStage(
stage_mod,
@@ -306,37 +419,10 @@ class StageTest(MultiProcContinousTest):
self.device,
dw_builder=lambda: None,
)
stage_with_dw_builder._has_backward = True
with self.assertRaisesRegex(AssertionError, "backward_one_chunk"):
stage_with_dw_builder.backward_weight_one_chunk(bwd_chunk_id=0)
instantiate_parametrized_tests(StageTest)
if __name__ == "__main__":
# Check if NPU and HCCL are available
if not (
dist.is_available()
and dist.is_hccl_available()
and torch.npu.device_count() > 1
):
print(
"c10d HCCL not available or not enough GPUs, skipping tests",
file=sys.stderr,
)
sys.exit(0)
rank = int(os.getenv("RANK", -1))
world_size = int(os.getenv("WORLD_SIZE", 2))
if rank != -1:
# Launched with torchrun or other multi-proc launchers. Directly run the test.
StageTest.run_rank(rank, world_size)
else:
# Launched as a single process. Spawn subprocess to run the tests.
# Also need a rendezvous file for `init_process_group` purpose.
rdvz_file = tempfile.NamedTemporaryFile(delete=False).name
torch.multiprocessing.spawn(
StageTest.run_rank,
nprocs=world_size,
args=(world_size, rdvz_file),
)
run_tests()
@@ -262,6 +262,193 @@ class TestAttentionOps(NPUDTensorTestBase):
for placement in placements:
test_placement_comb([placement], [placement], [placement])
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
@parametrize(
"sparse_mode,pre_tokens,next_tokens",
[
(0, 128, 128),
(1, 65536, 65536),
(2, 65536, 0),
(3, 65536, 0),
(4, 128, 128)
]
)
def test_npu_fusion_attention_v3_forward_bnsd(self, sparse_mode, pre_tokens, next_tokens):
device_mesh = self.build_device_mesh()
B, N, S, D = 4, 8, 32, 32
shape = (B, N, S, D)
query = torch.randn(shape, dtype=torch.float32, device="npu")
key = torch.randn(shape, dtype=torch.float32, device="npu")
value = torch.randn(shape, dtype=torch.float32, device="npu")
scale = 0.08838
atten_mask = get_atten_mask(shape, sparse_mode, pre_tokens, next_tokens)
result = torch_npu.npu_fusion_attention_v3(
query, key, value, head_num=N, input_layout="BNSD", scale=scale, sparse_mode=sparse_mode,
atten_mask=atten_mask, pre_tockens=pre_tokens, next_tockens=next_tokens
)
def test_placement_comb(query_placements, key_placements, value_placements, atten_mask_placements):
dist_query = distribute_tensor(query, device_mesh, query_placements)
dist_key = distribute_tensor(key, device_mesh, key_placements)
dist_value = distribute_tensor(value, device_mesh, value_placements)
dist_atten_mask = distribute_tensor(
atten_mask, device_mesh, atten_mask_placements
) if atten_mask is not None else None
dist_result = torch_npu.npu_fusion_attention_v3(
dist_query, dist_key, dist_value, head_num=N, input_layout="BNSD", scale=scale,
sparse_mode=sparse_mode, atten_mask=dist_atten_mask,
pre_tockens=pre_tokens, next_tockens=next_tokens
)
self.assertEqual(dist_result[0].full_tensor(), result[0])
self.assertEqual(dist_result[1].full_tensor(), result[1])
self.assertEqual(dist_result[2].full_tensor(), result[2])
placements = [Shard(0), Shard(1), Shard(2), Shard(3), Replicate()]
for placement in placements:
if atten_mask is None or (isinstance(placement, Shard) and atten_mask.ndim <= placement.dim):
test_placement_comb([placement], [placement], [placement], [Replicate()])
else:
test_placement_comb([placement], [placement], [placement], [placement])
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
@parametrize(
"sparse_mode,pre_tokens,next_tokens",
[
(0, 128, 128),
(1, 65536, 65536),
(2, 65536, 0),
(3, 65536, 0),
(4, 128, 128)
]
)
def test_npu_fusion_attention_v3_backward_bnsd(self, sparse_mode, pre_tokens, next_tokens):
device_mesh = self.build_device_mesh()
B, N, S, D = 4, 8, 32, 32
shape = (B, N, S, D)
query = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
key = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
value = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
scale = 0.08838
atten_mask = get_atten_mask(shape, sparse_mode, pre_tokens, next_tokens)
result = torch_npu.npu_fusion_attention_v3(
query, key, value, head_num=N, input_layout="BNSD", scale=scale, sparse_mode=sparse_mode,
atten_mask=atten_mask, pre_tockens=pre_tokens, next_tockens=next_tokens
)
gard_y = torch.ones_like(result[0])
result[0].backward(gard_y)
def test_placement_comb(query_placements, key_placements, value_placements, atten_mask_placements):
dist_query = distribute_tensor(query, device_mesh, query_placements)
dist_key = distribute_tensor(key, device_mesh, key_placements)
dist_value = distribute_tensor(value, device_mesh, value_placements)
dist_atten_mask = distribute_tensor(
atten_mask, device_mesh, atten_mask_placements
) if atten_mask is not None else None
dist_result = torch_npu.npu_fusion_attention_v3(
dist_query, dist_key, dist_value, head_num=N, input_layout="BNSD", scale=scale,
sparse_mode=sparse_mode, atten_mask=dist_atten_mask,
pre_tockens=pre_tokens, next_tockens=next_tokens
)
dist_grad_y = distribute_tensor(gard_y, device_mesh, dist_result[0].placements)
dist_result[0].backward(dist_grad_y)
self.assertEqual(dist_result[0].full_tensor(), result[0])
self.assertEqual(dist_result[1].full_tensor(), result[1])
self.assertEqual(dist_result[2].full_tensor(), result[2])
self.assertEqual(dist_query.grad.full_tensor(), query.grad)
self.assertEqual(dist_key.grad.full_tensor(), key.grad)
self.assertEqual(dist_value.grad.full_tensor(), value.grad)
placements = [Shard(0), Shard(1), Shard(2), Shard(3), Replicate()]
for placement in placements:
if atten_mask is None or (isinstance(placement, Shard) and atten_mask.ndim <= placement.dim):
test_placement_comb([placement], [placement], [placement], [Replicate()])
else:
test_placement_comb([placement], [placement], [placement], [placement])
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_npu_fusion_attention_v3_bsnd(self):
device_mesh = self.build_device_mesh()
B, N, S, D = 4, 8, 32, 32
shape = (B, S, N, D)
query = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
key = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
value = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
scale = 0.08838
result = torch_npu.npu_fusion_attention_v3(query, key, value, head_num=N, input_layout="BSND", scale=scale)
gard_y = torch.ones_like(result[0])
result[0].backward(gard_y)
def test_placement_comb(query_placements, key_placements, value_placements):
dist_query = distribute_tensor(query, device_mesh, query_placements)
dist_key = distribute_tensor(key, device_mesh, key_placements)
dist_value = distribute_tensor(value, device_mesh, value_placements)
dist_result = torch_npu.npu_fusion_attention_v3(
dist_query, dist_key, dist_value, head_num=N, input_layout="BSND", scale=scale
)
dist_grad_y = distribute_tensor(gard_y, device_mesh, dist_result[0].placements)
dist_result[0].backward(dist_grad_y)
self.assertEqual(dist_result[0].full_tensor(), result[0])
self.assertEqual(dist_result[1].full_tensor(), result[1])
self.assertEqual(dist_result[2].full_tensor(), result[2])
self.assertEqual(dist_query.grad.full_tensor(), query.grad)
self.assertEqual(dist_key.grad.full_tensor(), key.grad)
self.assertEqual(dist_value.grad.full_tensor(), value.grad)
placements = [Shard(0), Shard(1), Shard(2), Shard(3), Replicate()]
for placement in placements:
test_placement_comb([placement], [placement], [placement])
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_npu_fusion_attention_v3_bsh(self):
device_mesh = self.build_device_mesh()
B, N, S, D = 4, 8, 32, 32
shape = (B, S, N * D)
query = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
key = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
value = torch.randn(shape, dtype=torch.float32, device="npu", requires_grad=True)
scale = 0.08838
result = torch_npu.npu_fusion_attention_v3(query, key, value, head_num=N, input_layout="BSH", scale=scale)
gard_y = torch.ones_like(result[0])
result[0].backward(gard_y)
def test_placement_comb(query_placements, key_placements, value_placements):
dist_query = distribute_tensor(query, device_mesh, query_placements)
dist_key = distribute_tensor(key, device_mesh, key_placements)
dist_value = distribute_tensor(value, device_mesh, value_placements)
dist_result = torch_npu.npu_fusion_attention_v3(
dist_query, dist_key, dist_value, head_num=N, input_layout="BSH", scale=scale
)
dist_grad_y = distribute_tensor(gard_y, device_mesh, dist_result[0].placements)
dist_result[0].backward(dist_grad_y)
self.assertEqual(dist_result[0].full_tensor(), result[0])
self.assertEqual(dist_result[1].full_tensor(), result[1])
self.assertEqual(dist_result[2].full_tensor(), result[2])
self.assertEqual(dist_query.grad.full_tensor(), query.grad)
self.assertEqual(dist_key.grad.full_tensor(), key.grad)
self.assertEqual(dist_value.grad.full_tensor(), value.grad)
placements = [Shard(0), Shard(1), Shard(2), Replicate()]
for placement in placements:
test_placement_comb([placement], [placement], [placement])
instantiate_parametrized_tests(TestAttentionOps)
+48
View File
@@ -950,7 +950,55 @@ class TestRepeatInterleaveSelfInt(NPUDTensorTestBase):
self.assertEqual(input_dtensor.grad.full_tensor(), input_tensor.grad)
class TestKLDivLoss(NPUDTensorTestBase):
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
@parametrize(
"pred_placement,target_placement",
[
(Shard(0), Shard(0)),
(Shard(0), Shard(1)),
(Shard(0), Shard(2)),
(Shard(0), Replicate()),
(Shard(1), Shard(0)),
(Shard(1), Shard(1)),
(Shard(1), Shard(2)),
(Shard(1), Replicate()),
(Shard(2), Shard(0)),
(Shard(2), Shard(1)),
(Shard(2), Shard(2)),
(Shard(2), Replicate()),
(Replicate(), Shard(0)),
(Replicate(), Shard(1)),
(Replicate(), Shard(2)),
(Replicate(), Replicate()),
]
)
def test_torch_nn_KLDivLoss(self, pred_placement, target_placement):
reductions = ["none", "sum", "mean", "batchmean"]
mesh = self.build_device_mesh()
pred = torch.randn(4, 4, 4, device="npu", requires_grad=True)
target = torch.randn(4, 4, 4, device="npu")
# def test_placement_comb(placements1, placements2):
pred_dt = distribute_tensor(pred, mesh, [pred_placement])
# pred_dt = pred_dt
target_dt = distribute_tensor(target, mesh, [target_placement])
for reduction in reductions:
loss_fn = torch.nn.KLDivLoss(reduction=reduction, log_target=True).to("npu")
loss_dt = loss_fn(pred_dt.log_softmax(dim=-1), target_dt)
loss_dt.sum().backward()
loss = loss_fn(pred.log_softmax(dim=-1), target)
loss.sum().backward()
self.assertEqual(loss_dt.full_tensor(), loss)
self.assertEqual(pred_dt.grad.full_tensor(), pred.grad)
instantiate_parametrized_tests(TestMathOps)
instantiate_parametrized_tests(TestKLDivLoss)
if __name__ == "__main__":
+184
View File
@@ -1,4 +1,6 @@
import itertools
import operator
from functools import reduce
import numpy as np
import torch
@@ -814,7 +816,189 @@ class TestApplyAdamW(NPUDTensorTestBase):
self.assertEqual(v_ret_npu_dtensor.full_tensor(), v_ret_npu)
class TestMatmul(NPUDTensorTestBase):
def run_matmul(self, shape1, shape2, device_mesh, placement1, placement2):
x = torch.rand(shape1, device=self.device_type, requires_grad=True)
dist_x = distribute_tensor(x, device_mesh, [placement1])
y = torch.rand(shape2, device=self.device_type, requires_grad=True)
dist_y = distribute_tensor(y, device_mesh, [placement2])
local_out = torch.matmul(x, y)
dist_out = torch.matmul(dist_x, dist_y)
self.assertEqual(dist_out.full_tensor(), local_out)
grad = torch.rand(local_out.shape, device=self.device_type)
dist_grad = distribute_tensor(grad, device_mesh, [Replicate()])
local_out.backward(grad)
dist_out.backward(dist_grad)
self.assertEqual(dist_x.grad.full_tensor(), x.grad)
self.assertEqual(dist_y.grad.full_tensor(), y.grad)
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_n_n(self):
device_mesh = self.build_device_mesh()
shape1 = (8,)
shape2 = (8,)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Shard(0))
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_nm_m1(self):
device_mesh = self.build_device_mesh()
shape1 = (8, 4)
shape2 = (4)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Shard(0))
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_n_nk(self):
device_mesh = self.build_device_mesh()
shape1 = (4)
shape2 = (4, 8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Shard(0))
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_nm_mk(self):
device_mesh = self.build_device_mesh()
shape1 = (8, 4)
shape2 = (4, 8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Shard(0))
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_xnm_mk(self):
device_mesh = self.build_device_mesh()
shape1 = (8, 4, 8)
shape2 = (8, 8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Shard(2), Shard(0))
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Replicate())
shape1 = (8, 4, 8)
shape2 = (8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(2), Shard(0))
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Replicate())
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_nm_xmk(self):
device_mesh = self.build_device_mesh()
shape1 = (4, 8)
shape2 = (8, 8, 8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(2))
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Replicate())
shape1 = (8)
shape2 = (8, 8, 8)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(2))
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_matmul_sharding_strategy_xnm_xmk(self):
device_mesh = self.build_device_mesh()
shape1 = (8, 4, 8)
shape2 = (8, 8, 8, 4)
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(0), Shard(1))
self.run_matmul(shape1, shape2, device_mesh, Shard(1), Replicate())
self.run_matmul(shape1, shape2, device_mesh, Shard(2), Shard(2))
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(0))
self.run_matmul(shape1, shape2, device_mesh, Replicate(), Shard(3))
class TestDropout(NPUDTensorTestBase):
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
def test_torch_dropout_forward(self):
mesh = self.build_device_mesh()
tensor_input = torch.randn(4, 4, device="npu", requires_grad=True)
p = 0.5
out = torch.dropout(tensor_input, p, train=True)
plcaements = [[Replicate()], [Shard(0)], [Shard(1)]]
for plcaement in plcaements:
input_dtensor = distribute_tensor(tensor_input, mesh, plcaement)
output_dt = torch.dropout(input_dtensor, p, train=True)
mask = (output_dt.full_tensor() != 0) & (out != 0)
if torch.any(mask):
self.assertEqual(output_dt.full_tensor()[mask], out[mask])
@SupportedDevices(['Ascend910B'])
@skipIfUnsupportMultiNPU(2)
@with_comms
@parametrize(
"grad_placement,mask_placement",
[
([Shard(0)], [Shard(0)]),
([Shard(0)], [Replicate()]),
([Shard(1)], [Shard(0)]),
([Shard(1)], [Replicate()]),
([Replicate()], [Shard(0)]),
([Replicate()], [Replicate()]),
]
)
def test_torch_dropout_backward(self, grad_placement, mask_placement):
mesh = self.build_device_mesh()
size = (4, 4)
numel = reduce(operator.mul, size)
numel = (numel + 128 - 1) // 128 * 128
numel = numel // 8
tensor_grad = torch.randn(size, device="npu", requires_grad=True)
tensor_mask = (torch.rand(numel, device="npu") < 0.5).to(torch.uint8)
scale=0
grad_dtensor = distribute_tensor(tensor_grad, mesh, grad_placement)
mask_dtensor = distribute_tensor(tensor_mask, mesh, mask_placement)
out = torch.ops.aten.native_dropout_backward(tensor_grad, tensor_mask, scale=scale)
out_dtensor = torch.ops.aten.native_dropout_backward(grad_dtensor, mask_dtensor, scale=scale)
self.assertEqual(out_dtensor.full_tensor(), out)
instantiate_parametrized_tests(TestGroupedMatMulOp)
instantiate_parametrized_tests(TestDropout)
if __name__ == "__main__":
+1
View File
@@ -37,6 +37,7 @@ class HcclAlltoAllTest(TestCase):
@classmethod
def _test_alltoall_2p_size(cls, rank, world_size, init_pg, c2p, p2c):
torch_npu.npu.config.allow_internal_format = True
pg = init_pg(rank, world_size)
input_list = [(torch.zeros(rank + 1, 1) + rank).float().npu() for i in range(2)]
output_list = [torch.empty(i + 1, 1).float().npu() for i in range(2)]
@@ -133,6 +133,7 @@ class HcclAlltoAllSingleTest(TestCase):
HcclAlltoAllSingleTest._test_alltoall_single_2p,
HcclAlltoAllSingleTest._init_dist_hccl)
@unittest.skip("Disabled during A1 to A2 chip transition")
@skipIfUnsupportMultiNPU(2)
def test_alltoall_single_2p_size_dist(self):
self._test_multiprocess_2p(
+14
View File
@@ -167,6 +167,20 @@ class HcomAllReduceTest(TestCase):
HcomAllReduceTest._init_dist_hccl, input1, world_size,
dist.ReduceOp.AVG)
@skipIfUnsupportMultiNPU(2)
def test_dist_all_reduce_pre_mul(self):
ranks = [2]
dtype_list = [np.float32, np.float16]
shape_format = [[i, 2, [4, 9]] for i in dtype_list]
for world_size in ranks:
for shape in shape_format:
exp_input, input1 = create_common_tensor(shape, -10, 10)
expected = self._construct_excepted_result(exp_input, world_size, shape[0], dist.ReduceOp.SUM)
expected = expected * 2
reduce_op = torch_npu.distributed._make_hccl_premul_sum(2.0)
self._test_multiprocess(HcomAllReduceTest._test_all_reduce,
HcomAllReduceTest._init_dist_hccl, expected, input1, world_size, reduce_op)
if __name__ == '__main__':
run_tests()
@@ -102,6 +102,7 @@ class HcclSendRecvDistTest(TestCase):
for p in ps:
p.join(2)
@unittest.skip("Temporarily disable")
@skipIfUnsupportMultiNPU(2)
def test_avoid_isend_irecv_hccl(self):
self._test_multiprocess(
@@ -109,6 +110,7 @@ class HcclSendRecvDistTest(TestCase):
torch.randn(400, 1024, 1024),
HcclSendRecvDistTest._init_dist_hccl)
@unittest.skip("Temporarily disable")
@skipIfUnsupportMultiNPU(2)
def test_avoid_batch_isend_irecv_hccl(self):
self._test_multiprocess(
+1 -1
View File
@@ -76,7 +76,7 @@ class HcomCoalescedManagerTest(TestCase):
return expected
@skipIfUnsupportMultiNPU(2)
@SkipIfNotGteCANNVersion("8.5.0")
@SkipIfNotGteCANNVersion("9.0.0")
def test_all_reduce_coalesced_manager_hccl(self):
ranks = [2]
shape_format = [[np.float32, 2, [2, 3, 16]]]
+7 -1
View File
@@ -31,7 +31,13 @@ class TestDevice(MultiProcessTestCase):
t.start()
t.join()
self.assertEqual(result[0], 1)
def test_event_isinstance(self):
npu_event = torch.npu.Event()
self.assertIsInstance(npu_event, torch.npu.Event)
self.assertIsInstance(npu_event, torch.Event)
# Check whether torch_npu.npu.Event is a subclass of torch.Event
self.assertTrue(issubclass(torch_npu.npu.Event, torch.Event))
def test_stream_create(self):
s = torch_npu._C._npu_getCurrentStream(0)
+21
View File
@@ -4,6 +4,7 @@ import torch
import torch_npu
from torch_npu.testing.testcase import TestCase, run_tests
from torch_npu.testing.common_distributed import skipIfUnsupportMultiNPU
from torch_npu.testing.common_utils import SupportedDevices
class TestMode(TestCase):
@@ -135,6 +136,7 @@ class TestMode(TestCase):
)
@skipIfUnsupportMultiNPU(2)
@SupportedDevices(['Ascend910A', 'Ascend910B', 'Ascend910_93'])
def test_hccl_timeout(self):
path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_hccl_timeout.py')
process = subprocess.Popen(["torchrun", "--nproc-per-node=2", f"{path}"], shell=False, stdout=subprocess.PIPE,
@@ -153,6 +155,25 @@ class TestMode(TestCase):
message
)
@skipIfUnsupportMultiNPU(2)
@SupportedDevices(['Ascend950'])
def test_hccl_timeout_950(self):
path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_hccl_timeout.py')
process = subprocess.Popen(["torchrun", "--nproc-per-node=2", f"{path}"], shell=False, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, text=True)
message = process.stderr.read()
process.stderr.close()
process.stdout.close()
process.terminate()
process.wait()
self.assertIn(
"wait for compute device to finish failed",
message
)
self.assertIn(
"task timeout",
message
)
if __name__ == "__main__":
+175
View File
@@ -0,0 +1,175 @@
import os
from unittest.mock import patch
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from torch.distributed.distributed_c10d import _world
import torch_npu
from torch_npu.testing.common_distributed import skipIfUnsupportMultiNPU
from torch_npu.testing.testcase import TestCase, run_tests
class P2PStreamIdTest(TestCase):
@classmethod
def _init_dist_hccl(cls, rank, world_size):
"""Initialize HCCL distributed environment."""
os.environ['MASTER_ADDR'] = '127.0.0.1'
os.environ['MASTER_PORT'] = '29501'
os.environ['HCCL_WHITELIST_DISABLE'] = '1'
torch_npu.npu.set_device(rank)
dist.init_process_group(backend='hccl', world_size=world_size, rank=rank)
return dist
@classmethod
def _test_p2p_stream_id_batched(cls, rank, world_size, init_pg, c2p, p2c):
"""Test P2P stream ID in batched mode (is_batched=1)."""
dist_group = init_pg(rank, world_size)
# Get backend for stream operations
backend = _world.default_pg._get_backend(torch.device('npu'))
# Perform P2P operations to trigger stream creation
send_tensor = torch.ones(2, 2).to(f"npu:{rank}") * (rank + 1)
recv_tensor = torch.ones(2, 2).to(f"npu:{rank}") * -1
# Test P2P communication between ranks
peer = 1 - rank
p2p_op_list = [
dist.P2POp(dist.isend, send_tensor, peer),
dist.P2POp(dist.irecv, recv_tensor, peer),
]
reqs = dist.batch_isend_irecv(p2p_op_list)
for req in reqs:
req.wait()
device = torch.device(f'npu:{rank}')
p2p_stream_id = backend.get_p2p_stream_id(device, peer, 1) # is_batched=1
# Verify P2P Stream ID is valid
assert0 = False
if p2p_stream_id != -1:
# Create stream object to verify validity
stream = torch.npu.Stream(stream_id=p2p_stream_id, device_type=20, device_index=device.index)
assert0 = (stream.npu_stream is not None)
c2p.put(assert0)
p2c.get()
@classmethod
def _test_p2p_stream_id_non_batched(cls, rank, world_size, init_pg, c2p, p2c):
"""Test P2P stream ID in non-batched mode (is_batched=0)."""
dist_group = init_pg(rank, world_size)
# Get backend for stream operations
backend = _world.default_pg._get_backend(torch.device('npu'))
# Perform P2P operations to trigger stream creation
send_tensor = torch.ones(2, 2).to(f"npu:{rank}") * (rank + 1)
recv_tensor = torch.ones(2, 2).to(f"npu:{rank}") * -1
# Rank 0 sends to Rank 1, Rank 1 recvs from Rank 0
if rank == 0:
dist_group.send(send_tensor, 1)
else:
dist_group.recv(recv_tensor, 0)
device = torch.device(f'npu:{rank}')
peer = 1 - rank
p2p_stream_id = backend.get_p2p_stream_id(device, peer, 0)
assert0 = False
if p2p_stream_id != -1:
stream = torch.npu.Stream(stream_id=p2p_stream_id, device_type=20, device_index=device.index)
assert0 = (stream.npu_stream is not None)
c2p.put(assert0)
p2c.get()
@classmethod
def _test_p2p_stream_id_invaild(cls, rank, world_size, init_pg, c2p, p2c):
"""Test P2P stream ID without establishing communication."""
dist_group = init_pg(rank, world_size)
# Get backend for stream operations
backend = _world.default_pg._get_backend(torch.device('npu'))
device = torch.device(f'npu:{rank}')
peer = 1 - rank
p2p_stream_id = backend.get_p2p_stream_id(device, peer, 0)
# Verify P2P Stream ID is invaild
assert0 = True if p2p_stream_id == -1 else False
c2p.put(assert0)
p2c.get()
def _run_multiprocess_test(self, test_func, init_pg, world_size, test_name=""):
"""Helper method to run multi-process tests."""
ctx = mp.get_context('spawn')
c2p = ctx.Queue(world_size)
p2c = ctx.Queue(world_size)
ps = []
for rank in range(world_size):
p = ctx.Process(target=test_func, args=(rank, world_size, init_pg, c2p, p2c))
p.start()
ps.append(p)
for _ in range(world_size):
output = c2p.get()
self.assertEqual(True, output)
for _ in range(world_size):
p2c.put(0)
for p in ps:
p.join()
@skipIfUnsupportMultiNPU(2)
def test_p2p_stream_id_batched(self):
"""Test batched mode P2P stream ID with same device."""
print("\n=== Testing Batched P2P Stream ID ===")
with patch.dict(os.environ, {"P2P_HCCL_BUFFSIZE": "1"}):
ranks = [2]
for world_size in ranks:
self._run_multiprocess_test(
P2PStreamIdTest._test_p2p_stream_id_batched,
P2PStreamIdTest._init_dist_hccl,
world_size,
"Batched P2P Stream ID Test"
)
@skipIfUnsupportMultiNPU(2)
def test_p2p_stream_id_non_batched(self):
"""Test non-batched mode P2P stream ID with cross-rank communication."""
print("\n=== Testing Non-batched P2P Stream ID ===")
with patch.dict(os.environ, {"P2P_HCCL_BUFFSIZE": "1"}):
ranks = [2]
for world_size in ranks:
self._run_multiprocess_test(
P2PStreamIdTest._test_p2p_stream_id_non_batched,
P2PStreamIdTest._init_dist_hccl,
world_size,
"Non-batched P2P Stream ID Test"
)
@skipIfUnsupportMultiNPU(2)
def test_p2p_stream_id_invalid(self):
"""Test P2P stream ID without establishing communication."""
print("\n=== Testing Non P2P Stream ID ===")
with patch.dict(os.environ, {"P2P_HCCL_BUFFSIZE": "1"}):
ranks = [2]
for world_size in ranks:
self._run_multiprocess_test(
P2PStreamIdTest._test_p2p_stream_id_invaild,
P2PStreamIdTest._init_dist_hccl,
world_size,
"Non P2P Stream ID Test"
)
if __name__ == '__main__':
run_tests()
+15 -1
View File
@@ -171,7 +171,12 @@ class OptionsTest(TestCase):
@classmethod
def _test_options_qos_service_level_wrong_types(cls, rank, ranks, world_size, input1):
cls._test_options_wrong_type(rank, {"qos_service_level": "123"}, "Value type of qos_service_level should be int.", world_size, input1)
@classmethod
def _test_options_hccl_sdma_qos_wrong_types(cls, rank, ranks, world_size, input1):
cls._test_options_wrong_type(rank, {"hccl_sdma_qos": "123"}, "Value type of hccl_sdma_qos should be int.",
world_size, input1)
@classmethod
def _test_options_hccl_op_expansion_mode_wrong_types(cls, rank, ranks, world_size, input1):
cls._test_options_wrong_type(rank, {"hccl_op_expansion_mode": "123"}, "Value type of hccl_op_expansion_mode should be int.", world_size, input1)
@@ -278,6 +283,15 @@ class OptionsTest(TestCase):
self._test_multiprocess(OptionsTest._test_options_qos_service_level_wrong_types,
input1, world_size)
@skipIfUnsupportMultiNPU(2)
def test_options_hccl_sdma_qos_wrong_type(self):
ranks = [2]
shape = [np.int32, 0, [2, 3, 16]]
for world_size in ranks:
exp_input, input1 = create_common_tensor(shape, -10, 10)
self._test_multiprocess(OptionsTest._test_options_hccl_sdma_qos_wrong_types,
input1, world_size)
@skipIfUnsupportMultiNPU(2)
def test_options_hccl_op_expansion_mode_wrong_type(self):
ranks = [2]
+14
View File
@@ -125,6 +125,20 @@ class HcclReduceTest(TestCase):
self._test_multiprocess(HcclReduceTest._test_reduce,
HcclReduceTest._init_dist_hccl, expected, input1, world_size, dist.ReduceOp.AVG)
@skipIfUnsupportMultiNPU(2)
def test_reduce_dist_pre_mul(self):
ranks = [2]
dtype_list = [np.float32, np.float16]
shape_format = [[i, 2, [4, 9]] for i in dtype_list]
for world_size in ranks:
for shape in shape_format:
exp_input, input1 = create_common_tensor(shape, -10, 10)
expected = self._construct_excepted_result(exp_input, world_size, shape[0], dist.ReduceOp.SUM)
expected = expected * 2
reduce_op = torch_npu.distributed._make_hccl_premul_sum(2.0)
self._test_multiprocess(HcclReduceTest._test_reduce,
HcclReduceTest._init_dist_hccl, expected, input1, world_size, reduce_op)
if __name__ == '__main__':
run_tests()
+19
View File
@@ -178,6 +178,24 @@ class HcclReduceScatterTest(HcclReduceScatterTestBase):
self._test_multiprocess(HcclReduceScatterTest._test_reduce_scatter,
HcclReduceScatterTest._init_dist_hccl, expected, input_list, world_size, dist.ReduceOp.AVG)
@skipIfUnsupportMultiNPU(2)
def test_reduce_scatter_pre_mul(self):
ranks = [2]
dtype_list = [np.float32, np.float16]
shape_format = [[i, 2, [4, 9]] for i in dtype_list]
for world_size in ranks:
for shape in shape_format:
input_list = []
for _ in range(world_size):
_, input1 = create_common_tensor(shape, -10, 10)
input_list.append(input1.cpu())
expected = self._construct_excepted_result(input_list, world_size, dist.reduce_scatter, dist.ReduceOp.SUM)
expected = [i * 2 for i in expected]
reduce_op = torch_npu.distributed._make_hccl_premul_sum(2.0)
self._test_multiprocess(HcclReduceScatterTest._test_reduce_scatter,
HcclReduceScatterTest._init_dist_hccl, expected, input_list, world_size, reduce_op)
@skipIfUnsupportMultiNPU(2)
def test_reduce_scatter_with_input_internal_format_and_offset(self):
ranks = [2]
@@ -230,5 +248,6 @@ class HcclReduceScatterTest(HcclReduceScatterTestBase):
self._test_multiprocess(HcclReduceScatterTest._test_reduce_scatter,
HcclReduceScatterTest._init_dist_hccl, cpu_excepted_result, input_list, world_size, dist.ReduceOp.AVG)
if __name__ == '__main__':
run_tests()
@@ -83,6 +83,23 @@ class HcclReduceScatterBaseTest(HcclReduceScatterTestBase):
self._test_multiprocess(HcclReduceScatterBaseTest._test_reduce_scatter_base,
HcclReduceScatterBaseTest._init_dist_hccl, expected, input_list, world_size, dist.ReduceOp.AVG)
@skipIfUnsupportMultiNPU(2)
def test_reduce_scatter_base_pre_mul(self):
ranks = [2]
dtype_list = [np.float32, np.float16]
shape_format = [[i, 2, [4, 9]] for i in dtype_list]
for world_size in ranks:
for shape in shape_format:
input_list = []
for _ in range(world_size):
_, input1 = create_common_tensor(shape, -10, 10)
input_list.append(input1.cpu())
expected = self._construct_excepted_result(input_list, world_size, dist._reduce_scatter_base, dist.ReduceOp.SUM)
expected = [i * 2 for i in expected]
reduce_op = torch_npu.distributed._make_hccl_premul_sum(2.0)
self._test_multiprocess(HcclReduceScatterBaseTest._test_reduce_scatter_base,
HcclReduceScatterBaseTest._init_dist_hccl, expected, input_list, world_size, reduce_op)
if __name__ == '__main__':
run_tests()
@@ -87,7 +87,7 @@ class HcclReduceScatterTensorTest(HcclReduceScatterTestBase):
input_list_npu = [input.npu() for input in input_list]
input_tensor = torch.cat(input_list_npu)
output = torch.empty_like(input_list_npu[rank])
torch_npu.distributed.reduce_scatter_tensor_uneven(output, input_tensor, reduce_op)
torch_npu.distributed.reduce_scatter_tensor_uneven(output, input_tensor, op=reduce_op)
c2p.put((rank, output.cpu()))
dist.barrier()
p2c.get()
@@ -185,7 +185,7 @@ class HcclReduceScatterTensorTest(HcclReduceScatterTestBase):
input_list.append(input1.cpu())
expected = self._construct_excepted_result(input_list, world_size, dist.reduce_scatter_tensor, dist.ReduceOp.SUM)
expected = [i * 2 for i in expected]
reduce_op = torch.distributed._make_nccl_premul_sum(2.0)
reduce_op = torch_npu.distributed._make_hccl_premul_sum(2.0)
self._test_multiprocess(HcclReduceScatterTensorTest._test_reduce_scatter_tensor,
HcclReduceScatterTensorTest._init_dist_hccl, expected, input_list, world_size, reduce_op)
+137
View File
@@ -0,0 +1,137 @@
"""
Add validation cases for torch.distributed APIs on NPU:
1. test/distributed/test_store.py from PyTorch community lacks sufficient API validations, so this file is added.
2. This file validates
torch.distributed.FileStore.path
torch.distributed.Store.__init__
torch.distributed.Store.add
torch.distributed.Store.timeout
torch.distributed.TCPStore.host
torch.distributed.TCPStore.port
(extendable).
"""
import os
import time
import socket
import tempfile
from datetime import timedelta
import torch
import torch.distributed as dist
from torch.testing._internal.common_utils import TestCase, run_tests
import torch_npu
def find_free_port() -> int:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(('', 0))
return s.getsockname()[1]
class TestStoreAPIs(TestCase):
"""Test cases for specific behavioral validations of Store APIs."""
def test_filestore_path_behavior(self):
"""Test if FileStore actually uses the specified path for data exchange."""
with tempfile.TemporaryDirectory() as temp_dir:
filename = os.path.join(temp_dir, "npu_filestore.txt")
store_master = dist.FileStore(filename, 2)
self.assertEqual(store_master.path, filename)
store_master.set("shared_key", "npu_data")
store_worker = dist.FileStore(filename, 2)
val = store_worker.get("shared_key")
self.assertEqual(val, b"npu_data")
def test_store_init(self):
"""Test the initialization (super().__init__) of the base Store class."""
class MyCustomStore(dist.Store):
def __init__(self):
super().__init__()
self.is_initialized = True
custom_store = MyCustomStore()
self.assertTrue(custom_store.is_initialized)
self.assertIsInstance(custom_store, dist.Store)
def test_store_add_behavior(self):
"""Test the add operation mathematically on a HashStore."""
store = dist.HashStore()
key = "test_add_key"
res1 = store.add(key, 5)
self.assertEqual(res1, 5)
res2 = store.add(key, 10)
self.assertEqual(res2, 15)
self.assertEqual(store.get(key), b"15")
res3 = store.add(key, -3)
self.assertEqual(res3, 12)
def test_store_timeout_behavior(self):
"""Test if the timeout property actively interrupts blocking operations."""
store = dist.HashStore()
timeout_seconds = 1
test_timeout = timedelta(seconds=timeout_seconds)
store.set_timeout(test_timeout)
self.assertEqual(store.timeout, test_timeout)
start_time = time.time()
with self.assertRaises(RuntimeError) as context:
store.wait(["non_existent_key"], test_timeout)
elapsed_time = time.time() - start_time
self.assertTrue(
"Timeout" in str(context.exception) or "Wait timeout" in str(context.exception),
f"Exception message does not indicate timeout: {context.exception}"
)
self.assertTrue(
0.8 <= elapsed_time <= 2.5,
f"Actual wait time {elapsed_time:.2f}s did not respect the {timeout_seconds}s timeout."
)
def test_tcpstore_host_and_port_behavior(self):
"""Test TCPStore host and port by establishing an actual Client-Server connection."""
host = "127.0.0.1"
port = find_free_port()
server_store = dist.TCPStore(
host_name=host,
port=port,
world_size=2,
is_master=True,
timeout=timedelta(seconds=5),
wait_for_workers=False
)
self.assertEqual(server_store.host, host)
self.assertEqual(server_store.port, port)
server_store.set("tcp_key", "tcp_value")
client_store = dist.TCPStore(
host_name=host,
port=port,
world_size=2,
is_master=False,
timeout=timedelta(seconds=5)
)
client_store.wait(["tcp_key"], timedelta(seconds=5))
val = client_store.get("tcp_key")
self.assertEqual(val, b"tcp_value")
del client_store
del server_store
if __name__ == "__main__":
run_tests()
+26
View File
@@ -0,0 +1,26 @@
import torch
from torch.testing._internal.common_utils import TestCase, run_tests
import torch_npu
from torch_npu.testing.common_distributed import skipIfUnsupportMultiNPU
class TestWithDevice(TestCase):
@skipIfUnsupportMultiNPU(2)
def test_with_device(self):
torch.npu.set_device(1)
# -float -> _get_device_index -> return current_device
# -int -> ignore, return -1
# future exchangeDevice:
# if < std::numeric_limits<c10::DeviceIndex>::min(), raise error
# else, ignore, return -1
for i in [-258, -200.8, -128, -128.8, -127.99, -7, -7.88, -1, -0.2]:
s = torch.npu.Stream(i)
self.assertEqual(s.device_index, 1)
device = torch.npu.current_device()
self.assertEqual(device, 1)
if __name__ == "__main__":
run_tests()
-20
View File
@@ -1,15 +1,10 @@
# Owner(s): ["module: dynamo"]
import unittest
import torch
from torch._dynamo.test_case import TestCase
import torch_npu
DEVICE_NAME = torch_npu.npu.get_device_name(0)[:10]
class TestNpuBackend(TestCase):
def test_optimize_npu(self):
func = torch.ops.aten.relu.default
@@ -20,21 +15,6 @@ class TestNpuBackend(TestCase):
dynamo_result = dynamo_func(x)
self.assertEqual(eager_result, dynamo_result)
@unittest.skipIf(DEVICE_NAME == 'Ascend910A', "capture is not supported on 910A, skip this ut.")
def test_npugraph_ex_backend(self):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
return x + y
compiled_model = torch.compile(Model().npu(), backend="npugraph_ex", fullgraph=True, dynamic=False)
x = torch.ones(1, dtype=torch.int32).npu()
y = torch.ones(1, dtype=torch.int32).npu()
z = compiled_model(x, y)
self.assertEqual(z.item(), 2)
if __name__ == "__main__":
from torch._dynamo.test_case import run_tests
+193
View File
@@ -0,0 +1,193 @@
# Owner(s): ["module: dynamo"]
import dataclasses
import functools
import unittest
from typing import List
import torch
from torch._dynamo.test_case import TestCase
from torch._dynamo.testing import same
from torch._functorch.aot_autograd import aot_module_simplified
from torch._inductor.pattern_matcher import Match
from torch._subclasses.fake_tensor import FakeTensorMode
import torch_npu
DEVICE_NAME = torch_npu.npu.get_device_name(0)[:10]
@unittest.skipIf(DEVICE_NAME == "Ascend910A", "capture is not supported on 910A, skip this ut.")
class TestNpuGraphEx(TestCase):
def test_backend(self):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
return x + y
model = Model().npu()
compiled_model = torch.compile(model, backend="npugraph_ex", options={"clone_input": False}, fullgraph=True, dynamic=False)
x = torch.ones(1, dtype=torch.int32, device="npu")
y = torch.ones(1, dtype=torch.int32, device="npu")
z = compiled_model(x, y)
self.assertEqual(z.item(), 2)
def test_compile_fx(self):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, y):
return x + y
def custom_compiler(gm: torch.fx.GraphModule, example_inputs):
compiled_graph = torch.npu.npugraph_ex.compile_fx(gm, example_inputs)
return compiled_graph
def custom_compiler_with_options(gm: torch.fx.GraphModule, example_inputs):
test_kwargs = {
"clone_input": False
}
compiled_graph = torch.npu.npugraph_ex.compile_fx(gm, example_inputs, test_kwargs)
return compiled_graph
def my_backend(gm: torch.fx.GraphModule, example_inputs):
return aot_module_simplified(gm, example_inputs, fw_compiler=custom_compiler)
def my_backend_with_options(gm: torch.fx.GraphModule, example_inputs):
return aot_module_simplified(gm, example_inputs, fw_compiler=custom_compiler_with_options)
model = Model().npu()
compiled_model = torch.compile(model, backend=my_backend, fullgraph=True, dynamic=False)
x = torch.ones(1, dtype=torch.int32, device="npu")
y = torch.ones(1, dtype=torch.int32, device="npu")
z = compiled_model(x, y)
self.assertEqual(z.item(), 2)
compiled_model = torch.compile(model, backend=my_backend_with_options, fullgraph=True, dynamic=False)
z = compiled_model(x, y)
self.assertEqual(z.item(), 2)
def test_cache_compile(self):
@dataclasses.dataclass
class InputMeta:
data: torch.Tensor
is_prompt: bool
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.linear1 = torch.nn.Linear(2, 1)
self.linear2 = torch.nn.Linear(2, 1)
for param in self.parameters():
torch.nn.init.ones_(param)
self.cached_prompt = torch.npu.npugraph_ex.inference.cache_compile(self.prompt)
self.cached_decode = torch.npu.npugraph_ex.inference.cache_compile(self.decode)
def forward(self, x: InputMeta, kv: List[torch.Tensor]):
if x.is_prompt:
return self.cached_prompt(x, kv)
return self.cached_decode(x, kv)
def _forward(self, x, kv):
return self.linear2(x.data) + self.linear2(kv[0])
def prompt(self, x, y):
return self._forward(x, y)
def decode(self, x, y):
return self._forward(x, y)
x = InputMeta(data=torch.ones(2, 2).npu(), is_prompt=True)
kv = [torch.ones(2, 2).npu()]
model = Model().npu()
res_prompt = model(x, kv)
x.is_prompt = False
res_decode = model(x, kv)
res = torch.empty(2, 1).npu().fill_(6.0)
self.assertTrue(same(res, res_prompt))
self.assertTrue(same(res, res_decode))
def test_register_replacement(self):
def search_fn(x1, x2, gamma):
x_out = torch.add(x1, x2)
y, _ = torch_npu.npu_rms_norm(x_out, gamma)
return y, x_out
def replace_fn(x1, x2, gamma):
y, _, x_out = torch_npu.npu_add_rms_norm(x1, x2, gamma)
return y, x_out
def extra_check(match: Match):
x1 = match.kwargs.get("x1")
if x1 is None:
return False
if not hasattr(x1, "meta") or "val" not in x1.meta:
return False
a_shape = x1.meta["val"].shape
return a_shape[-1] == 7168
fake_mode = FakeTensorMode()
with fake_mode:
input_tensor = functools.partial(torch.empty, (1, 1, 2), dtype=torch.float16, device="npu")
kwargs_tensor = functools.partial(torch.empty, 2, dtype=torch.float16, device="npu")
torch.npu.npugraph_ex.register_replacement(
search_fn=search_fn,
replace_fn=replace_fn,
example_inputs=(input_tensor(), input_tensor(), kwargs_tensor()),
extra_check=extra_check
)
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, data1, data2, gamma):
x_out = torch.add(data1, data2)
y, _ = torch_npu.npu_rms_norm(x_out, gamma)
abs_01 = torch.abs(y)
sqrt_01 = torch.sqrt(x_out)
return abs_01, sqrt_01
model = Model().npu()
x1 = torch.randn(1, 1, 7168, dtype=torch.float16, device="npu")
x2 = torch.randn(1, 1, 7168, dtype=torch.float16, device="npu")
gamma = torch.randn(7168, dtype=torch.float16, device="npu")
compiled_model = torch.compile(model, backend="npugraph_ex", fullgraph=True, dynamic=False)
res = compiled_model(x1, x2, gamma)
self.assertEqual(res[0].shape[2], 7168)
self.assertEqual(res[1].shape[2], 7168)
def test_limit_core_num(self):
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, in1, in2, in3, in4):
with torch.npu.npugraph_ex.scope.limit_core_num(4, 5):
mm_result = torch.mm(in3, in4)
add_result = torch.add(in1, in2)
mm1_result = torch.mm(in3, in4)
return add_result, mm_result, mm1_result
model = Model().npu()
compiled_model = torch.compile(model, backend="npugraph_ex", fullgraph=True, dynamic=False)
in1 = torch.randn(1000, 1000, dtype=torch.float16, device="npu")
in2 = torch.randn(1000, 1000, dtype=torch.float16, device="npu")
in3 = torch.randn(1000, 1000, dtype=torch.float16, device="npu")
in4 = torch.randn(1000, 1000, dtype=torch.float16, device="npu")
res = compiled_model(in1, in2, in3, in4)
if __name__ == "__main__":
from torch._dynamo.test_case import run_tests
run_tests()
+38
View File
@@ -0,0 +1,38 @@
import unittest
import torch
import torch_npu
class TraceStreamEventTests(unittest.TestCase):
def test_dynamo_trace_stream_event(self):
def my_backend(gm, example_inputs):
print(gm.graph)
node_names = (node.name for node in gm.graph.nodes)
self.assertIn("current_stream", node_names)
self.assertIn("set_stream", node_names)
self.assertIn("fake_record_stream", node_names)
return gm
@torch.compile(backend=my_backend)
def test_stream_in_graph(a):
s = torch.npu.Stream()
event = torch.npu.Event()
r = torch.add(a, 2)
event.record()
with torch.npu.stream(s):
event.wait()
r = torch.add(r, 1)
r.record_stream(s)
r = torch.add(r, 1)
return r
i = torch.randn([3, 3], device="npu:0")
with self.assertRaises(RuntimeError) as context:
r = test_stream_in_graph(i)
return r
self.assertIn("tensor.record_stream is not supported on torch.compile", str(context.exception))
if __name__ == '__main__':
unittest.main()
+83
View File
@@ -0,0 +1,83 @@
"""
Add validation cases for torch.nn.models APIs on NPU:
1. test/test_modules.py from PyTorch community lacks sufficient API validations, so this file is added.
2. This file validates torch.nn.Module, torch.nn.Module.state_dict, torch.nn.ModuleDict, torch.nn.ModuleList (extendable).
"""
import torch
import torch.nn as nn
from torch.testing._internal.common_utils import run_tests, TestCase
import torch_npu
device = torch.device("npu:0")
class TestNPUModuleAPIs(TestCase):
def test_module_device_consistency(self):
"""验证Module设备迁移后参数/缓冲区设备一致"""
m = nn.Sequential(nn.Linear(10, 20), nn.ReLU(), nn.BatchNorm1d(20)).to(device)
for p in m.parameters():
self.assertEqual(p.device, device)
for b in m.buffers():
self.assertEqual(b.device, device)
def test_module_state_dict(self):
"""验证state_dict保存/加载后状态一致"""
base = nn.Sequential(nn.Linear(10, 20), nn.ReLU(), nn.BatchNorm1d(20))
m = nn.Module()
m.dict = nn.ModuleDict({"linear": nn.Linear(10, 20), "base": base})
m.list = nn.ModuleList([nn.Linear(20, 30), base])
m.to(device)
sd = m.state_dict()
torch.npu.synchronize()
for v in sd.values():
self.assertEqual(v.device, device)
base2 = nn.Sequential(nn.Linear(10, 20), nn.ReLU(), nn.BatchNorm1d(20))
m2 = nn.Module()
m2.dict = nn.ModuleDict({"linear": nn.Linear(10, 20), "base": base2})
m2.list = nn.ModuleList([nn.Linear(20, 30), base2])
m2.load_state_dict(sd)
m2.to(device)
torch.npu.synchronize()
for (n1, p1), (n2, p2) in zip(m.named_parameters(), m2.named_parameters()):
self.assertTrue(torch.allclose(p1, p2))
def test_moduledict_operations(self):
"""验证ModuleDict增删/索引/遍历"""
m = nn.ModuleDict({"a": nn.Linear(10, 20).to(device)})
self.assertIn("a", m)
m["b"] = nn.Linear(20, 30).to(device)
self.assertEqual(m["b"].weight.device, device)
del m["b"]
self.assertNotIn("b", m)
for sub in m.values():
for p in sub.parameters():
self.assertEqual(p.device, device)
def test_modulelist_operations(self):
"""验证ModuleList索引/新增/删除/遍历"""
m = nn.ModuleList([nn.Linear(20, 30).to(device), nn.BatchNorm1d(30).to(device)])
self.assertEqual(m[0].weight.device, device)
self.assertEqual(m[1].running_mean.device, device)
m.append(nn.Linear(30, 40).to(device))
m.insert(0, nn.Linear(10, 20).to(device))
m.pop(-1) # 修复:指定索引
m.pop(0) # 修复:指定索引
self.assertEqual(len(m), 2)
for sub in m:
for p in sub.parameters():
self.assertEqual(p.device, device)
if __name__ == "__main__":
run_tests()
+68
View File
@@ -0,0 +1,68 @@
"""
Add validation cases for torch.nn APIs on NPU:
1. test/test_nn.py from PyTorch community lacks sufficient API validations, so this file is added.
2. This file validates torch.nn.Parameter, torch.nn.Buffer (extendable).
"""
import torch
import torch.nn as nn
from torch.testing._internal.common_utils import run_tests, TestCase
import torch_npu
device = torch.device("npu:0")
class TestNPUParameterBuffer(TestCase):
def test_parameter_api(self):
"""验证torch.nn.Parameter的创建、属性及NPU设备支持"""
# 直接在NPU上创建Parameter(推荐方式)
p = nn.Parameter(torch.randn(10, 20, device=device))
# 验证类型和属性
self.assertIsInstance(p, nn.Parameter)
self.assertTrue(p.requires_grad)
self.assertEqual(p.device, device)
self.assertEqual(p.shape, (10, 20))
# 验证数据操作
p.data = p.data * 2 # Parameter支持.data访问
self.assertEqual(p.shape, (10, 20)) # 形状不变
# 修改requires_grad
p.requires_grad = False
self.assertFalse(p.requires_grad)
def test_buffer_api(self):
"""验证torch.nn.Buffer的创建、persistent属性及NPU设备支持"""
# 创建persistent Buffer(默认)
b1 = nn.Buffer(torch.randn(5, 5, device=device))
self.assertIsInstance(b1, nn.Buffer)
self.assertFalse(b1.requires_grad) # Buffer默认不需要梯度
self.assertEqual(b1.device, device)
# 创建non-persistent Buffer
b2 = nn.Buffer(torch.randn(3, 3, device=device), persistent=False)
self.assertFalse(b2.requires_grad)
self.assertEqual(b2.device, device)
# 验证persistent属性在Module中的行为
class TestModule(nn.Module):
def __init__(self):
super().__init__()
self.register_buffer('persistent_buf', b1)
self.register_buffer('non_persistent_buf', b2, persistent=False)
m = TestModule()
state_dict = m.state_dict()
# persistent buffer应在state_dict中
self.assertIn('persistent_buf', state_dict)
# non-persistent buffer不应在state_dict中
self.assertNotIn('non_persistent_buf', state_dict)
# 验证Buffer在state_dict中的值正确
self.assertEqual(state_dict['persistent_buf'].device, device)
if __name__ == "__main__":
run_tests()
+1 -1
View File
@@ -31,7 +31,7 @@ class MyModel(nn.Module):
class TestAclgraphLaunchHostFunc(TestCase):
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_launch_host_func(self):
torch_npu.npu.set_compile_mode(jit_compile=False)
torch_npu.npu.set_device(0)
+135
View File
@@ -0,0 +1,135 @@
import os
import torch
import torch_npu
from contextlib import nullcontext
from torch_npu.testing.common_utils import SupportedDevices
from torch_npu.testing.testcase import TestCase, run_tests
os.environ["PYTORCH_NPU_ALLOC_CONF"] = "expandable_segments:True"
def _npu_stream_switch(target_stream, enabled=True):
if not enabled:
return nullcontext()
return torch.npu.stream(target_stream)
class TestAclgraphMultiStream(TestCase):
"""
Tests for ACLGraph multi-stream capture correctness.
Covers two scenarios:
1. Shared-expert secondary stream pattern: a single side stream performs
computation in parallel with the main capture stream, joined via
wait_stream on both sides (fork / join).
2. Parallel-branch fork-join: two streams each compute a branch
simultaneously and merge the results; verifies numerical correctness
across multiple replays with updated inputs.
"""
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_shared_expert_stream_capture_replay(self):
device = torch.device("npu:0")
torch.npu.set_device(device)
shared_stream = torch.npu.Stream()
positions = torch.ones(4, 4, device=device, dtype=torch.bfloat16)
def _eager(x, side):
default = torch.npu.current_stream()
a = x + x
side.wait_stream(default)
with torch.npu.stream(side):
b = x / x
b = b + x
default.wait_stream(side)
return a, b
ref_a, ref_b = _eager(positions, torch.npu.Stream())
torch.npu.synchronize()
out_a = out_b = None
g = torch.npu.NPUGraph()
with torch.npu.graph(g):
stream_default = torch.npu.current_stream()
out_a = positions + positions
shared_stream.wait_stream(stream_default)
with _npu_stream_switch(shared_stream):
out_b = positions / positions
out_b = out_b + positions
stream_default.wait_stream(shared_stream)
torch.npu.synchronize()
torch.npu.empty_cache()
g.replay()
torch.npu.synchronize()
self.assertRtolEqual(out_a.cpu(), ref_a.cpu())
self.assertRtolEqual(out_b.cpu(), ref_b.cpu())
positions.fill_(2.0)
ref_a2, ref_b2 = _eager(positions, torch.npu.Stream())
torch.npu.synchronize()
g.replay()
torch.npu.synchronize()
self.assertRtolEqual(out_a.cpu(), ref_a2.cpu())
self.assertRtolEqual(out_b.cpu(), ref_b2.cpu())
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_parallel_branch_capture_replay(self):
device = torch.device("npu:0")
torch.npu.set_device(device)
M, K = 32, 32
dtype = torch.float16
s_inp = torch.randn(M, K, dtype=dtype, device=device)
wa = torch.randn(K, K, dtype=dtype, device=device)
wb = torch.randn(K, K, dtype=dtype, device=device)
capture_stream = torch.npu.Stream()
side_stream = torch.npu.Stream()
g = torch.npu.NPUGraph()
capture_stream.wait_stream(torch.npu.current_stream())
with torch.npu.stream(capture_stream):
for _ in range(3):
side_stream.wait_stream(capture_stream)
with torch.npu.stream(side_stream):
_b = torch.matmul(s_inp, wb)
_a = torch.matmul(s_inp, wa)
capture_stream.wait_stream(side_stream)
_ = _a + _b
torch.npu.current_stream().wait_stream(capture_stream)
torch.npu.synchronize()
with torch.npu.stream(capture_stream):
with torch.npu.graph(g, stream=capture_stream):
side_stream.wait_stream(capture_stream)
with torch.npu.stream(side_stream):
branch_b = torch.matmul(s_inp, wb)
branch_a = torch.matmul(s_inp, wa)
capture_stream.wait_stream(side_stream)
output = branch_a + branch_b
torch.npu.synchronize()
torch.npu.empty_cache()
ref1 = torch.matmul(s_inp, wa) + torch.matmul(s_inp, wb)
g.replay()
torch.npu.synchronize()
self.assertRtolEqual(output.cpu(), ref1.cpu(), prec16=0.01)
inp2 = torch.randn(M, K, dtype=dtype, device=device)
ref2 = torch.matmul(inp2, wa) + torch.matmul(inp2, wb)
s_inp.copy_(inp2)
g.replay()
torch.npu.synchronize()
self.assertRtolEqual(output.cpu(), ref2.cpu(), prec16=0.01)
if __name__ == "__main__":
run_tests()
+222
View File
@@ -0,0 +1,222 @@
import unittest
import os
import torch
import torch_npu
from torch_npu.testing.common_utils import SkipIfNotGteCANNVersion
from torch_npu.testing.testcase import TestCase, run_tests
class TestAclgraphSuperKernelScope(TestCase):
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_scope_begin_end_basic(self):
"""Test basic usage of super_kernel_scope_begin and super_kernel_scope_end"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
x = torch.randn(10, 10, device='npu')
y = torch.randn(10, 10, device='npu')
with torch.npu.graph(g):
torch_npu.npu.super_kernel_scope_begin("test_scope")
z = torch.matmul(x, y)
torch_npu.npu.super_kernel_scope_end("test_scope")
g.replay()
expected = torch.matmul(x, y)
self.assertTrue(torch.allclose(z, expected, rtol=1e-3, atol=1e-3))
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_scope_begin_end_without_name(self):
"""Test super_kernel_scope_begin and super_kernel_scope_end without scope name"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
x = torch.randn(5, 5, device='npu')
y = torch.randn(5, 5, device='npu')
with torch.npu.graph(g):
torch_npu.npu.super_kernel_scope_begin()
z = x + y
torch_npu.npu.super_kernel_scope_end()
g.replay()
expected = x + y
self.assertTrue(torch.allclose(z, expected, rtol=1e-3, atol=1e-3))
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_scope_begin_end_nested(self):
"""Test nested usage of super_kernel_scope_begin and super_kernel_scope_end"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
x = torch.randn(8, 8, device='npu')
y = torch.randn(8, 8, device='npu')
with torch.npu.graph(g):
torch_npu.npu.super_kernel_scope_begin("outer_scope")
z1 = torch.matmul(x, y)
torch_npu.npu.super_kernel_scope_begin("inner_scope")
z2 = z1 * 2.0
torch_npu.npu.super_kernel_scope_end("inner_scope")
z3 = z2 + 1.0
torch_npu.npu.super_kernel_scope_end("outer_scope")
g.replay()
expected = torch.matmul(x, y) * 2.0 + 1.0
self.assertTrue(torch.allclose(z3, expected, rtol=1e-3, atol=1e-3))
def test_super_kernel_scope_begin_end_invalid_name(self):
"""Test that empty string scope name raises error"""
torch.npu.set_device(0)
with self.assertRaises(RuntimeError):
torch_npu.npu.super_kernel_scope_begin("")
with self.assertRaises(RuntimeError):
torch_npu.npu.super_kernel_scope_begin(" ")
class TestAclgraphSuperKernelOptimize(TestCase):
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_optimize_basic(self):
"""Test basic super_kernel_optimize functionality"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
x = torch.randn(16, 16, device='npu')
y = torch.randn(16, 16, device='npu')
with torch.npu.graph(g):
z = torch.matmul(x, y)
# Test with no optimize options (None)
g.super_kernel_optimize(optimize_options=None, debug_options=None)
g.replay()
expected = torch.matmul(x, y)
self.assertTrue(torch.allclose(z, expected, rtol=1e-3, atol=1e-3))
def test_super_kernel_optimize_invalid_options_type(self):
"""Test that invalid options type raises error"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(optimize_options="invalid", debug_options=None)
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(optimize_options=None, debug_options="invalid")
def test_super_kernel_optimize_invalid_option_key(self):
"""Test that invalid option key raises error"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(
optimize_options={'invalid_key': 1},
debug_options=None
)
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(
optimize_options=None,
debug_options={'invalid_key': 1}
)
def test_super_kernel_optimize_invalid_option_value_type(self):
"""Test that invalid option value type raises error"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(
optimize_options={'preload_code': 'invalid_string'},
debug_options=None
)
with self.assertRaises(RuntimeError):
g.super_kernel_optimize(
optimize_options=None,
debug_options={'debug_sync_all': 'invalid_string'}
)
class TestAclgraphSuperKernelIntegration(TestCase):
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_scope_and_optimize_integration(self):
"""Test integration of super_kernel_scope and super_kernel_optimize"""
torch.npu.set_device(0)
g = torch.npu.NPUGraph()
x = torch.randn(16, 16, device='npu')
y = torch.randn(16, 16, device='npu')
with torch.npu.graph(g):
torch_npu.npu.super_kernel_scope_begin("compute_scope")
z = torch.matmul(x, y)
w = torch.relu(z)
torch_npu.npu.super_kernel_scope_end("compute_scope")
optimize_options = {
'preload_code': 1,
'stream_fusion': 1
}
g.super_kernel_optimize(optimize_options=optimize_options, debug_options=None)
g.replay()
expected_z = torch.matmul(x, y)
expected_w = torch.relu(expected_z)
self.assertTrue(torch.allclose(w, expected_w, rtol=1e-3, atol=1e-3))
@SkipIfNotGteCANNVersion("9.9.0")
def test_super_kernel_with_nn_module(self):
"""Test super_kernel features with nn.Module"""
torch.npu.set_device(0)
class SimpleModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.linear = torch.nn.Linear(32, 32).npu()
def forward(self, x):
return self.linear(x)
model = SimpleModel()
model.eval()
g = torch.npu.NPUGraph()
x = torch.randn(4, 32, device='npu')
with torch.npu.graph(g):
torch_npu.npu.super_kernel_scope_begin("model_forward")
out = model(x)
torch_npu.npu.super_kernel_scope_end("model_forward")
optimize_options = {
'stream_fusion': 1
}
g.super_kernel_optimize(optimize_options=optimize_options, debug_options=None)
g.replay()
expected = model(x)
self.assertTrue(torch.allclose(out, expected, rtol=1e-3, atol=1e-3))
if __name__ == '__main__':
run_tests()
+3 -3
View File
@@ -14,7 +14,7 @@ os.environ["ASCEND_LAUNCH_BLOCKING"] = "1"
class TestIFAAclgraphUpdateSupportBlocking(TestCase):
@SupportedDevices(['Ascend910B', 'Ascend910C'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_support_blocking(self):
torch.npu.set_device(0)
length = [29]
@@ -63,7 +63,7 @@ class TestIFAAclgraphUpdateSupportBlocking(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B', 'Ascend910C'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_with_auto_dispatch_capture_support_blocking(self):
torch.npu.set_device(0)
length = [29]
@@ -97,7 +97,7 @@ class TestIFAAclgraphUpdateSupportBlocking(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B', 'Ascend910C'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_with_non_out_and_auto_dispatch_capture_support_blocking(self):
torch.npu.set_device(0)
length = [29]
+12 -12
View File
@@ -15,7 +15,7 @@ from torch_npu.testing.testcase import TestCase, run_tests
class TestIFAAclgraphUpdate(TestCase):
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update(self):
torch.npu.set_device(0)
length = [29]
@@ -64,7 +64,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_update_stream_globally_unique(self):
torch.npu.set_device(0)
@@ -72,7 +72,7 @@ class TestIFAAclgraphUpdate(TestCase):
g2 = torch.npu.NPUGraph()
self.assertEqual(g1.graph_dispatch_mode.update_stream, g2.graph_dispatch_mode.update_stream)
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_with_auto_dispatch_capture(self):
torch.npu.set_device(0)
length = [29]
@@ -106,7 +106,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_with_non_out_and_auto_dispatch_capture(self):
torch.npu.set_device(0)
length = [29]
@@ -136,7 +136,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_v2_update_with_auto_dispatch_capture(self):
torch.npu.set_device(0)
length = [1]
@@ -169,7 +169,7 @@ class TestIFAAclgraphUpdate(TestCase):
g.replay()
self.assertEqual(output.cpu(), res_src[0].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_v2_update_with_non_out_and_auto_dispatch_capture(self):
torch.npu.set_device(0)
length = [1]
@@ -198,7 +198,7 @@ class TestIFAAclgraphUpdate(TestCase):
g.replay()
self.assertEqual(output.cpu(), res_src[0].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
@unittest.skip("this cann version is not supported")
def test_npu_fused_infer_attention_score_v2(self):
torch.npu.set_device(0)
@@ -246,7 +246,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_fia_out_4in1_with_graph(self, device="npu"):
q = torch.randn(1, 8, 164, 128, dtype=torch.float16).npu()
k = torch.randn(1, 8, 1024, 128, dtype=torch.float16).npu()
@@ -301,7 +301,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertTrue(torch.allclose(output, output2, 1e-4, 1e-4))
self.assertTrue(torch.allclose(softmax_lse, softmax_lse2, 1e-4, 1e-4))
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
@unittest.skip("this cann version is not supported")
def test_npugraph_debug_dump(self):
N, D_in, H, D_out = 640, 4096, 2048, 1024
@@ -330,7 +330,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertTrue(os.path.getsize(file_path) > 0, "npugraph debug dump assert error")
os.remove(file_path)
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_ifa_update_no_reset(self):
torch.npu.set_device(0)
length = [29]
@@ -378,7 +378,7 @@ class TestIFAAclgraphUpdate(TestCase):
self.assertEqual(output.cpu(), res_src[0].cpu())
self.assertEqual(softmax_lse.cpu(), res_src[1].cpu())
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
@unittest.skip("this cann version is not supported")
def test_npu_fused_infer_attention_score_v2_no_reset(self):
torch.npu.set_device(0)
@@ -548,7 +548,7 @@ class TestPAAclgraphUpdate(TestCase):
)
return params.output
@SupportedDevices(['Ascend910B'])
@SupportedDevices(['Ascend910B', 'Ascend910_93'])
def test_paged_attention_aclgraph_update(self):
params, golden_output = self.preprocess()
output = None
+51 -2
View File
@@ -71,10 +71,22 @@ class ProcessGroupHCCLTest(TestCase):
@classmethod
def _test_broadcast_process(
cls, rank, shared_tensors, world_size, init_pg, c2p, p2c):
dtype_name = None
if isinstance(shared_tensors, tuple):
shared_tensors, dtype_name = shared_tensors
pg = init_pg(rank, world_size)
xs = [shared_tensors[rank].to(f"npu:{rank}")]
if dtype_name is not None:
expected = shared_tensors[0].to(torch.float32)
result = xs[0].to(torch.float32).cpu()
pg.broadcast(xs).wait()
c2p.put((rank, torch.zeros(2, 2), xs[0].to("cpu")))
if dtype_name is not None:
expected = shared_tensors[0].to(torch.float32)
result = xs[0].to(torch.float32).cpu()
else:
expected = shared_tensors[0]
result = xs[0].to("cpu")
c2p.put((rank, expected, result))
p2c.get()
def test_shared_broadcast_hccl(self):
@@ -103,12 +115,24 @@ class ProcessGroupHCCLTest(TestCase):
@classmethod
def _test_allgather_process(
cls, rank, shared_tensors, world_size, init_pg, c2p, p2c):
dtype_name = None
if isinstance(shared_tensors, tuple):
shared_tensors, dtype_name = shared_tensors
pg = init_pg(rank, world_size)
xs = [shared_tensors[rank].to(f"npu:{rank}")]
if dtype_name is not None:
dtype = getattr(torch, dtype_name, getattr(torch_npu, dtype_name, None))
xs[0] = xs[0].to(dtype)
ys = [[torch.zeros_like(xs[0]) for i in range(world_size)]]
pg.allgather(ys, xs).wait()
for i in range(world_size):
c2p.put((rank, torch.ones(2, 2) * i, ys[0][i].to("cpu")))
if dtype_name is not None:
expected = shared_tensors[i].to(torch.float32)
result = ys[0][i].to(torch.float32).cpu()
else:
expected = shared_tensors[i]
result = ys[0][i].to("cpu")
c2p.put((rank, expected, result))
p2c.get()
@@ -119,6 +143,31 @@ class ProcessGroupHCCLTest(TestCase):
ProcessGroupHCCLTest._init_pg_hccl,
self.world_size)
def test_shared_broadcast_hccl_uint_dtypes(self):
base = torch.tensor([1, 2, 4, 8], dtype=torch.float16).reshape(2, 2)
shared_tensors = [base * (2 ** (i * 4)) for i in range(self.world_size)]
for dtype_name in ["uint16", "uint32", "uint64"]:
dtype = getattr(torch, dtype_name, getattr(torch_npu, dtype_name, None))
self.assertIsNotNone(dtype, f"{dtype_name} not available")
self._test_multiprocess(
ProcessGroupHCCLTest._test_broadcast_process,
(shared_tensors, dtype_name),
ProcessGroupHCCLTest._init_pg_hccl,
1)
def test_shared_allgather_hccl_uint_dtypes(self):
base = torch.tensor([1, 2, 4, 8], dtype=torch.float16).reshape(2, 2)
shared_tensors = [base * (2 ** (i * 4)) for i in range(self.world_size)]
for dtype_name in ["uint16", "uint32", "uint64"]:
dtype = getattr(torch, dtype_name, getattr(torch_npu, dtype_name, None))
self.assertIsNotNone(dtype, f"{dtype_name} not available")
self._test_multiprocess(
ProcessGroupHCCLTest._test_allgather_process,
(shared_tensors, dtype_name),
ProcessGroupHCCLTest._init_pg_hccl,
self.world_size)
class ComputeBucketAssignmentTest(TestCase):
def test_single_limit_single_dtype(self):
+3
View File
@@ -1,4 +1,5 @@
import re
import unittest
from torch.testing._internal.common_utils import TestCase, run_tests
import torch
@@ -8,6 +9,7 @@ from torch_npu.npu.utils import get_cann_version, _is_gte_cann_version
class TestCANNversion(TestCase):
@unittest.skip("ci error, beta version")
def test_get_cann_version(self):
version_env = get_cann_version_from_env()
version = get_cann_version(module="CANN")
@@ -48,6 +50,7 @@ class TestCANNversion(TestCase):
else:
self.assertTrue(version == "", "When verssion_env < '25.', the result of get_cann_version is not right.")
@unittest.skip("ci error, beta version")
def test_compare_cann_version(self):
version_env = get_cann_version_from_env()
if not version_env.startswith("CANN") and version_env >= "8.1.RC1":
+138
View File
@@ -0,0 +1,138 @@
import unittest
import torch
import numpy as np
import torch_npu
from torch_npu.testing.testcase import TestCase, run_tests
from torch_npu.testing.common_utils import create_common_tensor
class TestCopyKernelMemoryFormat(TestCase):
def test_h2d_copy_contiguous_tensor(self):
dtype_list = [np.float16, np.float32, np.int32, np.int64]
shape_list = [[10, 20], [32, 64, 128], [2, 3, 4, 5]]
shape_format = [
[dtype, 2, shape] for dtype in dtype_list for shape in shape_list
]
for item in shape_format:
cpu_input, npu_input = create_common_tensor(item, -100, 100)
npu_input_copy = cpu_input.npu()
self.assertRtolEqual(npu_input_copy.cpu().numpy(), cpu_input.numpy())
def test_h2d_copy_non_contiguous_tensor(self):
dtype_list = [np.float16, np.float32]
shape_list = [[32, 64], [16, 32, 64]]
shape_format = [
[dtype, 2, shape] for dtype in dtype_list for shape in shape_list
]
for item in shape_format:
cpu_input, npu_input = create_common_tensor(item, -100, 100)
cpu_transposed = cpu_input.transpose(-1, -2)
npu_transposed = cpu_transposed.npu()
npu_contiguous = npu_transposed.contiguous()
self.assertRtolEqual(npu_contiguous.cpu().numpy(), cpu_transposed.contiguous().numpy())
def test_d2h_copy_contiguous_tensor(self):
dtype_list = [np.float16, np.float32, np.int32, np.int64]
shape_list = [[10, 20], [32, 64, 128], [2, 3, 4, 5]]
shape_format = [
[dtype, 2, shape] for dtype in dtype_list for shape in shape_list
]
for item in shape_format:
cpu_input, npu_input = create_common_tensor(item, -100, 100)
cpu_output = npu_input.cpu()
self.assertRtolEqual(cpu_output.numpy(), cpu_input.numpy())
def test_d2h_copy_non_contiguous_tensor(self):
dtype_list = [np.float16, np.float32]
shape_list = [[32, 64], [16, 32, 64]]
shape_format = [
[dtype, 2, shape] for dtype in dtype_list for shape in shape_list
]
for item in shape_format:
cpu_input, npu_input = create_common_tensor(item, -100, 100)
npu_transposed = npu_input.transpose(-1, -2)
cpu_output = npu_transposed.cpu()
self.assertRtolEqual(cpu_output.numpy(), cpu_input.transpose(-1, -2).contiguous().numpy())
def test_h2d_copy_different_dtype(self):
src_dtype_list = [np.float32, np.float16]
dst_dtype_list = [torch.float16, torch.float32]
shape = [32, 64]
for src_dtype, dst_dtype in zip(src_dtype_list, dst_dtype_list):
cpu_input = torch.randn(shape, dtype=torch.float32) * 100
cpu_input = cpu_input.to(torch.from_numpy(np.array([])).dtype if src_dtype == np.float32 else torch.float16)
npu_input = cpu_input.npu()
npu_output = npu_input.to(dst_dtype)
cpu_output = cpu_input.to(dst_dtype)
self.assertRtolEqual(npu_output.cpu().numpy(), cpu_output.numpy())
def test_d2h_copy_different_dtype(self):
dtype_pairs = [
(np.float16, torch.float32),
(np.float32, torch.float16),
]
shape = [32, 64]
for src_dtype, dst_dtype in dtype_pairs:
cpu_input, npu_input = create_common_tensor([src_dtype, 0, shape], -100, 100)
cpu_output = npu_input.cpu().to(dst_dtype)
expected = cpu_input.to(dst_dtype)
self.assertRtolEqual(cpu_output.numpy(), expected.numpy())
def test_h2d_copy_slice_tensor(self):
shape = [64, 128]
cpu_input = torch.randn(shape)
cpu_slice = cpu_input[10:30, 20:60]
npu_slice = cpu_slice.npu()
npu_contiguous = npu_slice.contiguous()
self.assertRtolEqual(npu_contiguous.cpu().numpy(), cpu_slice.contiguous().numpy())
def test_d2h_copy_slice_tensor(self):
shape = [64, 128]
cpu_input = torch.randn(shape)
npu_input = cpu_input.npu()
npu_slice = npu_input[10:30, 20:60]
cpu_slice = npu_slice.cpu()
self.assertRtolEqual(cpu_slice.numpy(), cpu_input[10:30, 20:60].contiguous().numpy())
def test_d2h_copy_broadcast_tensor(self):
shape = [1, 64, 1]
cpu_input = torch.randn(shape)
npu_input = cpu_input.npu()
npu_broadcast = npu_input.expand(4, 64, 128)
cpu_output = npu_broadcast.cpu()
self.assertRtolEqual(cpu_output.numpy(), cpu_input.expand(4, 64, 128).contiguous().numpy())
def test_h2d_copy_permute_tensor(self):
shape = [32, 64, 128]
cpu_input = torch.randn(shape)
cpu_permuted = cpu_input.permute(2, 0, 1)
npu_permuted = cpu_permuted.npu()
npu_contiguous = npu_permuted.contiguous()
self.assertRtolEqual(npu_contiguous.cpu().numpy(), cpu_permuted.contiguous().numpy())
def test_d2h_copy_permute_tensor(self):
shape = [32, 64, 128]
cpu_input = torch.randn(shape)
npu_input = cpu_input.npu()
npu_permuted = npu_input.permute(2, 0, 1)
cpu_output = npu_permuted.cpu()
self.assertRtolEqual(cpu_output.numpy(), cpu_input.permute(2, 0, 1).contiguous().numpy())
if __name__ == "__main__":
run_tests()
+31
View File
@@ -0,0 +1,31 @@
import unittest
import numpy as np
import torch
import torch_npu
from torch_npu.testing.testcase import TestCase, run_tests
from torch_npu.testing.common_utils import SkipIfNotGteCANNVersion
@unittest.skip("This test is not supported yet")
class TestCompatibleImpl(TestCase):
def test__get_deterministic_level(self):
self.assertEqual(torch_npu.npu._get_deterministic_level(), 2)
@SkipIfNotGteCANNVersion("9.0.0")
def test_npu_matmul(self):
torch.set_default_device('npu')
B = 2048
D = 4096
R = 1000
a = torch.linspace(-R, R, B * D).reshape(B, D)
b = torch.linspace(-R, R, D * D).reshape(D, D)
out1 = torch.mm(a[:1], b)
out2 = torch.mm(a, b)[:1]
self.assertEqual(np.array_equal(out1.cpu().numpy().view(np.uint32), out2.cpu().numpy().view(np.uint32)), True)
if __name__ == "__main__":
torch_npu.npu.set_deterministic_level(2)
run_tests()
+1 -1
View File
@@ -8,7 +8,7 @@ from torch_npu.testing.decorator import Dtypes, instantiate_tests
@instantiate_tests
class TestDLPack(TestCase):
@Dtypes(torch.float, torch.double, torch.int8, torch.int16, torch.int32, torch.int64, torch.uint8, torch.bool)
@Dtypes(torch.float, torch.double, torch.int8, torch.int16, torch.int32, torch.int64, torch.bool)
def test_dlpack_roundtrip_basic(self, dtype, device="npu"):
"""Test basic dlpack roundtrip: torch_npu tensor -> dlpack -> torch_npu tensor"""
# Create original tensor
+3
View File
@@ -9,8 +9,11 @@ from torch.testing._internal.common_utils import TestCase, run_tests, TEST_PRIVA
os.environ["PYTORCH_NPU_ALLOC_CONF"] = "expandable_segments:True"
device_name = torch_npu.npu.get_device_name(0)
class Test_expandable_segments(TestCase):
@unittest.skipIf(device_name == "Ascend910B4", "Skip when device name is Ascend910B4")
def test_empty_virt_addr_cache(self):
gc.collect()
torch_npu.npu.empty_cache()
+2
View File
@@ -257,6 +257,7 @@ class TestMode(TestCase):
with self.assertRaisesRegex(ValueError, "loaded state dict has a different number of parameter groups"):
optimizer1.load_state_dict(optimizer2.state_dict())
@SupportedDevices(['Ascend910A', 'Ascend910B', 'Ascend910_93'])
def test_aclopCompile(self):
path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_aclopCompileAndExecute.py')
process = subprocess.Popen(["python", f"{path}"], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
@@ -271,6 +272,7 @@ class TestMode(TestCase):
error
)
@SupportedDevices(['Ascend910A', 'Ascend910B', 'Ascend910_93'])
def test_ascyn(self):
path = os.path.join(os.path.dirname(__file__), '_fault_mode_cases/error_aclopCompileAndExecute.py')
process = subprocess.Popen(["python", f"{path}"], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+97 -23
View File
@@ -176,17 +176,91 @@ class TestTreeManagerContainer(TestCase):
class TestStorageWeakRefWrapper(TestCase):
def test_storage_ref(self):
def test_init_from_tensor(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
self.assertEqual(wrapper.data_ptr(), tensor.untyped_storage().data_ptr())
del tensor
# Storage might still be alive due to Python's ref counting; force GC
import gc
self.assertFalse(wrapper.expired())
def test_init_from_untyped_storage(self):
tensor = torch.tensor([1], device="npu")
storage = tensor.untyped_storage()
wrapper = StorageWeakRefWrapper(storage)
self.assertEqual(wrapper.data_ptr(), storage.data_ptr())
self.assertFalse(wrapper.expired())
def test_expired_after_delete(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
del tensor
import gc
gc.collect()
self.assertTrue(wrapper.expired())
def test_call_returns_cdata_when_alive(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
result = wrapper()
self.assertIsNotNone(result)
def test_call_returns_none_when_expired(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
del tensor
import gc
gc.collect()
self.assertIsNone(wrapper())
def test_data_ptr_persists_after_expiry(self):
tensor = torch.tensor([1], device="npu")
expected_ptr = tensor.untyped_storage().data_ptr()
wrapper = StorageWeakRefWrapper(tensor)
del tensor
import gc
gc.collect()
# data_ptr() must return the original ptr even after storage has expired
self.assertEqual(wrapper.data_ptr(), expected_ptr)
def test_from_weakref_and_data_ptr(self):
tensor = torch.tensor([1], device="npu")
storage = tensor.untyped_storage()
cdata = storage._cdata
data_ptr = storage.data_ptr()
wrapper = StorageWeakRefWrapper.from_weakref_and_data_ptr(cdata, data_ptr)
self.assertEqual(wrapper.data_ptr(), data_ptr)
self.assertFalse(wrapper.expired())
def test_extra_ref_check_prevents_expiry(self):
tensor = torch.tensor([1], device="npu")
# extra_ref_check returning False means "not expired yet"
extra_check = MagicMock(return_value=False)
wrapper = StorageWeakRefWrapper(tensor, extra_ref_check=extra_check)
self.assertFalse(wrapper.expired())
extra_check.assert_called()
def test_remove_extra_reference(self):
tensor = torch.tensor([1], device="npu")
extra_check = MagicMock(return_value=False)
wrapper = StorageWeakRefWrapper(tensor, extra_ref_check=extra_check)
wrapper.remove_extra_reference()
self.assertIsNone(wrapper.extra_ref_check)
def test_repr_alive(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
r = repr(wrapper)
self.assertIn("alive", r)
self.assertIn(str(wrapper.data_ptr()), r)
def test_repr_dead(self):
tensor = torch.tensor([1], device="npu")
wrapper = StorageWeakRefWrapper(tensor)
del tensor
import gc
gc.collect()
r = repr(wrapper)
self.assertIn("dead", r)
class TestNPUWarmupNode(TestCase):
@patch("torch_npu.npu._graph_tree.StorageWeakRefWrapper")
@@ -364,7 +438,7 @@ class TestNPUGraphNode:
) as mock_construct:
outputs = basic_npu_graph_node.reconstruct_outputs()
assert len(outputs) == 1
def test_reconstruct_outputs_with_format(self, basic_npu_graph_node):
# Setup mock metadata and storage info
basic_npu_graph_node.outputs_metadata = [
@@ -694,15 +768,15 @@ class TestNPUGraphNodeRun(TestCase):
class TestGetNpugraphSegments(TestCase):
@patch('torch.npu.memory_snapshot')
def test_get_npugraph_segments(self, mock_snapshot):
@patch('torch.npu.memory_snapshot')
def test_get_npugraph_segments(self, mock_snapshot):
mock_snapshot.return_value = [
{"segment_pool_id": (0, 1), "address": 1000, "blocks": []},
{"segment_pool_id": (0, 0), "address": 2000, "blocks": []},
{"segment_pool_id": (0, 1), "address": 3000, "blocks": []},
]
result = get_npugraph_segments((0, 1))
self.assertEqual(len(result), 2)
]
result = get_npugraph_segments((0, 1))
self.assertEqual(len(result), 2)
mock_snapshot.assert_called_once_with()
@@ -919,15 +993,15 @@ class TestNPUGraphTreeManager:
manager.npu_graphs_thread_pool = "pool_handle"
manager.device_index = 0
manager.stream = MagicMock()
# 设置模拟返回值
mock_node_instance = MagicMock()
mock_node.return_value = mock_node_instance
mock_node_instance.run_first_inputs.return_value = [torch.tensor([1.0])]
# 执行测试
result = manager.record_function([torch.tensor([1.0])], FunctionID(1))
# 验证调用
mock_synchronize.assert_any_call()
mock_node.assert_called_once_with(
@@ -950,10 +1024,10 @@ class TestNPUGraphTreeManager:
manager = NPUGraphTreeManager(0)
mock_node = MagicMock()
mock_node.run.return_value = [torch.tensor([1.0])]
# 执行测试
result = manager.execute_node(mock_node, [torch.tensor([1.0])])
# 验证调用
mock_update_gen.assert_called_once_with()
assert manager.current_node == mock_node
@@ -970,15 +1044,15 @@ class TestNPUGraphTreeManager:
manager.graph = MagicMock()
manager.device_index = 0
manager.stream = MagicMock()
# 设置模拟返回值
mock_node_instance = MagicMock()
mock_warmup_node.return_value = mock_node_instance
mock_node_instance.run.return_value = [torch.tensor([1.0])]
# 执行测试
result = manager.run_eager([torch.tensor([1.0])], FunctionID(1))
# 验证调用
mock_update_gen.assert_called_once_with()
mock_warmup_node.assert_called_once_with(
@@ -1163,7 +1237,7 @@ class TestNPUGraphTreeManager:
):
manager = NPUGraphTreeManager(0)
mock_in_new_invocation.return_value = True
mock_node = MagicMock()
mock_node._path_from_root = [MagicMock()]
mock_node._path_from_root[0].wrapped_function.id = FunctionID(2)
@@ -1179,22 +1253,22 @@ class TestNPUGraphTreeManager:
):
manager = NPUGraphTreeManager(0)
mock_in_new_invocation.return_value = True
mock_node1 = MagicMock()
mock_node1.wrapped_function.id = FunctionID(1)
mock_node1.parent = MagicMock()
mock_node1.parent.wrapped_function.id = FunctionID(0)
mock_node2 = MagicMock()
mock_node2.wrapped_function.id = FunctionID(1)
mock_node2.parent = MagicMock()
mock_node2.parent.wrapped_function.id = FunctionID(0)
mock_current_node = MagicMock()
mock_current_node.wrapped_function.id = FunctionID(1)
mock_current_node.parent = MagicMock()
mock_current_node.parent.wrapped_function.id = FunctionID(0)
mock_current_node._path_from_root = [mock_node1, mock_node2]
manager.current_node = mock_current_node
manager.check_warn_on_unable_to_start_executing(FunctionID(1))

Some files were not shown because too many files have changed in this diff Show More