Pull Request has been successfully merged by CANN-robot.
(Thank you for wangfuhao's contribution.)变更摘要
本 PR 为 apace 的 AllGather + MX QuantMatmul 融合算子新增 Hcomm/CCU「通算融合」模板。核心做法是将通信等待逻辑抽象为 CommPolicy 模板参数注入 AllGatherQbmmMxKernel,并新增基于 hccl_.Wait(handle) 的 HcommCommWaitPolicy(AIC 核内 HCCL AllGather)与基于 CrossCoreWaitFlag 的 UdmaCommWaitPolicy(UDMA/AIV 版本),同时新增 Hcomm 路径专用的 hcommAllGatherMatmulTilingData 结构和 AllGatherMxQuantMatmulHcommImpl 实现模板,计算逻辑复用 AllGatherQbmmMxKernel 保持不变。
主要改动
- 新增 Hcomm 融合实现模板
all_gather_mx_matmul_hcomm_impl.h: 实现AllGatherMxQuantMatmulHcommImpl,AIC 核内通过hccl_.InitV2()/SetCcTilingV2()批量下发AllGather<true>(scale、dataHead、dataTail 三段),由HcommCommWaitPolicy::WaitTile()按 tile 依次调用hccl_.Wait(handle),并在 FP4 场景用CeilDiv(K,2)计算通信用 K 元素数(kForComm_)。 all_gather_qbmm_mx_kernel.h增加CommPolicy模板参数: 将原硬编码的CrossCoreWaitFlag<0x2, PIPE_MTE2>等待逻辑替换为commPolicy_.WaitTile(...)调用,新增commPolicy_成员与GetCommPolicy()接口,命名空间由Apace改为AllGatherQuantMatmulImpl,使同一计算内核可适配 UDMA 与 Hcomm 两种通信路径。all_gather_mx_matmul_udma_impl.h适配统一策略接口: 新增UdmaCommWaitPolicy(封装CrossCoreWaitFlag<0x2, PIPE_MTE2>),UDMA 版本改为实例化AllGatherQbmmMxKernel<AType, BType, CType, UdmaCommWaitPolicy>,并将头文件引用更新为新的all_gather_mx_matmul_tiling_data.h。- 新增
hcommAllGatherMatmulTilingData结构: 由all_gather_mx_matmul_udma_tiling_data.h重命名为all_gather_mx_matmul_tiling_data.h,新增 apace 自有的hcommAllGatherMatmulTilingData(含mc2InitTiling、mc2CcTiling、commTile、mmTile、gatherLen,其中gatherLen==0时通信写入gatherOut否则用 workspace),并增加__CCE_AICORE__条件包含保护及kernel_tiling/kernel_tiling.h头文件。 mc2_quant_batch_matmul.h宏定义清理: 在重新定义LOCAL_TEMPLATE_CLASS_PARAMS/LOCAL_TEMPLATE_FUNC_PARAMS之前增加#undef保护,避免重复定义。


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 |
|---|---|---|
| mc2 | ✅ libohao6, chenjunjian11 (2/2) | ✅ libohao6 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
w00951525, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm


/lgtm
/approve


描述
新增了 AllGather MX QuantMatmul 的 Hcomm通算融合模板:
新增 all_gather_mx_matmul_hcomm_impl.h(AIC 核内 HCCL AllGather 通信 + 复用 FragmentTensor QBMM kernel 的 CommPolicy 注入式实现,含 bias 可选输入接线与纯尾块 tileCnt=0 跳过守卫)与自有的 all_gather_mx_matmul_tiling_data.h(URMA/Hcomm 两路共用 tiling 结构),将原 urma_tiling_data.h 重命名合并、urma_impl.h 同步适配 11 行;
qbmm_mx_kernel.h 引入 CommPolicy 模板参数、恢复 bias 并同步 master 的 DIMS_NUM clean-code 改造,另将 all_gather_matmul_v3 两个文件的 tiling data include 路径更新为新文件名(urma ST main.cpp 同步);该提交不含 TransB(非转置 B)支持,全部代码位于 namespace Apace
关联的Issue
https://gitcode.com/cann/ops-transformer/issues/5259
测试
文档更新
类型标签
PR #10588 快速检视报告
4e761ac2(已与本地 ops-transformer 仓 commit 逐字节比对,10 文件 +408/-93,index hash 全匹配)总体结论
对现有功能(URMA 路径 / all_gather_matmul_v3)无影响,属增量变更。
SUSPICIOUS(2 项)
[SUSPICIOUS-1] CommPolicy 模板参数无默认值 — 头文件级接口破坏性变更 置信度:MED
问题描述:
AllGatherQbmmMxKernel新增第 4 模板参CommPolicy且无默认值(all_gather_qbmm_mx_kernel.h:50template <typename AType, typename BType, typename CType, typename CommPolicy>)。commit 树内验证:仅 2 处实例化,均已同步更新传参(urma_impl.h:56 传UrmaCommWaitPolicy、hcomm_impl.h:93 传HcommCommWaitPolicy<ServerType>),仓内编译安全。但作为公共 kernel 头文件,仓外任何按旧 3 参签名直接实例化该头的代码将编译失败。证据:规范违反 +40%(无默认值属硬破坏)+ PR 归属 +20% + 上下文防御缺失 +30%(无默认值兜底)= 90%,但考虑 apace 模板头文件当前无仓外消费者证据,降级 MED 人工确认。
建议:确认该头是否对外发布;若仅仓内使用可接受,否则补默认策略或走 deprecated 过渡。
[SUSPICIOUS-2]
hcommAllGatherMatmulTilingData.gatherLen无 host 填充方 置信度:MED问题描述:kernel 侧依赖
tilingData_->gatherLen(all_gather_mx_matmul_tiling_data.h:57)判断 gather_out 可用性(hcomm_impl.h:199if (tilingData_->gatherLen == 0 && gatherOut != 0)),但该结构体在本 commit 无任何 host 侧赋值路径(git grep确认 host tiling 仅填充 URMA 结构体)。当前未接线故无风险,但后续接线时若遗漏 gatherLen 初始化,将依赖未初始化内存做出错误的 buffer 选择。另:tileCnt_==0 && tailCnt_==0退化场景下 scale handle 已提交(repeat=1)但从不 Wait 即 Finalize(host 正常不应产生该切分,仅记录)。建议:接线时确保 host 侧初始化 gatherLen(语义对齐 mc2_tiling_struct.h 既有 gatherLen 约定),并在 tiling 生成处约束 commTurn ≥ 1。
PASS(7 项)
AllGather<commit>(send, recv, sendCount, dataType, strideCount, repeat);commit=true自动 Commit + 逐轮 Wait 消费,与官方多轮切分示例逐字一致;strideCount/repeat 寻址数学与 FragmentTensor 窗口布局一致(rank 块偏移i*strideCount,第 t 轮推进sendCount),Wait 次数与 repeat 配对正确(scale×1 / head×tileCnt / tail×tailCnt)UrmaCommWaitPolicy::WaitTile逐字还原原CrossCoreWaitFlag<0x2, PIPE_MTE2>(idx)调用序列(含 tileIdx=0 前置等待),既有 URMA 路径时序不变git grep确认被删头文件 0 残留引用,4 个消费方全部同步更新;AllGatherMxMatmulUrmaTilingData字段与对齐(alignas(8)/pack(8))逐字节一致,无 tiling 二进制兼容问题k*sizeof(AType)=K确为 2× 错位;修复IsMxFp4 ? k/2 : k*sizeof(AType)方向正确,与 kForComm_(CeilDiv(K,2))及 URMA 契约一致;FP8 行为不变(k*1==k)LOW 备注项(3 项)
#undef)与第 8 条(CrossCore 模式0 屏障)均不在本 commit diff 及 commit 树内。汇总