Hugging Face has released its kernel build tool, Kernels 0.19.0. It can build MLX kernels for Apple silicon and adds an experimental path for building CUDA kernels in Rust. Kernel authors gain build options suited to their target hardware and language.
1. Building MLX kernels on Apple silicon
This release adds support for MLX framework-based JIT kernels in Kernels and the kernel builder. These generate the necessary code at runtime and target Apple silicon through Metal. A complete example kernel is available to explore its setup and implementation.
The build configuration specifies general information and the Metal backend, with a section for MLX JIT kernels. The original source provides this example:
[general]
name = "my-mlx-kernel"
version = 1
edition = 6
license = "Apache-2.0"
backends = ["metal"]
[mlx-noarch]Metal is currently the only backend supported by the new MLX path.
2. CUDA kernels written in Rust remain experimental
The kernel builder also offers experimental support for building CUDA kernels in Rust. Two interfaces are supported: cuda-oxide and cutile-rs, each with a ReLU example showing how to use it. Rust developers can try creating CUDA kernels in their own language.
MLX support focuses on Apple silicon and Metal, while Rust support broadens the language choices for writing CUDA kernels. The release expands both hardware targeting and implementation language options.
3. An optional ZIP layout for kernels with many files
Kernel authors can select a ZIP layout in the build configuration to package Python and data files in one ZIP archive. Hugging Face says this can help avoid download limits for kernels with many files. It also explains how to read data files, using Triton autotuning files as an example.
Select the ZIP layout with build-layout = "zip" in the build configuration.
Bundling files comes with a version requirement for deployment targets. Kernels using the ZIP layout cannot be loaded by versions earlier than Kernels 0.19.0.
4. Improved porting and dependency inspection
The porting tool, which adapts kernels to other environments, has enhanced its conversion recipes. The process restructures code or switches native extensions to use ._ops, then adjusts imports to load other kernels and checks the results. After porting, it checks relative imports and Torch extension declarations, letting recipe authors detect some changes from the original project before building. The key is that conversion is followed by validation.
Dependency inspection covers not only the kernels a kernel directly requires, but also those connected beneath them. The --dep-tree option for kernels info displays these transitive dependencies as a tree. Adding --json makes the dependency_tree field available for automated processing, revealing dependencies beyond direct connections.
5. ROCm builds and deployment work
The builder in Nix, which manages packages and builds, improves kernel builds for ROCm, AMD's GPU software environment. When building for multiple hardware architectures, it uses hooks to parallelize HIP compilation, which generates code for AMD GPUs. The source says this works similarly to nvcc's thread option and can speed up builds severalfold. According to the company, this benefit can be expected when building for multiple architectures together.
Authors can choose new paths based on their target hardware and language, and consider the ZIP layout for kernels with many files. Porting and dependency inspection improvements help move and connect existing kernels.
Kernels 0.19.0 expands build options for different hardware and languages while strengthening the tools for porting and distributing kernels.
