From e3dfbb114b89788b726a81a68fed25c0c3ac05b8 Mon Sep 17 00:00:00 2001 From: drbh Date: Tue, 12 May 2026 13:42:16 -0400 Subject: [PATCH 1/7] feat: enforce that a version must be specified --- docs/source/basic-usage.md | 3 +- docs/source/layers.md | 6 ++-- docs/source/migration.md | 4 +-- kernel-builder/src/card.rs | 1 + kernel-builder/src/init/templates/CARD.md | 4 +-- kernels/src/kernels/_versions.py | 15 ++++----- kernels/src/kernels/layer/func.py | 6 +++- kernels/src/kernels/layer/layer.py | 7 +++-- kernels/src/kernels/utils.py | 13 ++++++-- kernels/tests/test_basic.py | 25 ++++++--------- kernels/tests/test_benchmarks.py | 2 +- kernels/tests/test_func.py | 6 ++++ kernels/tests/test_layer.py | 38 ++++++++++++++++++++++- 13 files changed, 89 insertions(+), 41 deletions(-) diff --git a/docs/source/basic-usage.md b/docs/source/basic-usage.md index 3581a2bfa..170f3f04e 100644 --- a/docs/source/basic-usage.md +++ b/docs/source/basic-usage.md @@ -28,8 +28,7 @@ get the latest kernel build from the `v1` branch. Kernels within a version branch must never break the API or remove builds for older PyTorch versions. This ensures that your code will continue to work. -Some kernels have not yet been updated to use versioning yet. In these cases, -you can use `get_kernel` without the `version` argument. +Hub kernels must be loaded with either a `version` or an explicit `revision`. ## Checking Kernel Availability diff --git a/docs/source/layers.md b/docs/source/layers.md index 2f6bcb465..3665b25a6 100644 --- a/docs/source/layers.md +++ b/docs/source/layers.md @@ -177,9 +177,8 @@ will get the latest kernel build from the `v1` branch. Kernel layers within a version branch must never break the API or remove builds for older PyTorch versions. This ensures that your code will continue to work. - -Some kernels have not yet been updated to use versioning yet. In these cases, -you can use `LayerRepository` without the `version` argument. +Hub-backed `LayerRepository` and `FuncRepository` entries must specify +either a `version` or an explicit `revision`. You can register a mapping, like the one above, using `register_kernel_mapping`: @@ -210,6 +209,7 @@ kernel_layer_mapping = { "cuda": FuncRepository( repo_id="kernels-community/activation", func_name="silu_and_mul", + version=1, ), } } diff --git a/docs/source/migration.md b/docs/source/migration.md index 67612539f..d49028522 100644 --- a/docs/source/migration.md +++ b/docs/source/migration.md @@ -6,8 +6,8 @@ Before `kernels` 0.12, kernels could be pulled from a repository without specifying a version. This is deprecated in kernels 0.12 -and will become an error in kernels 0.14. Instead, use of a kernel -should always specify a version (except for local kernels). +and is an error in kernels 0.15. Instead, use of a kernel should +always specify a version or revision (except for local kernels). Kernels only use a major version. The kernel maintainer is responsible for never breaking a kernel within a major version and should bump up diff --git a/kernel-builder/src/card.rs b/kernel-builder/src/card.rs index 0fab8861d..6f0794b97 100644 --- a/kernel-builder/src/card.rs +++ b/kernel-builder/src/card.rs @@ -126,6 +126,7 @@ fn render_card(build: &Build, kernel_dir: &Path) -> Result { .wrap_err("Cannot get card template")? .render(context! { repo_id => repo_id, + version => build.general.version, functions => functions, layers => layers, has_benchmark => has_benchmark, diff --git a/kernel-builder/src/init/templates/CARD.md b/kernel-builder/src/init/templates/CARD.md index 5a0007f0f..5ded435c7 100644 --- a/kernel-builder/src/init/templates/CARD.md +++ b/kernel-builder/src/init/templates/CARD.md @@ -12,7 +12,7 @@ This is the repository card of {{ repo_id }} that has been pushed on the Hub. It # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) {{ functions[0] }} = kernel_module.{{ functions[0] }} {{ functions[0] }}(...) @@ -42,7 +42,7 @@ Function list not available. ## Benchmarks {% if has_benchmark %} -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. {% else %} No benchmark available yet. diff --git a/kernels/src/kernels/_versions.py b/kernels/src/kernels/_versions.py index ed7cabb83..382914669 100644 --- a/kernels/src/kernels/_versions.py +++ b/kernels/src/kernels/_versions.py @@ -1,5 +1,4 @@ import logging -import warnings from huggingface_hub.hf_api import GitRefInfo @@ -59,14 +58,12 @@ def select_revision_or_version( if revision is not None: return revision - elif version is not None: + + if version is not None: return resolve_version_spec_as_ref(repo_id, version).target_commit - warnings.warn( - "Future versions of `kernels` (>=0.15) will require specifying a kernel version or revision. " - "See: https://huggingface.co/docs/kernels/migration", - FutureWarning, - stacklevel=2, + raise ValueError( + "A kernel version or revision must be specified. " + "Use `version=` for a stable kernel API version or `revision=` " + "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" ) - - return "main" diff --git a/kernels/src/kernels/layer/func.py b/kernels/src/kernels/layer/func.py index b7cfd567f..721ef9817 100644 --- a/kernels/src/kernels/layer/func.py +++ b/kernels/src/kernels/layer/func.py @@ -33,10 +33,11 @@ class FuncRepository: The Hub repository containing the layer. func_name (`str`): The name of the function within the kernel repository. - revision (`str`, *optional*, defaults to `"main"`): + revision (`str`, *optional*): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. version (`int`, *optional*): The kernel version to download. Cannot be used together with `revision`. + Either `version` or `revision` must be specified. Example: ```python @@ -46,6 +47,7 @@ class FuncRepository: layer_repo = FuncRepository( repo_id="kernels-community/activation", func_name="silu_and_mul", + revision="main", ) # Reference a layer by version @@ -68,6 +70,8 @@ def __init__( ): if revision is not None and version is not None: raise ValueError("Either a revision or a version must be specified, not both.") + if revision is None and version is None: + raise ValueError("Either a revision or a version must be specified.") self._repo_id = repo_id self.func_name = func_name diff --git a/kernels/src/kernels/layer/layer.py b/kernels/src/kernels/layer/layer.py index d280b6b9e..6b4b37d2d 100644 --- a/kernels/src/kernels/layer/layer.py +++ b/kernels/src/kernels/layer/layer.py @@ -38,10 +38,11 @@ class LayerRepository: The Hub repository containing the layer. layer_name (`str`): The name of the layer within the kernel repository. - revision (`str`, *optional*, defaults to `"main"`): + revision (`str`, *optional*): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. version (`int`, *optional*): The kernel version to download. Cannot be used together with `revision`. + Either `version` or `revision` must be specified. trust_remote_code (`bool | list[str]`, *optional*, defaults to `False`): Whether to allow loading kernels from untrusted organisations. A list of signing identities can be provided for future verification support; @@ -51,7 +52,7 @@ class LayerRepository: ```python from kernels import LayerRepository - # Reference a specific layer by revision + # Reference a specific layer by version layer_repo = LayerRepository( repo_id="kernels-community/activation", layer_name="SiluAndMul", @@ -71,6 +72,8 @@ def __init__( ): if revision is not None and version is not None: raise ValueError("Either a revision or a version must be specified, not both.") + if revision is None and version is None: + raise ValueError("Either a revision or a version must be specified.") self._repo_id = repo_id self.layer_name = layer_name diff --git a/kernels/src/kernels/utils.py b/kernels/src/kernels/utils.py index 329372b75..8c54b9ad4 100644 --- a/kernels/src/kernels/utils.py +++ b/kernels/src/kernels/utils.py @@ -352,10 +352,11 @@ def get_kernel( Args: repo_id (`str`): The Hub repository containing the kernel. - revision (`str`, *optional*, defaults to `"main"`): + revision (`str`, *optional*): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. version (`int`, *optional*): The kernel version to download. Cannot be used together with `revision`. + Either `version` or `revision` must be specified. backend (`str`, *optional*): The backend to load the kernel for. Can only be `cpu` or the backend that Torch is compiled for. The backend will be detected automatically if not provided. @@ -382,6 +383,13 @@ def get_kernel( result = activation.relu(out, x) ``` """ + if revision is None and version is None: + raise ValueError( + "A kernel version or revision must be specified. " + "Use `version=` for a stable kernel API version or `revision=` " + "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" + ) + override = _get_local_kernel_overrides().get(repo_id, None) if override is not None: return get_local_kernel(override) @@ -447,10 +455,11 @@ def has_kernel( Args: repo_id (`str`): The Hub repository containing the kernel. - revision (`str`, *optional*, defaults to `"main"`): + revision (`str`, *optional*): The specific revision (branch, tag, or commit) to download. Cannot be used together with `version`. version (`int`, *optional*): The kernel version to download. Cannot be used together with `revision`. + Either `version` or `revision` must be specified. backend (`str`, *optional*): The backend to load the kernel for. Can only be `cpu` or the backend that Torch is compiled for. The backend will be detected automatically if not provided. diff --git a/kernels/tests/test_basic.py b/kernels/tests/test_basic.py index fd1d9f016..4093fbc6c 100644 --- a/kernels/tests/test_basic.py +++ b/kernels/tests/test_basic.py @@ -27,7 +27,7 @@ def local_kernel(local_kernel_path): @pytest.fixture def metal_kernel(): - return get_kernel("kernels-test/relu-metal") + return get_kernel("kernels-test/relu-metal", version=1) @pytest.fixture @@ -129,18 +129,11 @@ def test_version_outdated_warning(caplog): assert "but version" not in caplog.text -def test_no_version_or_revision_warning(): - from packaging.version import Version - - from kernels import __version__ - - assert Version(__version__) < Version("0.15"), ( - "The deprecation cycle for requiring `version` or `revision` is complete. " - "Remove the fallback to 'main' in `select_revision_or_version` and make " - "`version` or `revision` a required argument." - ) - with pytest.warns(FutureWarning, match="will require specifying a kernel version or revision"): +def test_no_version_or_revision_error(): + with pytest.raises(ValueError, match="A kernel version or revision must be specified"): get_kernel("kernels-test/versions") + with pytest.raises(ValueError, match="A kernel version or revision must be specified"): + has_kernel("kernels-test/versions") def test_noarch_kernel(device): @@ -198,14 +191,14 @@ def test_local_overrides(monkeypatch, local_kernel_path): "LOCAL_KERNELS", f"kernels-test/activation={str(kernel_path)}:kernels-test/non-existing2=/non/existing", ) - get_kernel("kernels-test/activation") + get_kernel("kernels-test/activation", revision="main") with monkeypatch.context() as m: m.setenv( "LOCAL_KERNELS", f"kernels-test/non-existing2=/non/existing:kernels-test/activation={str(kernel_path)}", ) - get_kernel("kernels-test/activation") + get_kernel("kernels-test/activation", revision="main") with monkeypatch.context() as m: # Using a non-existing path should error. @@ -214,7 +207,7 @@ def test_local_overrides(monkeypatch, local_kernel_path): "kernels-test/non-existing2=/non/existing:kernels-test/activation=/non/existing", ) with pytest.raises(FileNotFoundError, match=r"Could not find kernel in /non/existing"): - get_kernel("kernels-test/activation") + get_kernel("kernels-test/activation", revision="main") with monkeypatch.context() as m: # Malformed entries must be rejected. @@ -223,7 +216,7 @@ def test_local_overrides(monkeypatch, local_kernel_path): "kernels-test/non-existing2=/non/existing:kernels-test/activation", ) with pytest.raises(ValueError, match=r"Invalid LOCAL_KERNELS entry"): - get_kernel("kernels-test/activation") + get_kernel("kernels-test/activation", revision="main") @pytest.mark.neuron_only diff --git a/kernels/tests/test_benchmarks.py b/kernels/tests/test_benchmarks.py index 072d2a007..1238e24ef 100644 --- a/kernels/tests/test_benchmarks.py +++ b/kernels/tests/test_benchmarks.py @@ -6,7 +6,7 @@ @pytest.fixture def kernel(): - return get_kernel("kernels-community/activation") + return get_kernel("kernels-community/activation", version=1) @pytest.fixture diff --git a/kernels/tests/test_func.py b/kernels/tests/test_func.py index 4b8c5d5eb..b606213dc 100644 --- a/kernels/tests/test_func.py +++ b/kernels/tests/test_func.py @@ -39,6 +39,11 @@ def identity(x): assert isinstance(identity, nn.Module) +def test_kernel_func_requires_version_or_revision(): + with pytest.raises(ValueError, match="Either a revision or a version must be specified"): + FuncRepository("kernels-test/flattened-build", func_name="silu_and_mul") + + def test_kernel_func(device): model = SurpriseMe() @@ -51,6 +56,7 @@ def test_kernel_func(device): device: FuncRepository( "kernels-test/flattened-build", func_name="silu_and_mul", + revision="main", ) } } diff --git a/kernels/tests/test_layer.py b/kernels/tests/test_layer.py index 5b2f3bfb1..e67abfc28 100644 --- a/kernels/tests/test_layer.py +++ b/kernels/tests/test_layer.py @@ -46,10 +46,12 @@ def local_kernel_path(): "cuda": LayerRepository( repo_id="kernels-test/op-without-fake-test", layer_name="SiluAndMul", + revision="main", ), "rocm": LayerRepository( repo_id="kernels-test/op-without-fake-test", layer_name="SiluAndMul", + revision="main", ), }, "SiluAndMulStringDevice": { @@ -63,6 +65,7 @@ def local_kernel_path(): "xpu": LayerRepository( repo_id="kernels-community/liger_kernels", layer_name="LigerRMSNorm", # Triton + revision="main", ) }, } @@ -197,6 +200,7 @@ def test_hub_func(cls): "cuda": FuncRepository( "kernels-test/flattened-build", func_name="silu_and_mul", + revision="main", ) } } @@ -301,6 +305,7 @@ def test_rocm_kernel_mapping(device): "rocm": LayerRepository( repo_id="kernels-test/silu-and-mul", layer_name="SiluAndMul", + revision="main", ) } } @@ -332,6 +337,7 @@ def test_capability(): ): LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -352,6 +358,7 @@ def test_capability(): ): LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -541,6 +548,11 @@ def test_mapping_contexts(): } +def test_layer_repository_requires_version_or_revision(): + with pytest.raises(ValueError, match="Either a revision or a version must be specified"): + LayerRepository(repo_id="kernels-test/silu-and-mul", layer_name="SiluAndMul") + + def test_validate_kernel_layer(): class BadLayer(nn.Module): def __init__(self, *args, **kwargs): @@ -548,7 +560,7 @@ def __init__(self, *args, **kwargs): self.foo = 42 def stub_repo(layer): - return LayerRepository(repo_id="kernels-test/nonexisting", layer_name=layer.__name__) + return LayerRepository(repo_id="kernels-test/nonexisting", layer_name=layer.__name__, revision="main") with pytest.raises( TypeError, @@ -595,6 +607,7 @@ def test_invalid_mode_for_mapping_rejected(): Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearNoBackward", + revision="main", ) } } @@ -616,6 +629,7 @@ def test_kernel_modes(): "cuda": LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -642,6 +656,7 @@ def test_kernel_modes(): Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -670,10 +685,12 @@ def test_kernel_modes(): Mode.FALLBACK: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), } } @@ -703,6 +720,7 @@ def test_kernel_modes(): Mode.TRAINING | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -737,6 +755,7 @@ def test_fallback_used_when_training(): Device(type="cuda"): LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -759,6 +778,7 @@ def test_fallback_used_when_training(): Device(type="cuda"): LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearImplicitBackward", + revision="main", ) } } @@ -801,6 +821,7 @@ def test_kernel_modes_inference(): Mode.INFERENCE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -829,6 +850,7 @@ def test_kernel_modes_inference(): Mode.INFERENCE | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -857,10 +879,12 @@ def test_kernel_modes_inference(): Mode.INFERENCE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.INFERENCE | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), } } @@ -896,10 +920,12 @@ def test_kernel_modes_mixed(): Mode.INFERENCE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), } } @@ -932,18 +958,22 @@ def test_kernel_modes_mixed(): Mode.INFERENCE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.INFERENCE | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.TRAINING | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), } } @@ -984,6 +1014,7 @@ def test_kernel_modes_cross_fallback(): Mode.TRAINING: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -1008,6 +1039,7 @@ def test_kernel_modes_cross_fallback(): Mode.TRAINING | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ) } } @@ -1042,10 +1074,12 @@ def test_kernel_modes_cross_fallback(): Mode.INFERENCE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), Mode.INFERENCE | Mode.TORCH_COMPILE: LayerRepository( repo_id="kernels-test/backward-marker-test", layer_name="LinearBackward", + revision="main", ), } } @@ -1077,6 +1111,7 @@ def forward(self) -> int: Device(type=device): LayerRepository( repo_id="kernels-test/versions", layer_name="Version", + revision="main", ) } } @@ -1151,6 +1186,7 @@ def test_local_overrides_layer(monkeypatch, local_kernel_path): Device(type="cuda"): LayerRepository( repo_id="kernels-test/silu-and-mul", layer_name="SiluAndMul", + revision="main", ), }, } From 15ba7dfe9844eb183465d4e9b0c0900c706092b8 Mon Sep 17 00:00:00 2001 From: drbh Date: Tue, 12 May 2026 13:57:05 -0400 Subject: [PATCH 2/7] fix: regenerate example cards and update tvm ffi examples to render correctly --- examples/kernels/cutlass-gemm-tvm-ffi/CARD.md | 45 +++--------------- examples/kernels/cutlass-gemm/CARD.md | 45 +++--------------- .../torch-ext/cutlass_gemm/__init__.py | 4 ++ examples/kernels/extra-data/CARD.md | 45 ++++-------------- .../kernels/relu-backprop-compile/CARD.md | 45 +++--------------- .../relu_backprop_compile/__init__.py | 9 ++-- examples/kernels/relu-compiler-flags/CARD.md | 45 +++--------------- .../torch-ext/relu_compiler_flags/__init__.py | 5 +- examples/kernels/relu-metal-cpp/CARD.md | 45 +++--------------- .../relu-metal-cpp/torch-ext/relu/__init__.py | 5 +- examples/kernels/relu-nki/CARD.md | 44 ++++-------------- examples/kernels/relu-specific-torch/CARD.md | 45 +++--------------- .../torch-ext/relu_specific_torch/__init__.py | 3 ++ examples/kernels/relu-torch-bounds/CARD.md | 45 +++--------------- .../torch-ext/relu/__init__.py | 3 ++ examples/kernels/relu-tvm-ffi/CARD.md | 46 ++++--------------- examples/kernels/relu/CARD.md | 44 ++++-------------- examples/kernels/silu-and-mul/CARD.md | 45 +++--------------- kernel-builder/src/card.rs | 10 ++-- 19 files changed, 117 insertions(+), 461 deletions(-) diff --git a/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md b/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md index 1243f0e94..06e785fdc 100644 --- a/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md +++ b/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/cutlass-gemm-tvm-ffi that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/cutlass-gemm-tvm-ffi", version=1) +cutlass_gemm = kernel_module.cutlass_gemm -{{ functions[0] }}(...) +cutlass_gemm(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `cutlass_gemm` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/cutlass-gemm/CARD.md b/examples/kernels/cutlass-gemm/CARD.md index 1243f0e94..d03067025 100644 --- a/examples/kernels/cutlass-gemm/CARD.md +++ b/examples/kernels/cutlass-gemm/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/cutlass-gemm that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/cutlass-gemm", version=1) +cutlass_gemm = kernel_module.cutlass_gemm -{{ functions[0] }}(...) +cutlass_gemm(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `cutlass_gemm` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py b/examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py index aa7d51e4d..a6a1d4b91 100644 --- a/examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py +++ b/examples/kernels/cutlass-gemm/torch-ext/cutlass_gemm/__init__.py @@ -2,6 +2,10 @@ from ._ops import ops + def cutlass_gemm(out: torch.Tensor, A: torch.Tensor, B: torch.Tensor) -> None: ops.cutlass_gemm(out, A, B) return out + + +__all__ = ["cutlass_gemm"] diff --git a/examples/kernels/extra-data/CARD.md b/examples/kernels/extra-data/CARD.md index 1243f0e94..4d6344a79 100644 --- a/examples/kernels/extra-data/CARD.md +++ b/examples/kernels/extra-data/CARD.md @@ -1,56 +1,29 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/extra-data that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/extra-data", version=1) +EASTER_EGG = kernel_module.EASTER_EGG -{{ functions[0] }}(...) +EASTER_EGG(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} +- `EASTER_EGG` +- `relu` ## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `ReLU` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-backprop-compile/CARD.md b/examples/kernels/relu-backprop-compile/CARD.md index 1243f0e94..b118789a9 100644 --- a/examples/kernels/relu-backprop-compile/CARD.md +++ b/examples/kernels/relu-backprop-compile/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-backprop-compile that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-backprop-compile", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py b/examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py index cedb3f7d3..d75042c68 100644 --- a/examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py +++ b/examples/kernels/relu-backprop-compile/torch-ext/relu_backprop_compile/__init__.py @@ -1,7 +1,7 @@ import torch from torch.library import register_autograd -from ._ops import ops, add_op_namespace_prefix +from ._ops import add_op_namespace_prefix, ops @torch.library.register_fake(add_op_namespace_prefix("relu_fwd")) @@ -28,6 +28,7 @@ def _backward(ctx, grad_outputs: torch.Tensor): return ops.relu_bwd(grad_outputs_contiguous, input) -register_autograd( - add_op_namespace_prefix("relu_fwd"), _backward, setup_context=_setup_context -) +register_autograd(add_op_namespace_prefix("relu_fwd"), _backward, setup_context=_setup_context) + + +__all__ = ["relu"] diff --git a/examples/kernels/relu-compiler-flags/CARD.md b/examples/kernels/relu-compiler-flags/CARD.md index 1243f0e94..4cf000ba5 100644 --- a/examples/kernels/relu-compiler-flags/CARD.md +++ b/examples/kernels/relu-compiler-flags/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-compiler-flags that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-compiler-flags", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py b/examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py index 8050dfd76..a844aae86 100644 --- a/examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py +++ b/examples/kernels/relu-compiler-flags/torch-ext/relu_compiler_flags/__init__.py @@ -9,4 +9,7 @@ def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor: if out is None: out = torch.empty_like(x) ops.relu(out, x) - return out \ No newline at end of file + return out + + +__all__ = ["relu"] diff --git a/examples/kernels/relu-metal-cpp/CARD.md b/examples/kernels/relu-metal-cpp/CARD.md index 1243f0e94..5d3fafe5f 100644 --- a/examples/kernels/relu-metal-cpp/CARD.md +++ b/examples/kernels/relu-metal-cpp/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-metal-cpp that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-metal-cpp", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py b/examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py index 8050dfd76..a844aae86 100644 --- a/examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py +++ b/examples/kernels/relu-metal-cpp/torch-ext/relu/__init__.py @@ -9,4 +9,7 @@ def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor: if out is None: out = torch.empty_like(x) ops.relu(out, x) - return out \ No newline at end of file + return out + + +__all__ = ["relu"] diff --git a/examples/kernels/relu-nki/CARD.md b/examples/kernels/relu-nki/CARD.md index 1243f0e94..ef12dd286 100644 --- a/examples/kernels/relu-nki/CARD.md +++ b/examples/kernels/relu-nki/CARD.md @@ -1,56 +1,28 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-nki that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-nki", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} +- `relu` ## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `ReLU` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-specific-torch/CARD.md b/examples/kernels/relu-specific-torch/CARD.md index 1243f0e94..6ab6c0d71 100644 --- a/examples/kernels/relu-specific-torch/CARD.md +++ b/examples/kernels/relu-specific-torch/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-specific-torch that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-specific-torch", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py b/examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py index d801867e6..a844aae86 100644 --- a/examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py +++ b/examples/kernels/relu-specific-torch/torch-ext/relu_specific_torch/__init__.py @@ -10,3 +10,6 @@ def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor: out = torch.empty_like(x) ops.relu(out, x) return out + + +__all__ = ["relu"] diff --git a/examples/kernels/relu-torch-bounds/CARD.md b/examples/kernels/relu-torch-bounds/CARD.md index 1243f0e94..20e956431 100644 --- a/examples/kernels/relu-torch-bounds/CARD.md +++ b/examples/kernels/relu-torch-bounds/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-torch-bounds that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-torch-bounds", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py b/examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py index d801867e6..a844aae86 100644 --- a/examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py +++ b/examples/kernels/relu-torch-bounds/torch-ext/relu/__init__.py @@ -10,3 +10,6 @@ def relu(x: torch.Tensor, out: Optional[torch.Tensor] = None) -> torch.Tensor: out = torch.empty_like(x) ops.relu(out, x) return out + + +__all__ = ["relu"] diff --git a/examples/kernels/relu-tvm-ffi/CARD.md b/examples/kernels/relu-tvm-ffi/CARD.md index 1243f0e94..ff8da5e42 100644 --- a/examples/kernels/relu-tvm-ffi/CARD.md +++ b/examples/kernels/relu-tvm-ffi/CARD.md @@ -1,56 +1,26 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu-tvm-ffi that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu-tvm-ffi", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `relu` +- `relu_jax` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/relu/CARD.md b/examples/kernels/relu/CARD.md index 1243f0e94..53c178914 100644 --- a/examples/kernels/relu/CARD.md +++ b/examples/kernels/relu/CARD.md @@ -1,56 +1,28 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/relu that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/relu", version=1) +relu = kernel_module.relu -{{ functions[0] }}(...) +relu(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} +- `relu` ## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `ReLU` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/examples/kernels/silu-and-mul/CARD.md b/examples/kernels/silu-and-mul/CARD.md index 1243f0e94..e5e0cb9ab 100644 --- a/examples/kernels/silu-and-mul/CARD.md +++ b/examples/kernels/silu-and-mul/CARD.md @@ -1,56 +1,25 @@ --- library_name: kernels -{% if license %}license: {{ license }} -{% endif %}--- +license: apache-2.0 +--- -This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of kernels-test/silu-and-mul that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use -{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("{{ repo_id }}") -{{ functions[0] }} = kernel_module.{{ functions[0] }} +kernel_module = get_kernel("kernels-test/silu-and-mul", version=1) +silu_and_mul = kernel_module.silu_and_mul -{{ functions[0] }}(...) +silu_and_mul(...) ``` -{% else %} - -Usage example not available. -{% endif %} ## Available functions -{% if functions %} -{% for func in functions %} -- `{{ func }}` -{% endfor %} -{% else %} - -Function list not available. -{% endif %} -{% if layers %} - -## Available layers -{% for layer in layers %} -- `{{ layer }}` -{% endfor %} -{% endif %} +- `silu_and_mul` ## Benchmarks -{% if has_benchmark %} - -Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }}`. -{% else %} No benchmark available yet. -{% endif %} -{% if upstream %} - -## Source code - -Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. -{% endif %} - diff --git a/kernel-builder/src/card.rs b/kernel-builder/src/card.rs index 6f0794b97..b226f518c 100644 --- a/kernel-builder/src/card.rs +++ b/kernel-builder/src/card.rs @@ -13,12 +13,12 @@ use kernels_data::config::Build; use crate::util::{check_or_infer_kernel_dir, parse_build}; fn extract_all(kernel_dir: &Path, module_name: &str) -> Option> { - let init_path = kernel_dir - .join("torch-ext") - .join(module_name) - .join("__init__.py"); + let init_path = ["torch-ext", "tvm-ffi-ext"] + .iter() + .map(|ext_dir| kernel_dir.join(ext_dir).join(module_name).join("__init__.py")) + .find(|path| path.exists())?; - let content = fs::read_to_string(&init_path).ok()?; + let content = fs::read_to_string(init_path).ok()?; let stmts = ast::Suite::parse(&content, "").ok()?; for stmt in stmts { From a78eaad64ad9d94bb7653990d73f2af456b4191a Mon Sep 17 00:00:00 2001 From: drbh Date: Wed, 13 May 2026 11:40:58 -0400 Subject: [PATCH 3/7] fix: reformat --- kernel-builder/src/card.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel-builder/src/card.rs b/kernel-builder/src/card.rs index b226f518c..b0047a5c3 100644 --- a/kernel-builder/src/card.rs +++ b/kernel-builder/src/card.rs @@ -15,7 +15,12 @@ use crate::util::{check_or_infer_kernel_dir, parse_build}; fn extract_all(kernel_dir: &Path, module_name: &str) -> Option> { let init_path = ["torch-ext", "tvm-ffi-ext"] .iter() - .map(|ext_dir| kernel_dir.join(ext_dir).join(module_name).join("__init__.py")) + .map(|ext_dir| { + kernel_dir + .join(ext_dir) + .join(module_name) + .join("__init__.py") + }) .find(|path| path.exists())?; let content = fs::read_to_string(init_path).ok()?; From 187940b18aa005f5a4a30747a02c6b7823a285f1 Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 15 May 2026 10:15:06 -0400 Subject: [PATCH 4/7] fix: remove card hydration --- examples/kernels/cutlass-gemm-tvm-ffi/CARD.md | 45 +++++++++++++++--- examples/kernels/cutlass-gemm/CARD.md | 45 +++++++++++++++--- examples/kernels/extra-data/CARD.md | 45 ++++++++++++++---- .../kernels/relu-backprop-compile/CARD.md | 45 +++++++++++++++--- examples/kernels/relu-compiler-flags/CARD.md | 45 +++++++++++++++--- examples/kernels/relu-metal-cpp/CARD.md | 45 +++++++++++++++--- examples/kernels/relu-nki/CARD.md | 44 ++++++++++++++---- examples/kernels/relu-specific-torch/CARD.md | 45 +++++++++++++++--- examples/kernels/relu-torch-bounds/CARD.md | 45 +++++++++++++++--- examples/kernels/relu-tvm-ffi/CARD.md | 46 +++++++++++++++---- examples/kernels/relu/CARD.md | 44 ++++++++++++++---- examples/kernels/silu-and-mul/CARD.md | 45 +++++++++++++++--- 12 files changed, 450 insertions(+), 89 deletions(-) diff --git a/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md b/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md index 06e785fdc..c7c707151 100644 --- a/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md +++ b/examples/kernels/cutlass-gemm-tvm-ffi/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/cutlass-gemm-tvm-ffi that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/cutlass-gemm-tvm-ffi", version=1) -cutlass_gemm = kernel_module.cutlass_gemm +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -cutlass_gemm(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `cutlass_gemm` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/cutlass-gemm/CARD.md b/examples/kernels/cutlass-gemm/CARD.md index d03067025..c7c707151 100644 --- a/examples/kernels/cutlass-gemm/CARD.md +++ b/examples/kernels/cutlass-gemm/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/cutlass-gemm that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/cutlass-gemm", version=1) -cutlass_gemm = kernel_module.cutlass_gemm +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -cutlass_gemm(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `cutlass_gemm` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/extra-data/CARD.md b/examples/kernels/extra-data/CARD.md index 4d6344a79..c7c707151 100644 --- a/examples/kernels/extra-data/CARD.md +++ b/examples/kernels/extra-data/CARD.md @@ -1,29 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/extra-data that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/extra-data", version=1) -EASTER_EGG = kernel_module.EASTER_EGG +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -EASTER_EGG(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `EASTER_EGG` -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} ## Available layers -- `ReLU` +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-backprop-compile/CARD.md b/examples/kernels/relu-backprop-compile/CARD.md index b118789a9..c7c707151 100644 --- a/examples/kernels/relu-backprop-compile/CARD.md +++ b/examples/kernels/relu-backprop-compile/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-backprop-compile that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-backprop-compile", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-compiler-flags/CARD.md b/examples/kernels/relu-compiler-flags/CARD.md index 4cf000ba5..c7c707151 100644 --- a/examples/kernels/relu-compiler-flags/CARD.md +++ b/examples/kernels/relu-compiler-flags/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-compiler-flags that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-compiler-flags", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-metal-cpp/CARD.md b/examples/kernels/relu-metal-cpp/CARD.md index 5d3fafe5f..c7c707151 100644 --- a/examples/kernels/relu-metal-cpp/CARD.md +++ b/examples/kernels/relu-metal-cpp/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-metal-cpp that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-metal-cpp", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-nki/CARD.md b/examples/kernels/relu-nki/CARD.md index ef12dd286..c7c707151 100644 --- a/examples/kernels/relu-nki/CARD.md +++ b/examples/kernels/relu-nki/CARD.md @@ -1,28 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-nki that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-nki", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} ## Available layers -- `ReLU` +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-specific-torch/CARD.md b/examples/kernels/relu-specific-torch/CARD.md index 6ab6c0d71..c7c707151 100644 --- a/examples/kernels/relu-specific-torch/CARD.md +++ b/examples/kernels/relu-specific-torch/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-specific-torch that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-specific-torch", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-torch-bounds/CARD.md b/examples/kernels/relu-torch-bounds/CARD.md index 20e956431..c7c707151 100644 --- a/examples/kernels/relu-torch-bounds/CARD.md +++ b/examples/kernels/relu-torch-bounds/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-torch-bounds that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-torch-bounds", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu-tvm-ffi/CARD.md b/examples/kernels/relu-tvm-ffi/CARD.md index ff8da5e42..c7c707151 100644 --- a/examples/kernels/relu-tvm-ffi/CARD.md +++ b/examples/kernels/relu-tvm-ffi/CARD.md @@ -1,26 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu-tvm-ffi that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu-tvm-ffi", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` -- `relu_jax` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/relu/CARD.md b/examples/kernels/relu/CARD.md index 53c178914..c7c707151 100644 --- a/examples/kernels/relu/CARD.md +++ b/examples/kernels/relu/CARD.md @@ -1,28 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/relu that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/relu", version=1) -relu = kernel_module.relu +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -relu(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `relu` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} ## Available layers -- `ReLU` +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + diff --git a/examples/kernels/silu-and-mul/CARD.md b/examples/kernels/silu-and-mul/CARD.md index e5e0cb9ab..c7c707151 100644 --- a/examples/kernels/silu-and-mul/CARD.md +++ b/examples/kernels/silu-and-mul/CARD.md @@ -1,25 +1,56 @@ --- library_name: kernels -license: apache-2.0 ---- +{% if license %}license: {{ license }} +{% endif %}--- -This is the repository card of kernels-test/silu-and-mul that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. +This is the repository card of {{ repo_id }} that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. ## How to use +{% if functions %} ```python # make sure `kernels` is installed: `pip install -U kernels` from kernels import get_kernel -kernel_module = get_kernel("kernels-test/silu-and-mul", version=1) -silu_and_mul = kernel_module.silu_and_mul +kernel_module = get_kernel("{{ repo_id }}", version={{ version }}) +{{ functions[0] }} = kernel_module.{{ functions[0] }} -silu_and_mul(...) +{{ functions[0] }}(...) ``` +{% else %} + +Usage example not available. +{% endif %} ## Available functions -- `silu_and_mul` +{% if functions %} +{% for func in functions %} +- `{{ func }}` +{% endfor %} +{% else %} + +Function list not available. +{% endif %} +{% if layers %} + +## Available layers +{% for layer in layers %} +- `{{ layer }}` +{% endfor %} +{% endif %} ## Benchmarks +{% if has_benchmark %} + +Benchmarking script is available for this kernel. Run `kernels benchmark {{ repo_id }} --version {{ version }}`. +{% else %} No benchmark available yet. +{% endif %} +{% if upstream %} + +## Source code + +Source code of this kernel originally comes from {{ upstream }} and it was repurposed for compatibility with `kernels`. +{% endif %} + From 06992fd19bf50f5dd5f8bc605154bb0e904a4d2f Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 15 May 2026 10:18:24 -0400 Subject: [PATCH 5/7] fix: prefer elif syntax --- kernels/src/kernels/_versions.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernels/src/kernels/_versions.py b/kernels/src/kernels/_versions.py index 382914669..cb228ed83 100644 --- a/kernels/src/kernels/_versions.py +++ b/kernels/src/kernels/_versions.py @@ -55,14 +55,12 @@ def select_revision_or_version( ) -> str: if revision is not None and version is not None: raise ValueError("Only one of `revision` or `version` must be specified.") - - if revision is not None: + elif revision is not None: return revision - - if version is not None: + elif version is not None: return resolve_version_spec_as_ref(repo_id, version).target_commit - - raise ValueError( + else: + raise ValueError( "A kernel version or revision must be specified. " "Use `version=` for a stable kernel API version or `revision=` " "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" From abf1a0a62c8781dadbf3f192b7dc62fa4632e8c4 Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 15 May 2026 10:19:26 -0400 Subject: [PATCH 6/7] fix: remove duplicate check --- kernels/src/kernels/utils.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/kernels/src/kernels/utils.py b/kernels/src/kernels/utils.py index 8c54b9ad4..9b07f31f1 100644 --- a/kernels/src/kernels/utils.py +++ b/kernels/src/kernels/utils.py @@ -383,13 +383,6 @@ def get_kernel( result = activation.relu(out, x) ``` """ - if revision is None and version is None: - raise ValueError( - "A kernel version or revision must be specified. " - "Use `version=` for a stable kernel API version or `revision=` " - "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" - ) - override = _get_local_kernel_overrides().get(repo_id, None) if override is not None: return get_local_kernel(override) From 9d56ed7a34f9576867de3bba34b6fbf666dd0cc2 Mon Sep 17 00:00:00 2001 From: drbh Date: Fri, 15 May 2026 10:20:19 -0400 Subject: [PATCH 7/7] fix: reformat --- kernels/src/kernels/_versions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernels/src/kernels/_versions.py b/kernels/src/kernels/_versions.py index cb228ed83..189a459dd 100644 --- a/kernels/src/kernels/_versions.py +++ b/kernels/src/kernels/_versions.py @@ -61,7 +61,7 @@ def select_revision_or_version( return resolve_version_spec_as_ref(repo_id, version).target_commit else: raise ValueError( - "A kernel version or revision must be specified. " - "Use `version=` for a stable kernel API version or `revision=` " - "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" - ) + "A kernel version or revision must be specified. " + "Use `version=` for a stable kernel API version or `revision=` " + "for an explicit Hub revision. See: https://huggingface.co/docs/kernels/migration" + )