| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
skip ci failed testcase Co-authored-by: XianglongZeng<zengxianglong1@huawei.com> # message auto-generated for no-merge-commit merge: !36277 merge v2.12.0 into v2.12.0 skip ci failed testcase Created-by: probiotics_53 Commit-by: XianglongZeng Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 https://gitcode.com/Ascend/op-plugin/pull/4958合入受阻,下掉一批与此次修改无关的门禁失败用例: ## 1. _afd/test_attention_worker_schedule File "/workspace/CODE/pytorch_ut/test/_afd/test_attention_worker_schedule.py", line 4, in <module> import torchair ModuleNotFoundError: No module named 'torchair' [ERROR] ERR99999 UNKNOWN applicaiton exception ## 2. _afd/test_ffn_worker_schedule 同上:ModuleNotFoundError: No module named 'torchair' + ERR99999 UNKNOWN ## 3. custom_ops/test_npu_multi_head_attention File "/workspace/CODE/pytorch_ut/test/custom_ops/test_npu_multi_head_attention.py", line 98 self.assertRtolEqual(cpu_result, npu_result) AssertionError: result error 精度比较失败(NPU 和 CPU 计算结果差异超阈值)。 ## 4. distributed/pipelining/test_schedule(2 个 error) ERROR [0.288s]: test_grad_with_split_b_w schedule._load_actions(...) AttributeError: '_PipelineScheduleRuntime' object has no attribute '_load_actions' ERROR [0.058s]: test_grad_with_v_schedule torch.distributed.init_process_group(...) _PipelineScheduleRuntime API 缺失 _load_actions 方法,distributed 接口不兼容。 ## 5. nn/test_module_hooks File "/workspace/CODE/pytorch_ut/test/nn/test_module_hooks.py", line 1487 with self.assertRaisesRegex(RuntimeError, "Output 0 of BackwardHookFunctionBackward is " AssertionError: expected: "Output 0 of BackwardHookFunctionBackward is a view..." got: "Output 0 of BackwardHookFunction is a view..." PyTorch 报错信息中类名变更(BackwardHookFunctionBackward → BackwardHookFunction),正则匹配失败。 ## 6. test_multiprocessing_api File "/workspace/CODE/pytorch_ut/test/test_multiprocessing_api.py", line 215 self.assertTrue(torch.equal(npu_tensor.cpu(), reconstructed_npu.cpu())) AssertionError: False is not true 多进程 tensor 序列化/反序列化后数据不一致。 ## 7. test_ops _complex(3 个 error,同一根因) RuntimeError: _index_put_impl_:IndexPutKernelNpuOpApi.cpp:82 call aclnnIndexPutImpl failed, error code is 161002 AclNN_Parameter_Error(EZ1001): Tensor self not implemented for DT_COMPLEX64, should be in dtype support list [DT_FLOAT, DT_INT32, DT_INT64, ...] ACL 底层 aclnnIndexPutImpl 不支持 complex64/complex128 数据类型。 ## 总结 | # | 测试 | 根因 | 与 0d CPU tensor 修改关系 | |---|------|------|:--:| | 1 | attention_worker_schedule | 环境缺 torchair 包 | 无关 | | 2 | ffn_worker_schedule | 环境缺 torchair 包 | 无关 | | 3 | multi_head_attention | 精度差异 | 无关 | | 4 | test_schedule | distributed API _load_actions 缺失 | 无关 | | 5 | module_hooks | PyTorch 错误消息类名变更 | 无关 | | 6 | multiprocessing_api | 多进程 tensor 序列化不一致 | 无关 | | 7 | test_ops _complex | ACL 不支持 complex dtype | 无关 | https://gitcode.com/Ascend/op-plugin/pull/4958 涉及的 15 个 test_base_ops/ 测试全部 **success**。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36277 | 3 个月前 | |
feat: add aclnnReselectStaticKernelWithPath interface Co-authored-by: rich<zhouruiqi5@huawei.com> # message auto-generated for no-merge-commit merge: !40390 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 feat: add aclnnReselectStaticKernelWithPath interface Created-by: rich9527 Commit-by: rich Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/2634 https://gitcode.com/Ascend/pytorch/pull/40386 https://gitcode.com/Ascend/pytorch/pull/40493 - [x] 需求 - [x] 问题单 - [x] issue/工单 - [x] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1.新增内部接口_aclnn_reselect_static_kernel_with_path,用于支持静态编译按照路径选择不同生效目录。 2.新增UT测试用例并且修正测试文件存量lint错误:去除未使用的import,修改一个重复定义bug。 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 新增UT验证正确,npugraph_ex集成验证正确 cmd (zrq_310_29) root@xxx:xxx# python /xxx/torch_npu/test/_inductor/test_npu_static_kernel.py /xxx/lib/python3.10/site-packages/torch_npu/_inductor/__init__.py:97: UserWarning: triton-ascend is not installed, install it first. warnings.warn("triton-ascend is not installed, install it first.") .......... ---------------------------------------------------------------------- Ran 10 tests in 0.593s OK # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!40390 | 1 个月前 | |
[v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Co-authored-by: Dring<17737727613@163.com> # message auto-generated for no-merge-commit merge: !45000 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Created-by: Dring Commit-by: Dring Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/3991 - [✕ ] 需求 - [ ✓] 问题单 - [ ✓] issue/工单 - [ ✓] 重构优化 - [✕ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 问题现象: PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配 aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。 根因分析: 1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法 #include "third_party/acl/inc/acl/acl_mdl.h" 因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h 但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h" 编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h 同一个翻译单元最终形成: acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本 acl_base.h -> 环境 CANN 9.0.0 版本 这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。 2 问题不局限于 acl_mdl.h 同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括: acl/... aml/... profiling/... graph/... ge/... op_proto/... 因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。 修改目标: 修改后需要满足 源码不再包含 third_party/acl/inc/... 这种仓库物理路径。 ACL、AML、profiling 等头文件全部通过统一 include root 查找。 一个编译 target 对 CANN 头文件只选择一套版本。 CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。 使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。 wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约 修改方案: 1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找 2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [✓ ] 代码注释完备,正确记录错误日志 - [✕ ] 代码实现进行了返回值、空指针等校验 - [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45000 | 2 天前 | |
fix: lintrunner --all-files --take NEWLINE -a Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !35875 merge v2.12.0_lintrunner into v2.12.0 fix: lintrunner --all-files --take NEWLINE -a Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 执行: lintrunner --all-files --take NEWLINE -a 修复换行符,不影响代码逻辑。 2. 屏蔽两个分布式用例,已提issue,给对应接口人跟踪。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35875 | 3 个月前 | |
| 2 年前 | ||
Rewrite cuda to npu in backend string of init_process_group Co-authored-by: ylw1234<lwying007@126.com> # message auto-generated for no-merge-commit merge: !39244 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 Rewrite cuda to npu in backend string of init_process_group Created-by: ylw1234 Commit-by: ylw1234 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/2494 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 该修改将 backend 自动映射从仅支持通信后端替换(nccl→hccl),扩展为同时支持设备类型替换(cuda→npu) # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图   # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!39244 | 1 个月前 | |
[Feature]rename head file and add cmake for libtorch_npu | 2 年前 | |
[v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Co-authored-by: Dring<17737727613@163.com> # message auto-generated for no-merge-commit merge: !45000 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Created-by: Dring Commit-by: Dring Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/3991 - [✕ ] 需求 - [ ✓] 问题单 - [ ✓] issue/工单 - [ ✓] 重构优化 - [✕ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 问题现象: PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配 aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。 根因分析: 1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法 #include "third_party/acl/inc/acl/acl_mdl.h" 因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h 但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h" 编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h 同一个翻译单元最终形成: acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本 acl_base.h -> 环境 CANN 9.0.0 版本 这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。 2 问题不局限于 acl_mdl.h 同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括: acl/... aml/... profiling/... graph/... ge/... op_proto/... 因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。 修改目标: 修改后需要满足 源码不再包含 third_party/acl/inc/... 这种仓库物理路径。 ACL、AML、profiling 等头文件全部通过统一 include root 查找。 一个编译 target 对 CANN 头文件只选择一套版本。 CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。 使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。 wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约 修改方案: 1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找 2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [✓ ] 代码注释完备,正确记录错误日志 - [✕ ] 代码实现进行了返回值、空指针等校验 - [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45000 | 2 天前 | |
[sync] PR-37772: test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !38112 merge sync-pr37772-2.9ut1-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37772: test update ut Created-by: ascend-ds-bot Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37772 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[0da1cc1f](https://gitcode.com/Ascend/pytorch/commit/0da1cc1fa484fb54e1daa7752a6ec2f5803d242c)|2026-06-06 09:46:06 +0800 CST|update ut<br>| See merge request: Ascend/pytorch!38112 | 2 个月前 | |
[v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Co-authored-by: Dring<17737727613@163.com> # message auto-generated for no-merge-commit merge: !45000 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Created-by: Dring Commit-by: Dring Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/3991 - [✕ ] 需求 - [ ✓] 问题单 - [ ✓] issue/工单 - [ ✓] 重构优化 - [✕ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 问题现象: PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配 aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。 根因分析: 1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法 #include "third_party/acl/inc/acl/acl_mdl.h" 因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h 但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h" 编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h 同一个翻译单元最终形成: acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本 acl_base.h -> 环境 CANN 9.0.0 版本 这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。 2 问题不局限于 acl_mdl.h 同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括: acl/... aml/... profiling/... graph/... ge/... op_proto/... 因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。 修改目标: 修改后需要满足 源码不再包含 third_party/acl/inc/... 这种仓库物理路径。 ACL、AML、profiling 等头文件全部通过统一 include root 查找。 一个编译 target 对 CANN 头文件只选择一套版本。 CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。 使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。 wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约 修改方案: 1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找 2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [✓ ] 代码注释完备,正确记录错误日志 - [✕ ] 代码实现进行了返回值、空指针等校验 - [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45000 | 2 天前 | |
fix: add PyObject_ClearWeakRefs in NPU Stream/Event tp_dealloc Co-authored-by: xiu_21<caixiuxiu1@huawei.com> # message auto-generated for no-merge-commit merge: !41909 merge cherry-pick-mr-41678-1784250811924-auto into v2.12.0-26.1.0 fix: add PyObject_ClearWeakRefs in NPU Stream/Event tp_dealloc Created-by: xiu_21 Commit-by: xiu_21 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 PyTorch 基础类 THPStream / THPEvent 中增加了 weakref 支持(添加了 weakreflist 字段),但 NPU 后端的 tp_dealloc 覆盖函数未同步更新。 CPython 对静态 PyType 不会自动链式调用父类 tp_dealloc,因此 THNPEvent_dealloc 和 THNPStream_dealloc 一直缺少: 1. PyObject_ClearWeakRefs() — 未清理 weakref,导致 wr_object 悬空指向已释放内存 2. Py_CLEAR(self->context)(仅 Stream)— lazy stream context 泄漏 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 pytest test/dynamo/test_stream.py -k test_npu_stream_event_weakref_callback 修改前:  修改后:  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!41909 | 1 个月前 | |
| 2 年前 | ||
[sync] PR-39006: [test]skip_test_jacfwd Co-authored-by: SCh-zx<1325467101@qq.com> # message auto-generated for no-merge-commit merge: !39336 merge sync-pr39006-v2.12.0-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-39006: [test]skip_test_jacfwd Created-by: ascend-ds-bot Commit-by: SCh-zx Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/39006 ### 2. Original pull request related issue(s): https://gitcode.com/Ascend/pytorch/issues/2451 ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[2f4fc241](https://gitcode.com/Ascend/pytorch/commit/2f4fc2412334f12a61dcab6e2b207afea3f607f6)|2026-06-23 09:32:05 +0800 CST|skip_test_jacfwd<br>| See merge request: Ascend/pytorch!39336 | 1 个月前 | |
[test] add fx graph api coverage for find_nodes and graph_copy Co-authored-by: anning-2026<870721918@qq.com> # message auto-generated for no-merge-commit merge: !36539 merge fx-graph-apis-v2.12.0 into v2.12.0 [test] add fx graph api coverage for find_nodes and graph_copy Created-by: anning-2026 Commit-by: anning-2026 Merged-by: ascend-robot Description: # 【合入来源】 > 如有社区issue,请关联issue链接 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 公开issue:https://gitcode.com/Ascend/pytorch/issues/1633 本次提交对应 Torch-NPU API 补齐任务,涉及以下 5 个 API: - torch.fx.Graph.find_nodes - torch.fx.Graph.graph_copy - torch.fx.Graph.eliminate_dead_code - torch.fx.Graph.erase_node - torch.fx.Graph.get_attr # 【API 功能介绍】 - torch.fx.Graph.find_nodes:根据 op 类型和 target 快速查询图中节点,支持 sort 参数控制返回顺序。属于图结构查询操作。 - torch.fx.Graph.graph_copy:将源图的所有节点复制到目标图中,通过 val_map 映射已有节点,支持节点复用。属于图结构复制操作。 - torch.fx.Graph.eliminate_dead_code:删除图中无用户的死节点,保留有副作用的节点。属于图结构优化操作。 - torch.fx.Graph.erase_node:从图中删除指定节点。属于图结构操作。 - torch.fx.Graph.get_attr:在图中创建一个 get_attr 节点,用于获取模块属性。属于图节点创建操作。 # 【社区用例分析】 ## 1.3 类 API(上游无专门用例,自行编写并提交 PR) torch.fx.Graph.find_nodes 上游无专门测试。虽然在 test/fx/test_fx_node_hook.py 和 test/export/test_export.py 中有间接使用,但都是作为辅助手段调用,没有针对 find_nodes 本身的参数(op、target、sort)和返回值进行验证。因此需要新增用例。 torch.fx.Graph.graph_copy 上游无专门测试。虽然在 test/test_fx.py 中有间接使用,但没有针对 graph_copy 的 val_map 填充、节点复制正确性、已有节点复用等核心行为进行独立验证。因此需要新增用例。 torch.fx.Graph.erase_node 上游在 test/fx/test_fx_node_hook.py 的 test_hooks_for_node_update 中有间接调用,但该测试核心目的是验证 Node Hook 机制,erase_node 仅作为清理手段,未对节点删除后的图结构完整性和计算正确性进行独立验证。因此需要新增用例。 torch.fx.Graph.get_attr 上游在 test/test_fx.py 的多个测试函数中有间接使用 get_attr 节点,但都是在验证其他功能时作为图的组成部分出现,没有针对 get_attr 节点的创建、多属性获取等核心行为进行独立验证。因此需要新增用例。 ## 1.2 类 API(NPU 无需任何修改) torch.fx.Graph.eliminate_dead_code 上游用例文件:test/fx/test_dce_pass.py,共 7 个测试函数(test_simple、test_dead_chain、test_dead_getattr、test_dead_placeholder、test_dead_placeholder_with_user、test_keep_module_with_side_effects、test_keep_torch_assert)。 源文件已自带 import torch_npu 和 import torch_npu.testing,无需 patch,直接运行全部通过。该 API 为纯图结构操作,NPU 无需任何修改。 # 【修改方案】 其中 eliminate_dead_code 源文件已自带 NPU 支持,无需修改。 对 find_nodes、graph_copy、erase_node、get_attr 各补充 1 个测试用例到 test/fx/test_fx_graph_api.py,在功能验证充分的前提下尽量简化,每个 API 聚焦一个用例覆盖核心功能: 1. torch.fx.Graph.find_nodes:在一个包含 call_function、call_module、get_attr 的图中验证 op/target 查询、sort 参数和空结果场景 2. torch.fx.Graph.graph_copy:验证基本复制与 val_map 填充、val_map 复用已有节点、return_output_node 参数 3. torch.fx.Graph.erase_node:删除中间节点并重接依赖,验证图结构和 NPU 计算正确性 4. torch.fx.Graph.get_attr:通过 symbolic_trace 产生多属性 get_attr 节点,验证节点正确性和 NPU 计算结果 # 【资料变更】 不涉及。本 PR 仅补测试,不包含资料修改。 # 【接口变更】 不涉及。未修改跨仓接口,也未修改用户可见接口行为。 # 【功能验证】 测试场景1:torch.fx.Graph.find_nodes、graph_copy、erase_node、get_attr 的核心行为验证。 python test/fx/test_fx_graph_api.py 测试日志: test_erase_node ... ok test_find_nodes ... ok test_get_attr ... ok test_graph_copy ... ok test_graph_inserting_after ... ok test_graph_inserting_before ... ok test_inplace_methods_format_codegen ... ok test_magic_methods_format_codegen ... ok ---------------------------------------------------------------------- Ran 8 tests in 12.657s OK 测试场景2:torch.fx.Graph.eliminate_dead_code 上游用例验证(1.2 类,源文件已自带 NPU 支持)。 python test/fx/test_dce_pass.py 测试日志:exit code 0,7/7 tests passed。 [#1633](https://gitcode.com/Ascend/pytorch/issues/1633) See merge request: Ascend/pytorch!36539 | 2 个月前 | |
Adapt test_jit_is_trancing in trace for NPU Co-authored-by: qq_42437014<yandj5@163.com> # message auto-generated for no-merge-commit merge: !37096 merge test-jit-is_tracing-in-trace212 into v2.12.0 Adapt test_jit_is_trancing in trace for NPU Created-by: qq_42437014 Commit-by: qq_42437014 Merged-by: ascend-robot Description: # 【合入来源】 [[Usage]: torch.jit.is_tracing () ----此API,在trace模式下,测试样例缺失](https://gitcode.com/Ascend/pytorch/issues/1706) > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] issue/工单 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) ## API 功能 torch.jit.istracing 是 TorchScript 核心执行模式判断 API,用于在静态图编译与执行阶段检测当前代码是否处于 tracing 编译上下文,支持在 tracing / scripting 混合编码场景下实现条件分支、执行路径切换、图编译行为适配,保障不同执行模式下代码逻辑的正确性,是 TorchScript 动态适配、图优化、模式感知的基础能力。 ## 测试用例说明 1. scrpit模式下,API torch.jit.is_tracing () PyTorch 官方 test_jit.py(官方路径: pytorch/test/test_jit.py;行号位置:两个测试用例的位置大概在9783-9798行)包含test_script_is_tracing、test_script_get_tracing_state 两个测试用例。 **测试用例详解** • test_script_get_tracing_state:调用底层私有接口判定追踪状态,依托NPU张量运算分支结果,校验底层接口识别追踪模式的有效性。 • test_script_is_tracing:使用官方标准接口判断追踪状态,结合NPU张量执行脚本编译校验,验证公开接口在图追踪场景下判定逻辑正常。 2. trace模式下,API torch.jit.is_tracing () 添加新测试用例test/test_jit_is_tracing_in_trace.py • 基础环境适配:引入torch_npu库启用NPU设备能力,构造NPU张量作为测试输入数据 • 核心功能验证:校验进入JIT轨迹录制流程时,接口可正确返回真值 **测试用例详解** • test_is_tracing_returns_true_in_trace_mode:基于接口返回结果编写分支判断逻辑,使用NPU张量执行轨迹录制。通过最终运算输出结果,确认程序成功走入轨迹模式分支,验证接口状态判定逻辑有效。 **测试用例构造说明** 由于 PyTorch 的 torch.jit.trace 机制限制,在被追踪函数内部执行时,底层的 Python 级追踪标志位(tracing flag)依然保持为 False,因此无法直接在函数内部进行断言验证。本测试转而采用严格的“行为验证”方案:利用 Tracer “仅记录单条执行路径”的特性,通过校验最终的输出结果,反向证明 is_tracing() 成功触发了目标分支,且该计算路径已被正确固化到 TorchScript 图中。 ## NPU 适配说明 1. scrpit模式下,API torch.jit.is_tracing ()适配说明 torch.jit.istracing 为 TorchScript 前端执行模式检测 API,无硬件相关底层算子依赖,NPU 完全兼容 PyTorch 原生实现,功能行为、状态语义、编译逻辑与 CPU 保持一致。此测试样例无需修改,可直接测试验证。 • 基础环境适配:将仓库test_upstream/test/test_jit.py.patch,进行apply之后,已有import torch_npu基础环境的适配; • 张量设备调整:将仓库test_upstream/test/test_jit.py.patch,进行apply之后,代码已将cpu的张量修改为npu上运行。确保异步计算的结果载体(张量)运行在 NPU 上,贴合 NPU 场景使用需求。 2. trace模式下,API torch.jit.is_tracing ()适配说明 新增测试用例:test/test_jit_is_tracing_in_trace.py,补齐NPU设备场景下接口相关测试覆盖。 • 基础环境适配:引入torch_npu库启用NPU设备能力,构造NPU张量作为测试输入数据。 # 【资料变更】 **需要添加2.9.0~2.12.0的API说明** 在 https://gitcode.com/Ascend/pytorch/tree/v2.7.1/docs/zh/native_apis 的文档中进行查找与验证。该目录下的pytorch_2-7-1文件夹下的torch-jit.md有API的说明,"torch.jit.is_tracing"全部标注"是 支持fp32"。 pytorch_2-9-0~pytorch_2-12-0没有对此API的说明,故对pytorch_2-9-0、pytorch_2-10-0、pytorch_2-11-0、pytorch_2-12-0文件夹下的torch-jit.md添加了API的说明,"torch.jit.is_tracing"全部标注"是 支持fp32"。 # 【接口变更】 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 **测试命令:** #script模式下,测试命令 cd pytorch/test python -m unittest test_jit.TestScript.test_script_is_tracing test_jit.TestScript.test_script_get_tracing_state -v #trace模式下,测试命令 cd pytorch/test python test_jit_is_tracing_in_trace.py -v **测试结果:** 1. script模式下,测试结果 `` root@5534245c24de:/workspace/user_data/527/212/pytorch/test_upstream#python -m unittest test_jit.TestScript.test_script_is_tracing test_jit.TestScript.test_script_get_tracing_state -v /usr/local/python3.11.14/lib/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:362: ImportWarning: ************************************************************************************************************* The torch.Tensor.cuda and torch.nn.Module.cuda are replaced with torch.Tensor.npu and torch.nn.Module.npu now.. The torch.cuda.DoubleTensor is replaced with torch.npu.FloatTensor cause the double type is not supported now.. The backend in torch.distributed.init_process_group set to hccl now.. The torch.cuda.* and torch.cuda.amp.* are replaced with torch.npu.* and torch.npu.amp.* now.. The device parameters have been replaced with npu in the function below: torch.logspace, torch.randint, torch.hann_window, torch.rand, torch.full_like, torch.ones_like, torch.rand_like, torch.randperm, torch.arange, torch.frombuffer, torch.normal, torch._empty_per_channel_affine_quantized, torch.empty_strided, torch.empty_like, torch.scalar_tensor, torch.tril_indices, torch.bartlett_window, torch.ones, torch.sparse_coo_tensor, torch.randn, torch.kaiser_window, torch.tensor, torch.triu_indices, torch.as_tensor, torch.zeros, torch.randint_like, torch.full, torch.eye, torch._sparse_csr_tensor_unsafe, torch.empty, torch._sparse_coo_tensor_unsafe, torch.blackman_window, torch.zeros_like, torch.range, torch.sparse_csr_tensor, torch.randn_like, torch.from_file, torch._cudnn_init_dropout_state, torch._empty_affine_quantized, torch.linspace, torch.hamming_window, torch.empty_quantized, torch._pin_memory, torch.load, torch.set_default_device, torch.get_device_module, torch.sparse_compressed_tensor, torch.Tensor.new_empty, torch.Tensor.new_empty_strided, torch.Tensor.new_full, torch.Tensor.new_ones, torch.Tensor.new_tensor, torch.Tensor.new_zeros, torch.Tensor.to, torch.Tensor.pin_memory, torch.nn.Module.to, torch.nn.Module.to_empty ************************************************************************************************************* warnings.warn(msg, ImportWarning) /usr/local/python3.11.14/lib/python3.11/site-packages/torch_npu/contrib/transfer_to_npu.py:291: RuntimeWarning: torch.jit.script and torch.jit.script_method will be disabled by transfer_to_npu, which currently does not support them, if you need to enable them, please do not use transfer_to_npu. warnings.warn(msg, RuntimeWarning) /usr/local/python3.11.14/lib/python3.11/site-packages/torch/jit/_script.py:362: DeprecationWarning: torch.jit.script_method is deprecated. Please switch to torch.compile or torch.export. warnings.warn( monkeytype is not installed. Skipping tests for Profile-Directed Typing test_script_is_tracing (test_jit.TestScript.test_script_is_tracing) ... /usr/local/python3.11.14/lib/python3.11/site-packages/torch/jit/_script.py:1480: DeprecationWarning: torch.jit.script is deprecated. Please switch to torch.compile or torch.export. warnings.warn( /usr/local/python3.11.14/lib/python3.11/site-packages/torch/jit/_serialization.py:89: DeprecationWarning: torch.jit.save is deprecated. Please switch to torch.export. warnings.warn( /usr/local/python3.11.14/lib/python3.11/site-packages/torch/jit/_serialization.py:176: DeprecationWarning: torch.jit.load is deprecated. Please switch to torch.export. warnings.warn( ok test_script_get_tracing_state (test_jit.TestScript.test_script_get_tracing_state) ... ok ---------------------------------------------------------------------- Ran 2 tests in 0.160s 2. trace模式下,测试结果 root@5534245c24de:/workspace/user_data/527/212/pytorch/test/jit# python test_jit_is_tracing_in_trace.py -v test_is_tracing_returns_true_in_trace_mode (__main__.TestJitIsTracing.test_is_tracing_returns_true_in_trace_mode) Validates that torch.jit.is_tracing() returns True during trace recording. ... /usr/local/python3.11.14/lib/python3.11/site-packages/torch/jit/_trace.py:1000: DeprecationWarning: torch.jit.trace is deprecated. Please switch to torch.compile or torch.export. warnings.warn( ok ---------------------------------------------------------------------- Ran 1 test in 1.373s OK `` **验证结论:** NPU 环境运行script/trace模式下的测试用例,三个用例执行成功,无功能失败项。torch.jit.is_tracing 模式检测、状态返回、控制流分支适配等能力均符合 PyTorch 标准语义,适配完成且验证通过 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37096 | 2 个月前 | |
[sync] PR-37317: delete-skip Co-authored-by: l00881990<lixinyu68@huawei.com> # message auto-generated for no-merge-commit merge: !38615 merge sync-pr37317-delete-skip-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37317: delete-skip Created-by: ascend-ds-bot Commit-by: l00881990 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37317 ### 2. Original pull request related issue(s): https://gitcode.com/Ascend/pytorch/issues/2177 ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[7bcf1299](https://gitcode.com/Ascend/pytorch/commit/7bcf12998a95e594482810ce4b8d93a20fb64782)|2026-06-01 15:41:27 +0800 CST|delete-skip<br>| See merge request: Ascend/pytorch!38615 | 2 个月前 | |
[fix]multi_stream_lazy_reclaim coredump error Co-authored-by: xuyun15<xuyun15@huawei.com> # message auto-generated for no-merge-commit merge: !42424 merge fix_multi_stream_lazy_reclaim_v26.1.0_v2.12.0 into v2.12.0-26.1.0 [fix]multi_stream_lazy_reclaim coredump error Created-by: xuyun15 Commit-by: xuyun15 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 选取issue中方案2作为解决方案 ### 方案2:将 sum > kLazyQuerySize 的 process_events 移到 get_free_block 之前(推荐) 将 sum > kLazyQuerySize 触发的 process_events() 移到 get_free_block 之前,保持与原生 PyTorch 相同的安全时序。同时引入 reaped 变量避免 process_events() 的冗余二次调用。 #### 2.1 process_events() 二次调用问题分析 方案2将 process_events() 的调用拆分为两段: 1. **第一段**:sum > kLazyQuerySize 时在 get_free_block 之前调用 2. **第二段**:!block_found 时在 get_free_block 之后调用 当 sum > kLazyQuerySize 且 get_free_block() 仍然失败时,两段都会触发 process_events(),导致**同一轮 malloc() 中 process_events() 被调用两次**。 # 【资料变更】 不涉及:当前pr不涉及,但是后续会持续跟踪搜集用户诉求,逐步补齐对应的资料和用例 # 【接口变更】 不涉及 # 【功能验证】 修复前:  修复后:  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!42424 | 1 个月前 | |
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
[sync] PR-37619: [v2.12.0] cherry-pick v2.7.1_fix_ut: remove unskip Co-authored-by: ffmh<fengminghao2@huawei.com> # message auto-generated for no-merge-commit merge: !38154 merge sync-pr37619-v2.12.0_fix_ut-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37619: [v2.12.0] cherry-pick v2.7.1_fix_ut: remove unskip Created-by: ascend-ds-bot Commit-by: ffmh Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37619 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[fee1ab78](https://gitcode.com/Ascend/pytorch/commit/fee1ab78f26447efb8389f666a034f02897cb9f7)|2026-06-05 15:10:05 +0800 CST|fix lint: remove trailing whitespace<br>| |[ea67ea2b](https://gitcode.com/Ascend/pytorch/commit/ea67ea2b734c7ba7f46303a94fb03520a07db6ed)|2026-06-04 17:06:56 +0800 CST|remove unskip<br>| See merge request: Ascend/pytorch!38154 | 2 个月前 | |
[fix]profiler fix config cache when analyse multi card Co-authored-by: hehongzhe<935062458@qq.com> # message auto-generated for no-merge-commit merge: !40002 merge jiexi12121 into v2.12.0-26.1.0 [fix]profiler fix config cache when analyse multi card 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/工单 https://gitcode.com/Ascend/pytorch/issues/2573 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) profiler离线解析设置的max_process_number的值小于总ascend_pt数量时,解析出来db文件的rank与profiler_info.json的rank不一致 这是因为离线解析会复用进程池里的进程,is_load标记位在设置为True后没有修改,被复用,config无法被更新 所以在获取rankid前需要重置is_load标记位 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 修改前,db文件名中的rankid错误  修改后rankid正确  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!40002 | 1 个月前 | |
AI assist developer for python dt master Co-authored-by: aksksks<mengzichao@h-partners.com> # message auto-generated for no-merge-commit merge: !26538 merge master into master AI assist developer for python dt master Created-by: aksksks Commit-by: aksksks 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!26538 | 9 个月前 | |
[sync] PR-37772: test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !38112 merge sync-pr37772-2.9ut1-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37772: test update ut Created-by: ascend-ds-bot Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37772 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[0da1cc1f](https://gitcode.com/Ascend/pytorch/commit/0da1cc1fa484fb54e1daa7752a6ec2f5803d242c)|2026-06-06 09:46:06 +0800 CST|update ut<br>| See merge request: Ascend/pytorch!38112 | 2 个月前 | |
[sync] PR-37772: test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !38112 merge sync-pr37772-2.9ut1-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37772: test update ut Created-by: ascend-ds-bot Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37772 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[0da1cc1f](https://gitcode.com/Ascend/pytorch/commit/0da1cc1fa484fb54e1daa7752a6ec2f5803d242c)|2026-06-06 09:46:06 +0800 CST|update ut<br>| See merge request: Ascend/pytorch!38112 | 2 个月前 | |
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
[docs]v2.12.0-26.1.0文档产品名称更新 Co-authored-by: chenrayray<chenxinrui11@huawei.com> Co-authored-by: zxchen152<1135990991@qq.com> # message auto-generated for no-merge-commit merge: !40045 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [docs]v2.12.0-26.1.0文档产品名称更新 Created-by: zxchen152 Commit-by: zxchen152;chenrayray Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ [#2602](https://gitcode.com/Ascend/pytorch/issues/2602) > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 [#2602](https://gitcode.com/Ascend/pytorch/issues/2602) - [ ] 重构优化 - [x] 资料更新 # 【修改方案】 更新代码仓文档中产品名称,使用 (?<![A-Za-z/])PTA(?![A-Za-z_])|(Ascend extension for pytorch)|((?<!import )(?<![A-Za-z_/.])(?<!(ninja ))torch_npu(?![A-Za-z_/.:])(?![-\\])(?!(进程|初始化)))|((?<!import )(?<![A-Za-z_/.])torch-npu(?![A-Za-z_/.:])(?![-\\]))匹配除doc目录外所有.md文档下的名称,并按需替换为TorchNPU # 【资料变更】 更新代码仓文档中产品名称,同时对文档的格式问题进行修复,不变更文档原有的代码。 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!40045 | 28 天前 | |
| 1 年前 | ||
| 1 年前 | ||
TORCH MAIN SYNC: switch to release candidate of torch 2.12 update Co-authored-by: chansinging<chenxingying2@huawei.com> Co-authored-by: Chansinging<1183520536@qq.com> # message auto-generated for no-merge-commit merge: !35103 merge main_sync_0509 into master TORCH MAIN SYNC: switch to release candidate of torch 2.12 update Created-by: chansinging Commit-by: Chansinging;chansinging Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 同步社区演进,例行更新 lintrunner规避,见[issue](https://gitcode.com/Ascend/pytorch/issues/1865) # 【修改方案】 出包参考社区改动,https://github.com/pytorch/pytorch/pull/177570/ # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 本地A3服务器和ci流水线已跑通测试  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35103 | 3 个月前 | |
| 1 年前 | ||
fix: lintrunner --all-files --take NEWLINE -a Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !35875 merge v2.12.0_lintrunner into v2.12.0 fix: lintrunner --all-files --take NEWLINE -a Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 执行: lintrunner --all-files --take NEWLINE -a 修复换行符,不影响代码逻辑。 2. 屏蔽两个分布式用例,已提issue,给对应接口人跟踪。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35875 | 3 个月前 | |
| 2 年前 | ||
Release 2.11.0rc1 Co-authored-by: Chansinging<1183520536@qq.com> # message auto-generated for no-merge-commit merge: !35503 merge v2.12.0rc1 into v2.12.0 Release 2.11.0rc1 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/工单 [版本升级](https://gitcode.com/Ascend/pytorch/issues/1941) - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 社区演进和版本升级 # 【资料变更】 修改内容参考[2.11rc合入](https://gitcode.com/Ascend/pytorch/pull/32267),做2.12版本升级 # 【接口变更】 不涉及 # 【功能验证】   # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35503 | 3 个月前 | |
| 2 年前 | ||
| 1 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
add test case for event elapsed_time Co-authored-by: chenkun<chenkun82@huawei.com> # message auto-generated for no-merge-commit merge: !26731 merge master_event_ut into master add test case for event elapsed_time Created-by: kuhn7 Commit-by: chenkun 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!26731 | 8 个月前 | |
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
| 1 年前 | ||
| 1 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33714 merge master into master add_test 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为以下API增加用例功能 Tensor.copy_ Tensor.narrow torch.cat torch.chunk torch._chunk_cat # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 新增文件 test_cat.py test_chunk.py test_chunk_cat.py test_copy_.py test_narrow.py # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33714 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33714 merge master into master add_test 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为以下API增加用例功能 Tensor.copy_ Tensor.narrow torch.cat torch.chunk torch._chunk_cat # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 新增文件 test_cat.py test_chunk.py test_chunk_cat.py test_copy_.py test_narrow.py # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33714 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33714 merge master into master add_test 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为以下API增加用例功能 Tensor.copy_ Tensor.narrow torch.cat torch.chunk torch._chunk_cat # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 新增文件 test_cat.py test_chunk.py test_chunk_cat.py test_copy_.py test_narrow.py # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33714 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33714 merge master into master add_test 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为以下API增加用例功能 Tensor.copy_ Tensor.narrow torch.cat torch.chunk torch._chunk_cat # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 新增文件 test_cat.py test_chunk.py test_chunk_cat.py test_copy_.py test_narrow.py # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33714 | 4 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
[sync] PR-37772: test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !38112 merge sync-pr37772-2.9ut1-to-v2.12.0-26.1.0 into v2.12.0-26.1.0 [sync] PR-37772: test update ut Created-by: ascend-ds-bot Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37772 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[0da1cc1f](https://gitcode.com/Ascend/pytorch/commit/0da1cc1fa484fb54e1daa7752a6ec2f5803d242c)|2026-06-06 09:46:06 +0800 CST|update ut<br>| See merge request: Ascend/pytorch!38112 | 2 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
test(fx): add CustomBuiltin test cases for v2.12.0 Co-authored-by: jingkai-2026<jingkai@isrc.iscas.ac.cn> # message auto-generated for no-merge-commit merge: !35578 merge custom-test-v2.12.0 into v2.12.0 test(fx): add CustomBuiltin test cases for v2.12.0 Created-by: jingkai-2026 Commit-by: jingkai-2026 Merged-by: ascend-robot Description: https://gitcode.com/Ascend/pytorch/issues/1630 ## 上游社区(PyTorch 官方)测试覆盖情况分析 ### torch.fx.Graph / torch.fx.Graph.__init__ - **社区测试文件**: test/test_fx.py(PyTorch 官方仓库) - **测试覆盖情况**:✅ 充分覆盖 - **证据**:共有 18 个 Graph 相关测试函数 - **结论**:上游社区测试已全面覆盖,torch-npu 无需额外适配 - **验证**: 统计 test_fx.py 中 Graph 相关的测试函数数量 grep -c "def test.*[Gg]raph" /workspace/pytorch/test/test_fx.py 查看具体是哪些测试函数 grep "def test.*[Gg]raph" /workspace/pytorch/test/test_fx.py | head -20 统计 GraphModule 相关的测试 grep -c "def test.*GraphModule" /workspace/pytorch/test/test_fx.py 统计 Graph 类被使用的次数(证明被广泛测试) grep -c "torch.fx.Graph" /workspace/pytorch/test/test_fx.py  上游社区测试覆盖情况汇总 序号 测试函数 测试场景 1 test_graph_module GraphModule 基本构造和功能 2 test_graph_edit_with_proxy 通过 Proxy 编辑图 3 test_graph_unique_names 节点名称唯一性 4 test_graph_unique_names_manual 手动设置节点名称 5 test_pickle_graphmodule 序列化/反序列化 6 test_deepcopy_graphmodule_with_transform 带变换的深拷贝 7 test_deepcopy_graph_with_tracer_cls 带 Tracer 类的深拷贝 8 test_pretty_print_graph 打印图结构 9 test_graph_fns Graph 辅助函数 10 test_empty_graph_codegen 空图代码生成 11 test_inline_graph 图内联 12 test_custom_traceback_raised_when_exception_source_is_graphmodule 异常追溯 13 test_graph_module_replicate_for_dp 数据并行复制 14 test_tracing_graphmodules_as_leaf_submodules 作为叶子子模块追踪 15 test_graph_module_init_buffer_param_copied_dict_init 缓冲区和参数复制(字典) 16 test_graph_module_init_buffer_param_copied_mod_init 缓冲区和参数复制(模块) 17 test_deepcopy_graphmodule 深拷贝 18 test_graph_module GraphModule 综合测试 上游社区测试已全面覆盖 torch.fx.Graph 的核心功能 __init__ 通过 30 次 torch.fx.Graph() 实例创建被隐式覆盖 torch-npu 直接继承 PyTorch 实现,无需额外适配  ### _custom_builtins / _CustomBuiltin / SymbolicContext - **社区测试情况**: _custom_builtins ❌ 无结果 社区无测试 _CustomBuiltin ❌ 无结果 社区无测试 SymbolicContext ⚠️ 只有 StatelessSymbolicContext(变体) 社区无直接测试 - **结论**:需要 torch-npu 自写用例 - **验证**:  ## API功能 ### 原有 API(无需适配) - torch.fx.Graph:PyTorch FX图模式的核心数据结构,用于构建和表示计算图 - torch.fx.Graph.__init__:Graph类的构造函数,初始化空的图结构 ### 本次新增测试的 API - **torch.fx.graph._custom_builtins.items()**:返回PyTorch FX图模块中内置函数的字典视图。这些内置函数在图追踪时被识别为特殊操作,不会被递归展开。返回值为 dict_items 类型,包含7个预注册的内置函数,每个键为函数名(str),值为 _CustomBuiltin 实例。 - **torch.fx.graph._CustomBuiltin**:表示FX图中的一个内置函数占位符。它是一个类,实例化后代表一个被注册为内置操作的函数对象,在图追踪过程中作为原子操作处理。模块归属为 torch.fx.graph。 - **torch.fx.experimental.symbolic_shapes.SymbolicContext**:符号形状推导的上下文类。可无参实例化,配合 StatelessSymbolicContext 等变体在导出或追踪过程中传递和管理符号形状信息。模块归属为 torch.fx.experimental.symbolic_shapes。 ## 用例完备性说明 PyTorch社区在test_fx.py、test_export.py等文件中已有丰富的Graph/GraphModule测试用例,覆盖图的创建、节点操作、符号追踪等核心功能。这些用例均为框架层逻辑测试,不涉及TEST_CUDA/TEST_PRIVATEUSE1等硬件强相关分支。 **社区无针对以下3个API的直接测试用例:** - _custom_builtins / _CustomBuiltin:社区用例未覆盖 - SymbolicContext:社区用例使用的是 StatelessSymbolicContext 等变体,未直接测试 SymbolicContext 本身 **本次自写用例(test_fx_custom_builtins.py)覆盖5个测试方法:** | 测试方法 | 验证内容 | |---------|---------| | test_custom_builtins_items | 验证 _custom_builtins.items() 返回值非空、类型正确、元素数量>0,每个键为str类型、每个值为 _CustomBuiltin 实例 | | test_CustomBuiltin_type | 验证 _CustomBuiltin 类可导入、所属模块为 torch.fx.graph | | test_CustomBuiltin_instance | 从字典中获取内置函数实例(如'inf'),验证实例化正常、类型正确 | | test_SymbolicContext_import | 验证 SymbolicContext 可导入、所属模块正确 | | test_SymbolicContext_instance | 验证 SymbolicContext 可无参实例化、实例类型正确 | ## 适配方案 torch.fx为框架层图模式API,与底层设备算子完全解耦。在NPU环境下导入torch_npu后直接可用,无需任何代码修改。新增测试用例同样无需适配,可直接在NPU环境运行。 ## 运行结果 在NPU环境下测试通过: - torch.fx.Graph() 创建成功 - torch.fx.Graph.__init__() 正常工作 - **新增5个测试用例全部通过**  ## 文档检查 已检查 docs/api/torch_npu_apis.md: - torch.fx.Graph 和 torch.fx.Graph.__init__ 已在文档中登记 ✅ - _custom_builtins、_CustomBuiltin、SymbolicContext 为 PyTorch FX 内部/实验性 API,不在 torch-npu 公开文档范围内 因此本次 **不需要** 额外提交文档 PR。 ## 多版本兼容性 torch.fx核心架构自PyTorch 1.8引入后保持稳定,推断在2.7.1 ~ 2.12.0及master分支行为一致,均无需适配。 See merge request: Ascend/pytorch!35578 | 2 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
test(hub): add test cases for torch.hub.help and torch.hub._get_torch_home APIs Co-authored-by: xiemingda1002<xiemingda1002@163.com> # message auto-generated for no-merge-commit merge: !34071 merge add-test-hub-help-api-master into master test(hub): add test cases for torch.hub.help and torch.hub._get_torch_home APIs Created-by: xiemingda1002 Commit-by: xiemingda1002 Merged-by: ascend-robot Description: # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1703**</font>\ - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 一、API 功能说明 torch.hub.help 和 torch.hub._get_torch_home 是 PyTorch hub 模块中用于文档查询和路径管理的辅助 API,功能说明如下: 1. torch.hub.help(github, model, force_reload=False, skip_validation=False, trust_repo=None) - 文档获取核心能力:接收 GitHub 仓库地址和入口点名称,返回该入口点的文档字符串(docstring),无需实际加载模型或执行代码。 - 远程仓库解析核心能力:支持 "owner/repo[:branch]" 格式的仓库地址,自动解析并获取 hubconf.py 中定义的入口点函数的文档。 - 安全机制支持:通过 skip_validation 参数可跳过 GitHub API 验证(避免 rate limit),trust_repo 参数控制仓库信任策略(False/True/check/None)。 - 无状态调用:多次调用 help 不会产生副作用,不修改缓存状态,不影响后续 load 等操作,不下载仓库代码。 - 返回值灵活性:返回字符串类型文档或 None(若入口点函数未定义 docstring),支持用户预览模型使用说明。 - 典型用途:在加载模型前查看入口点的参数说明、使用示例、依赖信息等。 2. torch.hub._get_torch_home() - 路径解析核心能力:根据环境变量 TORCH_HOME 或默认路径 ~/.cache/torch 确定 torch home 目录。 - 环境变量优先级机制:优先读取 TORCH_HOME 环境变量,若未设置则依次检查 XDG_CACHE_HOME/torch、~/.cache/torch。 - 内部 API 特性:作为 get_dir() 的底层实现,不直接暴露给用户,但可通过 hub 模块访问(用于测试或调试)。 - 路径标准化处理:返回的路径经过 os.path.expanduser 处理,支持 ~ 符号展开,确保路径可用性。 - 返回值:字符串类型路径,非空且为绝对路径。 上述 API 均为纯 Python 层实现,不涉及张量计算,仅负责文档查询和路径解析。 二、测试文件 test/test_hub_api.py 完整验证该 API 的原因 本测试文件针对 PyTorch 社区原生 test/test_hub.py 覆盖不足的 torch.hub.help / _get_torch_home API 进行补充验证,确保昇腾 NPU 环境下功能完整可用: 1. torch.hub.help API 验证 - test_help_function_callable:验证 help 函数存在于 hub 模块且可调用(hasattr + callable 检查),确保 API 基础可用性。 - test_help_returns_none_without_docstring:严格验证 help 函数在入口点无 docstring 时返回 None。使用 mock 本地仓库进行测试,无需外部网络依赖。 - test_help_returns_docstring_with_content:严格验证 help 函数在入口点有 docstring 时返回有效的字符串内容。使用 mock 本地仓库进行测试,检查返回值类型为 str、非空、且包含预期关键字 "EfficientNet"。 2. torch.hub._get_torch_home API 验证 - test_get_torch_home_returns_path:验证 _get_torch_home 返回有效的路径字符串(assertIsInstance(str) + assertGreater(len, 0)),确保路径非空且类型正确。 - test_get_torch_home_with_env_variable:验证 TORCH_HOME 环境变量能正确影响返回路径,使用 tempfile.TemporaryDirectory 创建临时目录作为测试路径,覆盖自定义路径场景。测试后恢复原始环境变量状态(os.environ.pop 或 restore),避免污染其他测试。 3. 测试隔离性保障 - setUp 机制:TestHubHelp 类在 setUp 中创建 mock 本地仓库目录,写入 hubconf.py 文件,包含有/无 docstring 的两个入口点函数。 - tearDown 机制:每个测试后清理临时目录,确保测试用例间无状态污染。 - 独立性设计:两个测试类(TestHubHelp、TestHubGetTorchHome)独立,无共享状态。 - 零外部依赖:使用 unittest.mock.patch 模拟 _get_cache_or_reload,避免对 GitHub 外部仓库的依赖,测试更快、更可靠,适合 CI 环境。 测试完整性 所有用例覆盖 API 的基础功能验证、接口存在性检查、环境变量交互、测试隔离性保障,完整覆盖昇腾 NPU 适配所需的最小功能集合。 三、昇腾 NPU 适配说明(解释为什么无需 NPU 适配) torch.hub.help 和 torch.hub._get_torch_home 均具备硬件无关性、纯 Python 层实现、无底层算子依赖三大核心特征,决定了其无需针对昇腾 NPU 做适配,具体分析: 1. 纯 Python 层抽象,无硬件相关逻辑 - help API 硬件无关性:仅负责解析远程仓库的 hubconf.py 并提取文档字符串,是「文档查询」的纯 Python 抽象接口,不涉及任何硬件相关的计算、存储、通信逻辑。 - _get_torch_home API 硬件无关性:仅负责读取环境变量和构建路径字符串,依赖 os.path 模块进行路径处理,无任何硬件相关的逻辑或依赖。 - 设备无关设计:两个 API 的核心逻辑与 CPU/GPU/NPU 等硬件架构完全解耦,在任意硬件环境下行为一致。 2. 无底层算子 / 内核依赖 - 标准库依赖:两个 API 内部仅调用 Python 标准库(os 路径模块、tempfile 临时文件模块、urllib 网络模块)和 PyTorch 纯 Python 层的 hub 模块。 - 无硬件扩展依赖:未依赖 CUDA/NPU 等硬件相关的扩展库、内核函数或底层驱动。 - help 的远程解析机制:基于 GitHub URL 和 Python import 机制,与硬件架构无关。 - _get_torch_home 的路径处理机制:基于 os.path.expanduser 和 os.getenv,纯文件系统操作。 3. 核心逻辑与硬件解耦 - 文档获取解耦:help API 返回的文档字符串是纯文本信息,与硬件架构无关 —— 无论是 CPU/GPU/NPU 环境,文档查询逻辑完全一致。 - 路径解析解耦:_get_torch_home 返回的路径是通用文件系统路径,不包含任何硬件相关字段(如设备 ID、内存地址),昇腾 NPU 环境下可直接复用。 - 无张量操作:两个 API 均不涉及张量的创建、计算或迁移,测试用例中无 tensor 相关代码,无需 NPU 设备支持。 结论 torch.hub.help 和 torch.hub._get_torch_home 均是「硬件无关的纯 Python 层抽象」,核心逻辑不耦合任何特定硬件。测试用例无需导入 torch_npu,API 本身无需适配修改,可直接复用。 # 【资料变更】 刷新2.7.1版本下有多个版本资料。 1、torch.hub._get_torch_home API该API昇腾支持,但是在文档中并无描述,因此需要增加。 文档修改PR链接:https://gitcode.com/Ascend/pytorch/pull/34365 # 【接口变更】 不涉及 # 【功能验证】 测试文件路径:test/test_hub_api.py 本地验证结果:  所有测试用例执行通过。torch.hub.help 和 torch.hub._get_torch_home API 核心功能验证正常。 两个 API 均为纯 Python 层实现,不涉及张量操作,无需 NPU 设备适配。测试用例无需导入 torch_npu,API 本身可在任意硬件环境稳定运行。验证结果表明,torch.hub.help 和 torch.hub._get_torch_home 在昇腾 NPU 环境下功能正常可用,无需修改源码。 # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签:test(hub) - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!34071 | 3 个月前 | |
| 2 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
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: !32402 merge fixtest-jit-api-master into master 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!32402 | 4 个月前 | |
[feat] Add test cases for verifying torch.jit.ScriptModule hook API on NPU Co-authored-by: hxm_<ha_m@foxmail.com> # message auto-generated for no-merge-commit merge: !35723 merge v2.12.0 into v2.12.0 [feat] Add test cases for verifying torch.jit.ScriptModule hook API on NPU Created-by: hxm_ Commit-by: hxm_ Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 issue连接:https://gitcode.com/Ascend/pytorch/issues/1723 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 ## 一、背景说明 1. 通过 torch.jit.script()创建的模型是RecursiveScriptModule实例,与测试目的不符,所以本次测试模型均通过继承torch.jit.ScriptModule创建。 2. torch.jit.ScriptModule 继承自 torch.nn.Module,在 __init__ 执行完毕后通过 torch.jit.ScriptModule .init_then_script() 将模块编译为 TorchScript,内部持有 torch.jit.ScriptModule ._actual_script_module(RecursiveScriptModule 实例)作为 C++ 侧代理。编译过程只迁移参数/子模块/缓冲区的存储,不替换类上的方法,也不影响 hook 相关属性(torch.jit.ScriptModule ._backward_hooks、torch.jit.ScriptModule ._backward_pre_hooks 等),因此大部分 hook API 在 ScriptModule 子类上行为与普通 Module 一致。 3. torch.jit.ScriptModule .register_full_backward_hook 例外的原因:该方法内部会设置 self._is_full_backward_hook = True,该属性赋值被 ScriptModule.__setattr__ 代理到 C++ 侧后,因类型不匹配(C++ 侧期望 NoneType)导致 RuntimeError。这是pytorch自身的bug。 ## 二、API 功能说明 ### 1. torch.jit.ScriptModule.register_full_backward_hook(hook, prepend=False) -> RemovableHandle 在模块上注册反向传播后置 hook。hook 签名为 hook(module, grad_input, grad_output) -> tuple[Tensor] or None,在模块梯度计算完成时被调用,可返回新的 grad_input 替代原有值。prepend=True 时 hook 在已有 hook 之前执行。返回 RemovableHandle 用于移除 hook。 ### 2. torch.jit.ScriptModule.register_full_backward_pre_hook(hook, prepend=False) -> RemovableHandle 在模块上注册反向传播前置 hook。hook 签名为 hook(module, grad_output) -> tuple[Tensor] or None,在模块梯度计算之前被调用,可返回新的 grad_output 影响后续梯度计算。prepend=True 时 hook 在已有 hook 之前执行。返回 RemovableHandle 用于移除 hook。 ### 3. torch.jit.ScriptModule.register_load_state_dict_pre_hook(hook) -> RemovableHandle 在 load_state_dict 调用前触发 hook。hook 签名为 hook(module, state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs) -> None,可用于在加载前对 state_dict 进行预处理。返回 RemovableHandle 用于移除 hook。 ### 4. torch.jit.ScriptModule.register_load_state_dict_post_hook(hook) -> RemovableHandle 在 load_state_dict 调用后触发 hook。hook 签名为 hook(module, incompatible_keys) -> None,incompatible_keys 包含 missing_keys 和 unexpected_keys,可原地修改。返回 RemovableHandle 用于移除 hook。 ### 5. torch.jit.ScriptModule.register_state_dict_pre_hook(hook) -> RemovableHandle 在 state_dict 调用前触发 hook。hook 签名为 hook(module, prefix, keep_vars) -> None,可用于在序列化前执行预处理。返回 RemovableHandle 用于移除 hook。 ### 6. torch.jit.ScriptModule.register_state_dict_post_hook(hook) -> RemovableHandle 在 state_dict 调用后触发 hook。hook 签名为 hook(module, state_dict, prefix, local_metadata) -> None,可原地修改 state_dict。返回 RemovableHandle 用于移除 hook。 ## 三、测试用例说明 ### 1. torch.jit.ScriptModule.register_full_backward_hook | 用例 | 说明 | |------|------| | test_register_full_backward_hook_raises | 验证调用 register_full_backward_hook 时抛出 RuntimeError | ### 2. torch.jit.ScriptModule.register_full_backward_pre_hook | 用例 | 说明 | |------|------| | test_register_full_backward_pre_hook_called | 验证 hook 在反向传播时被调用 | | test_register_full_backward_pre_hook_modify_grad | 验证 hook 返回修改后的 grad_output 可影响梯度计算(返回全零梯度,输入梯度为零) | | test_register_full_backward_pre_hook_prepend | 验证 prepend=True 时 hook 在已有 hook 之前执行 | | test_register_full_backward_pre_hook_remove | 验证 handle.remove() 后 hook 不再触发 | ### 3. torch.jit.ScriptModule.register_load_state_dict_pre_hook & torch.jit.ScriptModule.register_load_state_dict_post_hook | 用例 | 说明 | |------|------| | test_load_state_dict_pre_hook_fires_before_module_and_post_hook | 验证完整时序 pre_hook -> module(load_state_dict) -> post_hook,post_hook 先注册证明调用顺序与注册顺序无关;pre_hook 修改 state_dict 为全零,post_hook 检查权重已加载为零,证明 module 在 pre 和 post 之间执行 | | test_register_load_state_dict_pre_hook_called | 验证 pre_hook 在 load_state_dict 时被调用,接收到正确的 prefix 参数 | | test_register_load_state_dict_pre_hook_with_module | 验证 pre_hook 接收到的 module 参数就是当前模型实例 | | test_register_load_state_dict_pre_hook_remove | 验证 handle.remove() 后 pre_hook 不再触发 | | test_register_load_state_dict_post_hook_called | 验证 post_hook 在 load_state_dict 后被调用 | | test_register_load_state_dict_post_hook_with_module | 验证 post_hook 接收到的 module 参数就是当前模型实例 | | test_register_load_state_dict_post_hook_remove | 验证 handle.remove() 后 post_hook 不再触发 | ### 4. torch.jit.ScriptModule.register_state_dict_pre_hook & torch.jit.ScriptModule.register_state_dict_post_hook | 用例 | 说明 | |------|------| | test_state_dict_pre_hook_fires_before_module_and_post_hook | 验证完整时序 pre_hook -> module(state_dict) -> post_hook,post_hook 先注册证明调用顺序与注册顺序无关;post_hook 检查 state_dict 已包含模型参数,证明 module 在 pre 和 post 之间执行 | | test_register_state_dict_pre_hook_called | 验证 pre_hook 在 state_dict 时被调用,接收到正确的 prefix 参数 | | test_register_state_dict_pre_hook_with_module | 验证 pre_hook 接收到的 module 参数就是当前模型实例 | | test_register_state_dict_pre_hook_remove | 验证 handle.remove() 后 pre_hook 不再触发 | | test_register_state_dict_post_hook_called | 验证 post_hook 在 state_dict 后被调用,接收到正确的 prefix 参数 | | test_register_state_dict_post_hook_with_module | 验证 post_hook 接收到的 module 参数就是当前模型实例 | | test_register_state_dict_post_hook_remove | 验证 handle.remove() 后 post_hook 不再触发 | # 【资料变更】 torch.jit.ScriptModule.register_load_state_dict_pre_hook、torch.jit.ScriptModule.register_state_dict_post_hook API昇腾支持,但是在文档中并无描述,因此需要增加。 其他API昇腾支持,且在文档中有描述,无需添加。 文档修改PR链接:https://gitcode.com/Ascend/pytorch/pull/35840 # 【接口变更】 不涉及 # 【功能验证】 | 接口 | 状态 | 说明 | |------|------|------| | torch.jit.ScriptModule.register_full_backward_hook | 不可用 | 调用时抛出 RuntimeError | | torch.jit.ScriptModule.register_full_backward_pre_hook | 可用 | 正常注册并触发,支持修改 grad_output、prepend 顺序控制、handle 移除 | | torch.jit.ScriptModule.register_load_state_dict_pre_hook | 可用 | 在 load_state_dict 前触发,可接收 module 参数,支持 handle 移除 | | torch.jit.ScriptModule.register_load_state_dict_post_hook | 可用 | 在 load_state_dict 后触发,可接收 module 参数,支持 handle 移除 | | torch.jit.ScriptModule.register_state_dict_pre_hook | 可用 | 在 state_dict 前触发,可接收 module 参数,支持 handle 移除 | | torch.jit.ScriptModule.register_state_dict_post_hook | 可用 | 在 state_dict 后触发,可接收 module 参数,支持 handle 移除 | 测试日志 ======================================== Python代码多环境测试开始 测试脚本: /root/torch-2.11/test_script_module_hooks.py 测试时间: Fri Apr 24 06:37:57 AM UTC 2026 ======================================== 检测到已激活的虚拟环境,先取消激活... ---------------------------------------- 测试环境: torch-2.7.1 虚拟环境: /root/torch-2.7.1/.venv/bin/activate 日志文件: /root/torch-2.11/logs/test_2.7.1_20260424_063757.log ---------------------------------------- 测试环境: torch-2.7.1 退出码: 0 状态: 成功 ✅ 详细日志: /root/torch-2.11/logs/test_2.7.1_20260424_063757.log 完成测试: torch-2.7.1 (退出码: 0) ---------------------------------------- 测试环境: torch-2.8 虚拟环境: /root/torch-2.8/.venv/bin/activate 日志文件: /root/torch-2.11/logs/test_2.8_20260424_063757.log ---------------------------------------- 测试环境: torch-2.8 退出码: 0 状态: 成功 ✅ 详细日志: /root/torch-2.11/logs/test_2.8_20260424_063757.log 完成测试: torch-2.8 (退出码: 0) ---------------------------------------- 测试环境: torch-2.9 虚拟环境: /root/torch-2.9/.venv/bin/activate 日志文件: /root/torch-2.11/logs/test_2.9_20260424_063757.log ---------------------------------------- 测试环境: torch-2.9 退出码: 0 状态: 成功 ✅ 详细日志: /root/torch-2.11/logs/test_2.9_20260424_063757.log 完成测试: torch-2.9 (退出码: 0) ---------------------------------------- 测试环境: torch-2.10 虚拟环境: /root/torch-2.10/.venv/bin/activate 日志文件: /root/torch-2.11/logs/test_2.10_20260424_063757.log ---------------------------------------- 测试环境: torch-2.10 退出码: 0 状态: 成功 ✅ 详细日志: /root/torch-2.11/logs/test_2.10_20260424_063757.log 完成测试: torch-2.10 (退出码: 0) ---------------------------------------- 测试环境: torch-2.11 虚拟环境: /root/torch-2.11/.venv/bin/activate 日志文件: /root/torch-2.11/logs/test_2.11_20260424_063757.log ---------------------------------------- 测试环境: torch-2.11 退出码: 0 状态: 成功 ✅ 详细日志: /root/torch-2.11/logs/test_2.11_20260424_063757.log 完成测试: torch-2.11 (退出码: 0) ======================================== 测试完成总结 总测试环境数: 5 完成时间: Fri Apr 24 06:39:05 AM UTC 2026 成功测试数: 5 失败测试数: 0 所有详细日志保存在: /root/torch-2.11/logs 主日志文件: /root/torch-2.11/logs/test_results_20260424_063757.log ======================================== pytorch 2.12 ../root/.local/share/uv/python/cpython-3.12.13-linux-aarch64-gnu/lib/python3.12/multiprocessing/popen_fork.py:66: DeprecationWarning: This process (pid=3985006) is multi-threaded, use of fork() may lead to deadlocks in the child. self.pid = os.fork() [W515 03:02:03.790319610 NPUCachingAllocator.cpp:199] Warning: The current CANN and Soc versions require processing for 32 padding size, with memory allocation. (function operator()) [W515 03:02:11.756102926 IscloseKernelNpu.cpp:34] Warning: Device do not support double dtype of rtol and atol now, dtype cast repalce with float. (function operator()) .................... ---------------------------------------------------------------------- Ran 21 tests in 18.055s OK # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35723 | 3 个月前 | |
| 2 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
[sync] PR-37189: fix: unskip test_reductions test case in test_multiprocessing_api.py Co-authored-by: wuyouqi1<wuyouqi1@h-partners.com> # message auto-generated for no-merge-commit merge: !37686 merge sync-pr37189-fix/test_reductions_multiprocess-to-v2.12.0 into v2.12.0 [sync] PR-37189: fix: unskip test_reductions test case in test_multiprocessing_api.py Created-by: ascend-ds-bot Commit-by: wuyouqi1 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37189 ### 2. Original pull request related issue(s): ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[908d8d41](https://gitcode.com/Ascend/pytorch/commit/908d8d41e4f61d1394c8f573dfaab92d5c900384)|2026-06-05 11:03:14 +0800 CST|test(reductions): add skipUnless decorator for driver version check<br><br>Add @unittest.skipUnless to test_reductions to skip the test when<br>driver version < 25.3, as NPU IPC reduce/rebuild requires driver >= 25.3.<br><br>Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com><br>| |[e00edd92](https://gitcode.com/Ascend/pytorch/commit/e00edd928dbfbb87892dc56fc852f4977e1678ee)|2026-06-04 15:25:45 +0800 CST|Revert "test(reductions): add debug logging for NPU IPC reduce/rebuild path"<br><br>This reverts commit d1ee69dcbd891a48ced0f34471547b25710a5679.<br>| |[d1ee69dc](https://gitcode.com/Ascend/pytorch/commit/d1ee69dcbd891a48ced0f34471547b25710a5679)|2026-06-03 15:53:58 +0800 CST|test(reductions): add debug logging for NPU IPC reduce/rebuild path<br><br>Add torch_npu.multiprocessing.reductions debug logger to trace:<br>- _npu_reduce_tensor: which branch (NPU/meta/CPU), _share_npu_() return values, cache key format<br>- rebuild_npu_tensor: cache lookup key format, HIT/MISS, _new_shared_npu() result, rebuilt tensor data<br>- test worker: rebuild_fn args, rebuilt tensor data in child process<br><br>Purpose: verify cross-process IPC reduce→rebuild takes correct code path.<br><br>Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com><br>| |[5f3fe781](https://gitcode.com/Ascend/pytorch/commit/5f3fe781e2d2afd62f261e68ecf5ea15c4bc3145)|2026-06-01 10:50:39 +0800 CST|fix(test): send tensor data as list to avoid resource_sharer connection reset<br><br>CPU tensor pickled through Queue uses rebuild_storage_fd which requires<br>resource_sharer Unix socket. Child process exits before parent can<br>establish connection. Convert tensor to plain list before sending.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[4fbab4e4](https://gitcode.com/Ascend/pytorch/commit/4fbab4e426da26946aebb3f714f5b2a1b416e944)|2026-06-01 10:37:09 +0800 CST|test(multiprocessing): use explicit reduce/rebuild in cross-process test<br><br>Address review comments:<br>- Worker now receives (rebuild_fn, args) from reduce_tensor, explicitly<br> calls rebuild_fn(*args) to reconstruct tensor<br>- Main process puts reduced_npu handle instead of raw tensor<br>- Main process compares result with original npu_tensor instead of<br> hardcoding expected values in worker<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[8b7be3c2](https://gitcode.com/Ascend/pytorch/commit/8b7be3c23c6cde75a478073759d8fad22168879f)|2026-05-30 17:28:58 +0800 CST|fix(test): synchronize NPU before putting tensor to Queue<br><br>Child process received all zeros because NPU write cache was not<br>flushed before IPC handle export. torch.npu.synchronize() ensures<br>data is written to physical memory before cross-process transfer.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[89953a94](https://gitcode.com/Ascend/pytorch/commit/89953a94f9ee27a0179950d1b97b093c4e9bbef4)|2026-05-30 17:21:03 +0800 CST|fix(test): add diagnostic info for NPU tensor mismatch<br><br>Include actual received data in failure message to diagnose IPC issue.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[ad27f741](https://gitcode.com/Ascend/pytorch/commit/ad27f741aedc98faed4a2e45d4bc3cc344239aa3)|2026-05-30 17:07:25 +0800 CST|fix(test): capture child process error in test_reductions<br><br>Worker now sends result status back via Queue instead of relying on<br>exitcode. This propagates actual error messages from the child process<br>for diagnosis.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[9b2a8888](https://gitcode.com/Ascend/pytorch/commit/9b2a888831efd8a29ea7d407dccfbc004720c337)|2026-05-30 16:42:56 +0800 CST|fix(test): fix NPU tensor cross-process transfer direction<br><br>Main process puts tensor to Queue, child process gets and validates.<br>Matches torch_npu multiprocessing test patterns. Use Queue instead of<br>SimpleQueue to avoid resource_sharer lifecycle issues.<br><br>Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com><br>| |[db6b692b](https://gitcode.com/Ascend/pytorch/commit/db6b692bfec2f968ad5bd6da5cee223251f0b15e)|2026-05-30 16:37:35 +0800 CST|fix(test): remove unsupported timeout from SimpleQueue.get()<br><br>SimpleQueue.get() does not accept timeout parameter in Python 3.10.<br><br>Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com><br>| |[c0820b36](https://gitcode.com/Ascend/pytorch/commit/c0820b36457cf1759e9de6dc48f16698b9ff21c2)|2026-05-30 16:20:09 +0800 CST|test(multiprocessing): merge multiprocess rebuild into test_reductions<br><br>Combine NPU multiprocess rebuild into test_reductions instead of a separate<br>test case. CPU tensor uses same-process rebuild, NPU tensor uses cross-process<br>rebuild via Queue.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[aedaa436](https://gitcode.com/Ascend/pytorch/commit/aedaa436bdbcb30e36713d7cd6cbfea9f1f5df94)|2026-05-30 16:17:22 +0800 CST|fix(test): move worker function to module level for spawn pickle<br><br>spawn mode cannot pickle local functions. Move _npu_tensor_worker to<br>module top level.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| |[0e37c8f8](https://gitcode.com/Ascend/pytorch/commit/0e37c8f8015060dcffbef58b9377cd380d7e7687)|2026-05-30 10:40:03 +0800 CST|test(multiprocessing): fix test_reductions and add multi-process NPU test<br><br>- Remove @unittest.skip decorator from test_reductions<br>- Remove unreliable same-process NPU tensor reconstruction assertion<br> (IPC handles cannot be imported in the same process that exported them)<br>- Add test_reductions_multiprocess to validate cross-process NPU tensor<br> sharing via Queue, aligned with PyTorch upstream CUDA test pattern<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| See merge request: Ascend/pytorch!37686 | 2 个月前 | |
| 2 年前 | ||
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33714 merge master into master add_test 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为以下API增加用例功能 Tensor.copy_ Tensor.narrow torch.cat torch.chunk torch._chunk_cat # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 新增文件 test_cat.py test_chunk.py test_chunk_cat.py test_copy_.py test_narrow.py # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33714 | 4 个月前 | |
| 1 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
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: !32060 merge fixtest-nn-api-master into master 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 test 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!32060 | 4 个月前 | |
| 2 年前 | ||
[fix]add getMemoryFraction attribute for torch._C Co-authored-by: weixin_47897441<wuyouqi1@h-partners.com> # message auto-generated for no-merge-commit merge: !30619 merge master into master [fix]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  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!30619 | 5 个月前 | |
[v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Co-authored-by: Dring<17737727613@163.com> # message auto-generated for no-merge-commit merge: !45000 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Created-by: Dring Commit-by: Dring Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/3991 - [✕ ] 需求 - [ ✓] 问题单 - [ ✓] issue/工单 - [ ✓] 重构优化 - [✕ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 问题现象: PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配 aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。 根因分析: 1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法 #include "third_party/acl/inc/acl/acl_mdl.h" 因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h 但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h" 编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h 同一个翻译单元最终形成: acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本 acl_base.h -> 环境 CANN 9.0.0 版本 这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。 2 问题不局限于 acl_mdl.h 同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括: acl/... aml/... profiling/... graph/... ge/... op_proto/... 因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。 修改目标: 修改后需要满足 源码不再包含 third_party/acl/inc/... 这种仓库物理路径。 ACL、AML、profiling 等头文件全部通过统一 include root 查找。 一个编译 target 对 CANN 头文件只选择一套版本。 CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。 使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。 wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约 修改方案: 1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找 2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [✓ ] 代码注释完备,正确记录错误日志 - [✕ ] 代码实现进行了返回值、空指针等校验 - [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45000 | 2 天前 | |
| 1 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
test(reductions): note NPU/XLA skip searchsorted non-contiguous UserWarning check. Co-authored-by: Margaret_wangrui<wangrui178@huawei.com> # message auto-generated for no-merge-commit merge: !37097 merge searchsorted_testcase_v2.12.0 into v2.12.0 test(reductions): note NPU/XLA skip searchsorted non-contiguous UserWarning check. Created-by: Margaret_wangrui Commit-by: Margaret_wangrui Merged-by: ascend-robot Description: # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/1910 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) values_3d_permute = values_3d.permute(2, 1, 0).to(torch.int32) boundaries_permute = values_3d.permute(2, 1, 0).to(torch.float64) values_3d_permute和boundaries_permute在torch_npu中是连续的,不应该在用例中去捕获非连续告警信息 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 .png') # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37097 | 2 个月前 | |
[v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Co-authored-by: Dring<17737727613@163.com> # message auto-generated for no-merge-commit merge: !45000 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 [v2.12.0-26.1.0][bugfix]cann and pta header mixing bulid bugfix Created-by: Dring Commit-by: Dring Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/3991 - [✕ ] 需求 - [ ✓] 问题单 - [ ✓] issue/工单 - [ ✓] 重构优化 - [✕ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 问题现象: PTA 26.1.0 仓库中的 third_party/acl 头文件来自 CANN 9.1.0,而编译环境安装的是 CANN 9.0.0。当同一个编译单元同时包含两套版本的 ACL 头文件时,会出现类似以下错误:aclmdlRITask 未声明、未定义或类型不匹配 aclmdlRITask 是 CANN 9.1.0 头文件所依赖的定义,但 CANN 9.0.0 对应头文件中不存在该定义或定义不兼容。 根因分析: 1 当前头文件查找路径不统一:PTA 源码中大量使用以下写法 #include "third_party/acl/inc/acl/acl_mdl.h" 因为编译命令中包含 PTA 项目根目录,这种写法会直接命中 PTA 26.1.0 仓库内由 CANN 9.1.0 导入的头文件:torch_npu/third_party/acl/inc/acl/acl_mdl.h 但该头文件内部使用的是标准 SDK 相对路径:#include "acl/acl_base.h" 编译器无法相对 acl_mdl.h 所在目录找到 acl/acl_base.h,因此转而按照全部 -I 目录依次搜索。如果 CANN 9.0.0 的 include 路径排在 PTA 内置 ACL 路径前面,就会命中:CANN-9.0.0/include/acl/acl_base.h 同一个翻译单元最终形成: acl_mdl.h -> PTA third_party 中的 CANN 9.1.0 版本 acl_base.h -> 环境 CANN 9.0.0 版本 这是一种“首层头文件由源码路径固定版本、传递头文件由 -I 顺序选择版本”的混合查找模式。 2 问题不局限于 acl_mdl.h 同样风险存在于所有能够继续 include 其他 CANN 头文件的入口,包括: acl/... aml/... profiling/... graph/... ge/... op_proto/... 因此不能只修复出现错误的某一个头文件,也不能只替换 acl_mdl.h。必须统一整个 CANN 头文件族的查找规则。 修改目标: 修改后需要满足 源码不再包含 third_party/acl/inc/... 这种仓库物理路径。 ACL、AML、profiling 等头文件全部通过统一 include root 查找。 一个编译 target 对 CANN 头文件只选择一套版本。 CANN 9.0.0 环境构建时,首层和传递头文件必须全部命中 CANN 9.0.0。 使用 PTA 内置头文件构建时,首层和传递头文件必须全部命中 PTA 内置的同一套版本。 wheel、libtorch_npu、C++ Extension 和 Inductor/AOT 使用同一目录契约 修改方案: 1、代码中使用 PTA 内置 ACL 头文件的地方,删除 third_party/acl/inc/ 物理路径前缀,统一改成从 include root 查找 2、打包或安装时,把 third_party/acl/inc 下需要公开的目录按原相对结构复制到安装产物的公共 include 根目录 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 cann 9.0.0 + pta 26.1.0的vllm-ascend安装验证成功  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [✓ ] 代码注释完备,正确记录错误日志 - [✕ ] 代码实现进行了返回值、空指针等校验 - [✓ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [✓ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45000 | 2 天前 | |
fix: support quantized NPU flip dispatch Co-authored-by: hz893<zhanghao491@huawei.com> # message auto-generated for no-merge-commit merge: !36072 merge fix_quantized_flip_v2.12.0_20260519 into v2.12.0 fix: support quantized NPU flip dispatch Created-by: hz893 Commit-by: hz893 Merged-by: ascend-robot Description: # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [x] 问题单 https://gitcode.com/Ascend/pytorch/issues/2207 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 在 QuantizedPrivateUse1 的 codegen 注册中补充 aten::flip,使量化 NPU tensor 能命中 torch_npu 的 quantized helper。 2. 新增 quantized_flip helper:per-tensor 量化场景对 int_repr() 调用普通 NPU aten::flip,复用现有 op_plugin::flip -> aclnnFlip 数据翻转路径,再用原 scale/zero_point 重建 affine quantized tensor。 3. 对齐 CPU/CUDA 行为:sub-byte 量化 dtype 保持不支持报错;per-channel 量化保持 Setting strides is possible only on uniformly quantized tensor 报错。 4. 新增 per-channel quantized flip 报错回归测试。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。 # 【功能验证】 1. v2.7.1 环境执行 bash ci/build.sh --python=3.11,编译成功并生成 wheel。 2. v2.7.1 环境执行 python -m pytest test_shape_ops.py -v -k test_flip_npu_float32,结果:1 passed。 3. v2.7.1 环境执行 python -m pytest --import-mode=importlib test/test_shape_ops.py -v -k "test_flip_per_channel_quantized_error or test_flip_npu_float32",结果:2 passed。 4. 验证普通 float NPU flip backward 与 CPU 在 dims=(0,)、(1,)、(0, 1)、() 下 forward/grad 均一致;验证 quantized flip 的 autograd 状态和错误行为与 CPU 一致。 5. v2.7.1、v2.9.0、v2.10.0、v2.11.0、v2.12.0、master 源分支均执行 git diff --check,无异常。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36072 | 2 个月前 | |
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !36367 merge v2.12.0_lintrunner into v2.12.0 [Fix] Fix static check errors detected by SPACES Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 检测和删除代码中的行尾空白字符 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36367 | 3 个月前 | |
| 2 年前 | ||
fix: support to_sparse on non-default NPU devices Co-authored-by: hz893<zhanghao491@huawei.com> # message auto-generated for no-merge-commit merge: !35947 merge fix_to_sparse_v2.12.0 into v2.12.0 fix: support to_sparse on non-default NPU devices Created-by: hz893 Commit-by: hz893 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [x] 问题单 https://gitcode.com/Ascend/pytorch/issues/2182 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 将 aten::_to_sparse 和 aten::_to_sparse.sparse_dim 加入 NPU supported 注册,避免 dense NPU Tensor 转 sparse 时走 CPU fallback。 2. 新增 NPU 侧 _to_sparse 实现,复用 at::native::dense_to_sparse,使 sparse tensor、indices、values 保持在输入 Tensor 所在 NPU 设备上。 3. 新增非默认 NPU 设备场景 UT,覆盖输入位于 npu:1 时 to_sparse 结果的 device 和数值一致性。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。 # 【功能验证】 - 已在 v2.7.1 环境完成 torch_npu 编包并安装验证,torch_npu.__version__ 为 2.7.1.post5。 - 已确认 aten::_to_sparse 和 aten::_to_sparse.sparse_dim 的 PrivateUse1 dispatcher 注册到 RegisterNPU.cpp [kernel],不再走 CPU fallback。 - python -m pytest test_ops.py -v -k test_multiple_devices_to_sparse_npu_float32:1 passed。 - python -m pytest test/test_sparse_coo.py -v -k test_sparse_to_sparse_non_default_npu_device:1 passed。 - v2.9.0、v2.10.0、v2.11.0、v2.12.0、master 目标分支已完成 cherry-pick,无冲突;未分别编包验证。 补充验证: - 已在 fix_to_sparse_master 分支完成编译并安装生成的 torch_npu-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl。 - 通过临时 C++ 扩展直接调用新增 AOT shim aoti_torch_npu__to_sparse,在当前 device 为 npu:0、输入 tensor 位于 npu:1 的场景下验证返回 sparse tensor、indices、values 均保持在 npu:1,且 to_dense() 与输入一致。 - 测试结果:PASS aoti_torch_npu__to_sparse device=npu:1 nnz=3。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35947 | 2 个月前 | |
Skip failing torch official TestCase tests and disable unsupported test cases Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com> Co-authored-by: yuhaiyan8<yuhaiyan8@h-partners.com> # message auto-generated for no-merge-commit merge: !32140 merge cherry-pick-mr-32139-1774073503832-auto into master Skip failing torch official TestCase tests and disable unsupported test cases Created-by: yuhaiyan Commit-by: yuhaiyan;yuhaiyan8 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 暂时跳过失败用例 2. 已提单跟进修复 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32140 | 4 个月前 | |
| 2 年前 | ||
[feat]TensorTo support preserve_format consistent with GPU Co-authored-by: chenshuai<chenshuai81@huawei.com> # message auto-generated for no-merge-commit merge: !35353 merge cherry-pick-mr-34696-1778548963126-auto into v2.12.0 [feat]TensorTo support preserve_format consistent with GPU Created-by: culechan Commit-by: culechan;chenshuai Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1、NPU上tensorto支持preserve_format模式。行为逻辑上对齐pytorch原生框架 2、增加preserve_format模式相关的测试用例 # 【资料变更】 不涉及,原生API表格中未体现这部分内容 # 【接口变更】 Tensor.to默认使用且支持preserve_format模式 # 【功能验证】   # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35353 | 3 个月前 | |
Update test_torch.py Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com> # message auto-generated for no-merge-commit merge: !27371 merge master-dev2 into master Update test_torch.py 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!27371 | 8 个月前 | |
fix lazy_init and api export Co-authored-by: bellatan<tanmei2@huawei.com> # message auto-generated for no-merge-commit merge: !36707 merge v2.12.0_torch_npu_init_refactor into v2.12.0 fix lazy_init and api export Created-by: bellatan Commit-by: bellatan Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [ ] issue/工单 - [x] 重构优化 - [ ] 资料更新 # 【修改方案】 问题:test/test_npu.py的test_lazy_init用例失败  根因: 重构前 torch_npu/__init__.py 中,先做 accelerator 冲突检查,即_check_device_conflict 接口调用,再 import torch_npu.npu、torch_npu.utils 等内部模块,不会触发 NPU device count 提前枚举 重构后 torch_npu/__init__.py 中,先调用了_check_device_conflict 接口,再 import torch_npu.npu、torch_npu.utils 等内部模块,_check_device_conflict 接口调用顺序被延后,调用 _get_accelerator() 时 NPU backend 状态已经被拉起,触发底层设备探测,导致 _npu_getDeviceCount() 提前枚举真实设备数 8。 解决:在 torch_npu/__init__.py 中,保持和重构前一样的调用顺序,即_check_device_conflict 接口调用提前到所有的 import 之前。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 test/test_torch_npu_init.py 新增对应的测试项本地验证pass,CI pass  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36707 | 2 个月前 | |
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
[fix] add _npu_dtype_cast_backward sharding strategy Co-authored-by: zqwenn<zhangqiongwen@huawei.com> # message auto-generated for no-merge-commit merge: merge master_npu_dtype_cast_backsard_register_sharding into master [fix] add _npu_dtype_cast_backward sharding strategy 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!25308 | 10 个月前 | |
test(utils): add checkpoint API coverage tests on NPU Co-authored-by: Jinfan Liu<1300083451@qq.com> # message auto-generated for no-merge-commit merge: !37240 merge test-utils-checkpoint-weak-npu-2.12.0 into v2.12.0 test(utils): add checkpoint API coverage tests on NPU Created-by: JfanLiu Commit-by: Jinfan Liu Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/2026**</font> > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> [x] issue/工单 # 【修改方案】 一、API功能说明 本 PR 补充 torch.utils.checkpoint 弱覆盖 API 的直接验证用例: - torch.utils.checkpoint.SelectiveCheckpointContext:selective checkpoint policy function 接收的上下文对象,用于区分 forward/recompute 阶段;2.12.0 起还可携带 op_output。 - torch.utils.checkpoint.detach_variable:reentrant checkpoint 内部用于 detach 输入 Tensor 并保持 requires_grad 状态的辅助函数。 二、测试用例完备性说明 PyTorch 官方社区 test/test_autograd.py 已通过 checkpoint 调用链间接覆盖上述 API,但缺少直接、聚焦的 API 行为断言。本 PR 按 1.3 类补充 torch-npu 自定义测试文件 test/test_utils_checkpoint_api.py。 1. torch.utils.checkpoint.detach_variable 直接覆盖: - test_detach_variable_keeps_device_and_requires_grad 直接调用 torch.utils.checkpoint.detach_variable((x, y, marker))。 - x 和 y 均为 NPU Tensor,覆盖返回 Tensor 保持 NPU device、requires_grad 与原输入一致、grad_fn 被断开并成为 leaf Tensor,非 Tensor 对象透传。 - test_detach_variable_rejects_non_tuple_input 覆盖非 tuple 输入的 RuntimeError 分支。 2. torch.utils.checkpoint.SelectiveCheckpointContext 直接覆盖: - test_selective_checkpoint_context_direct_attributes 直接实例化 torch.utils.checkpoint.SelectiveCheckpointContext,断言对象类型和 is_recompute 属性;对支持 op_output 的版本,额外断言 op_output 指向 NPU Tensor 输出。 - test_selective_checkpoint_context_passed_to_policy_fn 通过 create_selective_checkpoint_contexts + checkpoint(..., use_reentrant=False, context_fn=...) 捕获 policy_fn 收到的 ctx,断言 forward/recompute 两阶段均收到 SelectiveCheckpointContext,并验证上下文来自 NPU Tensor 的 selective checkpoint 运行路径。 上述新增用例把原来的调用链弱覆盖补充为直接 API 行为覆盖;其中涉及 Tensor 的路径均使用 torch.accelerator.current_accelerator() 获取 NPU 设备并在 NPU Tensor 上执行。 三、NPU适配方案 1. API 源码无需修改:torch.utils.checkpoint.SelectiveCheckpointContext 与 torch.utils.checkpoint.detach_variable 均复用 PyTorch Python 层实现,不新增 NPU kernel,不改变接口语义。 2. 测试新增路径:新增 test/test_utils_checkpoint_api.py,文件聚焦 checkpoint API 直接行为,可后续扩展同模块 API。 3. 分支提交范围:新增测试文件提交到 2.7.1、2.9.0、2.10.0、2.11.0、2.12.0 以及 master。 四、变更文件 - test/test_utils_checkpoint_api.py # 【资料变更】 > 已检查资料支持情况,结论如下: > > checkpoint: > - 公开 API,在文档中记录:torch.utils.checkpoint.CheckpointPolicy、torch.utils.checkpoint.SelectiveCheckpointContext、torch.utils.checkpoint.create_selective_checkpoint_contexts、torch.utils.checkpoint.set_checkpoint_debug_enabled。对应资料 PR:https://gitcode.com/Ascend/pytorch/merge_requests/36231 > - 内部函数,不在文档中记录:torch.utils.checkpoint.detach_variable。 # 【接口变更】 > 不涉及。API 源码无修改,不新增、删除或变更对外接口。 # 【功能验证】 > 已在 2.12.0 对应 torch-npu 环境执行新增用例,结果如下;master 使用 2.12.0 验证环境执行。 ## 验证环境 - 操作系统:Ubuntu / Linux aarch64 - 昇腾硬件:910B2 - CANN 软件版本:8.3.RC1 - 验证环境: - 2.7.1:torch 2.7.1+cpu / torch-npu 2.7.1.post3 - 2.9.0:torch 2.9.0+cpu / torch-npu 2.9.0.post1 - 2.10.0:torch 2.10.0+cpu / torch-npu 2.10.0rc3 - 2.11.0:torch 2.11.0+cpu / torch-npu 2.11.0rc1 - 2.12.0 / master 验证:torch 2.12.0+cpu / torch-npu 2.12.0.rc1 ## 运行命令与结果 bash python test/test_utils_checkpoint_api.py Ran 4 tests in 1.612s OK # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37240 | 2 个月前 | |
test(utils): add data worker API coverage tests on NPU Co-authored-by: Jinfan Liu<1300083451@qq.com> # message auto-generated for no-merge-commit merge: !37246 merge test-utils-data-weak-npu-2.12.0 into v2.12.0 test(utils): add data worker API coverage tests on NPU Created-by: JfanLiu Commit-by: Jinfan Liu Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/2027**</font> > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> [x] issue/工单 # 【修改方案】 一、API功能说明 本 PR 补充 torch.utils.data worker/control 弱覆盖 API 的直接验证用例: - torch.utils.data.dataloader._MultiProcessingDataLoaderIter - torch.utils.data.dataloader._InfiniteConstantSampler - torch.utils.data._utils.worker.ManagerWatchdog - torch.utils.data._utils.worker._IterableDatasetStopIteration - torch.utils.data._utils.worker._ResumeIteration - torch.utils.data._utils.signal_handling._set_worker_signal_handlers - torch.utils.data._utils.signal_handling._remove_worker_pids 上述 API 属于 DataLoader 多进程 iterator、IterableDataset 采样控制、worker 存活检查、worker 控制消息以及 worker 信号/pid 管理逻辑。 二、测试用例完备性说明 PyTorch 官方社区 test/test_dataloader.py 已通过 DataLoader 多进程用例覆盖上述 API 的调用链,但缺少对部分内部对象和控制消息的直接行为断言。本 PR 按 1.3 类补充 torch-npu 自定义测试文件 test/test_utils_data_api.py。 1. torch.utils.data.dataloader._MultiProcessingDataLoaderIter 直接覆盖: - test_multiprocessing_dataloader_iter_type_and_shutdown 构造 num_workers=1 的 DataLoader,显式断言 iter(loader) 是 _MultiProcessingDataLoaderIter,并验证 next(iterator) 返回预期 batch,最后调用 _shutdown_workers() 覆盖正常关闭路径。 2. torch.utils.data.dataloader._InfiniteConstantSampler 直接覆盖: - test_infinite_constant_sampler_yields_none 直接实例化 _InfiniteConstantSampler,并断言连续 yield None,覆盖 IterableDataset 无限索引采样器的核心行为。 3. torch.utils.data._utils.worker.ManagerWatchdog 直接覆盖: - test_manager_watchdog_reports_parent_alive 直接构造 ManagerWatchdog,并断言正常父进程场景 is_alive() 为 True。 4. torch.utils.data._utils.worker._IterableDatasetStopIteration / torch.utils.data._utils.worker._ResumeIteration 直接覆盖: - test_worker_control_message_fields 直接构造两个 dataclass 控制消息,断言 worker_id、seed 字段和 repr 内容,覆盖 worker 耗尽通知与 persistent worker 恢复消息的对象行为。 5. torch.utils.data._utils.signal_handling._set_worker_signal_handlers / torch.utils.data._utils.signal_handling._remove_worker_pids 直接覆盖: - test_worker_signal_handlers_and_pid_cleanup 直接调用 _set_worker_signal_handlers,并通过 _set_worker_pids 注册当前 pid 后调用 _remove_worker_pids 清理,覆盖 C 侧 worker signal handler 初始化和 worker pid registry 清理入口的正常路径。 本文件验证的是 DataLoader worker/control 面 API。为避免把验证目标混入 NPU IPC 和 worker 子进程设备 Tensor 传输,本新增用例中的多进程 DataLoader 使用 Python 字符串 payload,不在 worker 子进程返回 NPU Tensor;原 DataLoader NPU Tensor payload 路径已由 test_upstream 中单进程 DataLoader/collate 用例覆盖。 三、NPU适配方案 1. API 源码无需修改:上述 API 是 torch.utils.data 的 Python/C++ 控制面入口,不新增 NPU kernel,不改变接口语义。 2. 测试新增路径:新增 test/test_utils_data_api.py,文件聚焦 worker/control API 直接行为,可后续扩展同模块 API。 3. 分支提交范围:新增测试文件提交到 2.7.1、2.9.0、2.10.0、2.11.0、2.12.0 以及 master。 四、变更文件 - test/test_utils_data_api.py # 【资料变更】 > 已检查资料支持情况,结论如下: > > dataloader: > - 公开 API,在文档中记录:torch.utils.data.DataLoader、torch.utils.data._utils.collate.collate。对应资料 PR:https://gitcode.com/Ascend/pytorch/merge_requests/36233 > - 内部函数/类,不在文档中记录:DataLoader iterator、worker、signal handling、persistent worker 相关内部对象。 # 【接口变更】 > 不涉及。API 源码无修改,不新增、删除或变更对外接口。 # 【功能验证】 > 已在 2.12.0 对应 torch-npu 环境执行新增用例,结果如下;master 使用 2.12.0 验证环境执行。 ## 验证环境 - 操作系统:Ubuntu / Linux aarch64 - 昇腾硬件:910B2 - CANN 软件版本:8.3.RC1 - 验证环境: - 2.7.1:torch 2.7.1+cpu / torch-npu 2.7.1.post3 - 2.9.0:torch 2.9.0+cpu / torch-npu 2.9.0.post1 - 2.10.0:torch 2.10.0+cpu / torch-npu 2.10.0rc3 - 2.11.0:torch 2.11.0+cpu / torch-npu 2.11.0rc1 - 2.12.0 / master 验证:torch 2.12.0+cpu / torch-npu 2.12.0.rc1 ## 运行命令与结果 bash python test/test_utils_data_api.py Ran 5 tests in 1.467s OK # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37246 | 2 个月前 | |
fix(npu): register QuantizedPrivateUse1 view/ravel/flatten for test_view_ops. Co-authored-by: Margaret_wangrui<wangrui178@huawei.com> # message auto-generated for no-merge-commit merge: !36702 merge v2.12.0_view_0524 into v2.12.0 fix(npu): register QuantizedPrivateUse1 view/ravel/flatten for test_view_ops. Created-by: Margaret_wangrui Commit-by: Margaret_wangrui Merged-by: ascend-robot Description: # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/2082 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 **问题简述:** 将 PyTorch 上游 test/test_view_ops.py 切换到 torch_npu 执行时,test_ravel_npu、test_flatten_npu 在处理 torch._empty_affine_quantized(..., quint8, device=npu) 量化张量时报错: text NotImplementedError: Could not run 'aten::view' with arguments from the 'Quantizednpu' backend 浮点 NPU 张量(PrivateUse1)可正常 view;量化 NPU 张量(QuantizedPrivateUse1)缺少对应 kernel 注册。 --- # 【修改方案】 本 PR 为 **QuantizedPrivateUse1** 补齐 shape / copy 相关 dispatch,并与 op-plugin stride_copy 修复配合,使量化 NPU 张量上的 view / ravel / flatten 语义与上游用例一致。 **组件交互关系:** text test_ravel_npu / test_flatten_npu(量化 quint8 on NPU) │ ▼ TensorShape.cpp(torch_npu) QuantizedPrivateUse1 注册:view / ravel / contiguous / clone / empty* / _copy_from │ ├─► MetaData 不匹配时 clone 物化(NPUStorageDesc 与 view shape 对齐) │ ▼ TensorFactories.cpp(torch_npu) NPUNativeFunctions::clone(quant):int_repr + npu_stride_copy_out │ ▼ AsStridedKernelNpu.cpp(op-plugin,子模块 071a046) 小 nbytes int_repr stride_copy 稳定走 AsStrided **具体实现:** 1. **torch_npu/csrc/aten/common/TensorShape.cpp(+312 行)** - 通过 TORCH_LIBRARY_IMPL(aten, QuantizedPrivateUse1, m) 注册:view、as_strided、ravel、contiguous、clone、empty_like、empty.memory_format、empty_strided、_copy_from。 - 实现 npu_quantized_view_symint:基于 infer_size + computeStride,经 alias_with_sizes_and_strides_npu 构造 QTensorImpl view;stride 不兼容且可展平为 rank-1 时走 clone + view。 - 实现 npu_quantized_ravel:aten::contiguous → view(-1),避免 composite reshape 在 NPU 量化张量上短路。 - 实现 npu_quantized_contiguous:除 is_contiguous() 外检查行主 stride,必要时 clone 物化。 - npu_quantized_view_materialize_if_storage_desc_mismatch:当 MetaDataAreMatch(q)==false 时对 view 结果 clone(Contiguous)。 - NPUNativeFunctions::as_strided 增加量化分支,构造 QTensorImpl view。 2. **torch_npu/csrc/aten/common/TensorFactories.cpp(+202 行)** - 增强 NPUNativeFunctions::clone 量化路径:empty_like + SetDesc + int_repr stride_copy。 - MetaDataAreMatch 异常(如 transpose、view 后 storage desc 不一致)时,CPU int_repr staging + H2D 物化。 - stride_copy 后 int_repr slab 传播与 canonical 缓冲对齐(npu_quantized_clone_write_int_repr_payload)。 3. **test/test_view_ops.py** - 量化 NPU 张量不再强制 flat._base is src(允许 NPUStorageDesc 不匹配时的物化拷贝路径)。 - 修正 is_quantized / is_npu 为属性访问(非可调用方法)。 **变更规模:** text test/test_view_ops.py | 5 +- torch_npu/csrc/aten/common/TensorFactories.cpp | 202 +++ torch_npu/csrc/aten/common/TensorShape.cpp | 312 +++ --- # 【资料变更】 不涉及。 --- # 【接口变更】 不涉及跨代码仓或客户面可见的公开 API 变更。 **内部说明(ATen dispatch 层,非 Python 公开接口):** | 算子 | Dispatch Key | 变更类型 | |------|--------------|----------| | view / as_strided / ravel / contiguous / clone | QuantizedPrivateUse1 | 新增 kernel 注册 | | empty_like / empty.memory_format / empty_strided / _copy_from | QuantizedPrivateUse1 | 新增 kernel 注册 | 用户可见行为变化:NPU 上 quint8 等量化张量可正常执行 view、ravel、flatten(此前为 NotImplementedError)。 --- # 【功能验证】 **环境要求:** 已编译安装 torch_npu;NPU 设备可用。 **测试步骤:** bash python test/test_view_ops.py -v -k test_ravel_npu python test/test_view_ops.py -v -k test_flatten_npu **覆盖场景:** | 场景 | 验证点 | |------|--------| | 连续量化张量 5×5×5×5 | ravel() / flatten(0,-1) 与 view(-1) 一致 | | 空 shape 0×2×3、3×0×2 | numel=0 时 shape 与 view 链正确 | | 转置 + ravel(nc=True) | 非连续路径 contiguous().view(-1) 与 ravel() 一致 | | 多组 flatten 维度 | (0,2)、(1,2)、(-2,-1) 等与 view(-1) 展开顺序一致 | | 浮点 NPU 回归 | 同一用例文件中浮点张量路径不受影响 | **UT 看护:** - [x] 适配 test/test_view_ops.py(量化 NPU _base 断言放宽、is_quantized/is_npu 属性修正) **自验证:** 请在合入前补充 NPU 环境执行上述命令的通过截图或 CI 流水线链接。   --- # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36702 | 2 个月前 | |
Update onnx_test_common.py Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com> # message auto-generated for no-merge-commit merge: merge master-dev1 into master Update onnx_test_common.py 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!25485 | 10 个月前 | |
| 2 年前 | ||
【bugfix】npugraph_ex.scope.limit_core_num增加默认参数stream Co-authored-by: wangkai<wangkai579@huawei.com> # message auto-generated for no-merge-commit merge: !39058 merge v2.12.0-26.1.0 into v2.12.0-26.1.0 【bugfix】npugraph_ex.scope.limit_core_num增加默认参数stream Created-by: mihudan Commit-by: wangkai Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/2445 - [ ] 需求 - [ ] 问题单 - [ ] issue/工单 - [x] 重构优化 - [ ] 资料更新 torchair仓合入PR:【refeat】limit_core_num控核支持单算子和可选参数streamhttps://gitcode.com/Ascend/torchair/pull/3181 资料修改: 【doc】limit_core_num支持可选参数streamhttps://gitcode.com/Ascend/torchair/pull/3227 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” ex资料修改已合入 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” npugraph_ex接口增加默认参数,ex资料修改已合入,组内已检视 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 已增加传入stream参数场景  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!39058 | 1 个月前 | |
| 2 年前 | ||
| 2 年前 |
简介
test目录为TorchNPU相关的测试用例。
安装依赖
pip3 install -r requirements.txt
补全脚本
该操作需要联网
cd test
bash get_synchronized_files.sh
通过以上操作,会自动补齐testfiles_synchronized.txt和testfolder_synchronized.txt中的文件或文件夹。
跳过失败用例
export DISABLED_TESTS_FILE=./unsupported_test_cases/.pytorch-disabled-tests.json
如果不是在test目录下运行测试用例,需要传入.pytorch-disabled-tests.json的绝对路径。
执行方式
执行单个测试脚本
运行以test开头的文件。以test_autocast.py为例:
方式一:
python test_autocast.py
方式二:
python run_test.py -i test_autocast
说明:部分以test开头的脚本不是直接运行的脚本,比如jit中的测试脚本是通过test_jit.py执行的。
执行具体的用例
通过-k参数传入具体的用例名。以test_autocast.py为例:
方式一:
python test_autocast.py -v -k test_autocast_nn_fp32
方式二:
python run_test.py -v -i test_autocast -- -k test_autocast_nn_fp32
执行全量UT的方式
# 进入到test目录的上一级
cd ../
运行非分布式全量用例:
python ci/access_control_test.py --all
运行分布式全量用例:
python ci/access_control_test.py --distributed
FAQ
-
报错:"dictionary changed size during interation".
如果python 环境是3.8.1版本,报错在unitest/case.py中,可考虑是sys.modules被修改导致的。第三方包可能会有对sys.modules的修改,比如beartype。 此问题为python 3.8.1版本/3.9.0版本的已知bug,可按照 https://github.com/python/cpython/issues/73806 中修改方式修改,将
for v in sys.modules.values()改为for v in list(sys.modules.values())可用于复现问题的用例:
python test_jit.py -v -k test_annotated_empty_dict -
test_public_bindings.py 用例的功能
该用例是为了校验接口的公开规范性,如果该用例报错,请确认报错的接口是否要公开,并按照报错的提示进行修改。