diff --git a/README.md b/README.md index c779c97..a8ec095 100644 --- a/README.md +++ b/README.md @@ -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//nvidia/_cuda.h` with the C API (4 functions: create, workspace, execute, destroy). -2. Create `ops//nvidia/_cuda.cu` with the CUDA implementation. -3. Create `python/operator_runtime/ops/.py` using `operator_runtime._internal.bind_*` functions. -4. Create `tests/cases/.py` with `correctness_cases()`, `api_error_cases()`, and `benchmark_cases()`. -5. Create `tests/ops/test_.py` and `tests/bench/.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 | diff --git a/README.zh.md b/README.zh.md index 06397a9..3f01c93 100644 --- a/README.zh.md +++ b/README.zh.md @@ -58,18 +58,6 @@ python tests/run_ops.py --op all --backend nvidia --mode bench TileLang 后端需要安装 `tilelang` Python 包。 -## 如何新增算子 - -1. 创建 `ops//nvidia/_cuda.h`,提供 4 个 C API:create、workspace、execute、destroy。 -2. 创建 `ops//nvidia/_cuda.cu`,实现 CUDA 逻辑。 -3. 创建 `python/operator_runtime/ops/.py`,使用 `operator_runtime._internal.bind_*` 绑定。 -4. 创建 `tests/cases/.py`,提供 `correctness_cases()`、`api_error_cases()` 和 `benchmark_cases()`。 -5. 创建 `tests/ops/test_.py` 和 `tests/bench/.py`。 -6. 在构建目录里重新执行 `cmake ..`,因为 glob 会自动拾取新的 `.cu` 文件。 -7. 在 `python/operator_runtime/__init__.py` 中导出公共 API。 - -这里没有 YAML、没有代码生成、也没有额外的注册步骤。 - ## 生产映射 | 训练概念 | 生产等价物 | diff --git a/tests/test_tilelang_copy_templates.py b/tests/test_tilelang_copy_templates.py deleted file mode 100644 index 52f509f..0000000 --- a/tests/test_tilelang_copy_templates.py +++ /dev/null @@ -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)