Merged
feat(mla): 接入 PR436 最新 DSL 实现与 Torch 适配 #16332
feat(mla): 接入 PR436 最新 DSL 实现与 Torch 适配 #16332
Merged
liqingsong16Add on 10 days ago
liqingsong16
liqingsong16Collaborators
10 days ago

描述

将 cannbot-dsl PR436 提交 6807d7c803e032bfcecde5bd968ce2f7609d427f 的非量化 mla_prolog_v4 和量化 quant_mla_prolog 接入 ops-transformer。

  • 两份 op_dsl 源码与该上游提交逐字节一致,包含 Prefill/Decode 实现、Host 参数分组、辅助函数命名整理、Native 导出和 mla_dispatch 映射。
  • 对外接口为 torch.ops.cann_ops_transformer.mla_prolog_v2 和 torch.ops.cann_ops_transformer.quant_mla_prolog,包含 Eager、Meta/Fake 和图模式适配。
  • Torch 接入层调用上游当前入口:非量化图路径使用 mla_prolog_v2_graph_npu;量化 Eager/图路径使用 execute_async / execute_graph。同步引用这些辅助函数的测试,避免调用已删除或重命名的函数。
  • 参数契约与上游一致:非量化 qkv_quant_mode、量化 w_qr_quant_mode/qkv_quant_mode 必填,可按位置或关键字传入;quant_scale_kv/rope_sin/rope_cos 仅支持关键字;cache_mode 默认 0(PA_BSND)。保留 MXFP8 图路径的 UINT8 scale carrier。
  • 默认 Native 键为非量化 20 个、量化 36 个,键值及顺序保持;量化 profiles 覆盖 RoPE 0/1/2。
  • 改动限定在两个算子目录,复用公共构建和 wheel 发现逻辑。

关联的Issue

本 PR 为上游算子实现接入,不关闭关联 Issue。

测试

  • Python 3.12 语法、Ruff 0.14.14 检查及格式检查通过。
  • 两份 DSL 源码 SHA256 与上述 PR436 提交一致;移植测试的计算、Golden 和验收函数 AST 与上游一致。
  • CPU 侧实际 PyTorch 2.8.0 dispatcher/Meta 检查通过:四个 schema 与上游一致,覆盖模式组合、QR 开关、模式参数位置/关键字传入、默认 cache_mode、缺失必填参数,以及量化图 Fake 的 MXFP8 carrier。
  • Native 键枚举及量化 RoPE profiles 检查通过;对比上一同步版本,20+36 个键值和顺序未变。
  • 实际生成 Python custom wheel,包内源码 SHA256、entry points、发现别名及四个 Torch schema 注册检查通过。
  • 使用包内实际 Torch 接入层及按上游真实函数签名构造的测试替身,检查两算子 Eager/图入口的位置和关键字参数转发,8 项通过。量化 Host 的 37 项参数名称、顺序及分组后的展开检查通过。这些是 CPU 接入检查,不代表设备执行验证。
  • 空白与改动范围检查通过,无公共文件或文档文件改动。

本轮未执行 Native/custom .run 全量构建、NPU 精度、性能或实际图捕获与重放测试。

文档更新

无文档文件改动。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for liqingsong16's contribution.)
liqingsong16liqingsong16Collaborators
10 days ago Created pull request, commit dff02f73
atomgit-bot
atomgit-bot
10 days ago Comments:

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

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
10 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
10 days ago 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
attention ✅ shasha_an, shen_weiling (2/2) ✅ shasha_an (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
10 days ago Set guijianwei,hz36amy_00,yangziqi_007,coder_linx,cheng_zhiwei,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,gitee-duhuiping,huang-wei-chen,liudan12,shasha_an,wangzhe123456789,Wei_NaChuan,zhangshuoleiokok,luwei_1104,gitcode-chenjiao,cc-z,kdy18482276080,xuchengyang,shen_weiling,lwx1255555,gaoxiang618,songjionghui,lining_210,miaofangzheng,mabing1118,tang-hao-hw-gitcode,haijie_699874,fengying555682,zzy__,Julius47,yuhao_,L_Euler,wangxun21,zzzzzzyf_,caiwenwen,yanglu-1 as approver
CANN-robotCANN-robotCollaborators
10 days ago Set guijianwei,hz36amy_00,yangziqi_007,coder_linx,cheng_zhiwei,juyangokok,monologue815,xuanyuandy,crystalhu,yu-xinjie62,huangwei791,jiang-lirui,yang-binrong,Allan_Yu,gitee-duhuiping,huang-wei-chen,liudan12,shasha_an,wangzhe123456789,Wei_NaChuan,zhangshuoleiokok,luwei_1104,gitcode-chenjiao,cc-z,kdy18482276080,xuchengyang,shen_weiling,lwx1255555,gaoxiang618,songjionghui,lining_210,miaofangzheng,mabing1118,tang-hao-hw-gitcode,haijie_699874,fengying555682,zzy__,Julius47,yuhao_,L_Euler,wangxun21,zzzzzzyf_,caiwenwen,yanglu-1 as approver
atomgit-bot
atomgit-bot
10 days ago Comments:

⚠️ 本次变更过大(10 个可审文件、27174 行,预估需 23 轮分片审查),已超出 AI 代码评审的处理范围,本次跳过。建议拆分为更小的 PR 以获得有效评审。

likedislike
Incorrect?
liqingsong16liqingsong16Collaborators
10 days ago Pre merge succeeded (commit_id: 3f919f3a515496014ae27b50570b70fa1069846c)
7 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
10 days ago Removed approver gitee-duhuiping,gitcode-chenjiao,lwx1255555,fengying555682,zzzzzzyf_,caiwenwen,yanglu-1
liqingsong16
liqingsong16Collaborators
10 days ago Comments:

/compile

likedislike
liqingsong16liqingsong16Collaborators
10 days ago Pre merge succeeded (commit_id: fab3fd67c18f21aedbec4bdce12e7615fabb22b8)
CANN-robot
CANN-robotCollaborators
10 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
10 days ago Added label: ci-pipeline-running
6 event messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
9 days ago Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
9 days ago Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: cann-cla/yes
6 event messages are collapsed here。 See more
liqingsong16liqingsong16Collaborators
9 days ago Modify description of pull request
liqingsong16
liqingsong16Collaborators
9 days ago Comments:

/compile

likedislike
liqingsong16liqingsong16Collaborators
9 days ago Pre merge succeeded (commit_id: b25b5857d37c5e45576d522d72d8175f96e80c40)
CANN-robot
CANN-robotCollaborators
9 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
9 days ago Added label: ci-pipeline-passed
shasha_an
shasha_anCollaborators
9 days ago Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: approved
shen_weiling
shen_weilingCollaborators
9 days ago Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
9 days ago Added label: lgtm
CANN-robotCANN-robotCollaborators
9 days ago Merged pull request