Metadata-Version: 2.4
Name: kernels
Version: 0.14.0.dev1
Summary: Download compute kernels
Author-email: Daniel de Kok <daniel@huggingface.co>, David Holtz <david@huggingface.co>
License: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: huggingface-hub>=1.10.0
Requires-Dist: packaging>=20.0
Requires-Dist: pyyaml>=6
Requires-Dist: tomli>=2.0; python_version < "3.11"
Requires-Dist: tomlkit>=0.13.3
Provides-Extra: abi-check
Requires-Dist: kernel-abi-check<0.7.0,>=0.6.2; extra == "abi-check"
Provides-Extra: benchmark
Requires-Dist: matplotlib>=3.7.0; extra == "benchmark"
Requires-Dist: numpy>=2.0.2; extra == "benchmark"
Requires-Dist: tabulate>=0.9.0; extra == "benchmark"
Requires-Dist: torch; extra == "benchmark"
Provides-Extra: torch
Requires-Dist: torch; extra == "torch"
Provides-Extra: docs
Requires-Dist: hf-doc-builder; extra == "docs"

# kernels

The Kernel Hub allows Python libraries and applications to load compute
kernels directly from the [Hub](https://hf.co/). To support this kind
of dynamic loading, Hub kernels differ from traditional Python kernel
packages in that they are made to be:

- Portable: a kernel can be loaded from paths outside `PYTHONPATH`.
- Unique: multiple versions of the same kernel can be loaded in the
  same Python process.
- Compatible: kernels must support all recent versions of Python and
  the different PyTorch build configurations (various CUDA versions
  and C++ ABIs). Furthermore, older C library versions must be supported.

The `kernels` Python package is used to load kernels from the Hub.

## 🚀 Quick Start

Install the `kernels` package with `pip` (requires `torch>=2.5` and CUDA):

```bash
pip install kernels
```

Here is how you would use the [activation](https://huggingface.co/kernels-community/activation) kernels from the Hugging Face Hub:

```python
import torch

from kernels import get_kernel

# Download optimized kernels from the Hugging Face hub
activation = get_kernel("kernels-community/activation", version=1)

# Random tensor
x = torch.randn((10, 10), dtype=torch.float16, device="cuda")

# Run the kernel
y = torch.empty_like(x)
activation.gelu_fast(y, x)

print(y)
```

You can [search for kernels](https://huggingface.co/models?other=kernels) on
the Hub.

## 📚 Documentation

Read the [documentation of kernels](https://huggingface.co/docs/kernels/).
