| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
refactor for torch_npu init module. Co-authored-by: bellatan<tanmei2@huawei.com> # message auto-generated for no-merge-commit merge: !35511 merge v2.12.0_torch_npu_init_refactor into v2.12.0 refactor for torch_npu init module. 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] 重构优化 - [ ] 资料更新 # 【修改方案】 本 PR 对 torch_npu 初始化链路进行重构,将原先集中在 torch_npu/__init__.py 中的初始化逻辑拆分到 _init 目录下的多个职责模块中,形成“**顶层编排 + 子模块分阶段执行 + 内部能力统一收口**”的结构。重构后,torch_npu/__init__.py 不再承载大量具体业务初始化细节,只负责固定初始化时序。各类具体能力分别由 _check_device_conflict、_load_core_modules、_register_components、_apply_patches、_enable_optional_features、_initialize_runtime_lifecycle 等内部函数承接。 ## 一、核心修改 ### 1. 重构 torch_npu/__init__.py 顶层初始化入口 重构后的初始化流程如下: python def _initialize(): _check_device_conflict() _load_core_modules() _register_components() _apply_patches() _enable_optional_features() _initialize_runtime_lifecycle() 顶层入口主要负责: 1. 维护 __all__; 2. 在 import torch 前关闭 TORCH_DEVICE_BACKEND_AUTOLOAD,避免 PyTorch 后端自动加载导致循环依赖; 3. 提前导入 torch_npu.utils.patch_getenv,用于捕获初始化阶段的环境变量访问; 4. 按固定顺序调用各初始化阶段入口; 5. 保留 _autoload() 作为 PyTorch 后端自动加载入口,用于恢复 TORCH_DEVICE_BACKEND_AUTOLOAD。 --- ### 2. 新增 _init 目录: 目录结构如下: text torch_npu/_init/ __init__.py common/ warning_utils.py core/ _exports.py module_loader.py optional_features.py runtime_lifecycle.py patches/ __init__.py api_patches.py asd_patches.py distributed_patches.py dynamo_patches.py monkey_patches.py npu_patches.py patch_manager.py profiler_patches.py warning_patches.py registry/ __init__.py backend.py distributed.py dynamo.py registry_manager.py --- ### 3. 通过 _check_device_conflict() 处理前置设备冲突检查 **_check_device_conflict()**:负责最早期的设备冲突检查,避免 NPU 与其他 accelerator 同时启用。该接口属于初始化内部逻辑,不作为 public API 暴露。 --- ### 4. 通过 _load_core_modules() 统一管理核心模块加载、注册副作用和顶层 API 导出 _load_core_modules() 将原先散落在 torch_npu/__init__.py 中的模块导入、底层 _C 子模块准备、基础 runtime 支撑模块初始化、导入即注册副作用以及顶层 API 导出统一收口。该阶段主要负责: 1. 加载 torch_npu 初始化所需的核心模块; 2. 统一准备 _C child submodules; 3. 初始化 logging、profiler、distributed 等基础组件; 4. 在 _C 准备完成后进行 torch_npu.npu 导入检查; 5. 加载需要通过 import 触发注册副作用的 Python 模块; 6. 导出 torch_npu 顶层 public API。 具体包括: * _C 子模块初始化:统一创建并注册 _profiler、_distributed_c10d、_cd、_logging、_flops_count 等 _C child submodules,保证业务 Python 模块只消费这些子模块,不再各自创建。 * torch_npu.npu 导入检查:在 _C 子模块完成准备后再检查 torch_npu.npu 导入状态,既保留对底层依赖缺失的友好报错,又避免 _C 未就绪时提前 import torch_npu.npu 导致循环导入。 * 导入副作用模块加载:统一加载需要通过 import 触发注册副作用的模块,例如 aclnn、optim、afd、custom ops、op_plugin、meta registrations 等,避免注册类副作用散落在初始化流程中。 * 顶层 API 导出:通过 export_all 将 torch_npu 顶层公开 API 统一导出到 globals() 和 __all__ 中,保证 public API 行为与旧版兼容。 * lazy Python API:对 HiFloat8Tensor、erase_stream、matmul_checksum 等接口采用 lazy export,保证接口可见但不在 import 阶段立即加载对应模块,减少循环导入风险。 * NPU custom ops:将 torch.ops.npu 下的公开算子导出到 torch_npu 顶层,并保留 torch.<op> deprecated wrapper。 * dtype symbols:将 _C._cd.DType 中的 dtype 符号导出到 torch_npu 顶层。 --- ### 5. 通过 _register_components() 统一管理框架集成注册 _register_components() 负责 backend 和 framework integration 注册,将原先散落在顶层入口中的 NPU backend、distributed、Dynamo、RPC、Inductor 等注册逻辑统一收口。通过该阶段统一收口后,框架集成注册逻辑不再散落在顶层 __init__.py 中,后续新增集成能力时可直接在 registry 目录下维护。该阶段主要负责: * NPU backend 注册:将 PyTorch PrivateUse1 backend 映射为 NPU,并注册 torch.npu 设备模块和相关方法。 * distributed backend 注册:注册 HCCL、LCCL backend,保证 NPU distributed 能力可用。 * Dynamo 注册:注册 Dynamo backend、NPU device interface 和 trace rules,保证 NPU 能接入 Dynamo 编译链路。 * RPC 注册:注册 NPU RPC backend,保证 RPC 场景下 NPU backend 可用。 * Inductor lightweight override 注册:只注册轻量级 NPU device op override,避免 import 阶段提前加载 heavy module。 * 默认 gradient device type 配置:保持 checkpoint 等场景下默认设备类型与旧行为兼容。 --- ### 6. 通过 _apply_patches() 统一管理 patch 注册与执行 引入集中式 patch 管理机制,统一收口原先散落在初始化入口中的 patch 逻辑。顶层入口 _apply_patches() 负责触发 patch 发现、注册和执行,具体由 PatchManager 承接。_apply_patches() 主要完成以下工作: 1. **patch 分组注册**:各组件 patch 按 group 注册,例如 monkey、api、distributed、dynamo、profiler、npu、warning、asd 等。 2. **内置 patch 自动发现**:PatchManager 会自动扫描 _init/patches 下符合命名规则的 patch 模块。模块被导入后,内部 patch 会完成注册。 3. **固定 patch 执行顺序**:patch group 按默认顺序执行,避免 import 顺序变化导致 patch 行为漂移。 4. **支持自定义 patch 顺序**:PatchManager 支持调整 patch group 执行顺序,便于测试或特殊场景扩展。 5. **异常钩子统一处理**:全局异常钩子由 PatchManager.run() 统一处理,便于初始化失败和运行时异常场景的集中管理。 --- ### 7. 通过 _enable_optional_features() 统一管理可选运行时能力 将 sanitizer、交互式模式配置、transfer_to_npu 等可选能力统一收口到 _enable_optional_features(),避免可选逻辑散落在顶层初始化入口。该阶段主要包括: python _enable_sanitizer_if_needed() _configure_interactive_mode() _enable_transfer_to_npu_if_needed() 具体说明: * sanitizer:仅在用户显式配置 TORCH_NPU_SANITIZER 时启用; * interactive mode:在交互式命令行环境中自动设置相关运行配置,并给出 warning 提示; * transfer_to_npu:通过 TORCH_TRANSFER_TO_NPU 控制是否启用,对非法配置进行显式报错。 --- ### 8. 通过 _initialize_runtime_lifecycle() 统一管理 runtime 生命周期 _initialize_runtime_lifecycle() 专门负责最终 C++ extension 初始化屏障和进程退出阶段的 shutdown hook 注册。该阶段主要包括: * extension finalize:调用 torch_npu._C._initExtension() 完成最终 C++ extension 绑定。该阶段放在核心模块加载、框架注册、API 导出和 patch 执行之后,保证 Python 侧初始化准备完成后再进入最终 extension barrier。 * shutdown hook 注册:负责注册进程退出阶段的 NPU 资源清理逻辑,包括设备同步、distributed 资源析构、异常处理和其他 runtime 清理流程。 --- ## 三、重构目的和收益 本次重构的目标是把 torch_npu 初始化从“单文件集中式副作用堆叠”调整为“阶段化、组件化、可维护”的初始化框架。主要收益包括: 1. **顶层入口更清晰** torch_npu/__init__.py 只保留初始化编排,不再堆叠大量具体 import、注册、patch 和 shutdown 逻辑。 2. **初始化顺序更稳定** _C 子模块和基础 runtime 支撑能力统一由 _load_core_modules 准备,降低循环导入和 _C 未就绪时提前访问的风险。 3. **组件职责更清楚** 模块加载、框架注册、API 导出、patch、可选功能、runtime 生命周期分别由不同接口承接。 4. **patch 更易维护** 各组件 patch 可以在自己的文件中维护,由 PatchManager 自动发现和统一执行,减少顶层冲突。 5. **支持后续扩展** 新增初始化能力时,只需放到对应处理的接口 或 patch group 中,不需要继续膨胀 __init__.py。 6. **便于问题定位** 初始化链路被拆成明确阶段,出现问题时可以快速判断是模块加载、注册、导出、patch、optional feature 还是 runtime lifecycle 阶段异常。 --- ## 四、兼容性说明 本次重构保持以下兼容性: 1. import torch_npu 行为保持兼容; 2. 顶层公开 API 保持兼容; 3. __version__ 仍从 torch_npu.version 导出。 --- ## 五、PatchManager 机制说明 本 PR 引入 PatchManager,用于统一管理 torch_npu 初始化阶段的 patch 注册与执行。原先 patch 逻辑集中在 torch_npu/__init__.py 中,和初始化流程、模块导入、框架注册逻辑混在一起,导致顶层文件过重,也不利于各组件独立维护。本次重构后,patch 逻辑从顶层入口中解耦,由 _apply_patches() 作为顶层入口触发执行,具体注册、发现、排序、幂等保护由 PatchManager 管理。 PatchManager 主要支持以下能力: 1. patch 按 group 分组注册; 2. 内置 patch 模块自动发现; 3. patch 按固定顺序执行; 4. patch 执行具备幂等保护; 5. 支持组件自行维护 patch module; 6. 支持按 group 执行,为后续按需使能 patch 打基础; 7. 支持自定义 patch 顺序,便于测试和问题定位。 整体机制如下: text 组件 patch 文件自注册 ↓ PatchManager 自动发现/加载 ↓ 按 group 统一管理 ↓ 按固定顺序执行 ↓ 幂等保护,避免重复 patch --- ### 场景一:新增 torch_npu 内置 patch 如果新增的是 torch_npu 内置 patch,例如 distributed patch、profiler patch、NPU API patch、warning patch、ASD patch 等,可以直接放到:torch_npu/_init/patches/ 目录下,并按 group 注册。 示例: python from torch_npu._init.patches.patch_manager import PatchManager @PatchManager.register_patch("profiler") def apply_profiler_patch(): ... 使用方式: text 1. 在 _init/patches 下新增或修改对应 *_patches.py 文件; 2. 在文件中通过 @PatchManager.register_patch(group) 注册 patch; 3. import torch_npu 时,由 _apply_patches() 统一触发; 4. PatchManager 自动发现并按 group 顺序执行。 --- ### 场景二:组件自行维护 patch module 如果某个组件自己的目录下新加了patch 文件,通过 patch module 注册机制接入。 示例: python PatchManager.register_patch_module("torch_npu.some_component.some_patches") 组件自己的 patch 文件中仍然使用 group 注册: python from torch_npu._init.patches.patch_manager import PatchManager @PatchManager.register_patch("some_component") def apply_some_component_patch(): ... 使用方式: text 1. 组件在自己的目录中维护 patch 文件; 2. 通过 register_patch_module 注册该 patch module; 3. module 被导入后,内部 patch 自动注册到 PatchManager; 4. 后续仍由 PatchManager 统一排序和执行。 适用场景: text 组件有独立维护边界; patch 逻辑不适合放到中心化 patches 目录; 后续组件可能独立演进、迁移或删除。 --- ### 场景三:按 group 执行 patch,用于测试或后续按需使能 PatchManager 支持按 group 执行 patch。当前默认初始化路径仍执行全部注册 patch,后续也可按需使能。 示例: python PatchManager.apply_registered_patches("distributed") 使用方式: text 1. 指定需要执行的 patch group; 2. PatchManager 只执行该 group 下已注册的 patch; 3. 已执行过的 patch 不会重复执行; 4. 可用于单独验证某一类 patch 的行为。 适用场景: text 只验证 distributed patch; 只执行 profiler patch; 排查某一类 patch 对初始化流程的影响; 后续通过环境变量控制某个 patch group 是否启用。 如果需要调整 patch group 顺序,也可以使用: python PatchManager.set_patch_order([ "monkey", "api", "distributed", ]) 适用场景: text 测试 patch 顺序; 排查 patch 依赖问题; 特殊构建或实验场景调整 patch 执行顺序。 # 【资料变更】 > 不涉及 # 【接口变更】 > 不涉及 # 【功能验证】 新增 TestTorchNpuBootstrap 初始化专项测试,覆盖以下场景: 1. test_01_import_order_compatibility 验证 import torch_npu、import torch; import torch_npu、import torch_npu; import torch、重复 import torch_npu 等不同导入顺序保持兼容。 2. test_02_import_state_snapshot 验证 import torch_npu 后的初始化状态,包括 torch.npu 注册、Tensor/Module.npu 方法生成、_C child submodules 准备、旧版初始化副作用模块加载、非预期模块不 eager import、顶层关键属性可访问等。 3. test_03_public_exports_snapshot 验证顶层 public API 导出行为,包括 lazy Python APIs、torch.ops.npu public ops、deprecated torch.<op> alias、dtype symbols 等导出保持兼容。 4. test_04_framework_registration_snapshot 验证框架集成注册行为,包括 Dynamo NPU device interface、Dynamo backend、Inductor lightweight device op override、distributed backend、RPC backend 等注册保持生效。 5. test_05_runtime_lazy_init_semantics 验证 import 阶段不触发 NPU runtime lazy init,查询类 API 不触发完整 runtime 初始化,真实 runtime API 和显式 torch_npu.npu.init() 能正常触发 lazy init。 6. test_06_component_behavior_snapshot 验证关键组件行为保持兼容,包括 patch_getenv 生效、ASD detector 兼容 API、AFD 通过 torch_npu._afd 暴露、torch_npu._C._afd 不暴露、AFD ops 可访问等。 7. test_07_distributed_patch_behavior 验证 distributed patch 行为保持兼容,包括 distributed 内部函数替换、public API alias、rendezvous/launcher patch、FSDP 相关 patch 等。 新增测试用例本地验证通过。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35511 | 3 个月前 | |
feat: Unified multi-branch to master branch, to build package for several pytorch version from master branch. Co-authored-by: chz34<chenhaozhe1@huawei.com> # message auto-generated for no-merge-commit merge: !33484 merge compat/master into master feat: Unified multi-branch to master branch, to build package for several pytorch version from master branch. Created-by: c_34 Commit-by: chz34 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 [#1688](https://gitcode.com/Ascend/pytorch/issues/1688) # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) add multi-version compat layer and ci/build.sh improvements - Add torch_npu/_compat/ with version detection shims for distributed (register_op_strategy/register_prop_rule) and inductor (backed_var_to_val, CachingAutotuner, gen_common_triton_imports) - Gate v2.10 bugfix patches in dynamo, inductor, distributed via _compat - Fix dynamo closure bug and restore version-gated patches - ci/build.sh: add --torch= parameter with version validation, write version.txt before build, export TORCH_DEVICE_BACKEND_AUTOLOAD=0 to prevent circular imports when building from source directory # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 构建方案的兼容性切换,验证与当前现有验证保持一致 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!33484 | 4 个月前 | |
add control of python GC before capture npugraph Co-authored-by: 周锐淇<zhouruiqi5@huawei.com> # message auto-generated for no-merge-commit merge: !27715 merge master into master add control of python GC before capture npugraph Created-by: rich9527 Commit-by: 周锐淇 Merged-by: ascend-robot Description: <!-- Thanks for sending a pull request! --> **What type of PR is this?** > /kind task **What does this PR do / why do we need it**: add control of python GC before capture npugraph **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!27715 | 8 个月前 | |
fix: preserve expm1 decomposition by backend Co-authored-by: wangkai<wangkai579@huawei.com> # message auto-generated for no-merge-commit merge: !45002 merge v2.12.0_expm1 into v2.12.0 fix: preserve expm1 decomposition by backend Created-by: mihudan Commit-by: wangkai Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> model = torch.compile( test, backend="inductor", options={"npu_backend": "ascendc" ) issue: https://gitcode.com/Ascend/pytorch/issues/4248 涉及修改的pr: [ [refactor]exmp1 的decomp提到了share_decomp](https://gitcode.com/Ascend/pytorch/pull/40576 ) [ 增加ascendc backend](https://gitcode.com/Ascend/pytorch/pull/40263/diffs) ascendc后端修改后也被注册了share_decompse, 但exmp1 的decomp提到了share_decomp前没有这个decompose,也不希望有这个decompose。 ascendc后端需要将exmp1构造和映射到ascir Expm1节点. - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 将expm1 decompose放回其他后端的注册中 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图  非新功能无新增ut # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45002 | 11 天前 | |
fix(profiler): sanitise trace metadata that would corrupt the export [v2.12] Co-authored-by: Dmitry Gladkov<gladkov.dmitry1@huawei.com> # message auto-generated for no-merge-commit merge: !44520 merge fix/profiler-metadata-sanitizer-v2.12 into v2.12.0 fix(profiler): sanitise trace metadata that would corrupt the export [v2.12] Created-by: gladkov_dmitry Commit-by: Dmitry Gladkov Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 - [ ] Requirement / Feature - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【Modification Scheme】 Backport of the same change on master. The patch is identical; only the base branch differs. The defect was confirmed present on torch 2.12 before backporting rather than assumed. A metadata value containing a double quote makes the exported chrome trace unparseable, losing the whole recording. Two defects combine. > torch.profiler's add_metadata wraps the value with '"' + value.replace('"', '\"') + '"', escaping quotes but not backslashes, so a value such as C:\temp is already malformed JSON before any writer sees it. > The trace writer then replaces every backslash with a forward slash, turning a correctly escaped \" into /" and ending the JSON string early. add_metadata_json is affected identically, so routing a value through it is not a workaround. Neither can be fixed in torch_npu: the writer belongs to PyTorch's libkineto, which is not vendored here. This patch removes the offending characters before the value is handed over and warns when a value had to be altered, so a quote costs the user an approximation of their string instead of the entire recording. > torch_npu/profiler/_add_metadata_sanitizer_patch.py: replaces characters whose JSON encoding would contain a backslash - quote, backslash and control characters - and walks nested structures for the JSON variant, re-serialising with ensure_ascii=False so no \uXXXX escapes are introduced either. > torch_npu/_init/patches/profiler_patches.py: registered in the "profiler" patch group beside the existing mstx and perf-dump patches. > Keys are sanitised the same way, since a key is written as a JSON object key in the same document and a quote in it corrupts the file just as one in the value does. > Values that would have been written correctly pass through byte for byte and raise no warning, so nothing changes for anyone whose metadata already worked. Not NPU-specific: the defect reproduces with activities=[ProfilerActivity.CPU] alone, with no device activity involved. # 【Documentation Change】 > Not involved. The behaviour is described in the module docstring, and the user is warned at runtime whenever a value is altered. # 【Interface Change】 > No API signature change. Customer-visible: a metadata key or value containing a double quote, backslash or control character is now written in an altered form with a UserWarning, rather than producing an unparseable trace file. Values without those characters are unaffected. A sanitised key can no longer be looked up by its original string, which is unavoidable - such a key would otherwise make the entire trace unparseable. # 【Functional Verification】 bash cd /tmp && python test/profiler/test_metadata_sanitizer.py > 20 tests across three classes, all passing in 0.03 s on torch 2.12.0+cpu. CPU activity only - no NPU and no PrivateUse1 backend required. > test_underlying_defect_is_still_present reproduces the defect through the underlying API that add_metadata funnels into, confirming the writer corrupts an unsanitised value on this branch as well as on master; test_trace_parses_with_a_quoted_value confirms the patched path produces a valid trace; test_a_clean_value_raises_no_warning confirms unaffected values are untouched. # 【CheckList】 - [x] Comments complete; the user is warned when a value is altered - [x] Return-value / null-pointer checks done - [x] PR title uses type label (fix) - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!44520 | 16 天前 | |
feat: [graph partition] aclgraph support graph partition Co-authored-by: luochao60<luochao60@huawei.com> # message auto-generated for no-merge-commit merge: !35327 merge pta_support_graph_partition_20260414_v2.12.0 into v2.12.0 feat: [graph partition] aclgraph support graph partition Created-by: luochao60 Commit-by: luochao60 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > (如有)请关联需求文档/issue链接 > 关联 issue: #1911 (https://gitcode.com/Ascend/pytorch/issues/1911) - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. ** torch_npu/utils/_graph_tree.py — 新增 get_manager monkey-patch** 上游 torch._inductor.output_code.maybe_handle_backward_generation 和 torch._dynamo.backends.cudagraphs 会直接调用 torch._inductor.cudagraph_trees.get_manager,依赖它返回真实的 manager 实例来推进 backward 的 cudagraph 状态机。NPU 把自己的 NPUGraphTreeManager 注册在独立 registry(torch_npu.npu._graph_tree),导致上游那两条路径在 NPU 设备上拿不到 manager,触发 AssertionError 或 AttributeError。在 _apply_npugraph_tree_methods() 末尾把 torch._inductor.cudagraph_trees.get_manager 重指到 NPU 的 get_manager(签名一致、duck-typing 兼容),打通 backward 状态机闭环。 2. **torch_npu/_inductor/codegen/wrapper.py — wrapper 体系重构以支持 graph partition** 提取 _NPUKernelCodegenMixin 混入类,把 NPU 特化逻辑(define_kernel 中 user_autotune → user_autotune_npu、PrecomputedGrid → PrecomputedGridNpu、FixedGrid → FixedGridNpu 替换;get_next_kernel_suffix、make_buffer_free 等)从原 NPUWrapperCodeGen 上移;新增 NPUSubgraphWrapperCodegen(_NPUKernelCodegenMixin, SubgraphPythonWrapperCodegen) 让 subgraph wrapper 共享 NPU 适配;NPUWrapperCodeGen.create() 在 is_subgraph=True 时返回新的 subgraph wrapper。 3. **torch_npu/_inductor/lowering_op_list.py — graph partition 所需算子注册** GENERATE_LIST 新增 prims.device_put、aten.unbind、torch.ops.higher_order.cond。 4. **torch_npu/csrc/core/npu/NPUHooksInterface.{h,cpp} — Pinned memory 接口实现** override 上游 at::PrivateUse1HooksInterface 新增的虚函数:isPinnedPtr() 走 CachingHostAllocator_isPinned,getPinnedMemoryAllocator() 返回 getPinnedMemoryAllocator()。同时新增 CachingHostAllocator.h 包含。 5. **test/_inductor/test_inductor_graph_partition.py — graph partition 测试集** 新增 graph partition 场景的系列用例:dynamic shapes、condition op、custom op 拆分、subgraph wrapper user_autotune 兜底、forward cudagraph + backward fallback 等。 # 【资料变更】 不涉及 # 【接口变更】 不涉及。C++ 层 NPUHooksInterface::isPinnedPtr 和 getPinnedMemoryAllocator 是对上游 PrivateUse1HooksInterface 已有虚函数的 override 实现,非新增对外 API。 # 【功能验证】 在 test/_inductor/test_inductor_graph_partition.py 中新增覆盖 graph partition 场景的用例: - test_graph_partition_dynamic_shapes:动态 shape 下产生 3 个 npugraph - test_graph_partition_condition_op:cond / higher-order op 切图 - test_graph_partition_custom_op:cudagraph_unsafe 自定义算子切分边界 - test_graph_partition_subgraph_wrapper_user_autotune:子图 wrapper 的 user_autotune 替换路径 - forward cudagraph + backward fallback 的混合路径 通过 python test/_inductor/test_inductor_graph_partition.py 在 NPU 设备上跑通全部用例。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35327 | 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 个月前 | |
sync: defer dynamo and inductor imports to first torch.compile (from v2.9.0_import) Co-authored-by: stevenaw0<huangguijun@huawei.com> # message auto-generated for no-merge-commit merge: !44299 merge v2.12.0_import2 into v2.12.0 sync: defer dynamo and inductor imports to first torch.compile (from v2.9.0_import) Created-by: stevenaw0 Commit-by: stevenaw0 Merged-by: ascend-robot Description: 同步 v2.9.0_import 分支的 15 个 import optimization commits 到 v2.12.0,将 Dynamo 和 Inductor 初始化延迟到首次 torch.compile 调用。详见 v2.12.0_syn.md 逐文件分类和冲突解决记录。 # 【合入来源】 - [x] 重构优化 # 【修改方案】 同步 v2.9.0_import 的 lazy import optimization(15 commits)到 v2.12.0。将 Dynamo/Inductor 初始化从 import 时延迟到首次 torch.compile。主要改动包括: 1. _dynamo.py: 线程锁 + fork 安全 + lazy 初始化架构 2. _rng_prims_patch.py: 提取 RNG patches 到独立模块 3. registry_manager.py: 移除 import 时 dynamo/inductor 注册 4. dynamo/__init__.py: lazy torchair, backend entrypoints 5. distributed: lazy fsdp, dtensor_patch 隔离, _graph_tree_state 轻量模块 6. deterministic.py: 本地 _forbid_in_graph 避免 torch._dynamo 导入 7. npugraph_ex: 延迟 torch._inductor 导入 8. setup.py: torch_dynamo_backends entry_points 9. test_compile_trigger.py + test_torch_npu_init.py: 验证测试 PyTorch 2.12 适配: EventVariable 在 streams, _ConfigEntry 需要 name, _TorchCompileInductorWrapper.__init__ 有 name=None # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 conda torch-npu-build-2.12.0-py311 验证: - 导入 torch_npu 后 torch._dynamo/torch._inductor 不加载 ✓ - test_compile_trigger.py 21 passed - test_torch_npu_init.py test_02/test_04 通过 ✓ # 【CheckList】 - [x] 代码注释完备 - [x] 返回值、空指针等校验 - [x] PR标题正确使用类型标签 - [ ] CI执行通过 See merge request: Ascend/pytorch!44299 | 21 天前 | |
fix: [910B/910_93] fall back to aclop for view tensors in format cast Co-authored-by: wuyouqi1<wuyouqi1@h-partners.com> # message auto-generated for no-merge-commit merge: !45060 merge v2.12.0-format-cast-view-fallback into v2.12.0 fix: [910B/910_93] fall back to aclop for view tensors in format cast Created-by: wuyouqi1 Commit-by: wuyouqi1 Merged-by: ascend-robot Description: # 【合入来源】 - [x] 问题单 # 【修改方案】 1. MaybeUseAclnnNpuFormatCast 非 aclnn-only 分支(910B/910_93)中,新增文件内 IsViewTensor 判定(张量逻辑形状 sizes 与存储 desc 的 base_sizes 不一致即为 view),将原 ND->NZ N×1 列向量窄守卫泛化为通用 sizes 守卫:view(reshape/transpose/slice)直接回退 aclop,恢复 PR 前行为。 2. 非连续 internal 守卫保持原样;同形异构 stride view(shape 一致、stride 不一致)经实测 aclnn 可正确且位级保值处理,不改变其原有路径。 3. aclnn-only(950)分支保持现状,不做未经验证的改动。 4. 回退安全性: aclop 路径尺寸由 torch_npu 侧确定性公式计算(check_size_nonnegative / GuessStorageFormat / GetMemorySize),无垃圾值输入来源。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 - 10×10 格式矩阵(view 场景,100 组合): 修复前 35 个 OOM 组合修复后全部回退 aclop 成功;28 个 aclnn 正常组合不受影响。 - 同形异构 stride view 修复前环境实测: 走 aclnn 正确处理,data_ptr 共享存储,数值位级一致(max_err=0),故守卫仅按 sizes 判定、不改变 stride 场景行为。 - 新增 UT(test_npu_format_cast.py Group 8,5 个用例): reshape / transpose / as_strided 三类 view,覆盖回退行为与数值正确性,适配 910B/910_93。 # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45060 | 13 天前 | |
feat: add input validation and test cases to all_to_all_vc Co-authored-by: limuan<liyijie16@huawei.com> # message auto-generated for no-merge-commit merge: !44785 merge alltoallvc_v2.12.0 into v2.12.0 feat: add input validation and test cases to all_to_all_vc Created-by: limuan Commit-by: limuan Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 为 torch_npu 新增 all_to_all_vc(variable-count all-to-all)集合通信算子,底层 backed by HCCL HcclAlltoAllVC,对应需求"ProcessGroupHCCL 模块接入 HcclAlltoAllVC 算子;python 层 distributed_c10d.py 封装 all_to_all_vc 接口对外使用"。 与已有的 alltoall/alltoall_base(走 HcclAlltoAllV,带 displs)不同,all_to_all_vc 由全局 [rankSize][rankSize] 的 sendCountMatrix 驱动:matrix[i][j] = rank i 发给 rank j 的元素个数。每个 rank 传同一份矩阵,发送自己的行、接收自己的列;send/recv buffer 按 rank 连续摆放,无需 displs。 对外路径:用户 from torch_npu.distributed import all_to_all_vc, torch_npu.distributed.all_to_all_vc。   # 【资料变更】 资料需更新,增加torch_npu.distributed.all_to_all_vc(output, input, matrix) 接口描述: 已有issue跟踪:https://gitcode.com/Ascend/pytorch/issues/4185 # 【接口变更】 新增接口:torch_npu.distributed.all_to_all_vc(output, input, matrix) # 【功能验证】  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!44785 | 15 天前 | |
fix: 修复 lazy 编译器代理子模块导入兼容性(#4222) Co-authored-by: stevenaw0<huangguijun@huawei.com> # message auto-generated for no-merge-commit merge: !45012 merge fix4222_2.12.0 into v2.12.0 fix: 修复 lazy 编译器代理子模块导入兼容性(#4222) Created-by: stevenaw0 Commit-by: stevenaw0 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > https://gitcode.com/Ascend/pytorch/issues/4222 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 抽取公共子模块绑定逻辑,扫描已加载的独立包子模块。 2. 同步绑定到 lazy proxy 和真实包对象,兼容 npugraph_ex、torchair 顶层绝对导入。 3. 新增回归用例覆盖 import npugraph_ex / import torchair 及 _optimize_fx 加载路径。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 - 已执行 python3 -m py_compile torch_npu/dynamo/__init__.py test/dynamo/test_compile_trigger.py。 - 已执行 git diff --check。 - 新增 UT 覆盖两个 lazy proxy 的顶层导入、子模块导入及真实包属性同步。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!45012 | 13 天前 | |
[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】batcnnorm_check_fix Co-authored-by: 1479518308<cuiduo1@huawei.com> # message auto-generated for no-merge-commit merge: !36324 merge v2.12.0 into v2.12.0 【fix】batcnnorm_check_fix Created-by: cuiduo Commit-by: 1479518308 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 为batcnnorm修改校验位置,适配NestedTensor以对其社区 # 【资料变更】 > 不涉及 # 【接口变更】 > 不涉及 # 【功能验证】 > 本地验证pass # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!36324 | 3 个月前 | |
sync: defer dynamo and inductor imports to first torch.compile (from v2.9.0_import) Co-authored-by: stevenaw0<huangguijun@huawei.com> # message auto-generated for no-merge-commit merge: !44299 merge v2.12.0_import2 into v2.12.0 sync: defer dynamo and inductor imports to first torch.compile (from v2.9.0_import) Created-by: stevenaw0 Commit-by: stevenaw0 Merged-by: ascend-robot Description: 同步 v2.9.0_import 分支的 15 个 import optimization commits 到 v2.12.0,将 Dynamo 和 Inductor 初始化延迟到首次 torch.compile 调用。详见 v2.12.0_syn.md 逐文件分类和冲突解决记录。 # 【合入来源】 - [x] 重构优化 # 【修改方案】 同步 v2.9.0_import 的 lazy import optimization(15 commits)到 v2.12.0。将 Dynamo/Inductor 初始化从 import 时延迟到首次 torch.compile。主要改动包括: 1. _dynamo.py: 线程锁 + fork 安全 + lazy 初始化架构 2. _rng_prims_patch.py: 提取 RNG patches 到独立模块 3. registry_manager.py: 移除 import 时 dynamo/inductor 注册 4. dynamo/__init__.py: lazy torchair, backend entrypoints 5. distributed: lazy fsdp, dtensor_patch 隔离, _graph_tree_state 轻量模块 6. deterministic.py: 本地 _forbid_in_graph 避免 torch._dynamo 导入 7. npugraph_ex: 延迟 torch._inductor 导入 8. setup.py: torch_dynamo_backends entry_points 9. test_compile_trigger.py + test_torch_npu_init.py: 验证测试 PyTorch 2.12 适配: EventVariable 在 streams, _ConfigEntry 需要 name, _TorchCompileInductorWrapper.__init__ 有 name=None # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 conda torch-npu-build-2.12.0-py311 验证: - 导入 torch_npu 后 torch._dynamo/torch._inductor 不加载 ✓ - test_compile_trigger.py 21 passed - test_torch_npu_init.py test_02/test_04 通过 ✓ # 【CheckList】 - [x] 代码注释完备 - [x] 返回值、空指针等校验 - [x] PR标题正确使用类型标签 - [ ] CI执行通过 See merge request: Ascend/pytorch!44299 | 21 天前 | |
[onnx] fix group_norm_silu and rotary_mul onnx api. Co-authored-by: shi-jiaxin9<shijiaxin10@h-partners.com> # message auto-generated for no-merge-commit merge: !31954 merge master into master [onnx] fix group_norm_silu and rotary_mul onnx api. Created-by: shi-jiaxin9 Commit-by: shi-jiaxin9 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 问题单 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!31954 | 5 个月前 | |
[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 个月前 | |
[feat][v2.12.0]torch_npu profiler analysis ability of display prof level0 && kernel shapes Co-authored-by: xieanran<694099604@qq.com> # message auto-generated for no-merge-commit merge: !44930 merge l0shape2.12.0 into v2.12.0 [feat][v2.12.0]torch_npu profiler analysis ability of display prof level0 && kernel shapes Created-by: SoraAzzz Commit-by: xieanran Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [x] issue/工单https://gitcode.com/Ascend/pytorch/issues/4212 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 新增形状表头常量 OP_SUMMARY_SHAPE_HEADERS: 在 _csv_headers.py 中新增形状相关列定义(Input Shapes、Input Data Types、Input Formats、Output Shapes、Output Data Types、Output Formats),为 kernel details输出 shape 信息提供表头 新增 _get_kernel_headers 过滤逻辑: 在 _kernel_view_parser.py 中新增类方法 _get_kernel_headers,当 is_all_kernel_headers 为真时返回全部表头;否则仅返回 OP_SUMMARY_SHOW_HEADERS 拼接源数据中存在的表头 generate_view 接入表头过滤: 将 OpSummaryBean.headers 的赋值改为通过 _get_kernel_headers(all_data[0].all_headers, ProfilerConfig().is_all_kernel_headers()) 计算,使 level0 模式下输出 CSV 时过滤掉 Model ID 等非展示字段,同时保留base 表头以及shape表头及数据 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” > kernel_details.csv在l0下存在新增表头 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” > 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!44930 | 14 天前 | |
[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: preserve deferred Triton backend loading (v2.12.0) Co-authored-by: stevenaw0<huangguijun@huawei.com> # message auto-generated for no-merge-commit merge: !44737 merge sync/deferred-triton-loader-v2.12.0 into v2.12.0 fix: preserve deferred Triton backend loading (v2.12.0) Created-by: stevenaw0 Commit-by: stevenaw0 Merged-by: ascend-robot Description: ## 关联 Issue - #4094 ## 背景 import torch性能优化需求(pull/44372)将 Inductor 初始化从首次 backend 执行阶段提前到 torch.compile() wrapper 创建阶段。默认 Triton backend 因此被提前导入;在未安装 triton-ascend 的环境中,torch_npu/_inductor/runtime/triton_helpers.py 会报 tl.extra.ascend 缺失。 ## 修改内容 - 恢复默认 Inductor backend 的首次执行加载时机。 - 增加测试,验证创建 backend="inductor" wrapper 时不会加载 torch_npu._inductor。 ## 验证 环境:torch-npu-2.10.0-py311、PyTorch 2.10.0+cpu、AArch64、CANN 9.1.0。 - 原 tl.extra.ascend 缺失错误消失。 See merge request: Ascend/pytorch!44737 | 16 天前 | |
[sync] PR-39678: revert: detect Ascend950 SoC for TORCH_NPU_USE_COMPATIBLE_IMPL default Co-authored-by: wuyouqi1<wuyouqi1@h-partners.com> # message auto-generated for no-merge-commit merge: !39715 merge sync-pr39678-revert/compat-impl-socname-routing-26.1.0-to-v2.12.0 into v2.12.0 [sync] PR-39678: revert: detect Ascend950 SoC for TORCH_NPU_USE_COMPATIBLE_IMPL default Created-by: ascend-ds-bot Commit-by: wuyouqi1 Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/39678 ### 2. Original pull request related issue(s): https://gitcode.com/Ascend/pytorch/issues/2561 ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[8539c290](https://gitcode.com/Ascend/pytorch/commit/8539c290bd0035b66335b3e92ac28540de8c2805)|2026-06-30 21:08:41 +0800 CST|Revert "feat: detect Ascend950 SoC for TORCH_NPU_USE_COMPATIBLE_IMPL default"<br><br>This reverts commit acebf35339791ea6fcac6f116acdb242a1c09096.<br><br>Removes the _is_ascend950() SoC auto-detection and the SoC-based default-value assignment for TORCH_NPU_USE_COMPATIBLE_IMPL in torch_npu/__init__.py, and drops test_compatible_impl_soc_detect.py.<br><br>Co-Authored-By: Claude <noreply@anthropic.com><br>| See merge request: Ascend/pytorch!39715 | 2 个月前 | |
| 1 年前 | ||
| 11 个月前 |