Skip to content

Latest commit

 

History

History
67 lines (51 loc) · 2.57 KB

File metadata and controls

67 lines (51 loc) · 2.57 KB

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.

🚀 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 \
  -v $(pwd)/../..:/app \
  -w /app/examples/activation \
  ghcr.io/huggingface/kernel-builder:{SHA} \
  build

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

📚 Documentation

Credits

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