Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/test_kernels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,31 @@ jobs:
max-parallel: 4
matrix:
python-version: ["3.10", "3.12"]
torch-version: ["2.9.0", "2.10.0"]
torch-version: ["2.10.0", "2.11.0"]

env:
UV_PYTHON_PREFERENCE: only-managed

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install uv and set the python version
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
python-version: ${{ matrix.python-version }}

- name: Install the project
- name: Override kernels-data source to local bindings
working-directory: ./kernels
run: uv sync --all-extras --dev
run: uv add ../kernels-data/bindings/python --no-sync

- name: Install Torch version
- name: Override the Torch version
working-directory: ./kernels
run: uv pip install "torch==${{ matrix.torch-version }}"
run: uv add "torch==${{ matrix.torch-version }}" --no-sync

- name: Install the project
working-directory: ./kernels
run: uv sync --all-extras --dev

- name: Install setuptools for Triton-based test
working-directory: ./kernels
Expand All @@ -72,7 +76,6 @@ jobs:
uv pip install einops nvidia-cutlass-dsl
uv run pytest tests/test_deps.py


- name: Check kernel check
working-directory: ./kernels
run: |
Expand Down
16 changes: 15 additions & 1 deletion docs/source/api/kernels.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@

### get_locked_kernel

[[autodoc]] kernels.get_locked_kernel
<<<<<<< kernels-use-kernels-data
[[autodoc]] kernels.get_locked_kernel

## Classes

### LoadedKernel

[[autodoc]] kernels.LoadedKernel

### RepoInfo

[[autodoc]] kernels.RepoInfo
=======
[[autodoc]] kernels.get_locked_kernel
>>>>>>> main
3 changes: 3 additions & 0 deletions docs/source/builder-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Initialize a new kernel project from template

###### **Options:**

* `--license <LICENSE>` — The kernel's license

Default value: `Apache-2.0`
* `--name <OWNER/REPO>` — Name of the kernel repo (e.g. `drbh/my-kernel`)
* `--backends <BACKENDS>` — Backends to enable (`all`, `cpu`, `cuda`, `metal`, `neuron`, `rocm`, `xpu`)

Expand Down
2 changes: 0 additions & 2 deletions docs/source/builder/build-variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ available. This list will be updated as new PyTorch versions are released.
- `torch211-cxx11-cu126-aarch64-linux`
- `torch211-cxx11-cu128-aarch64-linux`
- `torch211-cxx11-cu130-aarch64-linux`
- `torch29-cxx11-cu129-aarch64-linux`

## CPU x86_64-linux

Expand All @@ -43,7 +42,6 @@ available. This list will be updated as new PyTorch versions are released.
- `torch211-cxx11-cu126-x86_64-linux`
- `torch211-cxx11-cu128-x86_64-linux`
- `torch211-cxx11-cu130-x86_64-linux`
- `torch29-cxx11-cu129-x86_64-linux`

## ROCm x86_64-linux

Expand Down
10 changes: 8 additions & 2 deletions docs/source/kernel-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ metadata. Currently the following top-level keys are supported:
- `id` (`str`, required): a unique identifier for the kernel. This
identifier must also be a valid Python module name. If the kernel
registers Torch ops, they must be registered as `torch.ops.<id>`
- `name` (`str`, required): then name of the kernel. Replacing dashes
by underscores should result in the module name of the kernel.
- `version` (`int`, required): the kernel version number.
- `license` (`str`, required): the kernel license in. Refer to the
list of [supported license identifiers](https://huggingface.co/docs/hub/repositories-licenses).
- `backend` (`dict`, required): information about the compute backend that
this build variant supports.
- `python-depends` (`list[str]`, optional): list of Python dependencies
Expand All @@ -52,9 +56,11 @@ Example `metadata.json`:

```json
{
"id": "_mykernel_cuda_be238e4",
"python-depends": ["einops"],
"name": "mykernel",
"id": "_mykernel_cuda_7a4e5a7",
"version": 1,
"license": "Apache-2.0",
"python-depends": ["einops"],
"backend": {
"type": "cuda",
"archs": ["7.0", "7.2", "7.5", "8.0", "8.6", "8.7", "8.9", "9.0+PTX"]
Expand Down
20 changes: 11 additions & 9 deletions examples/kernels/cutlass-gemm-tvm-ffi/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "cutlass-gemm-tvm-ffi"
version = 1
license = "Apache-2.0"
backends = [
"cuda",
"xpu",
Expand All @@ -9,20 +11,20 @@ backends = [
repo-id = "kernels-test/cutlass-gemm-tvm-ffi"

[tvm-ffi]
src = [
"tvm-ffi-ext/tvm_ffi_binding.cpp",
]
src = ["tvm-ffi-ext/tvm_ffi_binding.cpp"]

[kernel.gemm]
backend = "cuda"
depends = [
"cutlass_3_6",
depends = ["cutlass_3_6"]
src = [
"gemm.cu",
"util.hh",
]
src = ["gemm.cu", "util.hh"]

[kernel.gemm_xpu]
backend = "xpu"
depends = [
"sycl_tla",
depends = ["sycl_tla"]
src = [
"gemm_sycl.cpp",
"util.hh",
]
src = ["gemm_sycl.cpp", "util.hh"]
18 changes: 10 additions & 8 deletions examples/kernels/cutlass-gemm/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "cutlass-gemm"
version = 1
license = "Apache-2.0"
backends = [
"cuda",
"xpu",
Expand All @@ -14,18 +16,18 @@ src = [
"torch-ext/torch_binding.h",
]

[kernel.gemm]
backend = "cuda"
depends = [
"torch",
"cutlass_3_6",
]
src = ["gemm.cu"]

[kernel.gemm_xpu]
backend = "xpu"
depends = [
"torch",
"sycl_tla",
]
src = ["gemm_sycl.cpp"]

[kernel.gemm]
backend = "cuda"
depends = [
"torch",
"cutlass_3_6",
]
src = ["gemm.cu"]
37 changes: 21 additions & 16 deletions examples/kernels/extra-data/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "extra-data"
version = 1
license = "Apache-2.0"
backends = [
"cpu",
"cuda",
Expand All @@ -12,28 +14,18 @@ backends = [
repo-id = "kernels-test/extra-data"

[torch]
pyext = [
"json",
"py",
]
src = [
"torch-ext/torch_binding.cpp",
"torch-ext/torch_binding.h",
]
pyext = ["json", "py"]

[kernel.relu]
backend = "cuda"
depends = ["torch"]
src = ["relu_cuda/relu.cu"]

[kernel.relu_metal]
backend = "metal"
src = [
"relu_metal/relu.mm",
"relu_metal/relu.metal",
"relu_metal/common.h",
]
depends = [ "torch" ]

[kernel.relu_rocm]
backend = "rocm"
depends = ["torch"]
rocm-archs = [
"gfx906",
"gfx908",
Expand All @@ -45,14 +37,27 @@ rocm-archs = [
"gfx1100",
"gfx1101",
]
depends = ["torch"]
src = ["relu_cuda/relu.cu"]

[kernel.relu_xpu]
backend = "xpu"
depends = ["torch"]
src = ["relu_xpu/relu.cpp"]

[kernel.relu_metal]
backend = "metal"
depends = ["torch"]
src = [
"relu_metal/relu.mm",
"relu_metal/relu.metal",
"relu_metal/common.h",
]

[kernel.relu]
backend = "cuda"
depends = ["torch"]
src = ["relu_cuda/relu.cu"]

[kernel.relu_cpu]
backend = "cpu"
depends = ["torch"]
Expand Down
4 changes: 3 additions & 1 deletion examples/kernels/relu-backprop-compile/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "relu-backprop-compile"
version = 1
license = "Apache-2.0"
backends = [
"cuda",
"rocm",
Expand All @@ -21,6 +23,7 @@ src = ["relu_cuda/relu.cu"]

[kernel.relu_rocm]
backend = "rocm"
depends = ["torch"]
rocm-archs = [
"gfx906",
"gfx908",
Expand All @@ -32,5 +35,4 @@ rocm-archs = [
"gfx1100",
"gfx1101",
]
depends = ["torch"]
src = ["relu_cuda/relu.cu"]
25 changes: 15 additions & 10 deletions examples/kernels/relu-compiler-flags/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "relu-compiler-flags"
version = 1
license = "Apache-2.0"
backends = [
"cuda",
"rocm",
Expand All @@ -10,16 +12,26 @@ backends = [
repo-id = "kernels-test/relu-compiler-flags"

[torch]
src = ["torch-ext/torch_binding.cpp", "torch-ext/torch_binding.h"]
src = [
"torch-ext/torch_binding.cpp",
"torch-ext/torch_binding.h",
]

[kernel.activation_xpu]
backend = "xpu"
depends = ["torch"]
sycl-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
src = ["relu_xpu/relu.cpp"]

[kernel.activation]
backend = "cuda"
cuda-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
depends = ["torch"]
src = ["relu_cuda/relu.cu"]
cuda-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]

[kernel.activation_rocm]
backend = "rocm"
depends = ["torch"]
rocm-archs = [
"gfx906",
"gfx908",
Expand All @@ -31,12 +43,5 @@ rocm-archs = [
"gfx1100",
"gfx1101",
]
depends = ["torch"]
src = ["relu_cuda/relu.cu"]
hip-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]

[kernel.activation_xpu]
backend = "xpu"
depends = ["torch"]
src = ["relu_xpu/relu.cpp"]
sycl-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
src = ["relu_cuda/relu.cu"]
16 changes: 10 additions & 6 deletions examples/kernels/relu-metal-cpp/build.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[general]
name = "relu"
version = 1
license = "Apache-2.0"
backends = ["metal"]

[general.hub]
Expand All @@ -11,13 +13,15 @@ src = [
"torch-ext/torch_binding.h",
]


[kernel.relu_metal]
backend = "metal"
depends = [
"torch",
"metal-cpp",
]
src = [
"relu/relu.cpp",
"relu/metallib_loader.mm",
"relu/relu_cpp.metal",
"relu/common.h",
"relu/relu.cpp",
"relu/metallib_loader.mm",
"relu/relu_cpp.metal",
"relu/common.h",
]
depends = [ "torch", "metal-cpp" ]
9 changes: 6 additions & 3 deletions examples/kernels/relu-nki/build.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[general]
name = "relu-nki"
version = 1
backends = [
"neuron",
]
license = "Apache-2.0"
backends = ["neuron"]

[general.hub]
repo-id = "kernels-test/relu-nki"

[general.neuron]
python-depends = ["nki"]

[torch-noarch]

[kernel]
Loading
Loading