Merged
Adapt MX basic API tiling for triple L1 buffer #7237
panzhijaAdd on Jul 8
Adapt MX basic API tiling for triple L1 buffer #7237
Merged
panzhijaAdd on Jul 8
panzhija
panzhijaCollaborators
Jul 8

描述

为 qbmmv3 arch35 MX Basic API tiling 补齐 3-buffer L1 估算和选择逻辑。当前 Blaze MX TensorAPI BlockMmad 已支持 3 个 L1 buffer,但 adaptive_sliding_window_mx_basic_api_tiling 只按 2/4 buffer 估算,会在 4buffer 放不下而 3buffer 可行时回退到 2buffer。

本 PR 调整为优先选择 4buffer,TensorAPI 路径下再尝试 3buffer,最后回退 2buffer;L1 占用计算中 A/B data window 使用实际 l1BufferNum,scale/bias 保持双 buffer。为避免 helper 入参过多,新增 MxL1EstimateParams 聚合 L1 估算参数。

关联的Issue

Fixes #3948

测试

文档更新

不涉及文档更新。

类型标签

AI/Agent生成声明

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for panzhija's contribution.)
panzhijapanzhijaCollaborators
Jul 8 Created pull request, commit 3f619b69
atomgit-bot
atomgit-bot
Jul 8 Comments:

变更摘要

该 PR 为 MX basic API tiling 引入了三级 L1 缓冲(triple/3-buffer)支持。原先仅在双缓冲(2-buffer)和四缓冲(4-buffer)之间选择,现在新增 L1_THREE_BUFFER 常量及相应的能力检查与选择逻辑。同时,将分散的 L1 大小估算参数统一封装为 MxL1EstimateParams 结构体,重构了 CalcFourBufferUsedL1Size4MX、GetFullCoverScaleKL1IfPossible、CanOpenFourBufferByL1Estimate 等核心方法,使其基于该结构体并支持 3-buffer 判断。

主要改动

  • 新增 L1_THREE_BUFFER 常量:在 quant_batch_matmul_v3_tiling_util.h 中定义 constexpr uint8_t L1_THREE_BUFFER = 3U,作为三级缓冲的标识。
  • 引入 MxL1EstimateParams 参数结构体:在头文件中新增该结构体,聚合 kL1、scaleKL1、baseM、baseN、isAFullLoad、l1BufferNum 六个字段,取代原先散列的独立参数传递。
  • 新增 SelectL1BufferNum4MX 选择方法:按 4-buffer → 3-buffer → 2-buffer 的优先级依次估算 L1 占用,若设备支持三级缓冲(IsTripleL1BufferCapable)且 L1 容量允许,则选用三级缓冲。
  • 重构 CalcUsedL1Size4MX(原 CalcFourBufferUsedL1Size4MX):不再硬编码四缓冲倍数,改为基于 params.l1BufferNum 动态计算 A/B 侧数据缓冲数,统一处理 2/3/4 缓冲场景。
  • 重命名 CanOpenFourBufferByL1Estimate → CanOpenMultiBufferByL1Estimate:语义从“能否开启四缓冲”扩展为“能否开启多缓冲(4-buffer 或 3-buffer)”,相应更新 CalculateNBufferNum4MX 和 UpdateAFullLoadStatus 中的调用与注释。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Jul 8 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 8 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 8 Comments:

CLA Signature Pass

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

likedislike
213 messages are collapsed here。 See more
gitee-duhuiping
gitee-duhuipingCollaborators
Jul 25 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Jul 25 Added label: lgtm
CANN-robotCANN-robotCollaborators
Jul 25 Closed associated issue
CANN-robotCANN-robotCollaborators
Jul 25 Merged pull request
CANN-robot
CANN-robotCollaborators
Jul 25 Comments:

Pull Request 已合并或已关闭。

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

likedislike