Skip to content

Instantly share code, notes, and snippets.

@drbh
Last active April 1, 2025 15:35
Show Gist options
  • Save drbh/46b4b59a78171b09cc0e79120e8b3ad7 to your computer and use it in GitHub Desktop.
Save drbh/46b4b59a78171b09cc0e79120e8b3ad7 to your computer and use it in GitHub Desktop.
# /// script
# dependencies = [
# "numpy",
# "torch",
# "kernels",
# ]
# ///
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment