已合并
feat(native_package): engram_gate接入Native打包 #176
luohui46创建于 24 天前
feat(native_package): engram_gate接入Native打包 #176
已合并
luohui46创建于 24 天前
luohui46
24 天前

当前PR是否有AI参与:

[ ] 否

[x] 是
__1. AI Agent 平台: opencode(CANNBot 编程助手)
__2. AI 模型: cannbot/glm-5.3
__3. Prompt上下文 : 用户提出"参考 #172(attn_epilogue 接入 Native 打包)为 indexer_prologue_k 和 engram_gate 算子补充 net/native_package/",AI 完成代码实现、AOT 构建、测试与真机验证;rebase 解决与 cdb49b4(上游已合入 indexer_prologue_qw/k 的 Native 打包)的冲突后,按检视意见收敛为仅保留 engram_gate 的接入

PR功能描述 / 为什么需要这个合入**:

将 engram_gate 算子接入 net/native_package 的 Native 打包,部署时通过 Native wheel 直接命中 AOT 二进制,省去首次调用 JIT 编译开销:

  1. engram_gate:新增 @export("engram_gate")。T、mask ABI 与核配额参与编译(张量形状、launch grid 与 host launcher 随之变化),默认按 56/64 核配额 × T=72 × 有/无 image_mask 共 4 个配置;eps/clamp_value 默认导出 1e-6,其余取值回退 JIT。支持 CANNBOTDSL_DS41_PROFILES 的 engram_gate 键覆盖默认集合,枚举前预清模块编译缓存(对齐 mqsmla/qli 写法)。
  2. operator_groups.toml 登记 engram_gate 并加入 ds41 组;sample README 增加"安装包调用"章节,CHANGELOG 补充条目。
  3. 修正 net/native_package/test_build.py 两处既有失败:export 探测不识别 @aot.export(...) 属性写法(flash_kda);test_ds41_selection 断言未随算子集更新(--group k3 已是合法组,且 ds41 组已含 indexer_prologue_qw/k)。

注:indexer_prologue_k 的 Native 打包已由 cdb49b4(!182)在上游合入,本 PR 经 rebase 后仅保留 engram_gate 部分;test_ds41_selection 断言已同步 ds41 组的最新成员。

该PR关联的issue

(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #<待填写>

希望检视人员了解:

  • engram_gate 的 block_num = min(max_blocks, rows) 在 @host 内求值并烙进二进制(max_blocks 取设备向量核数),故需按 56/64 配额枚举:T=72 时 rows=288,56 与 64 是两个不同的二进制。对比 indexer_prologue_k:launch 核数是运行时 int32 标量,二进制与核数无关(见 cdb49b4)。
  • engram_gate 默认仅枚举 T=72(模型 token 数),其他 T/eps/clamp_value 回退 JIT,可通过 CANNBOTDSL_DS41_PROFILES 的 engram_gate 键补充({"max_blocks": int, "tokens": [int, ...], "has_mask": [bool, ...]})。
  • 已知与本 PR 无关的环境问题:新版 setuptools 会将依赖名归一化为 cannbot-dsl <0.8,>=0.7.0,test_build_wheel_contains_sources_and_native_resources 在本地环境失败(未改动 pyproject/setup)。
  • 本轮验证在本地 Ascend950PR(28 Cube/56 Vector)完成。

改动类型 / Change Type

测试信息 / Testing

检查清单 / Checklist

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 luohui46 的贡献)
Lluohui46
24 天前 创建了 pull request,commit c23f8d2b
CANN-robotCANN-robot成员
24 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
24 天前 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
24 天前 评论:

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
repo-cann/cannbot-dsl ✅ yang-jiwei, liujun2025 (2/2) ✅ yang-jiwei, liujun2025 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
Lluohui46
24 天前 预合并成功(commit_id: a9947fef71a981bf6e68579db3ec5b94622061be)
此处折叠了80条消息 查看更多
liujun2025成员
23 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
23 天前 添加了label:approved
yang-jiwei成员
23 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
23 天前 添加了label:lgtm
CANN-robotCANN-robot成员
23 天前 合入了pull request