---
title: "Easily Build and Share ROCm Kernels with Hugging Face"
description: "Hugging Face's kernels library and kernel-builder can package a custom ROCm kernel as a native PyTorch operator and share it on the Hub, shown with the prize-winning RadeonFlow FP8 block-wise GEMM kernel for AMD MI300X."
url: "https://swe.quest/articles/easily-build-and-share-rocm-kernels-with-hugging-face-dfc0e1a655e74ace"
canonical: "https://huggingface.co/blog/build-rocm-kernels"
source: "Hugging Face"
published: "2025-11-17"
difficulty: "medium"
kind: "How-to"
reading_minutes: 13
tags: ["build-systems","hardware","machine-learning","c-cpp","python"]
---

# Easily Build and Share ROCm Kernels with Hugging Face

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-11-17, 13 min read, How-to. Original: [https://huggingface.co/blog/build-rocm-kernels](https://huggingface.co/blog/build-rocm-kernels)

## Summary

Hugging Face's kernels library and kernel-builder can package a custom ROCm kernel as a native PyTorch operator and share it on the Hub, shown with the prize-winning RadeonFlow FP8 block-wise GEMM kernel for AMD MI300X. The walkthrough covers the expected project layout, renaming HIP sources to .h/.hip, a build.toml manifest targeting gfx942, and a flake.nix for reproducible Nix builds. It also covers registering the launcher via TORCH\_LIBRARY so it is exposed through torch.ops, plus a Python \_\_init\_\_.py wrapper. Builds run with \`nix build\` or a \`nix develop\` shell using build2cmake and CMake, and enabling the Hugging Face cachix cache avoids expensive rebuilds.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch C++ extensions ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- GPU kernel programming ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- Nix basics

## Keywords

ROCm, HIP, kernel-builder, Hugging Face kernels, PyTorch, Nix, AMD Instinct MI300X, RadeonFlow

## Related posts

- [From Zero to GPU: A Guide to Building and Scaling Production-Ready CUDA Kernels](https://swe.quest/articles/from-zero-to-gpu-a-guide-to-building-and-scaling-production-ready-cuda-kernels-c01f08e3adeb6b0b.md): Hugging Face · 2025-08-18 · Medium · 16 min read · Hardware, Python, C & C++, Build systems, Machine learning
  Hugging Face's kernel-builder lets developers write a custom CUDA kernel, register it as a native PyTorch operator, build it reproducibly with Nix for every supported PyTorch/CUDA combination, and publish it to the Hub for loading via \`get\_kernel\`.
- [Custom Kernels for All from Codex and Claude](https://swe.quest/articles/custom-kernels-for-all-from-codex-and-claude-9d652cbc33fa9001.md): Hugging Face · 2026-02-13 · Medium · 9 min read · AI for coding, Performance engineering, Inference & serving, Hardware, Python
  Hugging Face packaged CUDA kernel expertise (GPU architecture guides for H100/A100/T4, diffusers and transformers integration patterns, vectorized kernel templates, benchmark scripts) into an agent skill that lets Claude and Codex generate complete kernel-builder projects with PyTorch bindings.
- [Learn the Hugging Face Kernel Hub in 5 Minutes](https://swe.quest/articles/learn-the-hugging-face-kernel-hub-in-5-minutes-049114b1e85677a7.md): Hugging Face · 2025-06-12 · Medium · 13 min read · Inference & serving, Performance engineering, Python, Hardware
  Hugging Face's Kernel Hub and \`kernels\` library let PyTorch code download pre-compiled, optimized GPU kernels such as FlashAttention, activations, RMSNorm and quantization kernels with a single \`get\_kernel\` call.
- [🤗 Kernels: Major Updates](https://swe.quest/articles/kernels-major-updates-0414619a175c2f31.md): Hugging Face · 2026-07-06 · Medium · 8 min read · Supply chain security, Inference & serving, Build systems, AI agents
  Hugging Face's Kernels project, which packages and distributes custom GPU kernels via the Hub, now has a dedicated "kernel" repository type and several security layers on top of Nix-based reproducible builds.
- [Creating custom kernels for the AMD MI300](https://swe.quest/articles/creating-custom-kernels-for-the-amd-mi300-c9305116e3ce561c.md): Hugging Face · 2025-07-09 · Hard · 31 min read · Inference & serving, Hardware, Performance engineering, LLMs
  Hugging Face and AMD wrote three open-source fused kernels for serving Llama 3.1 405B in FP8 with vLLM on an 8x MI300X node: residual add + RMS norm + FP8 quantization, SwiGLU + FP8 conversion, and a skinny GEMM for decode-sized batches.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
