GitHub - huggingface/kernels: Load compute kernels from the Hub (original) (raw)

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:

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)