目录

Intro-ops

这个仓库是一个面向训练的 GPU 算子运行时。它体积很小,但工作流尽量贴近真实的算子库开发流程:

  1. ops/<op>/ 下创建后端实现目录。
  2. 构建系统通过目录约定自动发现源码。
  3. 实现后端专属的 descriptor 生命周期(create、workspace、execute、destroy)。
  4. 提供 Python API,支持 out-of-place、out-variant 和 prepared 执行。
  5. 通过 PyTorch 做正确性验证,并做稳定态性能测试。

Python 目录结构

python/
  operator_runtime/
    backend.py
    ops/
    _internal/
  operator_runtime_testing/
  • operator_runtime.ops 放公开算子绑定。
  • operator_runtime._internal 放私有 FFI 和运行时细节。
  • operator_runtime_testing 放断言、benchmark 等仅测试使用的工具。

算子

算子 NVIDIA C++ TileLang MetaX
copy 可运行 安装 TileLang 后可运行 可运行
vector_add 可运行 安装 TileLang 后可运行 可运行
reduce_sum 可运行,row-wise fp32 安装 TileLang 后可运行 可运行,row-wise fp32
softmax 可运行,row-wise fp32 安装 TileLang 后可运行 可运行,row-wise fp32

安装

pip install -r requirements.txt

构建

mkdir -p build
cd build
cmake .. -DCAMP_ENABLE_NVIDIA=ON -DCAMP_ENABLE_METAX=OFF
cmake --build . -j$(nproc)
./scripts/build_metax.sh build

验证

python tests/run_ops.py --op copy --backend nvidia --mode all
CAMP_BUILD_DIR=build pytest tests/ -v --backend nvidia
pytest tests/ -v --backend tilelang
python tests/run_ops.py --op all --backend nvidia --mode bench
./scripts/build_metax.sh test

TileLang 后端需要安装 tilelang Python 包。MetaX 后端使用独立构建产物,构建时应关闭 NVIDIA 变体,并将后端源码放在 ops/*/metax/*.maca

生产映射

训练概念 生产等价物
ops/<op>/nvidia/*.cu 目录约定 构建系统自动发现 / 算子注册
include/operator_runtime/ops/<op>.h 头文件 经过评审的算子 API 契约
descriptor 生命周期 create、workspace、execute、destroy
tests/cases/<op>.py 正确性、布局和 API 契约覆盖
PerformanceResult 包含延迟、字节数、FLOPs、带宽的 profiler 报表行
eager TileLang kernel 使用 T.empty(...) 返回值的 puzzle-stage kernel
lazy TileLang out_idx template TileOPs 风格的 kernel factory 和输出位置契约
关于
140.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号