Skip to content

Commit 013b0e1

Browse files
danieldkdrbh
andauthored
kernels: use Metadata from kernels-data (#499)
* kernels: use `Metadata` from `kernels-data` This changeset combines a few related changes: - Use `Metadata` from `kernels-data` to ensure using the same metadata data structures in kernel-builder and kernels. - Make metadata mandatory and make several metadata fields mandatory, namely `id`, `version`, `license` the new `name` field. - Update the `build.toml` format to v4, making the required fields mandatory as well as the `torch-noarch` section for torch-noarch kernels. - Remove support for the very old v1 and v2 `build.toml` formats. * Regenerate variants * CI: install kernels-data Python package from repo, not PyPI * CI: fix subsequent uv commands syncing wrong kernels-data again * CI: test with Torch 3.10 and 3.11 * ci: override the Torch version in uv.lock * Fix kernels-data tests * License is mandatory now, so add to init * Card generation should fill the license in the card --------- Co-authored-by: drbh <david.richard.holtz@gmail.com>
1 parent cf23bea commit 013b0e1

56 files changed

Lines changed: 1144 additions & 738 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test_kernels.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,31 @@ jobs:
2727
max-parallel: 4
2828
matrix:
2929
python-version: ["3.10", "3.12"]
30-
torch-version: ["2.9.0", "2.10.0"]
30+
torch-version: ["2.10.0", "2.11.0"]
3131

3232
env:
3333
UV_PYTHON_PREFERENCE: only-managed
3434

3535
steps:
3636
- name: Checkout code
37-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
37+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3838

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

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

48-
- name: Install Torch version
48+
- name: Override the Torch version
4949
working-directory: ./kernels
50-
run: uv pip install "torch==${{ matrix.torch-version }}"
50+
run: uv add "torch==${{ matrix.torch-version }}" --no-sync
51+
52+
- name: Install the project
53+
working-directory: ./kernels
54+
run: uv sync --all-extras --dev
5155

5256
- name: Install setuptools for Triton-based test
5357
working-directory: ./kernels
@@ -72,7 +76,6 @@ jobs:
7276
uv pip install einops nvidia-cutlass-dsl
7377
uv run pytest tests/test_deps.py
7478
75-
7679
- name: Check kernel check
7780
working-directory: ./kernels
7881
run: |

docs/source/api/kernels.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@
2626

2727
### get_locked_kernel
2828

29-
[[autodoc]] kernels.get_locked_kernel
29+
<<<<<<< kernels-use-kernels-data
30+
[[autodoc]] kernels.get_locked_kernel
31+
32+
## Classes
33+
34+
### LoadedKernel
35+
36+
[[autodoc]] kernels.LoadedKernel
37+
38+
### RepoInfo
39+
40+
[[autodoc]] kernels.RepoInfo
41+
=======
42+
[[autodoc]] kernels.get_locked_kernel
43+
>>>>>>> main

docs/source/builder-cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Initialize a new kernel project from template
7575

7676
###### **Options:**
7777

78+
* `--license <LICENSE>` — The kernel's license
79+
80+
Default value: `Apache-2.0`
7881
* `--name <OWNER/REPO>` — Name of the kernel repo (e.g. `drbh/my-kernel`)
7982
* `--backends <BACKENDS>` — Backends to enable (`all`, `cpu`, `cuda`, `metal`, `neuron`, `rocm`, `xpu`)
8083

docs/source/builder/build-variants.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ available. This list will be updated as new PyTorch versions are released.
2828
- `torch211-cxx11-cu126-aarch64-linux`
2929
- `torch211-cxx11-cu128-aarch64-linux`
3030
- `torch211-cxx11-cu130-aarch64-linux`
31-
- `torch29-cxx11-cu129-aarch64-linux`
3231

3332
## CPU x86_64-linux
3433

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

4846
## ROCm x86_64-linux
4947

docs/source/kernel-requirements.md

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

5357
```json
5458
{
55-
"id": "_mykernel_cuda_be238e4",
56-
"python-depends": ["einops"],
59+
"name": "mykernel",
60+
"id": "_mykernel_cuda_7a4e5a7",
5761
"version": 1,
62+
"license": "Apache-2.0",
63+
"python-depends": ["einops"],
5864
"backend": {
5965
"type": "cuda",
6066
"archs": ["7.0", "7.2", "7.5", "8.0", "8.6", "8.7", "8.9", "9.0+PTX"]

examples/kernels/cutlass-gemm-tvm-ffi/build.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "cutlass-gemm-tvm-ffi"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = [
46
"cuda",
57
"xpu",
@@ -9,20 +11,20 @@ backends = [
911
repo-id = "kernels-test/cutlass-gemm-tvm-ffi"
1012

1113
[tvm-ffi]
12-
src = [
13-
"tvm-ffi-ext/tvm_ffi_binding.cpp",
14-
]
14+
src = ["tvm-ffi-ext/tvm_ffi_binding.cpp"]
1515

1616
[kernel.gemm]
1717
backend = "cuda"
18-
depends = [
19-
"cutlass_3_6",
18+
depends = ["cutlass_3_6"]
19+
src = [
20+
"gemm.cu",
21+
"util.hh",
2022
]
21-
src = ["gemm.cu", "util.hh"]
2223

2324
[kernel.gemm_xpu]
2425
backend = "xpu"
25-
depends = [
26-
"sycl_tla",
26+
depends = ["sycl_tla"]
27+
src = [
28+
"gemm_sycl.cpp",
29+
"util.hh",
2730
]
28-
src = ["gemm_sycl.cpp", "util.hh"]
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "cutlass-gemm"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = [
46
"cuda",
57
"xpu",
@@ -14,18 +16,18 @@ src = [
1416
"torch-ext/torch_binding.h",
1517
]
1618

17-
[kernel.gemm]
18-
backend = "cuda"
19-
depends = [
20-
"torch",
21-
"cutlass_3_6",
22-
]
23-
src = ["gemm.cu"]
24-
2519
[kernel.gemm_xpu]
2620
backend = "xpu"
2721
depends = [
2822
"torch",
2923
"sycl_tla",
3024
]
3125
src = ["gemm_sycl.cpp"]
26+
27+
[kernel.gemm]
28+
backend = "cuda"
29+
depends = [
30+
"torch",
31+
"cutlass_3_6",
32+
]
33+
src = ["gemm.cu"]

examples/kernels/extra-data/build.toml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "extra-data"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = [
46
"cpu",
57
"cuda",
@@ -12,28 +14,18 @@ backends = [
1214
repo-id = "kernels-test/extra-data"
1315

1416
[torch]
17+
pyext = [
18+
"json",
19+
"py",
20+
]
1521
src = [
1622
"torch-ext/torch_binding.cpp",
1723
"torch-ext/torch_binding.h",
1824
]
19-
pyext = ["json", "py"]
20-
21-
[kernel.relu]
22-
backend = "cuda"
23-
depends = ["torch"]
24-
src = ["relu_cuda/relu.cu"]
25-
26-
[kernel.relu_metal]
27-
backend = "metal"
28-
src = [
29-
"relu_metal/relu.mm",
30-
"relu_metal/relu.metal",
31-
"relu_metal/common.h",
32-
]
33-
depends = [ "torch" ]
3425

3526
[kernel.relu_rocm]
3627
backend = "rocm"
28+
depends = ["torch"]
3729
rocm-archs = [
3830
"gfx906",
3931
"gfx908",
@@ -45,14 +37,27 @@ rocm-archs = [
4537
"gfx1100",
4638
"gfx1101",
4739
]
48-
depends = ["torch"]
4940
src = ["relu_cuda/relu.cu"]
5041

5142
[kernel.relu_xpu]
5243
backend = "xpu"
5344
depends = ["torch"]
5445
src = ["relu_xpu/relu.cpp"]
5546

47+
[kernel.relu_metal]
48+
backend = "metal"
49+
depends = ["torch"]
50+
src = [
51+
"relu_metal/relu.mm",
52+
"relu_metal/relu.metal",
53+
"relu_metal/common.h",
54+
]
55+
56+
[kernel.relu]
57+
backend = "cuda"
58+
depends = ["torch"]
59+
src = ["relu_cuda/relu.cu"]
60+
5661
[kernel.relu_cpu]
5762
backend = "cpu"
5863
depends = ["torch"]

examples/kernels/relu-backprop-compile/build.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "relu-backprop-compile"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = [
46
"cuda",
57
"rocm",
@@ -21,6 +23,7 @@ src = ["relu_cuda/relu.cu"]
2123

2224
[kernel.relu_rocm]
2325
backend = "rocm"
26+
depends = ["torch"]
2427
rocm-archs = [
2528
"gfx906",
2629
"gfx908",
@@ -32,5 +35,4 @@ rocm-archs = [
3235
"gfx1100",
3336
"gfx1101",
3437
]
35-
depends = ["torch"]
3638
src = ["relu_cuda/relu.cu"]
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "relu-compiler-flags"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = [
46
"cuda",
57
"rocm",
@@ -10,16 +12,26 @@ backends = [
1012
repo-id = "kernels-test/relu-compiler-flags"
1113

1214
[torch]
13-
src = ["torch-ext/torch_binding.cpp", "torch-ext/torch_binding.h"]
15+
src = [
16+
"torch-ext/torch_binding.cpp",
17+
"torch-ext/torch_binding.h",
18+
]
19+
20+
[kernel.activation_xpu]
21+
backend = "xpu"
22+
depends = ["torch"]
23+
sycl-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
24+
src = ["relu_xpu/relu.cpp"]
1425

1526
[kernel.activation]
1627
backend = "cuda"
28+
cuda-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
1729
depends = ["torch"]
1830
src = ["relu_cuda/relu.cu"]
19-
cuda-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
2031

2132
[kernel.activation_rocm]
2233
backend = "rocm"
34+
depends = ["torch"]
2335
rocm-archs = [
2436
"gfx906",
2537
"gfx908",
@@ -31,12 +43,5 @@ rocm-archs = [
3143
"gfx1100",
3244
"gfx1101",
3345
]
34-
depends = ["torch"]
35-
src = ["relu_cuda/relu.cu"]
3646
hip-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
37-
38-
[kernel.activation_xpu]
39-
backend = "xpu"
40-
depends = ["torch"]
41-
src = ["relu_xpu/relu.cpp"]
42-
sycl-flags = ["-DWHO_AM_I_IF_NOT_THE_CANARY"]
47+
src = ["relu_cuda/relu.cu"]

0 commit comments

Comments
 (0)