已合并
fix(indexer_quant_cache): 修复GEIR内存泄漏并补充数值golden #11302
fix(indexer_quant_cache): 修复GEIR内存泄漏并补充数值golden #11302
已合并
chendunyang创建于 9月4日
chendunyang
chendunyang
9月4日

背景

  • 修复 #4792 反馈的 GEIR 示例成功路径中 Session 未释放问题。
  • 补充 IndexerQuantCache kernel UT 的真实数值 golden 校验,避免仅判断输出非零而漏检数值错误。

修改内容

  • 在 RunGraph 成功完成后、GEFinalize 前释放 Session,与失败路径的资源释放行为保持一致。
  • 新增 Normal 量化分支的独立 golden 测试,覆盖 roundScale=true/false。
  • 校验完整 cache 字节、float32 scale 位模式,以及 slotMapping=-1 时目标行保持不变。
  • golden 使用固定字面值,与被测 kernel 的计算逻辑独立。

验证结果

  • pre-commit 全部通过(含 clang-format、codespell、OAT)。
  • ascend950 opkernel UT:16/16 通过。
  • GEIR 示例编译通过。

Closes #4792

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chendunyang 的贡献)
chendunyangchendunyang
9月4日 创建了 pull request,commit 2663901f
chendunyangchendunyang
9月4日 关联了issue:【缺陷报告】内存泄漏 - 文件test_geir_indexer_quant_cache.cpp - 函数main - 行号246
atomgit-bot
atomgit-bot
9月4日 评论:

变更摘要

该 PR 旨在修复 GEIR 示例(test_geir_indexer_quant_cache.cpp)成功路径中的 Session 内存泄漏(对应 issue #4792),并为 IndexerQuantCache kernel 补充基于真实字面值的数值 golden UT,替代原先仅判断输出非零的弱校验。示例侧在 RunGraph 成功后、调用 ge::GEFinalize() 之前新增 delete session,使成功路径与失败路径的资源释放行为一致;UT 侧新增 test_indexer_quant_cache_golden.cpp,针对 Normal 量化分支分别覆盖 roundScale=true/false 两种场景,golden 采用与被测 kernel 计算逻辑无关的固定字面值。

主要改动

  • 修复 GEIR 示例 Session 泄漏:在 test_geir_indexer_quant_cache.cpp 的 ge::GEFinalize() 前新增 delete session;,确保 RunGraph 成功后释放 Session,与失败路径的资源回收行为保持一致,解决 #4792。
  • 新增 Normal 量化分支 golden 测试文件:新增 test_indexer_quant_cache_golden.cpp,通过 RunAndCheckNormalGolden 以交替输入 1.0/-0.5 分别运行 roundScale=1 与 roundScale=0(TEST(IndexerQuantCacheNormalGolden, RoundScale) / NoRoundScale),断言输出与固定字面值 golden 完全一致。
  • 校验量化输出的字节与位模式:逐字节校验完整 cache 输出(E4M3FN 字节 golden,如 0x78/0xF0、0x7E/0xF6),并以位模式校验 float32 scale(如 0x3B800000U、0x3B124925U),杜绝仅判断非零导致的数值错误漏检。
  • 校验 slotMapping=-1 行的行为:验证当 slotMapping[row] < 0(如 SLOT_MAPPING = {0, -1, 2, 3})时对应 cache 行与 scale 保持原值(初始 0)不变,并仅对非跳过的行应用量化结果。
likedislike
不准确?
CANN-robotCANN-robot成员
9月4日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月4日 评论:

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
attention ✅ luwei_1104, wangxun21 (2/2) ✅ wangxun21, luwei_1104 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
9月4日 将guijianwei,hz36amy_00,coder_linx,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,liudan12,shasha_an,wangzhe123456789,zhangshuoleiokok,luwei_1104,cc-z,shen_weiling,gaoxiang618,songjionghui,wenxin_fight,miaofangzheng,mabing1118,tang-hao-hw-gitcode,haijie_699874,zzy__,yuhao_,L_Euler,wangxun21设为评审人
此处折叠了5条事件消息 查看更多
CANN-robotCANN-robot成员
9月4日 添加了label:cann-cla/yes
chendunyang
chendunyang
9月4日 评论:

compile

likedislike
chendunyangchendunyang
9月4日 预合并成功(commit_id: 48a2050955765fec8a9167254b4c2345ba04c48c)
CANN-robot
CANN-robot成员
9月4日 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9月4日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月4日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月4日 添加了label:ci-pipeline-passed
wangxun21成员
9月4日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
9月4日 添加了label:approved
luwei_1104成员
9月4日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
9月4日 添加了label:lgtm
CANN-robotCANN-robot成员
9月4日 关闭了关联的issue
CANN-robotCANN-robot成员
9月4日 合入了pull request