2025-01-20 12:55:22 +01:00
2025-01-20 12:55:22 +01:00
2025-01-20 12:55:22 +01:00
2024-11-29 17:43:30 +01:00
2025-01-14 16:30:25 +01:00
2025-01-20 12:55:22 +01:00

hf-kernels

Make sure you have torch==2.5.1+cu124 installed.

import torch

from hf_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)

Docker Reference

build and run the reference example/basic.py in a Docker container with the following commands:

docker build --platform linux/amd64 -t kernels-reference -f docker/Dockerfile.reference .
docker run --gpus all -it --rm -e HF_TOKEN=$HF_TOKEN kernels-reference
Description
Load compute kernels from the Hub
Readme Apache-2.0 782 KiB
Languages
Python 98.7%
Nix 1.2%