Pull Request已成功合入, 合并人@CANN-robot
(感谢 何宇航 的贡献)compile


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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| posembedding | ✅ chen-linxin4, cc-z (2/2) | ✅ cc-z, chen-linxin4 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
weixin_44156099, thanks for your pull request. All authors of the commits have signed the CLA. 👍


变更摘要
此 PR 修复了 mrope(Multi-head Rotary Position Embedding)算子在两个内核实现中 Broadcast 操作越界的问题。当 loopN * num_heads_max 或 num_heads_each_loop 为 1 时,negOne 张量的 broadcast 目标维度会变为 0,导致越界。修复方案是在 Compute 和 ComputeAlongHeads 两处计算 dstShape_4Negone_ 的第一维时统一减 1,并增加行数 > 1 的守卫条件跳过不必要的 broadcast。fp32 版本同时移除了 __CCE_KT_TEST__ 条件编译分支,与 bf16 版本逻辑对齐。
主要改动
dstShape_4Negone_的第一维减 1:在rope_with_sin_cos_cache_f_bf16.h和rope_with_sin_cos_cache_fp32.h的Compute与ComputeAlongHeads两处,dstShape_4Negone_的第一维从原来的loopN * num_heads_max(或num_heads_each_loop)改为减 1 后的值,避免当行数为 1 时 broadcast 维度退化为 0 引发越界。- Broadcast 前新增守卫条件:在两个文件的
Compute和ComputeAlongHeads中,对Broadcast<float, 2, 0, false>调用加上if (negOneRows > 1)或if (this->num_heads_each_loop > 1)条件,当仅有一行时直接跳过 broadcast 操作。 - fp32 版本移除条件编译分支:
rope_with_sin_cos_cache_fp32.h中删除了#ifndef __CCE_KT_TEST__/#else/#endif预处理分支,使dstShape_4Negone_的计算逻辑与 bf16 版本统一,不再区分测试模式。


流水线任务触发成功
任务链接 [ddf00d2fba8944288e82e26c144b5792][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Pre | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910b | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_910c | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_monitor_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental_950_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_classify | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> | |
| UT_Test_report_lcov | ✅ SUCCESS | >>>>> |
[2026-07-01 15:41:19] CI执行结束


流水线任务触发成功
任务链接 [2aed755ee15c4e879761823d2ff9b855][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_style | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| codecheck_checkpr | ✅ SUCCESS | ||
| codecheck_precommit | ⚠️ WARNING | >>>>> | >>>>> |
[2026-07-01 15:22:45] CI执行结束


/approve


描述
关联的Issue
https://gitcode.com/cann/ops-transformer/issues/3500
测试
【精度验证】冒烟case:



【精度验证】泛化case:
【性能验证】基线看护case:
文档更新
类型标签