Merged
feat: add M-RoPE MX quantization support #10557
feat: add M-RoPE MX quantization support #10557
Merged
xubinglinAdd on Aug 25
xubinglin
xubinglinCollaborators
Aug 25

描述

为 QkvRmsNormRopeCacheWithKScale 增加 Ascend 950 上的 M-RoPE MX 场景。

功能

  • Q/K 执行 RMSNorm -> M-RoPE -> Dynamic MX Quant,每个 D32 block 生成 FP8 E4M3FN 数据和 FLOAT8_E8M0 scale。
  • V 使用 [Nv, D] 的 per-head-per-channel scale 写入 FP8 cache。
  • 保留原有 RoPE 和 M-RoPE 场景,并统一由公共 tiling 校验 shape、dtype、layout、stride 和场景组合。

接口

  • ACLNN 增加可选属性 kQuantMode,Q/K 的 MX 量化模式取值为 Mx。
  • qScaleOptional 为可选输出:
    • RoPE:FP32 rank 2,必须存在;
    • M-RoPE:不提供公开输出;
    • M-RoPE MX:FLOAT8_E8M0 [T, Nq, ceil(D/32)],必须存在。
  • Torch 原地接口返回 q_out, q_scale;functional 接口额外返回三个更新后的 cache。
  • package 使用 optionalOutputMode=gen_placeholder,同时包含 q_scale present/absent 的 simplified key。

约束

  • 仅支持 D=128、1 <= T <= 262144。
  • head_nums=[Nq,Nk,Nv] 满足 0 < Nq <= 64、Nq=8*Nk、Nk=Nv。
  • M-RoPE MX 固定 layout_qkv=layout_q_out="TND",qQuantMode=kQuantMode="Mx",且不传 rotation。
  • K/V/K-scale cache 必须满足文档规定的正 stride、非重叠和 K/V 前三维 stride 一致约束。

实现

  • 新增 M-RoPE MX controller、layout、vector 和 VF 实现,按 V -> K -> Q 串行调度。
  • M-RoPE MX controller 以同名场景类承载实现,公共 controller 仅保留模板特化绑定。
  • Torch Meta 场景参数使用具名结构封装,底层扩展调用参数顺序由单一映射维护。
  • Golden 的核心语义保留在 kernel golden;ACLNN/E2E golden 复用该实现。
  • arch35 新增的 ST 清单仅包含 M-RoPE MX 场景。
  • UT 覆盖率统计包含 ACLNN、tiling 和 infershape 实现。

关联的Issue

测试

  • Pre-commit:全部 PR 变更文件通过。
  • ACLNN UT:145/145 PASS;定向函数覆盖率 92.3%(12/13)。
  • Host/Tiling UT:136/136 PASS;tiling 定向函数覆盖率 92.6%(63/68)。
  • Infershape UT:定向函数覆盖率 100%(16/16)。
  • Ascend 950 package build 和 Torch Extension wheel build:PASS。
  • package 注册检查:q_scale 为 optional,optionalInputMode/optionalOutputMode 均为 gen_placeholder,present/absent simplified key 均存在。
  • Ascend 950PR_9589 设备 ST:
    • ACLNN L0:110/110 PASS;L1:400/400 PASS;package 冒烟:1/1 PASS;
    • Kernel release binary:180/180 PASS,精度和内存越界检查全部通过;
    • Torch Extension functional/inplace:34/34 PASS。

文档更新

  • 更新 ACLNN 接口文档与算子 README,补充 M-RoPE MX 调用场景、参数约束和 FLOAT8_E8M0 scale 类型。
  • 更新 Torch Extension 中文文档,补充 M-RoPE MX functional/inplace 调用示例。
  • 更新 ACLNN、算子和 Torch API 清单,概述 M-RoPE MX 能力。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for xubinglin's contribution.)
xubinglinxubinglinCollaborators
Aug 25 Created pull request, commit b0f096a7
atomgit-bot
atomgit-bot
Aug 25 Comments:

🤖 正在生成合并请求摘要,请稍候…

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

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robotCollaborators
Aug 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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
*/*/README.md ✅ 冯英, 蔡雯雯, 蒋礼锐, 刘丹 (4/2) ✅ 冯英, 蔡雯雯 (2/1)
*/*/docs/acl*.md ✅ 冯英, 蔡雯雯, 刘丹, 蒋礼锐 (4/2) ✅ 蔡雯雯, 冯英 (2/1)
*/*/op_host/*_def.cpp ✅ 王永光, 蒋礼锐, 刘丹 (3/2) ✅ 王永光 (1/1)
*/*/op_host/op_api/aclnn*.h ✅ 刘丹, 蒋礼锐, 王永光 (3/2) ✅ 王永光 (1/1)
docs ✅ 刘丹, 蒋礼锐 (2/2) ✅ 刘丹, 蒋礼锐 (2/1)
posembedding ✅ 刘丹, 蒋礼锐 (2/2) ✅ 蒋礼锐, 刘丹 (2/1)
sig-ops-transformer ✅ 刘丹, 蒋礼锐 (2/2) ✅ 刘丹, 蒋礼锐 (2/1)
tests ✅ 刘丹, 蒋礼锐 (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

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

likedislike
338 messages are collapsed here。 See more
caiwenwen
caiwenwenCollaborators
Sep 1 Comments:

/lgtm
/approve

likedislike
liudan12
liudan12Collaborators
Sep 1 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 1 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 1 Closed associated issue
CANN-robotCANN-robotCollaborators
Sep 1 Merged pull request