Merged
fix: truncation of repeatTimes in call of mul #13047
fix: truncation of repeatTimes in call of mul #13047
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 548a98ea
atomgit-bot
atomgit-bot
Sep 28 Comments:

变更摘要

本 PR 修复了 posembedding/inplace_partial_rotary_mul 模块中 inplacePartialRotaryMul 算子部分 special 路径用例精度失效的问题。问题根因是在 special 路径调用 Mul 时,repeatTimes 入参(由 numHead 决定)超过接口限制而被截断,导致计算结果不完整。修复方式是在调用 Mul 时,当 numHead 超过 MAX_MUL_REPEAT_TIME 时不再一次性调用,而是展开循环按段处理,直到处理完所有 head。

主要改动

  • Mul 调用改为分段循环: 在 InplacePartialRotaryMulABA<T, isBrc>::ComputeMul 的非 brc elewise 乘路径中,将原本单次 Mul(dtsUb[...], src0Ub[...], ..., mask, numHead, repeatParams_) 调用替换为以 done 为游标的 for 循环,按段累加直到覆盖全部 numHead。
  • 单次 repeatTimes 上限约束: 每段通过 remaining > MAX_MUL_REPEAT_TIME ? MAX_MUL_REPEAT_TIME : remaining 计算 repeats 并转换为 uint8_t,确保传入 Mul 的 repeatTimes 不超过接口允许的最大值,避免截断。
  • 分段偏移量调整: 每次 Mul 的 dtsUb 与 src0Ub 地址按 done * mask 递增偏移,使各段落在正确的数据区间,保证分段处理与整体处理等价。
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
9.2.0 ✅ gcw_kUomxQ2l, kdy18482276080 (2/2) ✅ gcw_kUomxQ2l (1/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-robot
CANN-robotCollaborators
Sep 28 Comments:

CLA Signature Pass

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

likedislike
Yuan Bin
Yuan BinCollaborators
Sep 28 Comments:

compile

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 97938acefc942d9e8993776974c335cf1447be6f)
CANN-robotCANN-robotCollaborators
Sep 28 Set hz36amy_00,juyangokok,monologue815,xuanyuandy,chen-linxin4,yu-xinjie62,jiang-lirui,Allan_Yu,TianXL,songkai111,liudan12,jiangtao_rts,Wei_NaChuan,luwei_1104,gitcode-chenjiao,cc-z,kdy18482276080,xuchengyang,hanxiaolong,mabing1118,Julius47,gcw_kUomxQ2l,Andy-lb,yuhao_,jiangjiawei,wangxun21 as approver
CANN-robotCANN-robotCollaborators
Sep 28 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
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#9125

流水线: https://gitcode.com/CANN/ops-transformer/actions/runs/ad258c65b5554ecea021e193edbd6171 | PR#13047 | 2026-09-28 10:43:25 ~ 2026-09-28 10:48:14 | 失败 Job 1 个

定界结论: 代码问题 / 代码检查错误 — clang-format 格式化不通过
  • 失败类型: 代码问题
  • 根因: CodeCheck_precommit Job 中 pre-commit 的 clang-format 检查失败, 文件 posembedding/inplace_partial_rotary_mul/op_kernel/inplace_partial_rotary_mul.h 未按 clang-format 规范格式化(hook 自动修改了该文件)
  • 处置建议: PR 提交者在本地执行 pre-commit run clang-format --all-files (或直接对上述文件执行 clang-format) 修复格式后重新推送
  • 排除项: 其余检查项(merge conflicts / private key / codespell / duplicate-header 等)均 Passed 或 Skipped, 无环境或平台类错误

失败根因分析

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

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

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Modify description of pull request
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: d7a95e8db7f20ddc625c42de7610372fb9a96579)
Yuan BinYuan BinCollaborators
Sep 28 Force-pushed 1 commits:ac42e081-fix: truncation of repeatTimes in call of mul
Yuan BinYuan BinCollaborators
Sep 28 Pre merge succeeded (commit_id: 01f112486a7a92429237ce27bb2b6a1f0cb2c6cb)
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: 823d501da4ad7e1d9680731f9ff18e504547bd9d)
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: 71a6026ca82bba8c59a58b7d731f1216113db26f)
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
kdy18482276080
kdy18482276080Collaborators
Sep 28 Comments:

/lgtm
/approve

likedislike
Yuan BinYuan BinCollaborators
Sep 28 Modify description of pull request
Yuan BinYuan BinCollaborators
Sep 28 Modify description of pull request
liulun0308
liulun0308Collaborators
Sep 29 Comments:

/approve

likedislike
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:

The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: kdy18482276080

likedislike
CANN-robotCANN-robotCollaborators
Sep 29 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 29 Closed associated issue
CANN-robotCANN-robotCollaborators
Sep 29 Merged pull request