Merged
fix: truncation of repeatTimes in call of mul #13040
fix: truncation of repeatTimes in call of mul #13040
Merged
Yuan BinAdd on Sep 28
Yuan Bin
Yuan BinCollaborators
Sep 28

描述

调用入参截断导致了inplacePartialRotaryMul算子的部分special路径的用例精度失效。

解决方法

在special路径调用Mul时针对repeatTime参数超过接口限制时展开循环逐段处理。

关联的Issue

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

测试

通过了本地白盒泛化测试。

文档更新

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Yuan Bin's contribution.)
Yuan BinYuan BinCollaborators
Sep 28 Created pull request, commit 271a6a59
atomgit-bot
atomgit-bot
Sep 28 Comments:

变更摘要

本 PR 修复了 posembedding/inplace_partial_rotary_mul/op_kernel/inplace_partial_rotary_mul.h 中 InplacePartialRotaryMulABA 模板的 ComputeMul 方法在非广播(非 brc)分支中调用 Mul 时的 repeatTimes 截断问题。原先直接以 numHead 作为重复次数传入,当 numHead 超过 Mul 接口支持的重复次数上限时会被截断;改动后通过内层循环将待处理numHead拆分为多段,每段重复次数限制在 MAX_MUL_REPEAT_TIME 以内,并按 done * mask 偏移源与目标地址,从而覆盖全部 head 数据。

主要改动

  • 分段调用 Mul 以规避重复次数上限:将原先单次传入 numHead 的 Mul 调用改为 for (uint32_t done = 0; done < numHead;) 循环,按 MAX_MUL_REPEAT_TIME 上限分段执行,避免 repeatTimes 被截断。
  • 引入重复次数计算逻辑:循环内通过 remaining = numHead - done 与 static_cast<uint8_t>(remaining > MAX_MUL_REPEAT_TIME ? MAX_MUL_REPEAT_TIME : remaining) 计算本段实际重复次数 repeats,并在每段结束后以 done += repeats 推进。
  • 同步调整地址偏移:Mul 的输入 src0Ub 与输出 dtsUb 偏移量由 j * count 改为 j * count + done * mask,保证各分段作用于正确的数据区间,而 src1Ub[j * headDim] 保持不变。
likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 28 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 28 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
posembedding ✅ kdy18482276080, cc-z (2/2) ✅ cc-z, kdy18482276080 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Set hz36amy_00,juyangokok,monologue815,xuanyuandy,chen-linxin4,yu-xinjie62,jiang-lirui,Allan_Yu,songkai111,liudan12,Wei_NaChuan,luwei_1104,cc-z,kdy18482276080,xuchengyang,mabing1118,Julius47,yuhao_,jiangjiawei,wangxun21 as approver
CANN-robotCANN-robotCollaborators
Sep 28 Set hz36amy_00,juyangokok,monologue815,xuanyuandy,chen-linxin4,yu-xinjie62,jiang-lirui,Allan_Yu,songkai111,liudan12,Wei_NaChuan,luwei_1104,cc-z,kdy18482276080,xuchengyang,mabing1118,Julius47,yuhao_,jiangjiawei,wangxun21 as approver
Yuan Bin
Yuan BinCollaborators
Sep 28 Comments:

compile

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: b6fa084e652413ccf7dd99e33f76701938271df1)
Yuan BinYuan BinCollaborators
Sep 28 Modify description of pull request
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 28 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 28 Added label: ci-pipeline-failed
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:

流水线分析报告 — ops-transformer run#9118

流水线: https://gitcode.com/CANN/ops-transformer/actions/runs/7caef5a76ae648a689b84a891032a464 | PR#13040 | 2026-09-28 10:34:56 ~ 2026-09-28 10:42:23 | 失败 Job 1 个

定界结论: 代码问题 / 代码检查错误 — clang-format 格式不通过
  • 失败类型: 代码问题
  • 根因: pre-commit 检查项 clang-format 不通过,文件被 hook 自动改写: posembedding/inplace_partial_rotary_mul/op_kernel/inplace_partial_rotary_mul.h
  • 处置建议: 通知 PR 提交者修复 — 本地对该文件执行 clang-format 格式化(或执行 pre-commit run clang-format --all-files)后重新提交推送
  • 排除项: 其余 pre-commit 检查项(trim trailing whitespace / fix end of files / ruff / codespell / OAT / duplicate-header)均 Passed;下游 Job(API_Check / UT / PreSmoke_A2 / Kirin_PreSmoke)因前置失败级联未启动,无独立失败

失败根因分析

根因 #1: 代码问题 / 代码检查错误 — clang-format 格式不通过
  • 判据: pre-commit 检查项不通过: clang-format(files were modified by this hook)
  • 定位步骤: 3_precommit.log
  • 影响 Job: CodeCheck_precommit
  • 根因证据(日志原文):
[2026-09-28 10:38:17.602+08:00] clang-format.............................................................Failed
[2026-09-28 10:38:17.603+08:00] - hook id: clang-format
[2026-09-28 10:38:17.604+08:00] - files were modified by this hook
[2026-09-28 10:38:17.607+08:00] Formatting [1/1] posembedding/inplace_partial_rotary_mul/op_kernel/inplace_partial_rotary_mul.h

由门禁失败定界分析自动生成 | repo: ops-transformer | run: 7caef5a76ae648a689b84a891032a464 | PR#13040

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 8ba5f4f02dec9789c1613e82f576e9e323856071)
Yuan BinYuan BinCollaborators
Sep 28 Force-pushed 1 commits:7f1cc904-fix: truncation of repeatTimes in call of mul
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 793c94aeb35d4e9e80d3b574647e99eadc6ed5b1)
CANN-robotCANN-robotCollaborators
Sep 28 Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
Sep 28 Added label: cann-cla/yes
Yuan Bin
Yuan BinCollaborators
Sep 28 Comments:

compile

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 71833570db9705d82e6a1215e97710ef8cbeaf98)
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Removed label: ci-pipeline-failed
7 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Sep 28 Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: cann-cla/yes
Yuan Bin
Yuan BinCollaborators
Sep 28 Comments:

compile

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 28a436ed2d13d552412583d50409694b2f496330)
CANN-robot
CANN-robotCollaborators
Sep 28 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 28 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 28 Added label: ci-pipeline-passed
Yuan BinYuan BinCollaborators
Sep 28 Modify description of pull request
赵臣臣
赵臣臣Collaborators
Sep 28 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: approved
kdy18482276080
kdy18482276080Collaborators
Sep 28 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 28 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 28 Merged pull request