| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[fix]profiler fix config cache when analyse multi card Co-authored-by: hehongzhe<935062458@qq.com> # message auto-generated for no-merge-commit merge: !39883 merge jiexim into master [fix]profiler fix config cache when analyse multi card Created-by: hhz0 Commit-by: hehongzhe Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 https://gitcode.com/Ascend/pytorch/issues/2573 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) profiler离线解析设置的max_process_number的值小于总ascend_pt数量时,解析出来db文件的rank与profiler_info.json的rank不一致 这是因为离线解析会复用进程池里的进程,is_load标记位在设置为True后没有修改,被复用,config无法被更新 所以在获取rankid前需要重置is_load标记位 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 修改前,db文件名中的rankid错误  修改后rankid正确  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!39883 | 2 个月前 | |
| 1 年前 | ||
【pytorch_master】 add dynamic step Co-authored-by: hewenbo<hewenbo16@h-partners.com> # message auto-generated for no-merge-commit merge: !37318 merge master into master 【pytorch_master】 add dynamic step Created-by: hewenbo Commit-by: hewenbo 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/2209 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 在_DynamicProfile类中增加set_state方法用于保存成员属性的值,用于重新拉起的新节点读取故障前的step值 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 资料中新增set_state接口 # 【接口变更】 在_DynamicProfile类中增加set_state方法用于保存成员属性的值,用于重新拉起的新节点读取故障前的step值 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 修改前:   修改后:   # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37318 | 3 个月前 | |
AI assist developer for python DT master Co-authored-by: deepSeekya<chenzhihan6@huawei.com> # message auto-generated for no-merge-commit merge: !26305 merge master into master AI assist developer for python DT master Created-by: deepSeekya Commit-by: deepSeekya Merged-by: ascend-robot Description: 【合入说明】 AI辅助研发python dt测试用例生成。 【合入来源】 AI辅助研发需求 dt测试文件覆盖率提升。 See merge request: Ascend/pytorch!26305 | 10 个月前 | |
[fix_torch_profiler_master]修复profiler L0级别kernel_details.csv无shape信息问题 Co-authored-by: yuliangbin<y1416490440@163.com> # message auto-generated for no-merge-commit merge: !31916 merge fix_profiler_l1 into master [fix_torch_profiler_master]修复profiler L0级别kernel_details.csv无shape信息问题 Created-by: yu_liangbin Commit-by: yuliangbin Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 关联issue号:https://gitcode.com/Ascend/pytorch/issues/1586 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1.功能:解析得时候会根据是否为aicore_none进行kernel_details.csv的表头过滤,但是在l1、aicore_metrics非aicore_none场景下会导致kernel_details.csv表头缺失shape字段,实际上只有l0场景下kernel_details.csv的表头比较少,l1场景下不应该缺失表头,因此过滤逻辑应当是是否为l0,若是l0场景,则过滤,反之不过滤; 2.UT:UT适配 # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 验证结果:离线解析一份l1+aicore_none场景的数据,kernel_details.csv的表头与op_summary.csv的表头一致,未被过滤  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!31916 | 5 个月前 | |
feat(profiler): add fused op flops formulas Co-authored-by: msjz11<liuchengju5@huawei.com> # message auto-generated for no-merge-commit merge: !37663 merge mfu2 into master feat(profiler): add fused op flops formulas Created-by: mjsz11 Commit-by: msjz11 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 在 profiler FLOPs 公式注册中补充融合算子默认 FLOPs 计算规则,新增支持 npu_all_gather_base_mm、npu_transpose_batchmatmul、npu_grouped_matmul、npu_quant_matmul_gelu、npu_grouped_matmul_swiglu_quant_v2、npu_alltoallv_gmm、npu_gmm_alltoallv、npu_block_sparse_attention。 2. 修正 npu_fusion_attention / npu_fused_infer_attention_score 的 Attention FLOPs 口径,按 QK^T + P @ V 统计,使用 q_dim + value_dim,不再误用 key_dim。 3. 统一只统计主 GEMM 或 Attention 矩阵乘 FLOPs,不统计通信、transpose/permute、bias、scale、量化/反量化、GELU/SwiGLU、softmax、dropout 等融合后处理。 4. 补充对应 UT 覆盖融合算子基础 shape、grouped matmul group_list、block sparse attention 有效块统计、BNSD actual lengths,以及 value_dim != key_dim 回归场景。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。未新增或变更客户可见 API,仅补充 profiler 内部 FLOPs 默认计算公式。 # 【功能验证】 1. 执行 python -m py_compile torch_npu/profiler/_flops_formulas.py test/profiler/test_flops_hook.py,通过。 2. 执行 git diff --check,通过。 3. 通过纯 Python 公式断言验证新增融合算子 FLOPs 计算结果,验证通过。 4. 尝试执行 python -m pytest test/profiler/test_flops_hook.py -q,当前本地环境缺少编译扩展 torch_npu._C,收集阶段报 ModuleNotFoundError,未进入 UT 执行。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37663 | 3 个月前 | |
feat(profiler): add fused op flops formulas Co-authored-by: msjz11<liuchengju5@huawei.com> # message auto-generated for no-merge-commit merge: !37663 merge mfu2 into master feat(profiler): add fused op flops formulas Created-by: mjsz11 Commit-by: msjz11 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 在 profiler FLOPs 公式注册中补充融合算子默认 FLOPs 计算规则,新增支持 npu_all_gather_base_mm、npu_transpose_batchmatmul、npu_grouped_matmul、npu_quant_matmul_gelu、npu_grouped_matmul_swiglu_quant_v2、npu_alltoallv_gmm、npu_gmm_alltoallv、npu_block_sparse_attention。 2. 修正 npu_fusion_attention / npu_fused_infer_attention_score 的 Attention FLOPs 口径,按 QK^T + P @ V 统计,使用 q_dim + value_dim,不再误用 key_dim。 3. 统一只统计主 GEMM 或 Attention 矩阵乘 FLOPs,不统计通信、transpose/permute、bias、scale、量化/反量化、GELU/SwiGLU、softmax、dropout 等融合后处理。 4. 补充对应 UT 覆盖融合算子基础 shape、grouped matmul group_list、block sparse attention 有效块统计、BNSD actual lengths,以及 value_dim != key_dim 回归场景。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。未新增或变更客户可见 API,仅补充 profiler 内部 FLOPs 默认计算公式。 # 【功能验证】 1. 执行 python -m py_compile torch_npu/profiler/_flops_formulas.py test/profiler/test_flops_hook.py,通过。 2. 执行 git diff --check,通过。 3. 通过纯 Python 公式断言验证新增融合算子 FLOPs 计算结果,验证通过。 4. 尝试执行 python -m pytest test/profiler/test_flops_hook.py -q,当前本地环境缺少编译扩展 torch_npu._C,收集阶段报 ModuleNotFoundError,未进入 UT 执行。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37663 | 3 个月前 | |
fix: correct init_step_count and erase_step_count cache behavior Co-authored-by: zhufu-2026<3470991357@qq.com> # message auto-generated for no-merge-commit merge: !43360 merge fix_kineto_step_tracker_master into master fix: correct init_step_count and erase_step_count cache behavior Created-by: zhufu-2026 Commit-by: zhufu-2026 Merged-by: ascend-robot Description: # 【合入来源】 ## 任务: [【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(39)#2968](https://gitcode.com/Ascend/pytorch/issues/2968) [【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(41)#2971](https://gitcode.com/Ascend/pytorch/issues/2971) ## 任务分析issue: [【社区任务】: KinetoStepTracker.init_step_count 和 KinetoStepTracker.erase_step_count 的测试覆盖与 NPU 适配检查 #3048](https://gitcode.com/Ascend/pytorch/issues/3048) - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 本次提交为 torch.autograd.profiler.KinetoStepTracker 的两个方法补充测试用例: - KinetoStepTracker.init_step_count - KinetoStepTracker.erase_step_count --- ## 【API 功能介绍】 - init_step_count(requester):为指定请求者初始化步数计数,首次调用时注册并将步数置为 0,重复调用无操作。 - erase_step_count(requester):移除指定请求者的步数计数记录,全局步数保持历史最大值。 --- ## 【修改内容】 新增测试文件 test/profiler/test_kineto_step_tracker.py,为原生行为建立回归测试,覆盖以下 7 个核心场景: | 测试用例 | 验证内容 | |----------|----------| | test_init_does_not_alter_global_step | init_step_count 不改变全局步数 | | test_increment_takes_maximum | current_step 返回所有 requester 步数的最大值 | | test_erase_keeps_step_monotonic | 删除 requester 后全局步数不下降 | | test_erase_all_requesters_keeps_history | 删除全部 requester 后全局步数保留历史最大值 | | test_erase_return_value_contract | erase_step_count 返回 bool 表示删除是否成功 | | test_reinit_is_idempotent | 重复 init_step_count 无副作用 | | test_new_requester_after_erase_inherits_zero | 新 requester 继承当前全局步数,保持步数对齐 | --- ## 【资料变更】 不涉及。 --- ## 【接口变更】 不涉及。 --- ## 【功能验证】 ### 测试场景:新增测试用例验证 **补丁本地验证** : bash python -c " import torch import torch_npu print(f'torch={torch.__version__}') print(f'torch_npu={torch_npu.__version__}') print(f'accelerator={torch.npu.get_device_name() if torch.npu.is_available() else \"cpu\"}') " python /workspace/ascend-pytorch/test/profiler/test_kineto_step_tracker.py -v 测试结果: bash torch=torch 2.12.0+cu130 torch_npu=torch-npu 2.12.0rc1 accelerator=Ascend910B3 Global step retains historical maximum even after all requesters are erased. ... ok test_erase_keeps_step_monotonic (__main__.TestKinetoStepTracker.test_erase_keeps_step_monotonic) Erasing any requester never decreases global step (monotonic contract). ... ok test_erase_return_value_contract (__main__.TestKinetoStepTracker.test_erase_return_value_contract) erase_step_count returns bool indicating whether deletion succeeded. ... ok test_increment_takes_maximum (__main__.TestKinetoStepTracker.test_increment_takes_maximum) current_step always equals the maximum step among all requesters. ... ok test_init_does_not_alter_global_step (__main__.TestKinetoStepTracker.test_init_does_not_alter_global_step) init_step_count only registers requester, never changes global step. ... ok test_new_requester_after_erase_inherits_zero (__main__.TestKinetoStepTracker.test_new_requester_after_erase_inherits_zero) New requester starts at step 0 even after global step has advanced. ... ok test_reinit_is_idempotent (__main__.TestKinetoStepTracker.test_reinit_is_idempotent) Calling init_step_count repeatedly on the same requester has no side effect. ... ok ---------------------------------------------------------------------- Ran 7 tests in 0.003s OK # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!43360 | 1 个月前 | |
test update ut Co-authored-by: huangyunlong2022<huangyunlong4@h-partners.com> # message auto-generated for no-merge-commit merge: !32377 merge 2.12ut into master 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!32377 | 5 个月前 | |
fix(profiler): sanitise trace metadata that would corrupt the export Co-authored-by: Dmitry Gladkov<gladkov.dmitry1@huawei.com> # message auto-generated for no-merge-commit merge: !43429 merge fix/profiler-metadata-sanitizer into master fix(profiler): sanitise trace metadata that would corrupt the export Created-by: gladkov_dmitry Commit-by: Dmitry Gladkov Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 - [ ] Requirement / Feature - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【Modification Scheme】 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. > 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 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. # 【Functional Verification】 bash cd /tmp && python /path/to/test/profiler/test_metadata_sanitizer.py > 16 tests across three classes, all passing in 0.02 s. CPU activity only - no NPU and no PrivateUse1 backend required, so this runs anywhere torch_npu can be imported. > test_underlying_defect_is_still_present reproduces the defect through the underlying API that add_metadata funnels into, confirming the writer still corrupts an unsanitised value; 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!43429 | 27 天前 | |
feat(profiler): mspti backend for torch.profiler PrivateUse1 Co-authored-by: Dmitry Gladkov<gladkov.dmitry1@huawei.com> # message auto-generated for no-merge-commit merge: !44554 merge feat/mspti-kineto-backend into master feat(profiler): mspti backend for torch.profiler PrivateUse1 Created-by: gladkov_dmitry Commit-by: Dmitry Gladkov Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 - [x] Requirement / Feature - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【Modification Scheme】 torch.profiler on Ascend collected CPU activity only. Nothing supplied device data for ProfilerActivity.PrivateUse1, so the NPU half of the timeline was empty and users had to reach for a second, incompatible profiler to see what the device did. This adds a libkineto plugin backed by mspti. NPU kernels now appear in a standard torch.profiler trace next to CPU operations, on one timeline. > PyTorch and libkineto are unchanged. The plugin registers itself through REGISTER_PRIVATEUSE1_PROFILER and is driven by libkineto through IActivityProfilerSession. > This is not torch_npu.profiler. That is a separate implementation over acl_prof with its own enums and configuration class; the two are independent front ends and can be used side by side. Files: > torch_npu/csrc/profiler/mspti_activity_profiler.{h,cpp}: the session - lifecycle, record conversion, device and stream lanes, flow emission. > torch_npu/csrc/framework/interface/MsptiInterface.{h,cpp}: wrappers over libmspti. Every symbol is resolved at runtime through FunctionLoader, so a missing or older libmspti.so gives an empty device lane rather than a link failure. > torch_npu/_init/registry/backend.py, CMakeLists.txt: registration and build. Kernels are linked back to the operations that launched them. A global RecordFunction callback pushes each operation's handle as an mspti external correlation id; mspti ties that handle to the correlation id of the launch call, which the kernel shares. processTrace turns the join into ac2g flows - the arrows a viewer draws from a CPU operation to the kernel it produced. > About three quarters of kernels link. The rest are launched outside any operation scope - allocator work, autograd internals, runtime housekeeping - and have nothing to point back to. The proportion is stable as the workload grows. > The flow tail is a PRIVATEUSE1_RUNTIME marker on the host process, mirroring CUDA where flows start on a cuda_runtime event rather than on a cpu_op. Two presentation decisions worth knowing when reading a trace: > Device operators export without an mspti:: prefix, so they read the way CUDA kernels do in a torch.profiler trace. > The NPU process takes a sort index above any real pid, so its lane renders below the CPU lane. Correlation ids on exported activities come from a private counter rather than from mspti: mspti's ids are not unique per event and collide with torch's low cpu-side ids, which would fail upstream's uniqueness check. stop() drains until records stop arriving rather than until a fixed deadline. mspti delivers asynchronously, roughly 200 ms behind execution, so a time cap truncated the tail of a recording. The loop now exits once several consecutive flushes add nothing, which captures more and returns in about 150 ms. # 【Documentation Change】 > Not involved. Behaviour and limitations are described in the module header. # 【Interface Change】 > No API signature change. Customer-visible: profiling with activities=[ProfilerActivity.CPU, ProfilerActivity.PrivateUse1] now yields NPU device kernels in the trace and in events() / key_averages(), where previously the device side was empty. Existing CPU-only behaviour is unchanged. # 【Functional Verification】 bash cd /tmp && python test/profiler/test_mspti_backend.py > 12 tests in three classes on Ascend 910B4, CANN 9.1.0, torch 2.13.0+cpu. > TestMsptiBackend: kernels reach the trace, carry type and streamId, export without the mspti:: prefix, the NPU lane sorts below the CPU lane, and every cycle of a schedule() run collects - so the backend re-arms between cycles. > TestMsptiAc2g: flows are emitted as start and finish pairs, every start has a finish, one start per operation, none points backwards in time, the ids match operations recorded by torch, the two ends land on different lanes, and the whole trace fits one timeline. > Kernel counts are never asserted in the tests: mspti delivers records asynchronously, so counts vary between runs. The assertions are structural. Trace view. Collected from bare tensor operations rather than a model, so the device lane holds a predictable set of kernels: python a = torch.randn(4096, 4096, device="npu") b = torch.randn(4096, 4096, device="npu") def phases(): with record_function("matmul"): for _ in range(5): torch.matmul(a, b) with record_function("add"): for _ in range(5): torch.add(a, b) with record_function("sum"): for _ in range(5): torch.sum(a) phases() # warm up outside profiling torch.npu.synchronize() with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.PrivateUse1]) as prof: phases() torch.npu.synchronize() prof.export_chrome_trace("trace.json") Fifteen operations issued, <N> device kernels collected. 4096x4096 keeps each kernel millisecond-scale and visible. Opened at ui.perfetto.dev.  > The NPU lane sits below the CPU lane with its kernels named, against the matmul, add and sum phases above, and an ac2g arrow runs from the operation to the kernel it launched. > The flow tail is placed at the kernel's timestamp rather than the host launch time: the host clock reachable from this path has a different base. The link itself is exact; only the arrow's visual origin is approximate. > On CANN versions: only 9.1.0 is installed on the verification machine, so this was not built against an earlier CANN. The mspti dependency is resolved at runtime through FunctionLoader rather than linked, so a CANN without libmspti.so gives an empty device lane rather than a build or load failure. The kineto include added to CMakeLists.txt points at PyTorch's bundled headers, not CANN's, so it carries no CANN version dependency. # 【CheckList】 - [x] Comments complete - [x] Return-value / null-pointer checks done - [x] PR title uses type label (feat) - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!44554 | 27 天前 | |
fix: lintrunner --all-files --take NEWLINE -a Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !35539 merge code_check_lintrunner into master fix: lintrunner --all-files --take NEWLINE -a Created-by: huangjingwei Commit-by: huangjingwei Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 文件必须以 LF 换行符结尾,不允许 CRLF(DOS 换行),执行: lintrunner --all-files --take NEWLINE -a # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 不涉及 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!35539 | 3 个月前 | |
Add support of Execution Trace Observer object to torch_npu profiler (based on acl_prof). Co-authored-by: ilya_a<abanin.ilya@huawei.com> # message auto-generated for no-merge-commit merge: !43983 merge add_execution_trace_observer_support into master Add support of Execution Trace Observer object to torch_npu profiler (based on acl_prof). Created-by: ilya_a Commit-by: ilya_a Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 Re-used existing PyTorch Execution Trace Observer object with torch_npu profiler (based on acl_prof). Migrated relevant unit tests from original PyTorch test_execution_trace.py # 【资料变更】 New parameter is added to npu_profiler - execution_trace_observer. Execution Trace Observer implementation with torch_npu profiler must work the same way as with PyTorch community profiler. # 【接口变更】 New parameter is added to npu_profiler - execution_trace_observer. execution_trace_observer (ExecutionTraceObserver) : A PyTorch Execution Trace Observer object. PyTorch Execution Traces <https://arxiv.org/pdf/2305.14516.pdf>__ offer a graph based representation of AI/ML workloads and enable replay benchmarks, simulators, and emulators. When this argument is included the observer start() and stop() will be called for the same time window as npu_profiler. It is the same Execution Trace Observer as the one used by PyTorch community profiler. # 【功能验证】 Build, install, run: export MAX_JOBS=2 TORCH_DEVICE_BACKEND_AUTOLOAD=0 bash ci/build.sh --python=3.11 pip install --no-deps --force-reinstall dist/torch_npu-*.whl ASCEND_LAUNCH_BLOCKING=1 pytest -s test_npu_execution_trace.py # Test results  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!43983 | 29 天前 | |
[sync] PR-37136: [feat]profiler add ProfilerStep range Co-authored-by: hehongzhe<935062458@qq.com> # message auto-generated for no-merge-commit merge: !37513 merge sync-pr37136-tx7-to-master into master [sync] PR-37136: [feat]profiler add ProfilerStep range Created-by: ascend-ds-bot Commit-by: hehongzhe Merged-by: ascend-robot Description: ### 1. Origin pull request: https://gitcode.com/Ascend/pytorch/merge_requests/37136 ### 2. Original pull request related issue(s): https://gitcode.com/Ascend/pytorch/issues/2223 ### 3. Original pull request related commit(s): | Sha | Datetime | Message | |---|---|---| |[0ec3656a](https://gitcode.com/Ascend/pytorch/commit/0ec3656a5b5faec26b77e1c93f9e01881f6f5606)|2026-06-02 12:28:23 +0800 CST|profiler add ProfilerStep range<br>| See merge request: Ascend/pytorch!37513 | 3 个月前 | |
test: add Ascend NPU UT for torch.autograd.profiler.parse_nvprof_trace Co-authored-by: yuhongming-2026<moshui_1@qq.com> # message auto-generated for no-merge-commit merge: !42226 merge part_master into master test: add Ascend NPU UT for torch.autograd.profiler.parse_nvprof_trace Created-by: yuhongming-2026 Commit-by: yuhongming-2026 Merged-by: ascend-robot Description: # 【合入来源】 > <font color="red">**https://gitcode.com/Ascend/pytorch/issues/2975**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 新增 test/profiler/test_parse_nvprof_trace.py,对原生 API torch.autograd.profiler.parse_nvprof_trace / load_nvprof 在 Ascend NPU 环境下做适配一致性验证。 2. 构造最小 nvprof 兼容 SQLite(含 Marker / Runtime / Concurrent Kernel 表结构),覆盖仅 Marker、Marker+Kernel 关联两类解析路径。 3. 用例依赖 CANN + NPU;无 NPU 时整模块 skip,避免在纯 CPU/CUDA 环境误跑。 4. 补充 API 可用性、EnforceUnique、以及 NPU 算子负载后解析仍可用等场景,保障该接口在 torch_npu 栈上行为正确。 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 **测试场景:** - Ascend NPU 环境下验证 parse_nvprof_trace / load_nvprof 可用性与解析结果正确性 - 覆盖:仅 Marker、带 Kernel 关联、NPU 算子执行后再次解析、EnforceUnique **测试方法:** bash cd test/profiler python test_parse_nvprof_trace.py **说明:** 已新增 UT 用例看护;请在本地/CI NPU 环境执行后补充自验证截图。  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!42226 | 1 个月前 | |
feat(profiler): add fused op flops formulas Co-authored-by: msjz11<liuchengju5@huawei.com> # message auto-generated for no-merge-commit merge: !37663 merge mfu2 into master feat(profiler): add fused op flops formulas Created-by: mjsz11 Commit-by: msjz11 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 在 profiler FLOPs 公式注册中补充融合算子默认 FLOPs 计算规则,新增支持 npu_all_gather_base_mm、npu_transpose_batchmatmul、npu_grouped_matmul、npu_quant_matmul_gelu、npu_grouped_matmul_swiglu_quant_v2、npu_alltoallv_gmm、npu_gmm_alltoallv、npu_block_sparse_attention。 2. 修正 npu_fusion_attention / npu_fused_infer_attention_score 的 Attention FLOPs 口径,按 QK^T + P @ V 统计,使用 q_dim + value_dim,不再误用 key_dim。 3. 统一只统计主 GEMM 或 Attention 矩阵乘 FLOPs,不统计通信、transpose/permute、bias、scale、量化/反量化、GELU/SwiGLU、softmax、dropout 等融合后处理。 4. 补充对应 UT 覆盖融合算子基础 shape、grouped matmul group_list、block sparse attention 有效块统计、BNSD actual lengths,以及 value_dim != key_dim 回归场景。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。未新增或变更客户可见 API,仅补充 profiler 内部 FLOPs 默认计算公式。 # 【功能验证】 1. 执行 python -m py_compile torch_npu/profiler/_flops_formulas.py test/profiler/test_flops_hook.py,通过。 2. 执行 git diff --check,通过。 3. 通过纯 Python 公式断言验证新增融合算子 FLOPs 计算结果,验证通过。 4. 尝试执行 python -m pytest test/profiler/test_flops_hook.py -q,当前本地环境缺少编译扩展 torch_npu._C,收集阶段报 ModuleNotFoundError,未进入 UT 执行。 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!37663 | 3 个月前 | |
| 1 年前 | ||
[Fix] Fix static check errors detected by SPACES Co-authored-by: huangjingwei<huangjingwei4@huawei.com> # message auto-generated for no-merge-commit merge: !35981 merge master_lintrunner into master [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!35981 | 3 个月前 | |
test: add autograd profiler api coverage Co-authored-by: baoxuebin_2026<xuebin@isrc.iscas.ac.cn> # message auto-generated for no-merge-commit merge: !41986 merge codex/autograd-profiler-apis-master into master test: add autograd profiler api coverage Created-by: baoxuebin_2026 Commit-by: baoxuebin_2026 Merged-by: ascend-robot Description: # 【合入来源】 [#2933](https://gitcode.com/Ascend/pytorch/issues/2933) [#2961](https://gitcode.com/Ascend/pytorch/issues/2961) [#2898](https://gitcode.com/Ascend/pytorch/issues/2898) - [ ] 需求 - [ ] 问题单 - [x] issue/工单 - [ ] 重构优化 - [ ] 资料更新 公开issue: - torch.autograd.Variable._execution_engine.run_backward:https://gitcode.com/Ascend/pytorch/issues/2933 - torch.autograd.profiler.EnforceUnique:https://gitcode.com/Ascend/pytorch/issues/2961 - torch.autograd.profiler_util.MemRecordsAcc.in_interval:https://gitcode.com/Ascend/pytorch/issues/2898 # 【修改方案】 1. API 功能说明: - torch.autograd.Variable._execution_engine.run_backward:PyTorch autograd execution engine 的反向传播入口,可对指定 graph roots 执行 backward,并返回指定输入的梯度。 - torch.autograd.profiler.EnforceUnique:profiler 内部用于校验 key 唯一性的辅助类,重复 key 会抛出异常。 - torch.autograd.profiler_util.MemRecordsAcc.in_interval:profiler memory records 的区间筛选接口,用于返回指定时间范围内的 memory record。 2. 上游用例检查情况: 检索 PyTorch / Torch-NPU 现有测试后,未找到面向以上 3 个 API 的独立、直接、最小验证用例,因此按任务要求新增 NPU API 验证用例。 3. 新增用例文件: - test/autograd/test_execution_engine.py - test/profiler/test_profiler_utils_api.py 4. 新增用例覆盖场景: - _execution_engine.run_backward 在当前 accelerator 设备上返回指定输入张量的梯度 - EnforceUnique 对重复 key 抛出异常 - MemRecordsAcc.in_interval 按时间区间筛选 memory records 5. 新增文件头部已按要求补充注释,说明该文件验证的 API 功能。 补充说明:当前分支中 MemRecordsAcc.in_interval 用例使用 in_interval(2000, 5000),与该版本 Event.start_ns() 返回的 ns 时间单位保持一致。 # 【资料变更】 不涉及。资料补齐已单独提交文档 PR。 # 【接口变更】 不涉及。未修改跨仓接口,也未修改用户可见接口行为。 # 【功能验证】 测试环境: text torch: 2.13.0 torch_npu: 2.13.0 CANN: 9.1.0 测试方法: source /usr/local/Ascend/ascend-toolkit/set_env.sh TORCH_DEVICE_BACKEND_AUTOLOAD=1 python3.11 test/autograd/test_execution_engine.py -v TORCH_DEVICE_BACKEND_AUTOLOAD=1 python3.11 test/profiler/test_profiler_utils_api.py -v 测试结果: test_run_backward_returns_requested_gradients ... ok Ran 1 test in 34.1s OK test_enforce_unique_raises_on_duplicate_key ... ok test_mem_records_acc_filters_records_in_interval ... ok Ran 2 tests in 21.4s OK See merge request: Ascend/pytorch!41986 | 1 个月前 | |
| 2 年前 | ||
对齐Pytorch Profiler部分接口 Co-authored-by: xfeng<zchlcw663@163.com> # message auto-generated for no-merge-commit merge: !34296 merge main into master 对齐Pytorch Profiler部分接口 Created-by: zyb_230 Commit-by: xfeng Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [x] 需求 - [ ] 问题单 - [x] issue/工单 https://gitcode.com/Ascend/pytorch/issues/1802 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 对齐pytorch profiler的部分接口: 一个是增加一个 skip_first_wait:  一个是custom_trace_id_callback,然后增加两个对应的set和get的接口set_custom_trace_id_callback和get_trace_id   # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” **涉及,需要和资料沟通** # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 涉及,前面已经说明 # 【功能验证】 **场景1** 设置schedule = torch_npu.profiler.schedule(wait=2, warmup=1, active=1, repeat=2, skip_first=0, skip_first_wait=1) 之前:采集第3和第7个step  现在:采集第1和第5个step  **场景2** 测试get_trace_id接口: …… with torch_npu.profiler.profile( activities=[ torch_npu.profiler.ProfilerActivity.NPU, torch_npu.profiler.ProfilerActivity.CPU, ], with_stack=True, schedule = torch_npu.profiler.schedule(wait=2, warmup=1, active=2, repeat=2, skip_first=1, skip_first_wait=1), on_trace_ready=torch_npu.profiler.tensorboard_trace_handler("./result_profiling"), experimental_config=experimental_config) as prof: for i in range(12): add(x0, x1) prof.step() print(f"step {i}: {prof.get_trace_id()}") ……  默认是一个uuid,是直接从pytorch里面拷贝过来的,现在会在profiler_metadata.json里面落盘,db里面也有    **场景3** 异常的skip_first_wait参数不生效,reset为0 正常: 异常:必须设置为整数,否则有警告信息,reset为0   **场景4:** 设置custom_trace_id_callback,这个trace_id,我们是想和每一份ascend_pt数据或者repeat参数绑定的, class RepeatTraceIdGenerator: def __init__(self): self.repeat_count = 0 # 从 0 开始 def __call__(self) -> str: # 每一轮 profile 启动,计数 +1 current_id = str(self.repeat_count) self.repeat_count += 1 return current_id trace_id_gen = RepeatTraceIdGenerator() …… with torch_npu.profiler.profile( activities=[ torch_npu.profiler.ProfilerActivity.NPU, torch_npu.profiler.ProfilerActivity.CPU, ], with_stack=True, schedule = torch_npu.profiler.schedule(wait=2, warmup=1, active=2, repeat=2, skip_first=1, skip_first_wait=1), on_trace_ready=torch_npu.profiler.tensorboard_trace_handler("./result_profiling"), experimental_config=experimental_config, custom_trace_id_callback=trace_id_gen) as prof: for i in range(12): add(x0, x1) prof.step() print(f"step {i}: {prof.get_trace_id()}")  如果call_back类型不对,会有警告信息,然后使用默认的uuid  # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [ ] 代码注释完备,正确记录错误日志 - [ ] 代码实现进行了返回值、空指针等校验 - [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [ ] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!34296 | 4 个月前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 个月前 | ||
| 1 年前 | ||
| 3 个月前 | ||
| 10 个月前 | ||
| 5 个月前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 1 个月前 | ||
| 5 个月前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 3 个月前 | ||
| 29 天前 | ||
| 3 个月前 | ||
| 1 个月前 | ||
| 3 个月前 | ||
| 1 年前 | ||
| 3 个月前 | ||
| 1 个月前 | ||
| 2 年前 | ||
| 4 个月前 |