Merged
fix(pro): fix profiling for cann 9.3.0 #6677
gravel1997Add on Sep 23
fix(pro): fix profiling for cann 9.3.0 #6677
Merged
gravel1997Add on Sep 23
gravel1997
gravel1997Collaborators
Sep 23

fix(pro): fix profiling for cann 9.3.0

Related Issue: #3299

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for gravel1997's contribution.)
gravel1997gravel1997Collaborators
Sep 23 Created pull request, commit a12582e0
gravel1997gravel1997Collaborators
Sep 23 Associated issue: [Bug-Report|缺陷反馈] pypto_pro JIT 算子 msprof 采集缺少算子名/shape/核类型:bisheng stub 链遮蔽框架上报(附根因分析与已验证修复方案)
atomgit-bot
atomgit-bot
Sep 23 Comments:

变更摘要

本 PR 面向 CANN 9.3.0 修复 PyPTO 的 profiling 能力。核心思路是把采集状态从编译期链接的 JIT 库中移出,改由进程级的 PyPTO 后端在加载时通过 CANN 公共接口 MsprofRegisterCallback 注册回调并维护全局状态,再由生成的 launcher 通过 GetPyptoProfStatus() 查询;同时重写生成的元数据上报逻辑(新增节点基础锚点与 launch API 事件、按需缓存捕获任务信息),并把张量方向标记从自定义 _DirectionMarker 改为 TensorDirection 枚举、按参数下标传递。配套更新了 ASC 编译目标/架构参数与标量启动 ABI。

主要改动

  • 采集状态改为进程级注册: 新增 framework/src/interface/pypto_pro/profiler.cpp,以模块 id 0x46 调用 MsprofRegisterCallback 注册 ProfCommand,解析 PROF_CTRL_SWITCH 并维护原子标志,导出 extern "C" bool GetPyptoProfStatus();pypto_profiler.h 新增弱符号声明与 GetProfStatus(),使独立加载的 launcher 在无后端时默认关闭 profiling。
  • 元数据上报逻辑重写: ReportCaptureTensorInfo 增加 capture 参数,先发出 MSPROF_REPORT_NODE_BASIC_INFO_TYPE 锚点记录和 MSPROF_REPORT_NODE_LAUNCH_TYPE 的 MsprofApi 事件,再发张量附加信息;新增 CacheCaptureTensorInfo 与 ProfCacheTaskInfo 结构,通过 aclrtCacheLastTaskOpInfo 缓存捕获任务的张量元数据,并用 MakeProfTensorData 统一张量转换。
  • 生成代码的采集门控更新: _generate_prof_range_snippet 以 pypto::GetProfStatus() 与 ACL_STREAM_ATTR_CACHE_OP_INFO 分别判定实时采集和捕获,替换原先基于弱符号 MsprofGetPath 的守卫;pyptoProfInfo.kernelType/blockNums 改为由 KernelTarget.profiler_kernel_type 与 AIV:AIC 比例生成。
  • 方向标记改为按参数下标的枚举: 新增 python/pypto_pro/language/typing/direction.py 定义 TensorDirection(Input/Output),移除 _DirectionMarker;TypeResolver 新增 param_directions: dict[int, TensorDirection],在 resolve_param_type 中以 parameter_index 记录方向并校验重复/非法方向,KernelDef.last_param_directions 与 _extract_param_specs 相应改为按参数下标取值。
  • ASC 编译目标与标量启动 ABI 调整: compile_config.py 将架构改为 dav-2201/dav-3510、编译参数改为 --npu-arch 与 -xasc、移除 --cce-fatobj-link,并新增 entry_qualifier/profiler_kernel_type;jit.py 新增 _scalar_launch_abi,将窄标量统一编码为 8 字节物理槽位(float 走位转换),_make_global_entry 使用 __mix__/__cube__/__vector__ 显式限定入口并按原类型解码。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 23 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 23 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:

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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
9.2.0 ✅ gcw_kUomxQ2l, congqiannan (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Set xinweiliu,cam_bxh,dai-zhentao,TianXL,lululu40888,shi-dingkun,gguuaanngg,codehjp423,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,gcw_kUomxQ2l,Andy-lb,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 23 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
gravel1997
gravel1997Collaborators
Sep 23 Comments:

compile

likedislike
gravel1997gravel1997Collaborators
Sep 23 Pre merge succeeded (commit_id: 99dd4c14e89fc8a2c4835b8dca023016f8161953)
CANN-robot
CANN-robotCollaborators
Sep 23 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 23 Added label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Sep 23 Added label: AscendC-SUCC
congqiannan
congqiannanCollaborators
Sep 24 Comments:

/lgtm

likedislike
liulun0308
liulun0308Collaborators
Sep 24 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 24 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 24 Merged pull request