Merged
add ops-tilelang init framework #2
add ops-tilelang init framework #2
Merged
ChaoyangJiAdd on Sep 7
ChaoyangJi
ChaoyangJiCollaborators
Sep 7

当前PR是否有AI参与:

无。

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

本 PR 初始化 ops-tilelang 高性能算子仓,为 CANN 社区提供基于 TileLang DSL 的 Ascend 算子开发、测试、性能回归和 wheel 发布基础框架。
项目采用运行时接口与硬件 kernel 分层设计,当前仅支持 Ascend A5 及以上架构。

主要改动

  1. 基础工程框架
  • 建立 src/ layout Python 工程。
  • 发行包名为 ops-tilelang,Python 命名空间为 cann_ops_tilelang。
  • 使用 setuptools、setuptools-scm 构建 wheel。
  • 支持 Python 3.10、3.11 和 3.12。
  • 运行时依赖 torch>=2.1 和 tilelang>=0.1.9。
  • torch_npu、CANN Toolkit 和驱动由目标环境提供。
  • License 使用 MIT。
  • 包导入阶段不初始化 NPU、不编译 kernel、不申请设备内存。
  1. Engram 算子
    首批提供四个公开 API:
  • engram_fused_weight
    • BF16 权重逐元素融合,使用 FP32 输出。
  • engram_gate_fwd
    • 支持动态 token 数。
    • 输出 gate 结果及反向所需统计量。
  • engram_gate_bwd
    • 融合计算输入梯度、KV 梯度和分片权重梯度。
  • engram_grad_w_reduce
    • 归并分片权重梯度并原地累加两份 FP32 权重梯度。
      算子采用:
  • PyTorch wrapper 与 *_kernel.py 分层。
  • tilelang.jit kernel generator。
  • GM/UB 分块、SimdVF、Persistent 调度及多级流水。
  • 明确的 device、dtype、shape、stride、contiguous 和输出缓冲区校验。
  • 无 CPU/CUDA 静默回退。
  1. 测试与性能回归框架
    参考 TileKernels-Nightly 迁移并适配完整 pytest 能力:
  • OPS_TILELANG_TEST_LEVEL=0|1|2 分级参数生成。
  • 基于 --seed 和 node ID 的确定性随机数。
  • PyTorch reference 数值验证。
  • NPU 峰值显存画像和 large_npu_mem 自动分类。
  • A5 benchmark JSONL 基线及回归检测。
  • -K 参数表达式筛选。
  • benchmark improvement 几何平均汇总。
  • xdist 多卡绑定及全局 fail-fast。
  • TileLang 编译告警汇总。
  • 普通显存与大/未知显存测试分阶段执行。
  1. 构建、CI 与脚本
    新增统一执行入口:
  • scripts/check.sh
  • scripts/build_wheel.sh
  • scripts/run_test.sh
  • scripts/run_tests.sh
  • scripts/run_ci.sh
    scripts/run_ci.sh 支持:
  • lint
  • cpu
  • wheel
  • npu
  • benchmark
  • all
    新增 GitHub workflows:
  • Ruff lint 检查。
  • Wheel 构建、安装及元数据验证。
  1. 文档
    新增并完善:
  • README:安装、使用、测试、CI 和硬件支持范围。
  • 架构说明。
  • 完整的新增算子开发流程。
  • pytest 插件、benchmark 和显存画像维护指南。
  • CONTRIBUTING 贡献规范。
  • MIT License。

该PR关联的issue

无。

希望检视人员了解:

ops-tilelang的框架代码是否合理和完善。

改动类型 / Change Type

  • [ √] 新功能 / New Feature

测试信息 / Testing

  • [√] 单元测试通过 / UT passed
  • [ √] 集成测试通过 / ST passed
  • [ √] 人工验证通过 / Manual verified

检查清单 / Checklist

  • [√] 代码符合规范 / Code follows style guide
  • [ √] 测试添加并通过 / Tests added and passed
  • [ √] 文档已更新 / Docs updated if needed
  • [√ ] 无硬编码敏感信息 / No secrets hardcoded
  • [ √] 提交信息符合规范 / Commit message follows convention
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for ChaoyangJi's contribution.)
ChaoyangJiChaoyangJiCollaborators
Sep 7 Created pull request, commit dc97bab8
CANN-robot
CANN-robotCollaborators
Sep 7 Comments:

Hi @ChaoyangJi, welcome to submitting your first PR to ops-tilelang!

PR Merge Steps

1. CLA Signing

If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.

2. CI Check

Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.

3. Code Review

After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.

likedislike
CANN-robotCANN-robotCollaborators
Sep 7 Added label: cann-cla/no
CANN-robot
CANN-robotCollaborators
Sep 7 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
repo-cann/ops-tilelang ✅ kevin365, jiawei_zhuang (2/2) ✅ kevin365 (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
Zzhangwei503Collaborators
Sep 8 Added squash commit note: compile
142 messages are collapsed here。 See more
WwangkaiCollaborators
Sep 16 Added squash commit note: 本 PR 初始化 ops-tilelang 高性能算子仓,为 CANN 社区提供基于 TileLang DSL 的 Ascend 算子开发、测试、性能回归和 wheel 发布基础框架。 项目采用运行时接口与硬件 kernel 分层设计,当前仅支持 Ascend A5 及以上架构。
ChaoyangJiChaoyangJiCollaborators
Sep 16 Resolved final issue
CANN-robotCANN-robotCollaborators
Sep 16 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 16 Added label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Sep 16 Merged pull request