Merged
fix(runtime): 修复 PyACL Allocator 回调大小参数截断 #5802
fix(runtime): 修复 PyACL Allocator 回调大小参数截断 #5802
Merged
KaranocaVeAdd on Oct 22
KaranocaVe
Oct 22

fix(runtime): 修复 PyACL Allocator 回调大小参数截断

在 64 位 Host 上,PyACL 将 size_t size 通过 Py_BuildValue 的 I 格式项传给 Python Allocator 回调。请求 4 GiB 时回调收到 0,而不是 4294967296;4 KiB 请求不受影响。两处格式串改为 K 并显式传入 unsigned long long 后,Host CPython C-API 对照保留了这两个大小。未运行完整 pyACL 构建或设备端测试。

关联 Issue: https://gitcode.com/cann/runtime/issues/1251

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for KaranocaVe's contribution.)
KaranocaVeKaranocaVe
Oct 22 Created pull request, commit a1851381
KaranocaVeKaranocaVe
Oct 22 Associated issue: [Bug-Report|缺陷反馈]: PyACL Allocator 回调的 size_t 参数截断
atomgit-bot
atomgit-bot
Oct 22 Comments:

变更摘要

本 PR 修复了 64 位 Host 上 PyACL Allocator 回调的 size 参数截断问题。在 python/pyACL/rt/rt_allocator.cpp 中,AllocatorAllocFunc 与 AllocatorAllocAdviseFunc 通过 Py_BuildValue 向 Python 侧回调传递 size_t size 时使用了 I 格式项,导致 4 GiB 等大尺寸请求被截断为 0;现将两处格式串改为 K,并将 size 显式转换为 unsigned long long 传入,从而在 Host CPython C-API 下完整保留大尺寸参数。

主要改动

  • 修正回调参数格式串: 将 AllocatorAllocFunc 中 Py_BuildValue("kI", allocator, size) 改为 Py_BuildValue("kK", allocator, static_cast<unsigned long long>(size)),使 4 GiB 及以上的分配请求不再被截断为 0。
  • 修正 Advise 回调参数格式串: 将 AllocatorAllocAdviseFunc 中 Py_BuildValue("kIk", allocator, size, addr) 改为 Py_BuildValue("kKk", allocator, static_cast<unsigned long long>(size), addr),保证带地址参数的回调同样按 64 位保留大小。
  • 统一大小参数类型传递: 两处均显式将 size_t size 转换为 unsigned long long,与 K 格式项的取值要求保持一致,确保在 64 位 Host 上传递行为正确。

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

likedislike
Incorrect?
atomgit-bot
atomgit-bot
Oct 22 Comments:

代码审查

✅ 未发现问题


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

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Oct 22 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Oct 22 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
repo-cann/runtime ✅ 卢煜坤, zhangpengpeng8 (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

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

likedislike
CANN-robotCANN-robotCollaborators
Oct 22 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
CANN-robotCANN-robotCollaborators
Oct 22 Set wangtao43,zhangpengpeng8,yanmingxiang,Reyn52166,ykl999,houyanbao,tingwood as approver
KaranocaVe
KaranocaVe
Oct 22 Comments:

/compile

likedislike
KaranocaVeKaranocaVe
Oct 22 Pre merge succeeded (commit_id: 48692743812eeb9bde3d3731fd9cd0be66167a8e)
CANN-robot
CANN-robotCollaborators
Oct 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Oct 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Oct 22 Added label: ci-pipeline-passed
KaranocaVe
KaranocaVe
28 days ago Comments:

根据 CANN-robot 当前审批进度,该 PR 仍缺少必要的代码检视或合入审批。麻烦 wangtao43 houyanbao ykl999 tingwood zhangpengpeng8 Reyn52166 抽空协助审核;确认无误后请按仓库规则执行 /lgtm 和 /approve,谢谢!

likedislike
KaranocaVe
KaranocaVe
28 days ago Comments:

再次提醒:根据 CANN-robot 当前审批进度,该 PR 仍缺少必要的代码检视或合入审批。麻烦 @wangtao43 @houyanbao @ykl999 @tingwood @zhangpengpeng8 @Reyn52166 抽空协助审核;确认无误后请按仓库规则执行 /lgtm 和 /approve,谢谢!

likedislike
KaranocaVe
KaranocaVe
25 days ago Comments:

已核对当前头提交 85b695376e2ca53a6e70e63e2b64d181cc9611b6:无冲突,CLA/ci-pipeline-passed 已通过,审批条件状态已满足。当前仅缺少维护者合入权限;尝试用 gc pr test 触发当前头提交检查返回 403 Unauthorized。请维护者按需重跑当前头提交流水线并合入。

likedislike
ykl999
ykl999Collaborators
24 days ago Comments:

/compile

likedislike
KaranocaVeKaranocaVe
24 days ago Pre merge succeeded (commit_id: f0391d6fa2390d2826c84758d2705e3f5248538b)
ykl999
ykl999Collaborators
24 days ago Comments:

/approve
/lgtm

likedislike
CANN-robotCANN-robotCollaborators
24 days ago Added label: approved
CANN-robot
CANN-robotCollaborators
24 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-failed
CANN-robot
CANN-robotCollaborators
24 days ago Comments:

流水线分析报告 — runtime run#6227

流水线: https://gitcode.com/cann/runtime/actions/runs/0cca9c536a8b46518663bc182f8f0688 | PR#5802 | 2026-11-02 11:33:11 ~ 11:45:00 | 失败 Job 1 个

定界结论: 代码问题 / LLT测试失败 — UT 用例 AclJsonChannelReporterFftsProfileTaskOffTest 断言失败
  • 失败类型: 代码问题(UT 测试运行失败)
  • 根因: AclJsonProfJsonStest.AclJsonChannelReporterFftsProfileTaskOffTest 中 MsprofMgr().AclJsonStart(0, data) 返回 -1(期望 PROFILING_SUCCESS=0),其前置原因是 profiling 数据校验在输出目录中找不到 device 数据(ffts_profile 通道采集 0 字节)。
  • 与 PR 变更关系: PR#5802 仅修改 python/pyACL/rt/rt_allocator.cpp(2 行, Py_BuildValue 格式 kI→kK),与该 C++ profiling UT 无关联,判定为与本次变更无关的偶发/数据采集类失败。
  • 处置建议: 重新触发 UT 验证;若稳定复现,再排查 profiler ffts_profile(channel 53) 采集 0 字节及 data_check 对 device 目录的校验逻辑。
  • 排除项: 日志中 AclJsonNanoStest 全部为 [ SKIPPED ](平台不支持),不是挂起/失败;本 run 仅 1 个失败 Job(UT),无下游级联失败。

失败根因分析

根因 #1: 代码问题 / LLT测试失败 — acljson_prof_json_stest.cpp:63 断言 AclJsonStart 返回 -1
  • 判据: acljson_prof_json_stest.cpp:63: Failure,Expected equality of these values: PROFILING_SUCCESS(0) vs MsprofMgr().AclJsonStart(0, data)(-1)
  • 定位步骤: 4_ut_acc.log(末尾 UT acljson_stest failed, exit code: 1)
  • 影响 Job: UT
  • 根因证据(日志原文):
[ERROR][data_check.cpp:337] Failed to find data pattern : device in path : ./acljsonJsonstest_workspace/output/PROF_000001_20261102114249253_00006872EOKGPQEM
[ERROR][data_check.cpp:286] Failed to read device dir: ./acljsonJsonstest_workspace/output/PROF_000001_20261102114249253_00006872EOKGPQEM
[ERROR][data_check.cpp:223] Fail to get device data path.
acljson_prof_json_stest.cpp:63: Failure
Expected equality of these values:
  PROFILING_SUCCESS
    Which is: 0
  MsprofMgr().AclJsonStart(0, data)
    Which is: -1
[  FAILED  ] AclJsonProfJsonStest.AclJsonChannelReporterFftsProfileTaskOffTest (1101 ms)
...
[  FAILED  ] 1 test, listed below:
[  FAILED  ] AclJsonProfJsonStest.AclJsonChannelReporterFftsProfileTaskOffTest
 1 FAILED TEST
  • 佐证: 同一用例停止采集时 channel: 53, file:data/ffts_profile.data, total_size_channel: 0 bytes, channelReadCnt:0,即 ffts_profile 通道未采到数据,与后续 device 数据缺失一致;其余 150+ 用例均 PASS。
结构化定界摘要
[{"repo": "runtime", "run_number": 6227, "Failed_Type": "代码问题", "Failed_Sub_Type": "LLT测试失败", "Failed_Reason": "UT 用例 AclJsonChannelReporterFftsProfileTaskOffTest 断言失败: MsprofMgr().AclJsonStart 返回 -1(期望0), 前置为 data_check 在 profiling 输出目录找不到 device 数据(ffts_profile 通道采集0字节); PR 仅改 pyACL rt_allocator.cpp, 与本失败无关联, 疑似偶发", "evidence": "acljson_prof_json_stest.cpp:63: Failure  Expected equality: PROFILING_SUCCESS(0) vs MsprofMgr().AclJsonStart(0, data)(-1); [ERROR][data_check.cpp:337] Failed to find data pattern : device in path : ./acljsonJsonstest_workspace/output/PROF_...", "suggestion": "重新触发 UT 验证; 若稳定复现再排查 profiler ffts_profile(channel 53) 采集0字节与 data_check 的 device 目录校验逻辑", "jobs": "UT"}]

由门禁失败定界分析自动生成 | repo: runtime | run: 0cca9c536a8b46518663bc182f8f0688 | PR#5802

likedislike
ykl999
ykl999Collaborators
24 days ago Comments:

/compile

likedislike
KaranocaVeKaranocaVe
24 days ago Pre merge succeeded (commit_id: 1516d8f2710d4e69e50c9245342e0780c98c694a)
CANN-robot
CANN-robotCollaborators
24 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
24 days ago Added label: ci-pipeline-passed
zhangpengpeng8
zhangpengpeng8Collaborators
24 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
24 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
24 days ago Merged pull request