docs: add detailed info md

Co-authored-by: wawahejun <hejunlbbc@gmail.com>
This commit is contained in:
yutianyu 2026-05-04 23:39:52 +08:00
parent 6d1f205610
commit ec8ed33b27
3 changed files with 0 additions and 82 deletions

View File

@ -59,18 +59,6 @@ python tests/run_ops.py --op all --backend nvidia --mode bench
The TileLang backend requires the `tilelang` Python package.
## Adding a New Operator
1. Create `ops/<name>/nvidia/<name>_cuda.h` with the C API (4 functions: create, workspace, execute, destroy).
2. Create `ops/<name>/nvidia/<name>_cuda.cu` with the CUDA implementation.
3. Create `python/operator_runtime/ops/<name>.py` using `operator_runtime._internal.bind_*` functions.
4. Create `tests/cases/<name>.py` with `correctness_cases()`, `api_error_cases()`, and `benchmark_cases()`.
5. Create `tests/ops/test_<name>.py` and `tests/bench/<name>.py`.
6. Re-run `cmake ..` in the build directory (the glob will pick up the new `.cu` file).
7. Register the public API in `python/operator_runtime/__init__.py`.
No YAML, no code generation, no registration step.
## Production Mapping
| Training concept | Production equivalent |

View File

@ -58,18 +58,6 @@ python tests/run_ops.py --op all --backend nvidia --mode bench
TileLang 后端需要安装 `tilelang` Python 包。
## 如何新增算子
1. 创建 `ops/<name>/nvidia/<name>_cuda.h`,提供 4 个 C APIcreate、workspace、execute、destroy。
2. 创建 `ops/<name>/nvidia/<name>_cuda.cu`,实现 CUDA 逻辑。
3. 创建 `python/operator_runtime/ops/<name>.py`,使用 `operator_runtime._internal.bind_*` 绑定。
4. 创建 `tests/cases/<name>.py`,提供 `correctness_cases()`、`api_error_cases()` 和 `benchmark_cases()`
5. 创建 `tests/ops/test_<name>.py``tests/bench/<name>.py`
6. 在构建目录里重新执行 `cmake ..`,因为 glob 会自动拾取新的 `.cu` 文件。
7. 在 `python/operator_runtime/__init__.py` 中导出公共 API。
这里没有 YAML、没有代码生成、也没有额外的注册步骤。
## 生产映射
| 训练概念 | 生产等价物 |

View File

@ -1,58 +0,0 @@
from __future__ import annotations
import importlib.util
import pytest
import torch
from operator_runtime_testing import require_cuda
pytestmark = pytest.mark.skipif(
importlib.util.find_spec("tilelang") is None,
reason="tilelang is not installed",
)
@pytest.mark.parametrize(
("copy_fn_name", "copy_out_fn_name", "module_name"),
[
("copy_eager", "copy_eager_", "operator_runtime_backends.tilelang.copy_templates"),
("copy_lazy_out_idx", "copy_lazy_out_idx_", "operator_runtime_backends.tilelang.copy_templates"),
],
)
def test_tilelang_copy_templates_match_torch(copy_fn_name, copy_out_fn_name, module_name) -> None:
require_cuda()
module = __import__(module_name, fromlist=[copy_fn_name, copy_out_fn_name])
copy_fn = getattr(module, copy_fn_name)
copy_out_fn = getattr(module, copy_out_fn_name)
src = torch.randn((1024,), dtype=torch.float32, device="cuda")
out = copy_fn(src)
torch.testing.assert_close(out, src)
user_out = torch.empty_like(src)
returned = copy_out_fn(user_out, src)
assert returned is user_out
torch.testing.assert_close(user_out, src)
@pytest.mark.parametrize(
("copy_out_fn_name", "module_name", "message"),
[
("copy_eager_", "operator_runtime_backends.tilelang.copy_templates", "matching shapes"),
("copy_lazy_out_idx_", "operator_runtime_backends.tilelang.copy_templates", "matching shapes"),
],
)
def test_tilelang_copy_templates_reject_mismatched_out(
copy_out_fn_name,
module_name,
message,
) -> None:
require_cuda()
module = __import__(module_name, fromlist=[copy_out_fn_name])
copy_out_fn = getattr(module, copy_out_fn_name)
src = torch.randn((1024,), dtype=torch.float32, device="cuda")
out = torch.empty((512,), dtype=torch.float32, device="cuda")
with pytest.raises(ValueError, match=message):
copy_out_fn(out, src)