Merged
chunk_gated_delta_rule支持initial_state 0轴1轴非连续 #8711
chunk_gated_delta_rule支持initial_state 0轴1轴非连续 #8711
Merged
liuxiao222Add on Jul 14
liuxiao222
liuxiao222Collaborators
Jul 14

描述

chunk_gated_delta_rule 算子 Ascend950 支持前两轴非连续,后两轴连续。

改动

1.aclnn层,当满足Ascend950且2,3轴连续时,用CreateView接口创建和输入initial_state同地址的view类tensor,否则转为连续tensor。可以在tiling获取到stride信息。
2.tiling层,新增tilingData获取前两轴的stride信息。
3.kernel层,当stage2阶段每个batch首次访问initial_state时,采用tilingData->stride获取偏移。

关联的Issue

#3428

测试

测试红线用例38条,STC用例31条,均通过。
测试图模式aclgraph红线用例38条,均通过。

文档更新

不涉及

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for liuxiao222's contribution.)
liuxiao222liuxiao222Collaborators
Jul 14 Created pull request, commit 7ee03e7a
atomgit-bot
atomgit-bot
Jul 14 Comments:

变更摘要

本 PR 为 chunk_gated_delta_rule 算子新增对 initialState 输入在 0 轴和 1 轴上非连续存储的支持。此前算子强制将 initialState 转换为连续内存布局,现在通过获取并传递实际的 stride 信息,使得 kernel 计算时能够正确处理非连续的 initial state 张量,避免不必要的内存拷贝。

主要改动

  • 新增 stateStride0 / stateStride1 tiling 字段:在 chunk_gated_delta_rule_tiling_data.h 中为 tiling 数据结构添加了 stateStride0 和 stateStride1 两个 int64_t 字段,用于记录 initial state 在 0 轴和 1 轴上的 stride。

  • 实现 GetStrides() 方法:在 chunk_gated_delta_rule_tiling.cpp 中新增 GetStrides(),优先从 context 获取 STATE_INDEX 输入的实际 stride;若 stride 不存在则回退计算默认值(stateStride1 = dk * dv,stateStride0 = nv * stateStride1),并在 GetShapeAttrsInfo 流程中调用该方法。

  • Host 侧改用 CreateView 保留 stride:在 aclnn_chunk_gated_delta_rule.cpp 中,将 initialState 的处理从直接调用 l0op::Contiguous 改为先判断连续性;若非连续则通过 CreateView 保留原始 stride 信息,避免强制内存拷贝。

  • Kernel 侧适配非连续 state 索引:在 chunk_gated_delta_rule.h 和 chunk_gated_delta_rule_stage2.h 中,将 initial state 的内存偏移计算从固定 nv * dv * dk 改为使用 stateStride0 / stateStride1,并通过 useInitialState 标志区分初始 state 与后续 state 的 stride 选取逻辑。

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 14 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 14 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


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
attention ✅ zzy__, haijie_699874 (2/2) ✅ zzy__, haijie_699874 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Jul 14 Set hz36amy_00,coder_linx,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,liudan12,huang_li,wangzhe123456789,cc-z,shen_weiling,gaoxiang618,songjionghui,wenxin_fight,miaofangzheng,mabing1118,tang-hao-hw-gitcode,haijie_699874,zzy__,yuhao_,L_Euler as approver
92 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Jul 16 Added label: api-check-pass
CANN-robotCANN-robotCollaborators
Jul 16 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Jul 16 Added label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Jul 16 Closed associated issue
CANN-robotCANN-robotCollaborators
Jul 16 Merged pull request