# Easily Build and Share ROCm Kernels with Hugging Face

[Hugging Face](https://yomu.fyi/company/hugging-face) · Abdennacer Badaoui, Daniel Huang, colorswind, Zesen Liu · Nov 17, 2025

**Type:** Tutorial

## Summary

Compiling custom deep learning GPU kernels across architectures often leads to complex build flag management, compiler errors, and ABI issues. Hugging Face's kernels library and kernel-builder streamline this workflow by supporting backends such as ROCm, CUDA, Metal, and XPU. Using the RadeonFlow FP8 block-wise GEMM kernel optimized for the AMD Instinct MI300X GPU as an example, developers organize files into specific headers and HIP implementations. The build is configured via a build.toml manifest and flake.nix to ensure reproducible compilation across supported PyTorch and ROCm versions. Artifacts can then be pushed to the Hugging Face Hub, allowing users to load and execute custom operators directly via get\_kernel without traditional installation steps.

## Context

Compiling custom GPU kernels for targeted hardware architectures, managing build flags, and integrating with PyTorch extensions frequently results in CMake or Nix configuration issues, compiler errors, and ABI mismatches.

## Approach / What changed

Hugging Face's kernels library and kernel-builder utilize build.toml manifests and flake.nix reproducibility files to compile ROCm HIP code, package PyTorch C++ bindings, and publish artifacts to the Hugging Face Hub for direct loading.

## Takeaways

- The RadeonFlow GEMM kernel uses the FP8 e4m3fnuz format with per-block FP32 scaling factors to maintain numerical accuracy on AMD Instinct MI300X (gfx942) GPUs.
- Kernel source files must distinguish between .h files for headers/declarations and .hip files for HIP implementation code that compiles separately.
- Published kernels do not require traditional installation and can be loaded directly from the Hugging Face Hub using the get\_kernel function.

**Tags:** [Machine Learning](https://yomu.fyi/topic/machine-learning), [Open Source](https://yomu.fyi/topic/open-source), [Performance](https://yomu.fyi/topic/performance), [Python](https://yomu.fyi/topic/python)

[Read original post](https://huggingface.co/blog/build-rocm-kernels)
