| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
attention/ffn的aicpu算子提供torch_npu._afd的调用方式 Co-authored-by: panweicheng<panweicheng@huawei.com> # message auto-generated for no-merge-commit merge: !28865 merge v2.8.0 into v2.8.0 attention/ffn的aicpu算子提供torch_npu._afd的调用方式 Created-by: pwc10490 Commit-by: panweicheng 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!28865 | 7 个月前 | |
rewrite_dropout_meta_and_decompose Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33664 merge v2.8.0 into v2.8.0 rewrite_dropout_meta_and_decompose Created-by: sunhaolun Commit-by: sunhaolun Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [ ] issue/工单 - [x] 重构优化 - [ ] 资料更新 # 【修改方案】 把mlir和triton侧对dropout以及dropout_backward的meta和decompose注册整合到了新的文件torch_npu/utils/_npu_meta_registration.py中,避免框架中的多余注册,并添加了UT对dropout进行看护。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 补充UT,并且触发了框架的UT,运行通过。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33664 | 4 个月前 | |
HOST内存统计API对齐社区 Co-authored-by: luanchaowei<luanchaowei3@huawei.com> # message auto-generated for no-merge-commit merge: !29055 merge v2.8.0 into v2.8.0 HOST内存统计API对齐社区 Created-by: luanchaowei Commit-by: luanchaowei Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > > /kind bug > /kind task > /kind feature **What does this PR do / why do we need it**: 1.torch_npu.npu. empty_pin_memory_cache()更名为torch_npu.npu.host_empty_cache() 2.torch_npu.npu.pin_memory_stats()更名为torch_npu.npu.host_memory_stats() 3.删除torch_npu.npu.pin_memory_allocated()和torch_npu.npu.pin_memory_reserved() 4.补齐torch_npu.npu.host_memory_stats()其他指标 5.新增:torch_npu.npu.host_memory_stats_as_nested_dict() torch_npu.npu.reset_accumulated_host_memory_stats() torch_npu.npu. reset_peak_host_memory_stats() **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!29055 | 7 个月前 | |
| 1 年前 | ||
| 2 年前 | ||
[Feature] transfer_to_npu adapt cuda_default_generators Co-authored-by: l30044004<louyujing@huawei.com> # message auto-generated for no-merge-commit merge: !34209 merge v2.8.0 into v2.8.0 [Feature] transfer_to_npu adapt cuda_default_generators Created-by: louyujing Commit-by: l30044004 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> https://gitcode.com/Ascend/pytorch/issues/1789 - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) torch.cuda.default_generators在NPU上需要迁移为torch_npu.npu.default_generators,且必须是设备init完成之后 使用torch_npu.npu._lazy_call的方式,在设备init完成之后,才使patch生效 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!34209 | 3 个月前 | |
[Feature]rename head file and add cmake for libtorch_npu | 2 年前 | |
fix: fix from blob bug Co-authored-by: luochao60<luochao60@huawei.com> # message auto-generated for no-merge-commit merge: !33190 merge pta_fix_from_blob_20260212_v2.8.0 into v2.8.0 fix: fix from blob bug Created-by: luochao60 Commit-by: luochao60 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > (如有)请关联需求文档/issue链接 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列 > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 修复 torch_npu/csrc/aten/common/from_blob.cpp 中 TensorMaker::computeStorageSize() 计算 storage size 时对 storage_offset_ 的处理 bug:原代码将 storage_offset_(按元素数计)直接累加到字节大小上,缺少 * itemsize,导致非 float32 类型或带偏移的 tensor 计算出的 storage size 偏小,from_blob 创建的 tensor storage 不足。修复后两处分支均改为 storage_size += storage_offset_.value() * itemsize;。 2. 修复 torch_npu/csrc/npu/Module.cpp 中 _weak_ref_tensor 实现:原实现通过 t.data_ptr() + t.sizes() + t.strides() 调用 from_blob 构造新 tensor,丢失了原 tensor 的 storage_offset 信息,且当原 tensor 是 view(带 offset 或非平凡 stride)时,新 tensor 的 storage 会被错误地按视图形状重新计算,与原 storage 不一致。修复方式:基于原 tensor 的完整 storage().mutable_data() 与 storage().nbytes() / element_size() 调用 from_blob 构造新 tensor(覆盖完整 storage),随后通过 set_sizes_and_strides 与 set_storage_offset 还原原 tensor 的视图信息,确保弱引用 tensor 的 storage、sizes、strides、offset 与原 tensor 完全一致。 3. 测试用例重构与新增: - 将原本散落在 test/cpp_extensions/extension.cpp 中的 from_blob 相关测试(check_from_blob/check_from_blob_strides/check_from_blob_delete)迁移到独立的 test/cpp_extensions/test_from_blob.cpp,按 at_npu::native::from_blob 接口能力分门别类组织。 - test/cpp_extensions/setup.py 注册新的扩展模块 torch_test_cpp_extension.npu_from_blob。 - test/cpp_extensions/test/test_cpp_extensions_aot.py 新增 TestFromBlob 测试类,覆盖 basic / deleter / strides / storage_offset / storage_offset_2d / storage_offset_dtype / storage_offset_contiguous / non_owning / clone 等场景;test_storage_sizes 增加 @SupportedDevices(['Ascend910B', 'Ascend910C']) 限制。 - test/npu/test_npu_format.py 新增 test_weak_ref_tensor_with_storage_offset 用例,构造带非平凡 stride 与 storage_offset 的 view,验证 _weak_ref_tensor 返回的 tensor 在 size、stride、storage_offset、storage().nbytes() 与数值上都与原 tensor 一致。 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写"不涉及" 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写"不涉及" 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤 > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 1. C++ 扩展用例 test/cpp_extensions/test/test_cpp_extensions_aot.py::TestFromBlob:覆盖 at_npu::native::from_blob 在 basic、自定义 deleter、显式 strides、带 storage_offset、二维带 offset、不同 dtype、contiguous 标志、non-owning 语义、clone 后数据正确性等场景,验证修复后 storage 计算正确。 2. Python 用例 test/npu/test_npu_format.py::TestNPUFormat::test_weak_ref_tensor_with_storage_offset:构造 view_shape=[2,1,8,64]、view_strides=[1536,0,192,1]、view_offset=128 的 strided view,验证 _weak_ref_tensor 保持 size/stride/offset/storage 字节数一致且数值相等。 3. UT 已随 PR 一同提交,本地自验证通过。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33190 | 4 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
【API】Add custom validation cases for HealthCheckServer APIs Co-authored-by: JfanLiu<1300083451@qq.com> # message auto-generated for no-merge-commit merge: !34494 merge test-healthcheck-server-api-v2.8.0 into v2.8.0 【API】Add custom validation cases for HealthCheckServer APIs Created-by: JfanLiu Commit-by: JfanLiu Merged-by: ascend-robot Description: 环境信息 操作系统:AlmaLinux 8.10 架构:aarch64 CANN 软件版本:8.5.0 安装的软件版本:torch 2.8.0+cpu、torch-npu 2.8.0.post2 一、4 个 API 功能如下: 1. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer elastic agent 健康检查服务的接口类。构造函数接收 alive_callback、port、timeout,并将三项配置保存到实例属性 _alive_callback、_port、_timeout,供后续 health check server 实现复用。当前社区实现是 noop health check server,不创建 socket、不启动后台线程、不访问设备资源。 2. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer.start 健康检查服务启动入口。当前社区实现保持 noop 行为,只通过 health_check_server logger 输出 WARNING 日志 No health check server started。该接口用于保持 elastic agent 健康检查启动链路的统一调用形态。 3. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer.stop 健康检查服务停止入口。当前社区实现保持 noop 行为,只通过 health_check_server logger 输出 INFO 日志 Stopping noop health check server.。该接口不维护额外运行状态,也不释放外部资源。 4. torch.distributed.elastic.agent.server.health_check_server.create_healthcheck_server 模块级 factory 函数。函数接收 alive_callback、port、timeout,返回 HealthCheckServer(alive_callback, port, timeout)。该函数的核心语义是返回类型固定、三项参数原样透传、创建阶段不执行 alive_callback。 二、社区用例对这 4 个 API 的验证完整性分析 搜索了官方 test 目录,搜了 HealthCheckServer、health_check_server、create_healthcheck_server,没有搜到,说明 4 个 API 没有直接测试用例。 1. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer 官方 test 目录未发现直接构造 HealthCheckServer 并校验 _alive_callback、_port、_timeout 的用例,也未发现构造阶段不触发 callback 的断言。构造参数保存和无副作用构造语义缺少直接覆盖。 2. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer.start 官方 test 目录未发现调用 start() 并校验 logger 名称、日志级别、日志内容的用例。当前 noop start 的外部可观察行为缺少直接覆盖。 3. torch.distributed.elastic.agent.server.health_check_server.HealthCheckServer.stop 官方 test 目录未发现调用 stop() 并校验 logger 名称、日志级别、日志内容的用例,也未发现 stop() 重复调用稳定性的验证。当前 noop stop 的外部可观察行为和幂等调用语义缺少直接覆盖。 4. torch.distributed.elastic.agent.server.health_check_server.create_healthcheck_server 官方 test 目录未发现调用 create_healthcheck_server() 并校验返回类型、alive_callback/port/timeout 参数透传、创建阶段不触发 callback 的用例。factory 函数的类型约束、参数传递和无副作用创建语义缺少直接覆盖。 三、NPU 适配 3.1 API 适配 这 4 个 API 属于 torch.distributed.elastic.agent.server.health_check_server 控制面逻辑。 这些 API 不执行 Tensor 计算,不涉及 NPU kernel、算子适配、计算图构建、精度对比、CANN runtime 或 HCCL 通信。 3.2 测试用例适配 本 PR 在 torch-npu test 目录新增自定义测试文件: - test/distributed/elastic/agent/server/test_healthcheckserver_api.py 测试文件覆盖以下用例: 1. test_init:直接构造 HealthCheckServer(alive_callback, 0, 30),校验 _alive_callback、_port、_timeout 与入参一致,并校验构造阶段没有调用 alive_callback。 2. test_create_healthcheck_server:调用 create_healthcheck_server(alive_callback, 0, 45),校验返回对象是 HealthCheckServer,校验 alive_callback、port、timeout 原样传入实例,并校验 factory 阶段没有调用 alive_callback。 3. test_start_logs_warning:调用 start(),使用 assertLogs 捕获 torch.distributed.elastic.agent.server.health_check_server logger 的 WARNING 记录,校验只产生 1 条日志,且 message 精确等于 No health check server started。 4. test_stop_logs_info:调用 stop(),使用 assertLogs 捕获 torch.distributed.elastic.agent.server.health_check_server logger 的 INFO 记录,校验只产生 1 条日志,且 message 精确等于 Stopping noop health check server.。 5. test_start_stop_lifecycle_safe:按 start() -> stop() 顺序执行完整生命周期调用,校验 noop 实现不抛异常,覆盖常规调用链。 6. test_stop_idempotent:执行 start() 后连续调用 stop() 三次,校验重复 stop() 不抛异常,覆盖停止接口的幂等调用场景。 3.3 文档修改 本测试 PR 不修改 docs 文件。docs 支持项由独立 docs PR 补齐。 四、运行日志 python test/distributed/elastic/agent/server/test_healthcheckserver_api.py ...W0428 12:03:38.190000 11500 torch_npu_2.8.0/lib/python3.11/site-packages/torch/distributed/elastic/agent/server/health_check_server.py:48] No health check server started .W0428 12:03:38.191000 11500 torch_npu_2.8.0/lib/python3.11/site-packages/torch/distributed/elastic/agent/server/health_check_server.py:48] No health check server started .. ---------------------------------------------------------------------- Ran 6 tests in 1.377s OK See merge request: Ascend/pytorch!34494 | 3 个月前 | |
修改npugraph_ex.compile_fx接口签名 Co-authored-by: wangkai<wangkai579@huawei.com> # message auto-generated for no-merge-commit merge: !32080 merge v2.8.0 into v2.8.0 修改npugraph_ex.compile_fx接口签名 Created-by: mihudan Commit-by: wangkai Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [x] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 修改npugraph_ex.compile_fx接口 compile_fx(gm, example_inputs=None, options=None) # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 资料已对应修改:https://gitcode.com/Ascend/torchair/pull/2744 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 资料已对应修改:https://gitcode.com/Ascend/torchair/pull/2744 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 对应用例也已同步修改  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32080 | 4 个月前 | |
| 2 年前 | ||
| 1 年前 | ||
test(fx): add NPU tests for torch.fx graph APIs Co-authored-by: zhouzirui1234<2490136803@qq.com> # message auto-generated for no-merge-commit merge: !35514 merge intern/fx-graph-api-tests-v2-8-0 into v2.8.0 test(fx): add NPU tests for torch.fx graph APIs Created-by: zhouzirui-2026 Commit-by: zhouzirui1234 Merged-by: ascend-robot Description: # 【合入来源】 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 关联 issue: - 任务 issue:https://gitcode.com/Ascend/pytorch/issues/1634 # 【修改方案】 本 PR 新增 test/fx/test_fx_graph_api.py,补充 torch.fx Graph 相关 API / 内部 codegen 链路在 NPU 环境下可直接运行的轻量验证用例。测试中涉及 Tensor 的输入均通过 .to(device_type) 放到当前 accelerator 上执行。 任务 API 功能及上游社区用例情况如下: | API / 内部链路 | 功能说明 | 上游社区用例情况 | 本 PR 处理 | | --- | --- | --- | --- | | torch.fx.Graph.inserting_after | 设置 FX Graph 插入点,使后续新节点插入到指定节点之后。 | PyTorch 上游 test/quantization/fx/test_model_report_fx.py::TestFxModelReportDetectDynamicStatic.test_nested_detection_case 中有使用,但该用例在当前 Kunpeng/ARM 环境会因 FBGEMM 条件被 skip,无法直接进入目标主体。 | 参考上游构图方式,新增轻量 NPU 测试直接验证插入顺序、节点参数传递和 NPU 执行结果。 | | torch.fx.Graph.inserting_before | 设置 FX Graph 插入点,使后续新节点插入到指定节点之前。 | PyTorch 上游 test/test_fx.py::TestFX.test_insertion_point 已有直接用例,但当前环境运行 test/test_fx.py 会受 libtorchbind_test.so 缺失影响。 | 新增独立轻量 NPU 测试,避免大文件环境依赖,同时验证插入顺序、参数重写和 NPU 执行结果。 | | torch.fx.Graph.lint | 校验 FX Graph 结构合法性,包括节点拓扑顺序、引用关系、owner、target 等约束。 | PyTorch 上游 test/test_fx.py 已有直接专项测试,例如 TestFX.test_wrong_topo、TestFX.test_copy_no_remap。 | 不重复新增 lint 专项测试;本 PR 仅在新增测试中调用 graph.lint() 校验所构造图的合法性。 | | torch.fx.graph.magic_methods.format | torch.fx.graph 内部 codegen 模板链路,用于生成 magic method 对应的 Python 表达式。 | PyTorch 上游 test/test_fx.py::TestFX.test_fx_shifts 通过 shift 表达式覆盖相关 codegen 链路。 | 新增 NPU 测试,通过 symbolic_trace 验证 Proxy 节点生成、节点参数、codegen 文本和 NPU 执行结果。 | | torch.fx.graph.inplace_methods.format | torch.fx.graph 内部 inplace codegen 模板链路,用于生成 inplace 操作对应的 Python 代码。 | PyTorch 上游 test/test_fx.py::TestFX.test_imul_code_print 通过 operator.imul 覆盖 inplace codegen。 | 新增 NPU 测试,手动构造 operator.imul 节点触发 a *= b codegen,并验证节点参数、输出结果和输入 Tensor 原地更新。 | 主要开发思路: 1. 先复查 PyTorch 上游社区用例,确认 5 个任务 API / 内部链路的已有覆盖情况。 2. 对 torch.fx.Graph.lint,上游已有直接专项测试,因此本 PR 不重复新增 lint 测试。 3. 对 torch.fx.Graph.inserting_after,上游 quantization 用例会因当前 Kunpeng/ARM 环境不支持 FBGEMM 被 skip,因此参考其插入点使用方式新增轻量测试。 4. 对 torch.fx.Graph.inserting_before、torch.fx.graph.magic_methods.format、torch.fx.graph.inplace_methods.format,上游相关用例集中在 test/test_fx.py,该文件在当前环境存在 libtorchbind_test.so 依赖问题,因此新增独立小文件验证核心行为。 5. 新增测试聚焦 FX 图构建、Proxy 生成、节点 target、节点参数传递、codegen 文本以及 NPU Tensor 执行结果,不修改 API 实现。 本 PR 覆盖以下 4 个新增测试目标项: | API / 内部链路 | 验证内容 | | --- | --- | | torch.fx.Graph.inserting_after | 验证 FX Graph 插入点设置后,新节点可插入到指定节点之后,并校验节点顺序、节点参数传递、节点 target 以及 NPU 执行结果。 | | torch.fx.Graph.inserting_before | 验证 FX Graph 插入点设置后,新节点可插入到指定节点之前,并校验节点顺序、节点参数传递、节点 target 以及 NPU 执行结果。 | | torch.fx.graph.magic_methods.format | 通过 symbolic_trace 触发 Proxy 生成链路,验证 operator.lshift / operator.rshift 节点生成、参数传递、生成代码格式以及 NPU 执行结果。 | | torch.fx.graph.inplace_methods.format | 手动构造 operator.imul FX 节点,验证 inplace codegen 生成 a *= b、节点参数传递、NPU 执行结果以及输入 Tensor 被原地更新。 | 本 PR 不新增 torch.fx.Graph.lint 专项测试,原因如下: 1. 复查 PyTorch 官方 test/test_fx.py,torch.fx.Graph.lint 已有直接专项测试覆盖,例如 TestFX.test_wrong_topo、TestFX.test_copy_no_remap 等。 2. 本 PR 新增的 4 个测试中也在构造或 trace 完 FX Graph 后调用 graph.lint(),用于校验测试图结构合法性,但不把它作为本 PR 的新增目标 API。 本 PR 不修改 API 实现,不修改 test/test_fx.py。新增独立测试文件 test/fx/test_fx_graph_api.py,避免受 test/test_fx.py 中历史环境依赖 libtorchbind_test.so 缺失问题影响。 新增测试文件: text test/fx/test_fx_graph_api.py 新增测试方法: text test_graph_inserting_after test_graph_inserting_before test_magic_methods_format_codegen test_inplace_methods_format_codegen 各测试核心验证点如下: | 测试方法 | 核心验证点 | | --- | --- | | test_graph_inserting_after | 构造 placeholder -> neg -> relu -> output;使用 graph.inserting_after(neg);断言 relu 紧跟 neg;断言 neg.args == (x,)、relu.args == (neg,)、relu.target == torch.relu;在 NPU Tensor 上执行 GraphModule 并校验结果。 | | test_graph_inserting_before | 先构造 placeholder -> relu -> output;使用 graph.inserting_before(relu) 插入 neg;断言 neg 位于 relu 前且相邻;断言 neg.args == (x,)、relu.args == (neg,)、neg.target == torch.neg;在 NPU Tensor 上执行 GraphModule 并校验结果。 | | test_magic_methods_format_codegen | 使用 symbolic_trace trace x << 3, x >> 3;断言 FX Graph 中生成 operator.lshift / operator.rshift 节点;断言节点参数为 (x_node, 3);断言 codegen 包含 x << 3、x >> 3;在 NPU LongTensor 上执行并校验结果。 | | test_inplace_methods_format_codegen | 手动构造 operator.imul(a, b) 节点;断言节点参数和 target;断言 codegen 包含 a *= b;在 NPU Tensor 上执行并校验输出结果,同时校验输入 Tensor 被原地更新。 | # 【资料变更】 当前不涉及资料补齐 PR。三个公开 torch.fx.Graph.* API 已在 docs/zh/native_apis 中记录;两个 torch.fx.graph.*.format 项为内部 codegen 字典模板链路,不宜按普通公开 API 强行补入 native API 表。 # 【接口变更】 不涉及。 # 【功能验证】 执行命令: bash cd /root python /workspace/pytorch/test/fx/test_fx_graph_api.py 执行结果: text .... ---------------------------------------------------------------------- Ran 4 tests in 7.673s OK 最终验证结论: 1. 本 PR 新增 4 个轻量 NPU 测试,覆盖 inserting_after、inserting_before、magic_methods.format、inplace_methods.format。 2. 新增测试不仅验证 API 调用不崩溃,也验证 FX 图构建、Proxy 生成、节点 target、节点参数传递、codegen 文本和 NPU Tensor 执行结果。 3. torch.fx.Graph.lint 已有 PyTorch 官方直接专项测试覆盖,因此本 PR 不重复新增 lint 专项测试。 4. 本 PR 不修改 API 实现,不涉及资料变更和接口变更。 # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35514 | 2 个月前 | |
| 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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
[sync] PR-34629: skip ci error (update cann) Co-authored-by: SCh_zx<1325467101@qq.com> # message auto-generated for no-merge-commit merge: !35718 merge sync-pr34629-v2.10.0-26.0.0-to-v2.8.0 into v2.8.0 [sync] PR-34629: skip ci error (update cann) 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/34629 ### 2. Original pull request related issue(s): https://gitcode.com/Ascend/pytorch/issues/1749 ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[607d7a42](https://gitcode.com/Ascend/pytorch/commit/607d7a42c2cb3b26e1610398cb2a282e0979b0c3)|2026-04-28 17:04:19 +0800 CST|skip ci error<br><br>Signed-off-by: SCh_zx <1325467101@qq.com>| See merge request: Ascend/pytorch!35718 | 3 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
AI assist developer for python dt v2.8.0 Co-authored-by: aksksks<mengzichao@h-partners.com> # message auto-generated for no-merge-commit merge: !26536 merge v2.8.0 into v2.8.0 AI assist developer for python dt v2.8.0 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!26536 | 8 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
refactor: replace hard-coded dispatch with Registry + Template Method for NPU Graph op handlers Co-authored-by: suhaibo<suhaibo1@huawei.com> # message auto-generated for no-merge-commit merge: !31271 merge v2.8.0 into v2.8.0 refactor: replace hard-coded dispatch with Registry + Template Method for NPU Graph op handlers Created-by: suhaibo Commit-by: suhaibo Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 拓展aclgraph update功能,支持自定义算子注册update能力,避免侵入式修改pta源码 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” <span style="color:#0066cc;">新增register_npu_graph_handler和NpuGraphOpHandler对外接口</span> # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!31271 | 5 个月前 | |
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !32255 merge 2.8ut into v2.8.0 test update ut Created-by: huangyunlong2022 Commit-by: huangyunlong2022 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 更新ut # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32255 | 4 个月前 | |
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
add test case for event elapsed_time Co-authored-by: chenkun<chenkun82@huawei.com> # message auto-generated for no-merge-commit merge: !26733 merge v2.8.0_event_ut into v2.8.0 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!26733 | 8 个月前 | |
feat(autocast): 支持float32作为自动混合精度计算的数据类型 Co-authored-by: leland17<lileliao@foxmail.com> # message auto-generated for no-merge-commit merge: !30513 merge v2.8.0 into v2.8.0 feat(autocast): 支持float32作为自动混合精度计算的数据类型 Created-by: leland17 Commit-by: leland17 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > (如有)请关联需求文档/issue链接 issue:[支持float32作为自动混合精度计算的数据类型](https://gitcode.com/Ascend/pytorch/issues/1537) - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 当前现状with autocast(device="npu", dtype=torch.float32)暂时不支持按照float32的精度获取结果。同liwei有过详细的讨论方案,并且确定了如下的支持思路 在autocast_utils.py中支持float32的数据类型支持。 # 【资料变更】 > 不涉及 # 【接口变更】 > 不涉及 # 【功能验证】 bash cd ${pytorch}/test && python -m unittest test_autocast.TestAutocastNPUfp32 新增4个用例场景,验证暂无问题  整体test_autocast.py的用例执行结果  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!30513 | 6 个月前 | |
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33712 merge v2.8.0 into v2.8.0 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!33712 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33712 merge v2.8.0 into v2.8.0 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!33712 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33712 merge v2.8.0 into v2.8.0 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!33712 | 4 个月前 | |
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33712 merge v2.8.0 into v2.8.0 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!33712 | 4 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
add group_type=2 meta tests and negative cases for npu_grouped_matmul Co-authored-by: XianglongZeng<zengxianglong1@huawei.com> # message auto-generated for no-merge-commit merge: !34653 merge v2.8.0 into v2.8.0 add group_type=2 meta tests and negative cases for npu_grouped_matmul 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/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 ## 1. meta 层(fake tensor)测试 | 用例ID | 场景 | split_item | group_type | 验证要点 | |---|---|---|---|---| | meta_g2_1 | K轴分组 fp16 单单单 | 2 | 2 | 输出为 3D shape=(num_groups, M, N) | | meta_g2_2 | K轴分组 fp16 单单单 | 3 | 2 | 输出为 3D shape=(num_groups, M, N) | ## 2.异常场景看护用例 | 测试文件 | 用例名称 | 测试内容 | |---|---|---| | test/test_fake_tensor.py | test_npu_grouped_matmul_meta_invalid_group_type | group_type=1/3/100 应抛出 group_type only supports 错误 | # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】    # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!34653 | 3 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 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: !34073 merge add-test-hub-help-api-v2.8.0 into v2.8.0 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!34073 | 3 个月前 | |
| 2 年前 | ||
fix: skip test_index_put_accumulate_large_tensor Co-authored-by: zhanw_coding<zhanwang@huawei.com> # message auto-generated for no-merge-commit merge: !31417 merge v2.8.0 into v2.8.0 fix: skip test_index_put_accumulate_large_tensor Created-by: zhanw_coding Commit-by: zhanw_coding Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 门禁A1机器cann8.5.0 AsStrided124 算子报错 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!31417 | 5 个月前 | |
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: !32382 merge fixtest-jit-api-2.8.0 into v2.8.0 fix(jit): fix test for jit api: torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load Created-by: dinglaiping Commit-by: dinglaiping Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1597**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] issue/工单 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 2.7.1及以上版本提示additional_module_tests、new_module_tests和module_tests找不到,要把additional_module_tests换成get_all_nn_module_tests并且删除new_module_tests和module_tests,最后在调用的时候使用get_all_nn_module_tests()。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 整体结论: 本次验证基于torch-npu 官方test_jit.py用例全量复用的方式,在完成最小化的文件、代码、环境适配后,于 NPU环境下完成torch.jit.script、torch.jit.trace、torch.jit.save、torch.jit.load四个核心 API 的全量验证,所有指定的测试方法均执行成功。验证结果表明,torch-npu 官方 JIT 用例可完整覆盖四个 API 的核心功能,使用官网用例完成 NPU 适配验证已足够;四个 API 在 NPU环境下的基础能力、协同逻辑均正常可用,完全满足 NPU 场景下模型编译优化、序列化部署、跨设备迁移、推理执行的实际业务需求。 1. torch.jit.script:官方用例中函数重复脚本化操作正常,脚本化模型的序列化 / 反序列化无数据丢失,NPU 设备下编译后模型的参数、设备属性与原模型保持一致,编译优化逻辑正常生效; 2. torch.jit.trace:官方用例中追踪化过程可完整保留模型的 train/eval 状态,字典类型可正常作为示例输入完成追踪,NPU 设备下追踪化模型的前向传播执行正常,输出结果与原模型一致; 3. torch.jit.save:官方用例中模型可成功保存至 zip 压缩包格式,保存过程中可完整保留 NPU 设备信息与模型全状态(参数、缓冲区、计算图),序列化过程无数据遗漏或损坏; 4. torch.jit.load:官方用例中可成功还原模型保存时的 NPU 设备信息,模型中自定义方法可正常导入并调用,zip 压缩包格式的模型可正确解析,加载后模型可直接在 NPU 上推理,执行结果与保存前模型一致。 运行日志: root@hostname-fqv42:~/torchnpuapi/torch-npu/2.7.1/pytorch/test# python -m unittest test_jit.TestJit.test_restore_device test_jit.TestJit.test_import_method test_jit.TestJit.test_torch_load_zipfile_check test_jit.TestScript.test_repeated_script_on_function test_jit.TestJit.test_script_fn_pkl test_jit.TestJit.test_trace_retains_train test_jit.TestFrontend.test_dictionary_as_example_inputs_for_jit_trace -v monkeytype is not installed. Skipping tests for Profile-Directed Typing test_restore_device (test_jit.TestJit.test_restore_device) ... ok test_import_method (test_jit.TestJit.test_import_method) ... ok test_torch_load_zipfile_check (test_jit.TestJit.test_torch_load_zipfile_check) ... ok test_repeated_script_on_function (test_jit.TestScript.test_repeated_script_on_function) ... ok test_script_fn_pkl (test_jit.TestJit.test_script_fn_pkl) ... ok test_trace_retains_train (test_jit.TestJit.test_trace_retains_train) ... ok test_dictionary_as_example_inputs_for_jit_trace (test_jit.TestFrontend.test_dictionary_as_example_inputs_for_jit_trace) ... ok ---------------------------------------------------------------------- Ran 7 tests in 0.104s OK root@hostname-fqv42:~/torchnpuapi/torch-npu/2.7.1/pytorch/test# # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32382 | 4 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
test: add test for multiprocessing Co-authored-by: HeYang<heyang88@h-partners.com> # message auto-generated for no-merge-commit merge: !32098 merge v2.8.0 into v2.8.0 test: add test for multiprocessing Created-by: VnOcean Commit-by: HeYang Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 [[Usage]: test 目录下 torch.multiprocessing 的 Array、get_start_method、set_start_method等测试用例缺失。](https://gitcode.com/Ascend/pytorch/issues/1584?ref=&did=3810729#tid-3810729) > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] issue/工单 # 【修改方案】 ## 设计原则 该测试用例的设计遵循了三个核心原则:聚焦核心、贴合场景、轻量化。 ## 核心思路 测试用例的核心思路围绕跨进程数据共享与通信展开,通过五个典型场景验证多进程编程的正确性: 1. 共享内存模式测试Value和Array时,创建子进程对共享数据进行修改,主进程验证修改结果,直观展示了多进程间数据共享的基本原理——共享内存在不同进程地址空间中的可见性。 2. 管道通信模式测试Pipe时,构建了双向通信场景:子进程发送多种类型数据(字符串、整数、列表),父进程接收验证;随后测试请求-响应模式,验证了管道作为双向通信通道的可靠性。 3. 管理器模式测试展示了比共享内存更高级的抽象,通过Manager创建共享列表、字典和命名空间,子进程的修改自动同步到主进程,体现了管理器服务进程作为代理的同步机制。 4. 张量规约测试特别针对NPU场景,验证了PyTorch张量在多进程环境下的序列化与反序列化能力,确保深度学习模型中的张量数据可以跨进程高效传递。 5. 多进程编程的核心本质是在独立进程地址空间之间,通过序列化、共享内存或代理服务等方式,建立安全可靠的数据交换通道,同时保持进程的独立性和并发执行能力。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 用例验证结果: python test_multiprocessing_api.py -v test_array (\__main__.TestMultiprocessingAPIs.test_array) Test Array API ... ok test_get_set_start_method (__main__.TestMultiprocessingAPIs.test_get_set_start_method) Test get_start_method and set_start_method APIs ... ok test_manager (__main__.TestMultiprocessingAPIs.test_manager) Test Manager API ... ok test_pipe (__main__.TestMultiprocessingAPIs.test_pipe) Test Pipe API ... ok test_reductions (__main__.TestMultiprocessingAPIs.test_reductions) Test reductions API ... ok test_value (__main__.TestMultiprocessingAPIs.test_value) Test Value API ... ok ---------------------------------------------------------------------- Ran 6 tests in 1.304s OK # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32098 | 4 个月前 | |
| 2 年前 | ||
add_test Co-authored-by: sunhaolun<sunhaolun3@huawei.com> # message auto-generated for no-merge-commit merge: !33712 merge v2.8.0 into v2.8.0 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!33712 | 4 个月前 | |
| 1 年前 | ||
[feat] add nestedtensor backend Co-authored-by: culechan<chenshuai81@huawei.com> # message auto-generated for no-merge-commit merge: !30979 merge cherry-pick-mr-30508-1771989684490-auto into v2.8.0 [feat] add nestedtensor backend Created-by: culechan Commit-by: culechan Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > (如有)请关联需求文档/issue链接 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 创建Nestedtensor相关的后端,参考quantized后端的实现,因为二者较为类似,因此在文件代码自动生成逻辑部分做了合并重构。 # 【资料变更】 > 不涉及 # 【接口变更】 > 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增已适配UT测试用例看护,并补充测试自验证截图  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!30979 | 5 个月前 | |
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: !32057 merge fixtest-nn-api-2.8.0 into v2.8.0 fix(nn): fix test for nn api: torch.nn.ParameterDict, torch.nn.ParameterList, torch.nn.Sequential Created-by: dinglaiping Commit-by: dinglaiping Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/1585**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] issue/工单 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 2.6.0版本提示skipIfMps找不到,要换成skipIfMPS。 2. 2.7及以上版本skipIfMps找不到,换成skipIfMPS;new_module_tests找不到,需要把导入new_module_tests改成导入get_new_module_tests并在调用的地方换成get_new_module_tests();tf32_on_and_off找不到,删掉导入,并在调用tf32_is_not_fp32()的地方换成调用torch.cuda.is_tf32_supported() # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 整体结论: 本次验证通过修复官网test_nn.py用例文件,验证3个API,功能正常: ParameterDict:官方用例中键值对索引、新增、删除、遍历等操作均正常,容器内所有参数设备统一为npu:0,无设备漂移问题; ParameterList:官方用例中数字索引、append新增、遍历等操作均正常,参数设备一致性与长度校验均通过,有序管理能力正常; Sequential:官方用例中getitem/setitem/delitem/append/insert/extend/pop等所有核心操作均正常执行,操作后子模块设备均保持为npu:0,动态扩展与元素管理能力完整。 运行日志: [root@hostname-fqv42 torchnpuapi]# docker exec -it test28 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!32057 | 4 个月前 | |
| 2 年前 | ||
[fix][2.8.0]add getMemoryFraction attribute for torch._C Co-authored-by: weixin_47897441<wuyouqi1@h-partners.com> # message auto-generated for no-merge-commit merge: !30793 merge v2.8.0 into v2.8.0 [fix][2.8.0]add getMemoryFraction attribute for torch._C Created-by: weixin_47897441 Commit-by: weixin_47897441 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > (如有)请关联需求文档/issue链接 - [ ] 需求 - [ ] 问题单 - [x] issue/工单 : torch._C不支持_npu_getMemoryFraction - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1、NPUCachingAllocator中新增getMemoryFraction方法及虚函数声明,Module中注册_npu_getMemoryFraction绑定; 2、在torch_npu.npu和torch_npu.npu.memory中实现并暴露get_per_process_memory_fraction接口,支持指定设备,调用底层 C++ 接口; 3、新增该接口的测试用例; 4、将该接口及底层Cpp绑定加入Dynamo追踪规则,完成适配。 # 【资料变更】 > 不涉及 # 【接口变更】 > 否 # 【功能验证】 > UT用例测试通过:python test_npu.py -v -k test_get_per_process_memory_fraction  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!30793 | 5 个月前 | |
add torch.npu.memory._set_allocator_settings(only support expandable_segments) and testcases Co-authored-by: zhaoyu<nanzhaogang@qq.com> # message auto-generated for no-merge-commit merge: !25984 merge v2.8.0 into v2.8.0 add torch.npu.memory._set_allocator_settings(only support expandable_segments) and testcases Created-by: zhaoyu65 Commit-by: zhaoyu Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > /kind feature **What does this PR do / why do we need it**: 1、增加torch_npu.npu.memory.\_set\_allocator\_settings接口,仅支持expandable_segments:True或expandable_segments:False场景。 2、增加对应的测试用例。 **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!25984 | 9 个月前 | |
Rollback for bugfix Co-authored-by: guoguanghao<guoguanghao@huawei.com> # message auto-generated for no-merge-commit merge: !25595 merge v2.8.0 into v2.8.0 Rollback for bugfix Created-by: guoguanghao Commit-by: guoguanghao 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!25595 | 10 个月前 | |
host allocator support pinned_use_background_threads Co-authored-by: zhaoyu<nanzhaogang@qq.com> # message auto-generated for no-merge-commit merge: !28843 merge v2.8.0 into v2.8.0 host allocator support pinned_use_background_threads Created-by: zhaoyu65 Commit-by: zhaoyu Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line: > /kind feature **What does this PR do / why do we need it**: host allocator 支持背景线程 **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**: 修改了namespace作用域内的缩进 See merge request: Ascend/pytorch!28843 | 7 个月前 | |
[bugfix] Add proper handling for view and factory function for csan, and supplement the corresponding test cases. Co-authored-by: chenkun<chenkun82@huawei.com> # message auto-generated for no-merge-commit merge: !26404 merge cherry-pick-mr-26401-1762829615088-auto into v2.8.0 [bugfix] Add proper handling for view and factory function for csan, and supplement the corresponding test cases. Created-by: kuhn7 Commit-by: chenkun Merged-by: ascend-robot Description: **What type of PR is this?** bug **What does this PR do / why do we need it**: 增加 ArgumentHander.parse_input() 缺失的 is_factory 参数, 并补充了相应的看护用例。 **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**: 开源社区对应改动如下: https://github.com/pytorch/pytorch/commit/c4ed03cea17d2ec9b09427786627bba479f4cb6b See merge request: Ascend/pytorch!26404 | 9 个月前 | |
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
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: !31979 merge cherry-pick-mr-31977-1773819107621-auto into v2.8.0 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!31979 | 4 个月前 | |
| 2 年前 | ||
| 1 年前 | ||
Update test_torch.py Co-authored-by: yuhaiyan<yuhaiyan8@huawei.com> # message auto-generated for no-merge-commit merge: !27368 merge v2.8.0-dev2 into v2.8.0 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!27368 | 8 个月前 | |
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
fix issues with npu_format_cast function parameters Co-authored-by: wangzhenwu7<5ge@live.com> Co-authored-by: wangzhenwu<wangzhenwu7@huawei.com> # message auto-generated for no-merge-commit merge: !32693 merge v2.8.0 into v2.8.0 fix issues with npu_format_cast function parameters Created-by: wangzhenwu Commit-by: GotFusion;wangzhenwu;wangzhenwu7 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” torch_npu.npu_format_cast参数声明与调用方式统一为关键字参数形式:(self, acl_format, *, customize_dtype=None)。同步调整ONNX wrapper相关测试调用,取消跳过相关测试用例:test_wrapper_npu_multi_head_attention,test_wrapper_npu_format_cast,test_wrapper_npu_gru,test_wrapper_npu_lstm,test_wrapper_npu_lstm_cell # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!32693 | 4 个月前 | |
| 2 年前 | ||
| 2 年前 |
简介
test目录为PTA相关的测试用例。
安装依赖
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 用例的功能
该用例是为了校验接口的公开规范性,如果该用例报错,请确认报错的接口是否要公开,并按照报错的提示进行修改。