已合并
fix: enforce block dim hardware core budget #1956
zhang_shengjie创建于 4 天前
fix: enforce block dim hardware core budget #1956
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhang_shengjie 的贡献)4 天前 创建了 pull request,commit 9dff0c88
此处折叠了11条事件消息 查看更多
4 天前 添加了label:cann-cla/yes
CANN-robot
4 天前 评论:
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 |
|---|---|---|
| repo-cann/graph-autofusion | ✅ yangyongqiang0606, liyuewei, xchu42 (3/2) | ✅ yangyongqiang0606 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhang_shengjie, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4 天前 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,depeng1994,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为评审人
4 天前 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,depeng1994,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为评审人
此处折叠了12条事件消息 查看更多
3 天前 修改了pull request 的描述
zhang_shengjie
3 天前 评论:
3 天前 评论:
compile


Zzhang_shengjie
3 天前 update merge request[project id: 8005834, iid: 1956, commit_id: 14662b7af56493237a241857aea9963310d3ab4b] virtual merging success
3 天前 update merge request[project id: 8005834, iid: 1956, commit_id: 14662b7af56493237a241857aea9963310d3ab4b] virtual merging success
CANN-robot
3 天前 评论:
3 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


3 天前 添加了label:ci-pipeline-running
3 天前 删除了label:ci-pipeline-running
3 天前 添加了label:ci-pipeline-passed
xchu42
3 天前 评论:
3 天前 评论:
/lgtm


liyuewei
3 天前 评论:
3 天前 评论:
/lgtm


3 天前 添加了label:lgtm
yangyongqiang
2 天前 评论:
2 天前 评论:
/approve


2 天前 添加了label:approved
2 天前 合入了pull request
Pull Request
1. 主要解决的问题
PGO 多 Group/TopN 场景中,生成或恢复的
block_dim可能超过硬件实际 AIV 数;同时存在以下关联失败链路:block_dim,且失败回退前会污染实时 tiling 的初始状态。2. 修改方案
DoTiling前提前求值。GeneralTiling后校验每个 tiling case 的block_dim <= corenum_,fused 顶层再次校验聚合结果;超预算返回失败,不做静默截断,避免 tile 漏算。block_dim取各 Group 最大值;并行 Group 按求和语义安排 block offset,并限制在当前硬件 probe 范围内。min(limit->aiv_num, g_no_limit_res.aiv_num)作为可用 AIV 数。memcpy_s和 block budget 校验;先读取到临时副本,仅校验成功后写回,失败时使用未污染的实时 tiling 状态重新搜索。AutofuseTilingWithConfig失败后立即向 C++ tiling/静态生成入口传播;静态生成返回空结果时,两个 Python 编译入口抛出明确异常。3. 代码修改流程图
flowchart TD A[获取实际 AIV/UB 资源] --> B[初始化 tiling core budget] B --> C{PGO 配置有效且 block_dim 合法?} C -- 是 --> D[提交 PGO 临时副本] C -- 否 --> E[使用未污染状态实时搜索] E --> F[solver 执行 CORENUM 约束] F --> G[各 tiling case 计算并校验 block_dim] G --> H[串行 Group 取 max / 并行 Group 求和并安排 offset] H --> I{聚合 block_dim 不超过硬件预算?} D --> I I -- 是 --> J[TopN 仅保留有效候选并执行 profile] J --> K[输出选中 tiling 或静态 kernel] I -- 否 --> L[逐层返回失败] L --> M[实时搜索 fallback 或 Python 编译异常]4. 测试用例说明
4.1 UT/静态检查
cmake --build build --target att_ut -j 8cmake --build build --target test_main -j 8GeneratorUT.*+ CORENUM solver 用例test_ascendc_compile.py+test_asc_codegen_compile_conv2d.py4.2 PGO 实机验证
验证环境:CANN 9.2.0,Ascend950PR_9579,硬件 AIV 数 56;用例位于
/workspace/CANN-DevTools/att_generalization。选择
ATT-CG-01:6 输入连续 Add +Pow/Mean/RsqrtRMSNorm,shape 为(1, 2048, 1024),同时覆盖 Reduce、多个 schedule result/group 与 PGO TopN,是本问题最直接的回归图。验证前执行:
运行时通过本地 package path/
LD_LIBRARY_PATH成套加载本分支pyautofuse.so、libaihac_codegen.so及 graph/expression 依赖,避免新旧 C++ ABI 混用;实测加载路径为:分别执行:
结论:Top1/Top10 均完成 PGO host/device 编译、候选 profiling、NPU 执行和精度比对,未出现 SIGFPE、core dump 或超核数
block_dim。block_dimblock_dim27–564.76837158203125e-07block_dim27–564.76837158203125e-07Top10 实际编译的 10 个候选外层
block_dim为53, 52, 53, 54, 54, 52, 49, 52, 49, 46;PGO 搜索结果中block_dim > 56的数量为 0。5. 核对清单
6. 其他信息
libaihac_codegen.so、仍使用安装包旧pyautofuse.so时,在 graph/expression 对象析构处出现 ABI 混用崩溃;改为成套加载本分支 binding 和依赖后 Top1/Top10 均通过。该现象属于验证部署组合问题,不是 PGO 流程回归。