已合并
调整mrope算子broadcast越界问题 #8001
调整mrope算子broadcast越界问题 #8001
已合并
何宇航创建于 7月1日
何宇航
何宇航成员
7月1日

描述

关联的Issue

https://gitcode.com/cann/ops-transformer/issues/3500

测试

【精度验证】冒烟case:
image.png
【精度验证】泛化case:
image.png
【性能验证】基线看护case:
image.png

文档更新

类型标签

  • 🐛 Bug修复
  • ✨ 新特性
  • ⚡ 性能优化
  • ♻️ 重构
  • 🧪 测试
  • 📦 构建/CI
  • 🔧 配置变更
  • 📝 文档更新
  • ⬆️ 依赖升级
  • 🔒 安全修复
  • 🧹 代码清理
  • ❓ 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 何宇航 的贡献)
何宇航何宇航成员
7月1日 创建了 pull request,commit 1983cb56
CANN-robotCANN-robot成员
7月1日 添加了label:cann-cla/yes
何宇航
何宇航成员
7月1日 评论:

compile

likedislike
CANN-robot
CANN-robot成员
7月1日 评论:

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 /approve or /lgtm
  • Commenting /approve implies 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. 👍

likedislike
何宇航何宇航成员
7月1日 update merge request[project id: 7673863, iid: 8001, commit_id: 49a5eb301d8b77b1ff6608542018fbe5a350effa] virtual merging success
atomgit-bot
atomgit-bot
7月1日 评论:

变更摘要

此 PR 修复了 mrope(Multi-head Rotary Position Embedding)算子在两个内核实现中 Broadcast 操作越界的问题。当 loopN * num_heads_maxnum_heads_each_loop 为 1 时,negOne 张量的 broadcast 目标维度会变为 0,导致越界。修复方案是在 ComputeComputeAlongHeads 两处计算 dstShape_4Negone_ 的第一维时统一减 1,并增加行数 > 1 的守卫条件跳过不必要的 broadcast。fp32 版本同时移除了 __CCE_KT_TEST__ 条件编译分支,与 bf16 版本逻辑对齐。

主要改动

  • dstShape_4Negone_ 的第一维减 1:在 rope_with_sin_cos_cache_f_bf16.hrope_with_sin_cos_cache_fp32.hComputeComputeAlongHeads 两处,dstShape_4Negone_ 的第一维从原来的 loopN * num_heads_max(或 num_heads_each_loop)改为减 1 后的值,避免当行数为 1 时 broadcast 维度退化为 0 引发越界。
  • Broadcast 前新增守卫条件:在两个文件的 ComputeComputeAlongHeads 中,对 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 版本统一,不再区分测试模式。
likedislike
不准确?
CANN-robotCANN-robot成员
7月1日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
7月1日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robot
CANN-robot成员
7月1日 评论:

流水线任务触发成功
任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
7月1日 添加了label:api-check-pass
此处折叠了5条事件消息 查看更多
何宇航何宇航成员
7月1日 修改了pull request 的描述
赵臣臣成员
7月1日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月1日 添加了label:approved
chen-linxin4成员
7月1日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
7月1日 添加了label:lgtm
CANN-robotCANN-robot成员
7月1日 关闭了关联的issue
CANN-robotCANN-robot成员
7月1日 合入了pull request