kernels
The Kernel Hub allows Python libraries and applications to load compute kernels directly from the Hub. 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.
🚀 Quick Start
Install the kernels package with pip (requires torch>=2.5 and CUDA):
pip install kernels
Here is how you would use the activation kernels from the Hugging Face Hub:
import torch
from kernels import get_kernel
# Download optimized kernels from the Hugging Face hub
activation = get_kernel("kernels-community/activation")
# 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 on the Hub.
📚 Documentation
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kernels-0.2.0.tar.gz
(9.2 kB
view details)
File details
Details for the file kernels-0.2.0.tar.gz.
File metadata
- Download URL: kernels-0.2.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d845035efec6c8442dba4161d08756714d25b3d2ffc29fe4ce79edc1926c08eb
|
|
| MD5 |
ee418884b1ebb9f9c1a76ca9fbd8f495
|
|
| BLAKE2b-256 |
ec1b48eb6b4938c55bb45a930f2aef56c86fe0fae82402f2e4c606628f304d9f
|