Skip to content

moujar/kernel-builder

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

238 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

kernel-builder

kernel-builder logo

Build and Push Docker Image GitHub tag GitHub package


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.9 note: kernel-builder currently builds Torch 2.9 extensions based on the fifth release candidate. If you upload Torch 2.9 kernels, please validate them against the final Torch 2.9.0 release. In the unlikely case of an ABI-breaking change, you can rebuild and upload your kernel once kernel-builder is updated for the final release

πŸš€ Quick Start

We recommend using Nix to build kernels. To speed up builds, first enable the Hugging Face binary cache:

# Install cachix and configure the cache
cachix use huggingface

# Or run once without installing cachix
nix run nixpkgs#cachix -- use huggingface

Then quick start a build with:

cd examples/activation
nix run .#build-and-copy \
  --override-input kernel-builder github:huggingface/kernel-builder \
  --max-jobs 8 \
  -j 8 \
  -L

The compiled kernel will then be available in the local build/ directory. We also provide Docker containers for CI builds. For a quick build:

# Using the prebuilt container
cd examples/activation
docker run --rm \
  --mount type=bind,source=$(pwd),target=/kernelcode \
  -w /kernelcode ghcr.io/huggingface/kernel-builder:main build

See dockerfiles/README.md for more options, including a user-level container for CI/CD environments.

🎯 Hardware Support

Hardware Kernels Support Kernel-Builder Support Kernels Validated in CI Tier
CUDA βœ“ βœ“ βœ“ 1
ROCm βœ“ βœ“ βœ— 2
XPU βœ“ βœ“ βœ— 2
Metal βœ“ βœ“ βœ— 2
Huawei NPU βœ“ βœ— βœ— 3

πŸ“š Documentation

Credits

The generated CMake build files are based on the vLLM build infrastructure.

About

πŸ‘· Build compute kernels

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 38.6%
  • Nix 22.1%
  • CMake 18.9%
  • Python 15.7%
  • Dockerfile 3.1%
  • Shell 1.1%
  • C 0.5%