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
16 changes: 16 additions & 0 deletions docs/source/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ activation.gelu_fast(y, x)
print(y)
```

### Using version bounds

Kernels are versioned using tags of the form `v<major>.<minor>.<patch>`.
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:
Expand Down
3 changes: 2 additions & 1 deletion docs/source/kernel-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Kernels are versioned on the Hub using Git tags. Version tags must be of
the form `v<major>.<minor>.<patch>`. 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
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions docs/source/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<major>.<minor>.<patch>`.
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,
Expand Down
Loading