Closed
[Requirement|需求建议]: Optimize QBMM MX tiling #3358
panzhijaAdd on  Jun 16Closed at  Jul 6
panzhija
panzhijaCollaborators
Jun 16 Create

Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.

Backgroud(背景信息)

QuantBatchMatmulV3 的 MX per-group 场景需要进一步优化 tiling 策略。当前 MXFP8/MXFP4 部分 shape 下,baseM/baseN 搜索、baseK 选择、scaleKL1 覆盖范围和 L1 buffer 选择仍有优化空间,可能导致 AICore 负载不均衡、K 尾部重复搬运 scale 或 4-buffer 使用不充分。

Origin(信息来源)

ops-nn QuantBatchMatmulV3 / QBMM MX tiling 性能优化需求。

Benefit / Necessity (价值/作用)

  • 提升 MXFP8/MXFP4 场景 baseM/baseN 的负载均衡效果。
  • 单轮场景额外优化 baseK,提高 K 方向数据复用。
  • scaleKL1 在 L1 可容纳时覆盖完整 K,减少 K 尾部 scale 重复搬运。
  • 在 usedL1Size 等于 L1 容量时允许使用 4-buffer,减少不必要的 2-buffer 退化。
  • 规范 tail merge 后 baseM/baseN 与 block window 的状态更新,避免 full-load 判定中隐式修改 baseM 导致状态不一致。

Design(设计方案)

  1. 在 BaseBlockCalculator 中新增 MX load-balance 优化路径:

    • MX DEFAULT + DAV_3510 场景跳过通用 AdjustBaseBlockDefault;
    • 按外轴 16、内轴 128 遍历 baseM/baseN;
    • 以 balanceRate 为主评分,mnShapeScore 和 shapeRatioScore 作为 tie-break;
    • baseM/baseN 超过实际 shape 时按对应对齐规则回收;
    • roundLimit == 1 时单独更新 baseK。
  2. 在 MX Basic API tiling 中新增 MxL1Plan:

    • 统一 Build / Cache / Apply L1 plan;
    • 计算 adjusted scaleKL1,优先尝试 full K cover;
    • 4-buffer 放不下时尝试 stepK 从 4 回退到 2;
    • 同步更新 lib api stepKa/stepKb、scaleKL1 和 nBufferNum。
  3. 在 AdaptiveSlidingWindowTiling 中新增 NormalizeFullyMergedAxis:

    • 当 tail merge 已经覆盖完整轴时,将 tailMain 收编为 baseM/baseN;
    • 更新后重新计算 block window 信息;
    • full-load 判定统一使用 baseM/baseN,避免判定阶段直接修改 block 基础参数。

关联 PR:https://gitcode.com/cann/ops-nn/pull/6498

likedislike
panzhijapanzhijaCollaborators
Jun 16 Added label: requirement
panzhijapanzhijaCollaborators
Jun 16 Change title to "[Requirement|需求建议]: Optimize QBMM MX tiling", originally titled "[Requirement|需求建议]: 1".
panzhijapanzhijaCollaborators
Jun 16 Modify description of issue
panzhija
panzhijaCollaborators
Jun 16 Comments:

/assign

likedislike
CANN-robotCANN-robotCollaborators
Jun 16 Assign smdbha as responsible person
panzhijapanzhijaCollaborators
Jun 25 Modify description of issue
panzhijapanzhijaCollaborators
Jul 6 changed custom state from 进行中 to 已解决
panzhijapanzhijaCollaborators
Jul 6 Close issue
panzhijapanzhijaCollaborators
Oct 12 Deleted associated pull request: Optimize QBMM MX tiling