@RisingSayak: Found a faster kernel? You shouldn’t need to rewrite your model to use it. With Kernels, you can choose which kernel ru…
Summary
This Twitter thread introduces Hugging Face's Kernels, a tool that allows users to select and replace optimized kernel implementations for supported layers in AI models without rewriting the entire model.
View Cached Full Text
Cached at: 09/19/26, 04:57 AM
Found a faster kernel? You shouldn’t need to rewrite your model to use it.
With 🤗 Kernels, you can choose which kernel runs a supported layer and replace its forward() with an optimized implementation.
Here’s how 🧵
1/5
First, make a layer swappable with a decorator:
use_kernel_forward_from_hub("SiluAndMul")
Then register a mapping that says: “For this layer, on this device, use this kernel from the Hub.”
You choose the implementation.
2/5
Now apply it:
kernelize(model, mode=Mode.INFERENCE)
Kernels walks through the model & replaces forward() on the eligible layers with registered kernels.
The other layers stay untouched.
You can also configure things with granulaity (device, capability specificity).
3/5
Need one kernel for inference and another for training? You can specify both.
You can also choose different kernels for different device types.
You can register those choices in a mapping, either globally or locally.
4/5
That’s the useful bit: trying another compatible kernel becomes a mapping change, not a model rewrite.
Swap it in. Benchmark your workload. Keep what actually helps.
Docs: https://huggingface.co/docs/kernels/en/layers…
5/5
No
🔥 “best-fit” kernels should always just populate!
Speaking of, any luck w further ROCm support @RisingSayak? Happy I got to contribute for qwen-series on DGX Spark, want to show Strix Halo some love too :)
Compile works. Export — we haven’t tested.
Similar Articles
@RisingSayak: The kernels project at Hugging Face has been growing! We want it to be the go-to place for kernel devs and kernel users…
Hugging Face's kernels project is expanding and seeking contributors for agentic kernel development to provide real optimization value to models.
@RisingSayak: We want to work with kernel developers to help them publish their cool kernels on the @huggingface Hub via Kernels. Thi…
Hugging Face is inviting kernel developers to publish their custom kernels on the Hugging Face Hub via 🤗 Kernels, offering benefits like consistent build structure, ease of use, standardized distribution, and reproducibility.
@TheAhmadOsman: You don’t “run a model” You run Kernels The model is just a graph The Inference Engine is scheduler / optimizer / execu…
The tweet explains that running AI models is really about running optimized kernels, and that inference engines and their kernel implementations are critical for performance, not just the model or hardware.
@TheAhmadOsman: You wanna learn how do these AI kernels work? Start here
Tweet by @TheAhmadOsman pointing to a resource for learning how AI kernels work.
@PyTorch: The @huggingface Kernels project now has Helion support. This blog walks through how to build, autotune, and ship perfo…
The Hugging Face Kernels project now supports Helion, a high-level DSL for writing performant ML kernels, enabling users to build, autotune, and ship kernels seamlessly.