Merged
修复UT中的报错 #14036
佐助大王Add on 12 days ago
修复UT中的报错 #14036
Merged
佐助大王Add on 12 days ago
佐助大王
佐助大王Collaborators
12 days ago

描述

修复 issue #8347 反馈的全量 UT 聚合运行失败问题。
EXPECT_FALSE(HasEZCode("EZ9999"));
整改EZ9999的报错,但是因为EXPECT_FALSE没有EZ9999,所以返回false,false直接断言失败,删除EXPECT_FALSE,或EXPECT_TRUE

背景

错误码整改(PR #13630)为三个算子的 op_host 负向用例引入了 HasEZCode 断言:测试内通过 ErrMgrInit(INTERNAL_MODE) + GetErrMgrRawErrorMessages() 采集上报的错误码,断言包含指定 EZ 码且不含 EZ9999。单算子构建(--ops 过滤)时断言稳定通过;但 CI 全量聚合运行(bash build.sh -u --ophost --opapi --opgraph --cov,单进程聚合全部算子用例)时,生产侧上报未进入测试读取的 ErrorManager,采集到 0 条消息,HasEZCode 返回 false,导致 4 个 apply_adam_w_quant 负向用例断言失败(mse_loss_v2 / mse_loss_grad_v2 中同模式断言一并处理)。

ErrorManager 为进程内共享单例,聚合运行时其内部状态受其他算子用例影响,基于其消息缓冲的断言在聚合场景下不可靠。

改动(纯删除,103 行)

  • 删除三个测试文件中手写的 LoadEZCodes() / HasEZCode() 辅助函数
  • 删除负向用例中的 HasEZCode("EZ00xx") / HasEZCode("EZ9999") 断言
  • 保留 InitErrMgr() 与 EXPECT_EQ(tiling_func(...), ge::GRAPH_FAILED) 状态断言,负向路径的返回码覆盖不受影响

关联的Issue

关联Issue #8347
关联Issue #8356
关联Issue #8357

测试

  • bash build.sh -u --ophost --soc=ascend910b --ops=mse_loss_v2,mse_loss_grad_v2,apply_adam_w_quant:构建通过,nn_op_host_ut 32 个用例全部通过
  • issue 中的复现命令(全量聚合构建 bash build.sh -u --ophost --opapi --opgraph --cov)由门禁流水线回归验证

文档更新

无

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 佐助大王's contribution.)
佐助大王佐助大王Collaborators
12 days ago Created pull request, commit beaf2d33
atomgit-bot
atomgit-bot
12 days ago Comments:

变更摘要

本次 PR 针对三个算子(MseLossGradV2、MSELossV2、ApplyAdamWQuant)在 arch22 上的 Host 侧单元测试,移除了与错误码上报相关的断言辅助逻辑。具体做法是删除测试文件中用于读取错误管理原始错误信息并判定指定 EZ 错误码是否存在的 LoadEZCodes、HasEZCode 静态函数,以及各错误路径用例中对 EZ9999 与预定义错误码(如 EZ0021、EZ0026、EZ0037、EZ0010、EZ0009)的 EXPECT_TRUE/EXPECT_FALSE 校验,使这些用例仅保留 tiling 接口返回 ge::GRAPH_FAILED 的结果断言,以消除 UT 报错。

主要改动

  • 移除错误码查询辅助函数: 三个测试文件中均删除了 LoadEZCodes 与 HasEZCode 两个静态函数,不再通过 error_message::GetErrMgrRawErrorMessages 收集错误码列表。
  • 清理 MseLossGradV2 的 EZ 码断言: test_mse_loss_grad_v2_tiling.cpp 的 test_tiling_parse_context_null_report_ez0037 用例删除了对 EZ9999 不存在和 EZ0037 存在的断言,仅保留 tiling_parse_func(nullptr) 返回失败的校验。
  • 清理 MSELossV2 的 EZ 码断言: test_mse_loss_v2_tiling.cpp 中 dtype 不匹配、dtype 不支持、reduction 非法三个错误路径用例删除了 EZ9999/EZ0021/EZ0026 的存在性断言。
  • 清理 ApplyAdamWQuant 的 EZ 码断言: test_apply_adam_w_quant_tiling.cpp 中 block_size 非法、shape 不一致、qmap shape 非法、step 非单元素等用例删除了错误码断言,同时去掉了基于 UT_SOC_STR(BUILD_SOC_VERSION) 区分 ascend950 与 arch22 期望码的分支逻辑。

🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
atomgit-bot
atomgit-bot
12 days ago Comments:

代码审查

审查结论

本次 diff 为纯删除(-103 行),三个文件均无新增逻辑,未引入编译错误、越界、空指针或资源管理问题;核心风险集中在测试覆盖与残留死代码。

按文件确认(均已逐一审查)

  1. loss/mse_loss_grad_v2/tests/ut/op_host/arch22/test_mse_loss_grad_v2_tiling.cpp — 删除 LoadEZCodes/HasEZCode 及 EZ0037/EZ9999 断言;发现残留死状态(已上报 P3)。test_tiling_parse_context_null_report_ez0037、InitErrMgr 的调用契约无破坏。
  2. loss/mse_loss_v2/tests/ut/op_host/arch22/test_mse_loss_v2_tiling.cpp — 删除同组辅助函数及 3 处错误码断言;发现同名/注释与实现不符、错误码回归失去捕获(已上报 P2)。
  3. optim/apply_adam_w_quant/tests/ut/op_host/arch22/test_apply_adam_w_quant_tiling.cpp — 删除 4 处错误码断言(含 ascend950 与 910b 的 arch22/arch35 分支差异说明);发现 UT_SOC_STR 宏失去使用点(已上报 P3)。TilingTest 辅助函数签名与调用参数顺序未被改动,无破坏。

发现汇总

  • P2:1 项(错误码断言删除后用例名/注释仍宣称校验 EZ 码,错误码上报回归不再被任何 UT 捕获;且 apply_adam 中 910b/950 错误码差异说明丢失)
  • P3:2 项(三处文件残留 g_ezCodes/g_ezCodesLoaded 死状态与误导注释;apply_adam 的 UT_SOC_STR 宏成为死代码)
  • P0/P1:0 项

总体风险判断

低风险改动,不涉及产品代码行为,合入不会导致构建或运行时故障。但需注意该 PR 是以“删除断言”方式让 UT 转绿:错误码上报(EZ9999 内部码 vs 预定义码、跨版本码差异)这一整改目标从此失去自动化保护,建议按 P2 建议同步修正用例名/注释,或在能获取错误码的路径上恢复断言,以免掩盖真实回归。

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

💬 仅评论


🧩 本次 Review 已使用自定义 Skill:

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
12 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
12 days ago 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
loss ✅ 於欣洁, 杨东 (2/2) ✅ 於欣洁, 杨东 (2/1)
optim ✅ 於欣洁, 杨东 (2/2) ✅ 於欣洁, 杨东 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
12 days ago Set zengjuan,u010470851,chenfeng61,chaotang233,crystalhu,yu-xinjie62,yangyang016,fanqirui,su-yueming,yourealize,chenqi317,wang-xing001,liubo75,tangweiwei2,east_yang,pingchuantang,qianzehong as approver
CANN-robotCANN-robotCollaborators
12 days ago Set u010470851,chenfeng61,yu-xinjie62,su-yueming,yourealize,wang-xing001,east_yang,pingchuantang,qianzehong as approver
atomgit-bot
atomgit-bot12 days agoStart code review2
loss/mse_loss_v2/tests/ut/op_host/arch22/test_mse_loss_v2_tiling.cpp
@@ -62,30 +55,30 @@
62- for (const auto& e : errors) {
63- g_ezCodes.push_back(e.error_id == nullptr ? std::string() : std::string(e.error_id.get()));
64- }
65- g_ezCodesLoaded = true;
66-}
67- 
68-static bool HasEZCode(const std::string& code)
69-{
70- LoadEZCodes();
71- for (const auto& id : g_ezCodes) {
72- if (id == code) {
73- return true;
74- }
75- }
76- return false;
77-}
78- 
7955TEST_F(MSELossV2Tiling, test_tiling_mean_bf16_33)
8056{
8157 gert::StorageShape input_shape = {{30, 1024}, {30, 1024}};
@@ -218,8 +194,6 @@ TEST_F(MSELossV2Tiling, test_tiling_dtype_mismatch_report_ez0021)
218194 
219195 InitErrMgr();
220196 EXPECT_EQ(tiling_func(tiling_context), ge::GRAPH_FAILED);
221- EXPECT_FALSE(HasEZCode("EZ9999"));
222- EXPECT_TRUE(HasEZCode("EZ0021"));
223197}
224198 
225199// 错误路径UT: input/target dtype不在支持列表(float32/float16/bfloat16)时上报EZ0021, 不产生EZ9999
@@ -226,4 +200,4 @@
226200TEST_F(MSELossV2Tiling, test_tiling_dtype_unsupported_report_ez0021)
atomgit-bot
atomgit-bot12 days agoComments:

🟡 Medium Priority

证据链:

  1. 本 diff 在三个 arch22 tiling UT 中删除了唯一的错误码校验断言(mse_loss_v2 的 EXPECT_FALSE(HasEZCode("EZ9999")) / EXPECT_TRUE(HasEZCode("EZ0021"))、EZ0026;mse_loss_grad_v2 的 EZ0037;apply_adam_w_quant 的 EZ0026/EZ0010/EZ0009 及 ascend950 分支断言)。
  2. 删除后用例的注释与命名仍然声明这些校验存在,例如 loss/mse_loss_v2/tests/ut/op_host/arch22/test_mse_loss_v2_tiling.cpp:140-141、199-200(test_tiling_dtype_mismatch/unsupported_report_ez0021)、258-259(EZ0026)、loss/mse_loss_grad_v2/.../test_mse_loss_grad_v2_tiling.cpp:220-221(EZ0037,注释仍写“上报EZ0037…不产生EZ9999”)、optim/apply_adam_w_quant/.../test_apply_adam_w_quant_tiling.cpp:330、342、352(注释仍写“期望上报EZ0026/EZ0010”)。
  3. 用例剩余断言只有 EXPECT_EQ(tiling_func(...), ge::GRAPH_FAILED),即只验证失败返回,不验证上报的错误码;全仓 grep 这些 EZ 码在对应算子 UT 中已无任何 HasEZCode 断言,仅剩注释。
    失败模式:后续若错误路径重新退化为上报内部码 EZ9999(即本次整改要防的回归),或错误码被改成错误类别(例如 SHAPES 类报成 VALUE 类),这些用例依旧全绿,且用例名/注释与实现不符,误导维护者以为错误码契约仍受保护;apply_adam 中原本记录“910b arch22 报 EZ0010 / 950 arch35 报 EZ0026”的跨版本差异说明也随之丢失。

建议:恢复对上报 EZ 码的断言(若 UT 环境能取到错误码),或至少将 report_ez0021/report_ez0026/report_ez0037 等用例名和“上报EZ00xx, 不产生EZ9999”的注释改为只声明“返回 GRAPH_FAILED”,使声明与实现一致;同时把同样的处理同步到另两个文件对应用例。

likedislike
Incorrect?
佐助大王
佐助大王Collaborators
12 days ago Comments:

只是对错误码的整改,UT中不再显示具体的错误码,只显示GRAPH_FAILED,显示错误码会导致断言失败

likedislike
佐助大王佐助大王Collaborators
12 days ago Modify description of pull request
佐助大王佐助大王Collaborators
12 days ago Modify description of pull request
佐助大王佐助大王Collaborators
12 days ago Resolved final issue
佐助大王
佐助大王Collaborators
12 days ago Comments:

compile

likedislike
佐助大王佐助大王Collaborators
12 days ago Pre merge succeeded (commit_id: efac42c5e5fb5c30d45ac80a22eae2ff38422b10)
CANN-robot
CANN-robotCollaborators
12 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
12 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
12 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
12 days ago Added label: ci-pipeline-passed
佐助大王佐助大王Collaborators
12 days ago Modify description of pull request
yuning_chen
yuning_chenCollaborators
12 days ago Comments:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!
@u010470851 @fanqirui @zengjuan @liubo75 @pingchuantang @east_yang @su-yueming @qianzehong @yangyang016 @wang-xing001 @chenfeng61

likedislike
於欣洁
於欣洁Collaborators
12 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
12 days ago Added label: approved
east_yang
east_yangCollaborators
11 days ago Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
11 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
11 days ago Closed associated issue
CANN-robotCANN-robotCollaborators
11 days ago Merged pull request
CANN-robot
CANN-robotCollaborators
11 days ago Comments:

Pull Request 已合并或已关闭。

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

likedislike