Skip to content

Commit b9e2405

Browse files
danieldkMekkCyber
andauthored
Describe new flattened layout and dependencies (#184)
* Describe new flattened layout and dependencies * Fixes Co-authored-by: Mohamed Mekkouri <[email protected]> --------- Co-authored-by: Mohamed Mekkouri <[email protected]>
1 parent 72a1d91 commit b9e2405

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

docs/source/kernel-requirements.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ following the template
1515
`<framework><version>-cxx<abiver>-<cu><cudaver>-<arch>-<os>`.
1616
For example `build/torch26-cxx98-cu118-x86_64-linux`.
1717

18-
Each variant directory must contain a single directory with the same name
19-
as the repository (replacing `-` by `_`). For instance, kernels in the
20-
`kernels-community/activation` repository have a directories like
21-
`build/<variant>/activation`. This directory
22-
must be a Python package with an `__init__.py` file.
18+
The kernel is in the build variant directory and must contain a
19+
`__init__.py` file. For compatibility with older versions of the
20+
`kernels` package, each variant directory must also contain a single
21+
directory with the same name as the repository (replacing `-` by `_`).
22+
For instance, kernels in the `kernels-community/activation` repository
23+
have a directory like `build/<variant>/activation`. This directory
24+
must contain an `__init__.py` file that exports the same symbols as
25+
`__init__.py` in the build variant directory `build/<variant>`.
26+
[This example](https://huggingface.co/kernels-test/flattened-build/blob/main/build/torch-universal/flattened_build/__init__.py)
27+
shows how this can be done. This compatibility directory is
28+
automatically created by `kernel-builder`.
2329

2430
## Build variants
2531

@@ -28,6 +34,17 @@ architecture (e.g. x86_64). For compliance with a compute framework and
2834
architecture combination, all the variants from the [build variant list](https://github.com/huggingface/kernel-builder/blob/main/docs/build-variants.md)
2935
must be available for that combination.
3036

37+
## Kernel metadata
38+
39+
The build variant directory can optionally contain a `metadata.json` file.
40+
Currently the only purpose of the metadata is to specify the kernel python dependencies, for example:
41+
42+
```json
43+
{ "python-depends": ["nvidia-cutlass-dsl"] }
44+
```
45+
46+
The following dependencies are the only ones allowed at this stage: `einops` and `nvidia-cutlass-dsl`
47+
3148
## Versioning
3249

3350
Kernels are versioned on the Hub using Git tags. Version tags must be of
@@ -50,10 +67,10 @@ have dynamic library dependencies outside:
5067

5168
The Kernel Hub also encourages to write the kernels in a `torch.compile`
5269
compliant way. This helps to ensure that the kernels are compatible with
53-
`torch.compile` without introducing any graph breaks and triggering
70+
`torch.compile` without introducing any graph breaks and triggering
5471
recompilation which can limit the benefits of compilation.
5572

56-
[Here](https://github.com/huggingface/kernel-builder/blob/d1ee9bf9301ac8c5199099d90ee1c9d5c789d5ba/examples/relu-backprop-compile/tests/test_relu.py#L162) is a simple test example which checks for graph breaks and
73+
[Here](https://github.com/huggingface/kernel-builder/blob/d1ee9bf9301ac8c5199099d90ee1c9d5c789d5ba/examples/relu-backprop-compile/tests/test_relu.py#L162) is a simple test example which checks for graph breaks and
5774
recompilation triggers during `torch.compile`.
5875

5976
### Linux

0 commit comments

Comments
 (0)