已合并
[Huawei][AscendNPU-IR][SIMT] Add support for using global scratch memory for staging in TileDotLoads and for Convert Layout ops #2333
[Huawei][AscendNPU-IR][SIMT] Add support for using global scratch memory for staging in TileDotLoads and for Convert Layout ops #2333
已合并
SanidhyaBarara创建于 15 天前
15 天前
--- title: "[AscendNPU IR]:" --- ## 描述 Description 请提供此 Pull Request 的高级别说明。 Add support for using global scratch memory for staging in TileDotLoads and for Convert Layout ops. Also adds a default false option to enable using global scratch. ## 类型 Category - 新功能 New feature - 代码风格更新(格式化,局部变量)Style changes - 重构(即不是新增功能,也不是修改bug的代码变动)Refactor ## Checklist - 我的代码遵循这个项目的代码风格 My code follows the project's code style - 我已经自己测试过我的代码 I have self-tested my code - 我已经更新了相应的文档 I have updated the relevant documentation - 我已经根据需要更新了对应的变更日志 I have updated the changelog as needed - 我已经在标题中正确使用了类型标签(例如:`feat:`, `fix:`)I have correctly used type labels in the title (e.g., feat:, fix:)
likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 SanidhyaBarara 的贡献)
SSanidhyaBarara
15 天前 创建了 pull request,commit ca74fb03
atomgit-bot
atomgit-bot
15 天前 评论:

变更摘要

此 PR 为华为 AscendNPU SIMT 后端新增了全局 scratch 内存(global scratch memory)的分阶段(staging)支持,主要应用于 TileDotLoads 中的非加载操作数分阶段和 ConvertLayout 操作的跨布局转换。核心思路是:当共享内存(SMEM)预算不足以容纳分阶段缓冲区时,允许回退到全局内存(GMEM)路径。为此,PR 将原有的 SharedMemConflictModel 重构为更通用的 DotTilingCostModel,新增了 storeDGlobal/loadDGlobal 接口,引入了 enable-global-scratch-allocation(默认关闭)的管道选项,并重命名了 ConvertSharedPtrToMemDescLowerDotBuffersAndSharedMem 以更准确地反映其职责扩展。

主要改动

  • 成本模型重构SharedMemConflictModel 重命名为 DotTilingCostModelAscendSmemGeometry 重命名为 AscendMemGeometry 并新增 peakBandwidthBytesPerCycleGmem() 方法;StagingDecisionInputs 从单一 roundTripBytes 拆分为 roundTripBytesA/roundTripBytesB,新增 smemStageA/smemStageB 标志和 stagingFixedOverheadCyclesGmem 字段,stageThroughSmem 改为 stageThroughMem,使成本模型能分别评估 SMEM 和 GMEM 路径的开销。

  • 新增全局内存加载/存储接口:在 TargetInfoTargetInfoBase 中新增 storeDGloballoadDGlobal 虚方法,TargetInfo.cpp 中实现了完整的全局内存存取逻辑,支持向量化、子字节元素处理、大宽度拆分,并使用 ascend_dpx::StoreOp/ascend_dpx::LoadOpL2_CACHE_HINT_NORMAL_FV 缓存策略。

  • StageNonLoadOperandPattern 支持全局 scratch:当 totalStageBytes > smemBudgetBytesallowGlobalScratch 为真时,模式不再直接失败,而是按需将 A 或 B 操作数的地址空间切换为 kGlobalMemoryAddressSpaceptr<1>),并通过 appendScratchArg 向函数追加带 bishengir.scratch_global 标记的参数,使非加载操作数可通过全局内存完成分阶段。

  • ConvertLayoutOp 全局内存路径:新增 ConvertLayoutOpConversionGM 模式,在 Allocation.cpp 中当 allowGlobalScratch 开启且 ConvertLayoutOp 的共享内存偏移量超出 smemSize 时,将其标记为 store_to_gmem 并分配全局 scratch 偏移;lowerLdStShared 新增 switchToGM 参数,在 GMEM 路径下调用 storeDGlobal/loadDGlobal 替代 storeDShared/loadDShared

  • 管道与 Pass 重命名ConvertSharedPtrToMemDesc pass 重命名为 LowerDotBuffersAndSharedMemlower-dot-buffers-and-shared-mem),新增 SetAllowGlobalScratchAttr pass(set-allow-global-scratch-attr)用于将命令行选项写入模块属性 ttg.enable-global-scratch-allocation;管道中条件性插入 TritonGPUGlobalScratchAllocationPass

likedislike
ascend-robot
ascend-robot成员
15 天前 评论:

libing-pipeline创建中,请等待……

likedislike
atomgit-bot
atomgit-bot
15 天前 评论:

代码审查

✅ 未发现问题

likedislike
ascend-robotascend-robot成员
15 天前 添加了label:stat/needs-squash
ascend-robotascend-robot成员
15 天前 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
15 天前 评论:

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
repo-Ascend/AscendNPU-IR yue-xy, michael_hliao (2/2) michael_hliao (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robot
ascend-robot成员
15 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
15 天前 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
15 天前 评论:

✅ 文档门禁通过!

检查项 检查结果 详情
markdownlint ✅ 已通过 查看详情
link-validity-check ✅ 已通过 查看详情
resource-existence-check ✅ 已通过 查看详情
tag-closed-check ✅ 已通过 查看详情
likedislike
ascend-robotascend-robot成员
15 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
15 天前 添加了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
15 天前 添加了label:SC-FAIL
SanidhyaBarara
15 天前 评论:

compile

likedislike
ascend-robotascend-robot成员
15 天前 添加了label:ci-pipeline-running
ascend-robot
ascend-robot成员
15 天前 评论:

ascend docs pipeline is running...

likedislike
ascend-robotascend-robot成员
15 天前 删除了label:docs-ci-pipeline-success
ascend-robotascend-robot成员
15 天前 添加了label:docs-ci-pipeline-running
ascend-robot
ascend-robot成员
15 天前 评论:

✅ 文档门禁通过!

检查项 检查结果 详情
markdownlint ✅ 已通过 查看详情
link-validity-check ✅ 已通过 查看详情
resource-existence-check ✅ 已通过 查看详情
tag-closed-check ✅ 已通过 查看详情
likedislike
ascend-robotascend-robot成员
15 天前 删除了label:docs-ci-pipeline-running
ascend-robotascend-robot成员
15 天前 添加了label:docs-ci-pipeline-success
SanidhyaBarara
15 天前 评论:

npuir-smoke

likedislike
ascend-robotascend-robot成员
15 天前 添加了label:NPUIR-DT-RUNNING
ascend-robotascend-robot成员
15 天前 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
15 天前 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
15 天前 评论:
流水线 PR-pipeline_ascendnpu-ir#4171 已完成
阶段 任务名 状态 详情
恶意代码检查 Antipoison >>>
编码安全与规范检查 CodeCheck >>>
流水线 PR-pipeline_ascendnpu-ir >>>
likedislike
ascend-robotascend-robot成员
15 天前 删除了label:NPUIR-DT-RUNNING
ascend-robotascend-robot成员
15 天前 添加了label:NPUIR-DT-SUCC
ascend-robot
ascend-robot成员
15 天前 评论:
流水线 PR-pipeline_npuir-smoke#1565 已完成
阶段 任务名 状态 详情
编译构建 Compile >>>
开发者测试 CVOps >>>
流水线 PR-pipeline_npuir-smoke >>>
likedislike
ascend-robotascend-robot成员
14 天前 删除了label:SC-FAIL
ascend-robotascend-robot成员
14 天前 添加了label:SC-FAIL
ascend-robotascend-robot成员
10 天前 删除了label:SC-FAIL
ascend-robotascend-robot成员
10 天前 添加了label:SC-FAIL
yue-xy
yue-xy
9 天前 评论:

/lgtm

likedislike
michael_hliao成员
2 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
2 天前 添加了label:approvedlgtm
ascend-robot
ascend-robot成员
2 天前 评论:

Not enough required testers

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
ascend-robotascend-robot成员
2 天前 删除了label:SC-FAIL
ascend-robotascend-robot成员
2 天前 添加了label:SC-SUCC
PpCSICompileDV成员
2 天前 通过测试
ascend-robotascend-robot成员
2 天前 合入了pull request,合并节点 SHA:a8711ecf6e12572dbe33513cd33026a32652eff0