Merged
Optimize QBMM MX tiling #6498
panzhijaAdd on Jun 25
Optimize QBMM MX tiling #6498
Merged
panzhijaAdd on Jun 25
panzhija
panzhijaCollaborators
Jun 25

描述

优化 QuantBatchMatmulV3 在 MX per-group 场景下的 tiling 选择,主要覆盖 MXFP8/MXFP4 的 base block、L1 plan、scaleKL1 和 tail/full-load 相关逻辑。

主要改动:

  1. 优化 MX 场景 baseM/baseN 选择:

    • MX DEFAULT 模式不再复用通用 AdjustBaseBlockDefault 路径;
    • 在 DAV_3510 上新增 OptimizeBaseBlockForLoadBalance,按外轴 16、内轴 128 搜索 baseM/baseN;
    • 当 baseM/baseN 超过实际 m/n 时,按 dtype 与 transpose 对应的对齐粒度回收;
    • roundLimit == 1 时额外更新 baseK,提高单轮场景 K 方向复用。
  2. 优化 MX Basic API L1 tiling:

    • 新增 MxL1Plan,统一缓存和复用 L1 tiling 结果;
    • scaleKL1 支持在 L1 可容纳时覆盖完整 K,减少 K 尾部重复搬运 scale;
    • stepK=4 放不下 4-buffer 时尝试回退到 stepK=2;
    • usedL1Size == l1Size 时允许使用 4-buffer。
  3. 优化 adaptive sliding window 状态:

    • 新增 NormalizeFullyMergedAxis,在 tail merge 完全覆盖某个轴时统一更新 baseM/baseN 并重算 block window;
    • A full-load 判定不再直接用 mTailMain 修改 baseM,避免窗口状态不一致。
  4. 更新 op_host UT 期望:

    • 刷新 test_quant_batch_matmul_v3.csv 中受影响的 MX Basic API tilingData。

关联的Issue

关联Issue #3358
https://gitcode.com/cann/ops-nn/issues/3358

测试

  • 已更新 matmul/quant_batch_matmul_v3/tests/ut/op_host/test_quant_batch_matmul_v3.csv 中受影响的 MX tilingData。
  • 已执行 git diff --check,检查通过。

文档更新

不涉及文档更新。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for panzhija's contribution.)
panzhijapanzhijaCollaborators
Jun 25 Created pull request, commit 78ad988b
CANN-robotCANN-robotCollaborators
Jun 25 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Jun 25 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jun 25 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
matmul ✅ 王子韬, 陈琦 (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

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

likedislike
panzhijapanzhijaCollaborators
Jun 25 Modify description of pull request
187 messages are collapsed here。 See more
panzhijapanzhijaCollaborators
Oct 12 Associated issue: [Requirement|需求建议]: Matmul Q3 性能优化规划
CANN-robotCANN-robotCollaborators
Oct 12 Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
Oct 12 Comments:

The following label is not ready.

ci-pipeline-passed: The ci-pipeline-passed label is expired as added over 72 hours. Please use /compile to recompile.

likedislike
CANN-robot
CANN-robotCollaborators
Oct 12 Comments:

The following label is not ready.

ci-pipeline-passed: The ci-pipeline-passed label is expired as added over 72 hours. Please use /compile to recompile.

likedislike
CANN-robot
CANN-robotCollaborators
Oct 12 Comments:

The following label is not ready.

ci-pipeline-passed: The ci-pipeline-passed label is expired as added over 72 hours. Please use /compile to recompile.

likedislike