已关闭
[Bug-Report|缺陷反馈]: QuantBatchMatmulInplaceAdd MXFP8 示例 workspace 缺少释放 #5608
ddssz创建于 9月7日关闭于 9月7日
9月7日 添加了label:bug-report
9月7日 关联了pull request:fix(quant_batch_matmul_inplace_add): 释放 MXFP8 示例 workspace
9月7日 将 smdbha 设为负责人
9月7日 修改了issue 的描述
9月7日 关闭了 issue
9月7日 添加了label:resolved
Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.
Describe the current behavior / 问题描述 (Mandatory / 必填)
文件:
matmul/quant_batch_matmul_inplace_add/examples/arch35/test_aclnn_quant_batch_matmul_inplace_add_mxfp8.cpp。AclnnQuantBatchMatmulInplaceAddTest在 workspaceSize > 0 时通过 aclrtMalloc 分配 workspaceAddr,但后续没有配对的 aclrtFree 或 RAII 管理。成功分配后的正常返回和 CHECK_RET 提前返回路径均遗漏函数级资源释放,存在设备内存泄漏风险。Environment / 环境信息 (Mandatory / 必填)
仓库:cann/ops-nn,master 分支。
涉及 arch35 的 MXFP8 ACLNN 示例。
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
Describe the expected behavior / 预期结果 (Mandatory / 必填)
在 workspace 分配的 if 块之后增加:
std::unique_ptr<void, aclError (*)(void*)> workspaceAddrPtr(workspaceAddr, aclrtFree);使 workspace 生命周期覆盖后续算子调用和流同步,并在函数退出时由 aclrtFree 自动释放;workspaceSize 为 0 时管理空指针,无需释放。
Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
源码静态检查结果:aclrtMalloc(&workspaceAddr, workspaceSize, ACL_MEM_MALLOC_HUGE_FIRST) 成功后,函数内没有 workspaceAddr 对应的 aclrtFree,也没有持有 workspaceAddr 的 RAII 对象。
未运行 NPU 实机复现,无运行日志或截图。
Special notes for this issue/备注 (Optional / 选填)
修复 PR:https://gitcode.com/cann/ops-nn/pull/9938
来源分支:smdbha/ops-nn:backup → cann/ops-nn:master。