diff --git a/docs/source/basic-usage.md b/docs/source/basic-usage.md index 60f9975..1d9fd93 100644 --- a/docs/source/basic-usage.md +++ b/docs/source/basic-usage.md @@ -21,6 +21,22 @@ activation.gelu_fast(y, x) print(y) ``` +### Using version bounds + +Kernels are versioned using tags of the form `v..`. +You can specify which version to download using Python version specifiers: + +```python +import torch +from kernels import get_kernel + +activation = get_kernel("kernels-community/activation", version=">=0.0.4,<0.1.0") +``` + +This will get the latest kernel tagged `v0.0.z` where `z` is at least 4. It +is strongly recommended to specify a version bound, since a kernel author +might push incompatible changes to the `main` branch. + ## Checking Kernel Availability You can check if a specific kernel is available for your environment: diff --git a/docs/source/kernel-requirements.md b/docs/source/kernel-requirements.md index be5a101..ee8930f 100644 --- a/docs/source/kernel-requirements.md +++ b/docs/source/kernel-requirements.md @@ -34,6 +34,8 @@ Kernels are versioned on the Hub using Git tags. Version tags must be of the form `v..`. Versions are used by [locking](./locking.md) to resolve the version constraints. +We recommend using [semver](https://semver.org/) to version kernels. + ## Native Python module Kernels will typically contain a native Python module with precompiled @@ -50,7 +52,6 @@ have dynamic library dependencies outside: for compatibility with Python 3.9 and later. - Compatible with [`manylinux_2_28`](https://github.com/pypa/manylinux?tab=readme-ov-file#manylinux_2_28-almalinux-8-based). This means that the extension **must not** use symbols versions higher than: - - GLIBC 2.28 - GLIBCXX 3.4.24 - CXXABI 1.3.11 diff --git a/docs/source/layers.md b/docs/source/layers.md index c018858..430f8cd 100644 --- a/docs/source/layers.md +++ b/docs/source/layers.md @@ -157,6 +157,33 @@ with use_kernel_mapping(kernel_layer_mapping): This ensures that the mapping is not active anymore outside the `with`-scope. +### Using version bounds + +Kernels are versioned using tags of the form `v..`. +You can specify which version of the kernel to download using Python version +specifiers: + +```python +kernel_layer_mapping = { + "SiluAndMul": { + "cuda": LayerRepository( + repo_id="kernels-community/activation", + layer_name="SiluAndMul", + version=">=0.0.4,<0.1.0", + ), + "rocm": LayerRepository( + repo_id="kernels-community/activation", + layer_name="SiluAndMul", + version=">=0.0.4,<0.1.0", + ) + } +} +``` + +This will get the layer from latest kernel tagged `v0.0.z` where `z` is at +least 4. It is strongly recommended to specify a version bound, since a +kernel author might push incompatible changes to the `main` branch. + ### Registering kernels for specific modes You might want to register two different kernels for a particular layer,