Skip to content

Commit 4d498a1

Browse files
committed
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.
1 parent 865145b commit 4d498a1

50 files changed

Lines changed: 1066 additions & 708 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.

docs/source/api/kernels.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@
2727
### get_locked_kernel
2828

2929
[[autodoc]] kernels.get_locked_kernel
30+
31+
## Classes
32+
33+
### LoadedKernel
34+
35+
[[autodoc]] kernels.LoadedKernel
36+
37+
### RepoInfo
38+
39+
[[autodoc]] kernels.RepoInfo

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"]

examples/kernels/relu-metal-cpp/build.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[general]
22
name = "relu"
3+
version = 1
4+
license = "Apache-2.0"
35
backends = ["metal"]
46

57
[general.hub]
@@ -11,13 +13,15 @@ src = [
1113
"torch-ext/torch_binding.h",
1214
]
1315

14-
1516
[kernel.relu_metal]
1617
backend = "metal"
18+
depends = [
19+
"torch",
20+
"metal-cpp",
21+
]
1722
src = [
18-
"relu/relu.cpp",
19-
"relu/metallib_loader.mm",
20-
"relu/relu_cpp.metal",
21-
"relu/common.h",
23+
"relu/relu.cpp",
24+
"relu/metallib_loader.mm",
25+
"relu/relu_cpp.metal",
26+
"relu/common.h",
2227
]
23-
depends = [ "torch", "metal-cpp" ]
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
[general]
22
name = "relu-nki"
33
version = 1
4-
backends = [
5-
"neuron",
6-
]
4+
license = "Apache-2.0"
5+
backends = ["neuron"]
76

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

1110
[general.neuron]
1211
python-depends = ["nki"]
12+
13+
[torch-noarch]
14+
15+
[kernel]

examples/kernels/relu-specific-torch/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-specific-torch"
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"]

0 commit comments

Comments
 (0)