已合并
adapt the case when prof level 0 with task track shapes only (runtime op) #445
xieanran创建于 1 天前
adapt the case when prof level 0 with task track shapes only (runtime op) #445
已合并
xieanran创建于 1 天前
xieanran
xieanran成员
1 天前

PR 合入模板

注:经过自检不涉及的可标注“不涉及”或直接打勾,特殊情况请文字备注。不符合规范的 PR 不允许合入,请(后备)commit 注意。


1. 修改描述

  • 修改原因: 识别到capture的task time l0场景下目前aclnn和runtime都会上报算子tensor,但是为避免aclnn不上报的场景,做兼容性处理
  • 修改内容: 修改AddTensorShapeInfo 接口,重构接口,减少参数传递深度,l0场景支持 仅 task track 场景支持 tensor 信息落盘。Python 侧同步适配 && UT

2. 功能验证


3. 分支合并要求


3. 代码检视

  • 要求:

    • 合入代码超过 200 行,需三人以上会议检视。
    • 检视密度≥1个/100行。
    • 检视缺陷密度未达要求需提供说明。
    • 大于 1000 行代码原则上不允许合入,需进行备案。
  • 检视意见数:__2 (请填写本次检视的意见总数,用于commit合入前审视)


4. 安全自检

Python、C++

C++


5. 变更知会


likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 xieanran 的贡献)
atomgit-bot
atomgit-bot
1 天前 评论:

变更摘要

该 PR 主要适配 prof level 0 场景下仅包含 task track shapes(运行时算子,如 aclgraph)的落盘逻辑。核心改动是:AddTensorShapeInfo 的入参由按值传递的 MsprofNodeBasicInfo 改为可空的指针 const MsprofNodeBasicInfo * 并移除 isLevel0 分支,当没有节点基本信息时算子名回退为 task->op->name,其余节点级字段(opStatetaskTypeopTypeopFlaghashId 等)回退为 NA/0;同时在 C++ 侧 AddTaskInfoForOnlyTaskTrack 与 Python 侧 TaskGear 中,当运行时算子信息有效且 tensorNum > 0 时,将 tensor 信息(tensor 数量、输入/输出 format、数据类型、shape)实际写入落盘数据,而非固定写 0/NA/None

主要改动

  • AddTensorShapeInfo 接口重构: 参数由值传递的 MsprofNodeBasicInfo 改为可空指针 const MsprofNodeBasicInfo *nodeBasicInfo,删除 isLevel0 参数,通过 hasNodeBasicInfo 统一两种场景;无节点信息时 opNametask->op->nameopState/taskType/opType/opFlag/hashId 回退为 NAblockNum/mixBlockNum 回退为 0。
  • level 0 仅 task track 场景支持 tensor 信息落盘: AddTaskInfoForOnlyTaskTrack 中当 info.isValid && info.tensorNum > 0 时写入 info.tensorNum 及输入/输出 inputFormatsinputDataTypesinputShapesoutputFormatsoutputDataTypesoutputShapes,否则保持 0/NAAddTaskInfo 的 level 0 分支增加 desc->tensorDesc->tensorNum > 0 校验后再调用 AddTensorShapeInfo(desc->tensorDesc, nullptr, data, task)
  • Python 侧 TaskGear 同步适配: cann_analysis_gear.py 中新增 has_tensor_info 判断(tensor_num 非空且大于 0,level 0 分支额外要求 op_info.is_valid),满足条件时输出真实的 tensor 信息,否则对应字段为 None
  • 补充单元测试: C++ UT 新增 TestAddTaskInfoWhenTypeIsReservedAndProfLevel0WithTensorInfo,Python UT 新增 test_task_gear_should_save_runtime_tensor_info_for_aclgraph_in_prof_level0,分别验证 prof level 0 下保留算子(aclgraph_op)的 tensor 数量、输入输出 shape 等信息可正确保存。
likedislike
atomgit-bot
atomgit-bot
1 天前 评论:

代码审查

All changed files have been reviewed and the confirmed findings reported. I have completed my investigation within budget.

审查结论

按文件确认

  • analysis/csrc/domain/services/persistence/host/cann_trace_db_dumper.cpp — 已审查。AddTensorShapeInfo 改为可空指针参数、两个调用点均同步更新,level0 路径语义与原 isLevel0=true 分支一致(NA/0 回退),无边界问题。问题:新增的 hasTensorInfo = info.isValid && info.tensorNum > 0(line 383)依赖一个在生产加载链路上恒为 false 的标志,导致 level0 仅 task track 场景的 tensor 落盘新功能不可达(P2)。
  • analysis/csrc/domain/services/persistence/host/cann_trace_db_dumper.h — 已审查。AddTensorShapeInfo 签名变更与 .cpp 实现及两处调用点(含测试)完全一致,无遗漏调用者,无问题。
  • analysis/mscalculate/cann/cann_analysis_gear.py — 已审查。add_kernel_task_l0 门控基于 tensor_num 本身、不依赖 is_valid,逻辑正确;add_kernel_task_only_task_trackhas_tensor_info 门控与 C++ 侧存在同一 is_valid 恒 false 问题(与 finding 2 同根因,未重复上报)。
  • test/msprof_cpp/analysis_ut/viewer/test/cann_db_dumper_utest.cpp — 已审查。问题:新测试 TestAddTaskInfoWhenTypeIsReservedAndProfLevel0WithTensorInfo(line 445)用 19 参构造函数构造 RuntimeOpInfo,该构造函数不初始化 isValid(默认 false),导致 hasTensorInfo 为 false、三条断言必然失败(P2)。
  • test/msprof_python/ut/testcase/mscalculate/cann/test_cann_analysis_gear.py — 已审查。测试正确设置 is_valid=TrueRTAddInfoCenter 为单例(@singleton),实例级 patch 可命中 add_kernel_task_only_task_track 内的调用,断言位置 13:20 与落库顺序一致,无问题。

总体风险判断

共 2 条 P2 发现(无 P0/P1):

  1. 新增 C++ 单测必然失败(置信 0.85)——RuntimeOpInfo 19 参构造函数不置位 isValid,测试走不进 level0 tensor 落盘分支,三条断言全红。
  2. 新功能在生产环境不可达(置信 0.65)——C++ RTAddInfoCenter::LoadDB 与 Python RuntimeOpInfoViewModel 的加载链路从不把 isValid/is_valid 置为 true,PR 核心目标(level0 + task track shapes only 场景落盘 runtime tensor 信息)在真实数据上永远不会写 tensor 字段,功能形同死代码。

两者同根因(isValid 语义在数据加载链路缺失),建议一并修复:在加载处置位 isValid,或改用记录存在性(tensor_num 非空)作为门控。本次改动主体逻辑(指针化参数、NA 回退、两语言一致性)本身无正确性问题,但核心功能未真正生效且新增测试为红,合入前需修复。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
ascend-robotascend-robot成员
1 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
1 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-Ascend/msprof 潘杨杰, 陈豪 (2/2) 潘杨杰 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

SoraAzzz, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了60条消息 查看更多
panyj1993
panyj1993成员
1 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
1 天前 添加了label:approvedlgtm
ascend-robotascend-robot成员
1 天前 合入了pull request
ascend-robot
ascend-robot成员
1 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robot
ascend-robot成员
1 天前 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike