Skip to content

feat: make PTA OOM injection controllable - #3

Draft
yjyang62 wants to merge 4 commits into
pta_oom_2.9.2from
cursor/pta_oom-only-b9b0
Draft

feat: make PTA OOM injection controllable#3
yjyang62 wants to merge 4 commits into
pta_oom_2.9.2from
cursor/pta_oom-only-b9b0

Conversation

@yjyang62

@yjyang62 yjyang62 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

【合入来源】

  • 需求
  • 问题单
  • issue/工单
  • 重构优化
  • 资料更新

【修改方案】

  1. 保留原有 PTA OOM “计数到一定次数后向上抛 OutOfMemoryError” 的构造方式,默认阈值仍为 30004,即第 30005 次候选分配触发。
  2. 将触发点从内部 DeviceCachingAllocator::malloc 入口移到外层普通 tensor NpuCachingAllocator::allocate 路径:只统计普通 NPU tensor allocation,不再覆盖 raw/aligned/内部 allocator malloc 等更底层路径。
  3. 触发前不进入真实 allocator 分配流程,也不修改 block/pool 状态;异常边界更接近普通 tensor 分配失败,便于快恢。
  4. 跳过 graph capture 状态,避免在 capture/replay 敏感阶段触发。
  5. 默认所有 rank、所有 device 都可触发;每个进程本地计数并只触发一次。
  6. 保留可选 PTA_OOM_TRIGGER_COUNT 调整触发阈值;设置为小于等于 0 可关闭注入。

【资料变更】

不涉及

【接口变更】

不涉及正式接口变更;新增仅用于故障注入分支的环境变量 PTA_OOM_TRIGGER_COUNT

【功能验证】

  • 已执行 git diff --check pta_oom_2.9.2...HEAD,无空白格式问题。
  • 已确认相对 pta_oom_2.9.2 只修改 torch_npu/csrc/core/npu/NPUCachingAllocator.cpp
  • 当前环境未运行依赖 NPU 的实机 OOM 快恢用例。

【CheckList】

  • 代码注释完备,正确记录错误日志
  • 代码实现进行了返回值、空指针等校验
  • PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
  • PR持续集成流水线(CI)执行通过,代码检查无异常
Open in Web Open in Cursor 

cursoragent and others added 4 commits June 14, 2026 07:59
Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Co-authored-by: yjyang62 <yjyang62@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants