From 91f427e65e7d385c96780a4960168aeef1977fb6 Mon Sep 17 00:00:00 2001 From: drbh Date: Wed, 7 Jan 2026 11:02:03 -0500 Subject: [PATCH] fix: pin version specifier and add warning to docs --- README.md | 7 ++++++- docs/source/basic-usage.md | 11 ++++++++--- docs/source/layers.md | 16 ++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8eaed0f..0049a19 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ import torch from kernels import get_kernel # Download optimized kernels from the Hugging Face hub -activation = get_kernel("kernels-community/activation") +activation = get_kernel("kernels-community/activation", version=">=0.1.0,<0.2.0") # Random tensor x = torch.randn((10, 10), dtype=torch.float16, device="cuda") @@ -51,6 +51,11 @@ activation.gelu_fast(y, x) print(y) ``` +> [!WARNING] Strongly recommended to specify version bounds +> Loading kernels without specifying a version will fetch from the `main` branch. +> The `main` branch may contain breaking changes or incompatible updates at any time. +> Always specify version bounds to ensure reproducible builds and avoid unexpected issues. + You can [search for kernels](https://huggingface.co/models?other=kernels) on the Hub. diff --git a/docs/source/basic-usage.md b/docs/source/basic-usage.md index 1d9fd93..5b61198 100644 --- a/docs/source/basic-usage.md +++ b/docs/source/basic-usage.md @@ -9,7 +9,7 @@ import torch from kernels import get_kernel # Download optimized kernels from the Hugging Face hub -activation = get_kernel("kernels-community/activation") +activation = get_kernel("kernels-community/activation", version=">=0.1.0,<0.2.0") # Create a random tensor x = torch.randn((10, 10), dtype=torch.float16, device="cuda") @@ -21,6 +21,11 @@ activation.gelu_fast(y, x) print(y) ``` +> [!WARNING] Strongly recommended to specify version bounds +> Loading kernels without specifying a version will fetch from the `main` branch. +> The `main` branch may contain breaking changes or incompatible updates at any time. +> Always specify version bounds to ensure reproducible builds and avoid unexpected issues. + ### Using version bounds Kernels are versioned using tags of the form `v..`. @@ -30,10 +35,10 @@ You can specify which version to download using Python version specifiers: import torch from kernels import get_kernel -activation = get_kernel("kernels-community/activation", version=">=0.0.4,<0.1.0") +activation = get_kernel("kernels-community/activation", version=">=0.1.0,<0.2.0") ``` -This will get the latest kernel tagged `v0.0.z` where `z` is at least 4. It +This will get the latest kernel tagged `v0.1.z` where `z` is at least 0. It is strongly recommended to specify a version bound, since a kernel author might push incompatible changes to the `main` branch. diff --git a/docs/source/layers.md b/docs/source/layers.md index 99629e8..93ad5db 100644 --- a/docs/source/layers.md +++ b/docs/source/layers.md @@ -159,15 +159,22 @@ kernel_layer_mapping = { "cuda": LayerRepository( repo_id="kernels-community/activation", layer_name="SiluAndMul", + version=">=0.1.0,<0.2.0", ), "rocm": LayerRepository( repo_id="kernels-community/activation", layer_name="SiluAndMul", + version=">=0.1.0,<0.2.0", ) } } ``` +> [!WARNING] Strongly recommended to specify version bounds +> Loading kernels without specifying a version will fetch from the `main` branch. +> The `main` branch may contain breaking changes or incompatible updates at any time. +> Always specify version bounds to ensure reproducible builds and avoid unexpected issues. + You can register such a mapping using `register_kernel_mapping`: ```python @@ -197,6 +204,7 @@ kernel_layer_mapping = { "cuda": FuncRepository( repo_id="kernels-community/activation", func_name="silu_and_mul", + version=">=0.1.0,<0.2.0", ), } } @@ -214,19 +222,19 @@ kernel_layer_mapping = { "cuda": LayerRepository( repo_id="kernels-community/activation", layer_name="SiluAndMul", - version=">=0.0.4,<0.1.0", + version=">=0.1.0,<0.2.0", ), "rocm": LayerRepository( repo_id="kernels-community/activation", layer_name="SiluAndMul", - version=">=0.0.4,<0.1.0", + version=">=0.1.0,<0.2.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 +This will get the layer from the latest kernel tagged `v0.1.z` where `z` is at +least 0. 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