已合并
修复swiglu_group_quant_grad bf16输入Cast hazard与group_index场景死锁 #8667
修复swiglu_group_quant_grad bf16输入Cast hazard与group_index场景死锁 #8667
已合并
shilulu创建于 21 天前
shilulu
21 天前

描述

修复swiglu_group_quant_grad bf16输入Cast hazard与group_index场景死锁

关联的Issue

https://gitcode.com/cann/ops-nn/issues/4787

测试

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 shilulu 的贡献)
Sshilulu
21 天前 创建了 pull request,commit cb13285d
atomgit-bot
atomgit-bot
21 天前 评论:

变更摘要

本 PR 主要修复 swiglu_group_quant_grad 算子在 bf16 输入下的 Cast hazard 问题,以及 group_index 场景下的死锁问题。改动集中在 host 侧的 tiling 计算与 kernel 侧的缓冲区初始化、数据搬移/转换流程:通过为 cast 场景预留独立缓冲区和扩大 UB 分配,避免 bf16 输入在 Cast 时源/目标内存重叠;同时调整 ProcessZeroOutTrunc 的多核执行逻辑,使所有核都参与同步与清零,从而消除 group_index 场景的死锁。

主要改动

  • 修复 bf16 输入的 Cast hazard:在 CopyInGradYCopyInXCopyInYOrigin 中引入 castSrcBaseIdx 偏移,将 bf16 源数据搬移到缓冲区的高地址区域后再执行 Cast,使源与目标不再重叠。
  • 为 cast 场景扩展缓冲区InitBuffer 新增 isCastInput 参数,gradYQueueyOriginQueue 的缓冲大小在 bf16 输入时按 castBufferFactor = 2 扩容。
  • 调整 host 侧 tiling 的 UB 预算UB_BASE_FACTOR12 调整为 14,新增 UB_CAST_EXTRA_FACTOR = 2,并在输入非 DT_FLOAT 及同时带 weight 时额外累加该因子。
  • 修复 group_index 场景死锁Process 不再对 blockIdx >= usedCoreNum 提前返回,所有核都会执行 SyncAllInitZeroOutTruncBuffer
  • 修正清零步长ZeroOutTrunc 中的 zeroTokenStepusedCoreNum 改为 coreNumAll,使清零范围覆盖全部核。
likedislike
atomgit-bot
atomgit-bot
21 天前 评论:

代码审查

✅ 未发现问题

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
21 天前 评论:

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
activation 查建青, 刘杰 (2/2) 查建青, 刘杰 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
21 天前 将zengjuan,chaotang233,kevin_huang1234,crystalhu,yangyang016,fanqirui,renruhai,su-yueming,zhajianqing123,chenqi317,wang-xing001,liubo75,tangweiwei2,liujie12345678,pingchuantang,Chen_HaoWen设为评审人
CANN-robotCANN-robot成员
21 天前 将kevin_huang1234,renruhai,su-yueming,zhajianqing123,wang-xing001,liujie12345678,pingchuantang,Chen_HaoWen设为审查人
shilulu
21 天前 评论:

compile

likedislike
Sshilulu
21 天前 update merge request[project id: 7665709, iid: 8667, commit_id: db127a5ee46f0b8a231a1b3f778360812221a813] virtual merging success
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [08a370aa04a94859848dc0558d3ddc4f][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-13 19:45:12]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [865a21fb4a154c9b82431f6efc91076e][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ❌ FAILED >>>>> >>>>>
SCA ✅ SUCCESS >>>>>
likedislike
Sshilulu
21 天前 修改了pull request 的描述
此处折叠了13条事件消息 查看更多
CANN-robotCANN-robot成员
21 天前 删除了label:stat/needs-squash
CANN-robot
CANN-robot成员
21 天前 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): stat/needs-squash.

likedislike
shilulu
21 天前 评论:

compile

likedislike
Sshilulu
21 天前 update merge request[project id: 7665709, iid: 8667, commit_id: 803b8ecf0aaf37f8618ab392c5d89fef2c06bd27] virtual merging success
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-failedapi-check-pass
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [8a6e42d4b501436ebea796ae05eee1ba][流水线指导]

任务名称状态日志下载链接
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
Compile_Pre ✅ SUCCESS >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910b ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_910c ✅ SUCCESS >>>>> >>>>>
Compile_X86_monitor_950 ✅ SUCCESS >>>>> >>>>>
Compile_classify ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_9030_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
PreSmoke_A900 ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
PreSmoke_ATK_Test_A2 ✅ SUCCESS >>>>>
UT_Test_report_lcov ✅ SUCCESS >>>>>

[2026-08-13 20:03:07]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
21 天前 评论:

流水线任务触发成功
任务链接 [358436b6a8704cd58cf11d64e13cc544][流水线指导]

任务名称状态日志下载链接
antipoison ✅ SUCCESS >>>>>
codecheck_checkpr ✅ SUCCESS
StaticCheck_codespell ✅ SUCCESS
StaticCheck_link_validity ✅ SUCCESS
StaticCheck_resource_existence ✅ SUCCESS
StaticCheck_tag_closed ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_precommit ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>

[2026-08-13 19:49:51]    CI执行结束

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:api-check-pass
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-passed
zhajianqing123成员
21 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:approved
liujie12345678成员
21 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:lgtm
CANN-robotCANN-robot成员
21 天前 关闭了关联的issue
CANN-robotCANN-robot成员
21 天前 合入了pull request