已合并
Support allocator trace tracker in NPU caching allocator #38691
zzhongmin创建于 6月16日
Support allocator trace tracker in NPU caching allocator #38691
已合并
zzhongmin创建于 6月16日
zzhongmin
zzhongmin成员
6月16日

【合入来源】

如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)

【修改方案】

将 NPU Caching Allocator 对齐到上游 CUDA 实现,补齐 Allocator Trace Tracker 回调机制。v2.7.1 分支的 NPU 侧尚未引入 mempool ID 直接存储等重构,本次仅对齐 attachAllocatorTraceTracker 核心功能,不涉及 mempool 相关改动。

  1. 新增 AllocatorTraceTracker 回调机制(NPUCachingAllocator.h + .cpp)
  • 新增 AllocatorTraceTracker 类型、虚方法、trace_trackers_ 成员、公共接口层转发及便捷函数,与 CUDA 接口对齐
  1. record_trace 支持 tracker 回调分发(NPUCachingAllocator.cpp)
  • 入口条件改为 !record_history && trace_trackers_.empty(),构造 TraceEntry 后遍历 trace_trackers_ 调用回调
  1. NPUPluggableAllocator 补齐接口(NPUPluggableAllocator.h + .cpp)
  • 新增 attachAllocatorTraceTracker override,TORCH_CHECK(false) 拒绝调用
  1. 新增测试
  • C++ 扩展注册回调统计 SEGMENT_ALLOC/FREE 事件,Python 测试验证两种场景下回调正确触发

【资料变更】

不涉及

【接口变更】

不涉及

【功能验证】

test/npu/test_allocator_trace_tracker.py

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 zzhongmin 的贡献)
zzhongminzzhongmin成员
6月16日 创建了 pull request,commit 77ad860f
ascend-robotascend-robot成员
6月16日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
6月16日 评论:

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/pytorch liujunzhu, hbhu_bin (2/2) liujunzhu (1/1)
test liujunzhu, hbhu_bin (2/2) liujunzhu (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
6月16日 添加了label:needs-issue
此处折叠了48条消息 查看更多
zzhongminzzhongmin成员
6月22日 修改了pull request 的描述
liujunzhu
liujunzhu成员
6月22日 评论:

/approve

likedislike
ascend-robotascend-robot成员
6月22日 添加了label:approvedlgtm
ascend-robotascend-robot成员
6月22日 合入了pull request
ascend-robot
ascend-robot成员
6月22日 评论:
流水线 pytorch_gitcode_PR_multiVersion#11011 [ commitID:a80e597a ] 已完成
likedislike