This repo contains a Nix package that can be used to build custom machine learning kernels for PyTorch. The kernels are built using the PyTorch C++ Frontend and can be loaded from the Hub with the kernels Python package.
This builder is a core component of the larger kernel build/distribution system.
Torch 2.7 note: kernel-builder currently builds Torch 2.7 extensions based on the final release candidate. If you upload kernels Torch 2.7 kernels, please validate them against the final Torch 2.7.0 release. In the unlikely case of an ABI-breaking change, you can rebuild and upload a your kernel once kernel-builder is updated for the final release.
We provide a Docker image with which you can build a kernel:
# navigate to the activation directory
cd examples/activation
# then run the following command to build the kernel
docker run --rm \
-v $(pwd):/kernelcode \
ghcr.io/huggingface/kernel-builder:latest
This will build the kernel and save the output in the build
directory in
the activation folder.
- Writing Hub kernels
- Building kernels with Docker
- Building kernels with Nix
- Local kernel development (IDE integration)
- Why Nix?
The generated CMake build files are based on the vLLM build infrastructure.