已合并
[Feature] 新增显存OOM分析项,发生OOM时dump最新和最大内存块信息UT ST #190
[Feature] 新增显存OOM分析项,发生OOM时dump最新和最大内存块信息UT ST #190
已合并
yangchen创建于 20 天前
yangchen
yangchen成员
20 天前

感谢您贡献的Pull Request!
在提交之前,请务必阅读 Contributing

1. 修改描述

  • 修改原因: 添加需求UTST
  • 修改内容: 新增UT与ST

2. 功能验证


3. 代码检视

  • 要求:
    • 合入代码大于 200 行,需三人以上会议检视。
    • 检视密度≥2个/100行。
    • 检视缺陷密度达不到要求的需给出说明。

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

变更摘要

此 PR 为显存 OOM 分析功能新增了单元测试和冒烟测试覆盖,主要围绕 OOMDetailedAnalyzer 类进行验证。单元测试覆盖了分析器启用判断、防抖 dump 控制、近期分配记录查询(按时间戳降序)和 Top 内存分配查询(按大小降序),以及 oomTopK 参数对结果数量的控制。冒烟测试则通过命令行 --analysis=oom:K 拉起实际训练脚本触发 OOM,并验证生成的 dump CSV 中是否包含 OOM_DETAIL 事件的三种子类型(OOM_TRIGGEROOM_RECENT_ALLOCOOM_TOP_ALLOC)及其必要字段。

主要改动

  • 新增 test_analysis/test_oom_detailed_analyzer.cpp 单元测试:为 OOMDetailedAnalyzer 类添加 9 个测试用例,涵盖 IsEnabledShouldDumpDetails(含 2 秒防抖窗口验证)、QueryRecentAllocs(验证按时间戳降序及 TopK 截断)、QueryTopAllocs(验证按内存大小降序)以及空记录边界场景。测试通过 InjectHalRecordInjectNpuRecord 辅助方法注入 HAL 和 NPU 内存事件。

  • test/smoke/run_st.py 中集成 OOM 冒烟测试套件:新增导入 OOMTestSuite,定义 oom_cmd 命令行参数(含 --analysis=oom:5),并将 OOMTestSuite 注册到测试套件列表中,超时时间设为 60 秒。

  • 新增 test/smoke/src/test_suit/oom_test.py 冒烟用例:定义 OOMTestSuiteOOMTestCase,通过 pandas 读取 dump CSV,校验 OOM_DETAIL 事件存在且包含三种 Event TypeOOM_TRIGGEROOM_RECENT_ALLOCOOM_TOP_ALLOC),并验证 OOM_TRIGGERAttr 字段包含 funcreq_size

  • 新增 test/smoke/testfile/scripts/test_oom_smoke.py 烟雾测试脚本:通过 torch_npu 执行 1 步训练产生 alloc/free 记录后,调用 trigger_oom 循环分配 1GB tensor 直至触发 NPU OOM,供 msmemscope 命令行工具拉起并采集 OOM dump 数据。

likedislike
atomgit-bot
atomgit-bot
20 天前 评论:

代码审查

I've completed my thorough review of all four changed files. Here is my final summary.


审查总结

优先级 数量
P0 0
P1 0
P2 1
P3 0

各文件审查结果:

  • test/analysis/test_oom_detailed_analyzer.cpp — 无问题。新增的 C++ 单元测试覆盖了 IsEnabledShouldDumpDetailsQueryRecentAllocsQueryTopAllocs、TopK 控制、空记录等场景,测试逻辑正确,与 oom_detailed_analyzer.cpp 的实现保持一致。#define private public / #include <gtest/internal/gtest-port.h> 均为项目既有约定,不视为本次 diff 引入的问题。

  • test/smoke/run_st.py — 无问题。变更仅为新增 OOMTestSuite 导入、oom_cmd 命令定义、以及将其加入 test_suites 列表,与现有测试套件的注册模式完全一致。

  • test/smoke/src/test_suit/oom_test.py — 发现 1 个 P2 问题:_verify_csv 方法中 pd.read_csv 及后续列访问均未做异常处理,CSV 格式异常时会导致整个冒烟测试运行崩溃,跳过后续所有测试套件。

  • test/smoke/testfile/scripts/test_oom_smoke.py — 无问题。冒烟脚本结构清晰,路径计算正确,逻辑简洁。

整体风险评估:低风险。 唯一的 P2 问题是测试代码自身的健壮性不足(缺少异常处理),不影响生产代码。该变更可以合入,建议修复上述 P2 问题以提升测试稳定性。

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

💬 仅评论

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

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/msmemscope 毛晨, 王朝 (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

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

likedislike
此处折叠了60条消息 查看更多
ascend-robotascend-robot成员
19 天前 合入了pull request,合并节点 SHA:bc33451b7e12522a612582a3df58ad7483abced9
xzm123成员
19 天前 评论:

🤖 AIDD 文档质量检测报告

PR #190 已关闭,相关检测任务已归档。

评论由 AIDD 自动生成。

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

The MR is merging by another one

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

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

Pull Request 已合并或已关闭。

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

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

Pull Request 已合并或已关闭。

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

likedislike