Pull Request has been successfully merged by CANN-robot.
(Thank you for gravel1997's contribution.)变更摘要
本 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,以模块 id0x46调用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__显式限定入口并按原类型解码。


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
/approveor/lgtm- Commenting
/approveimplies 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. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


fix(pro): fix profiling for cann 9.3.0
Related Issue: #3299