---
title: "Creating custom kernels for the AMD MI300"
description: "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."
url: "https://swe.quest/articles/creating-custom-kernels-for-the-amd-mi300-c9305116e3ce561c"
canonical: "https://huggingface.co/blog/mi300kernels"
source: "Hugging Face"
published: "2025-07-09"
difficulty: "hard"
kind: "Case study"
reading_minutes: 31
tags: ["inference","hardware","performance","llms"]
---

# Creating custom kernels for the AMD MI300

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-07-09, 31 min read, Case study. Original: [https://huggingface.co/blog/mi300kernels](https://huggingface.co/blog/mi300kernels)

## Summary

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. The write-up walks through the MI300X hierarchy (threads, 64-thread warps, compute units, XCDs, L2 and infinity cache), then uses vLLM profiling to show that GEMMs and all-reduce communications dominate decode latency. RMS norm and SwiGLU still account for about 15% of latency, which made them worth fusing. The basic fused RMS norm kernel alone is about 10x faster than PyTorch, and memory-access optimizations push it further; the kernels and benchmarks are available in the hf-rocm-kernels repo.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- GPU programming model ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- CUDA/HIP kernels
- transformer inference ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- FP8 quantization ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))

## Keywords

AMD MI300X, vLLM, ROCm, Llama 3.1 405B, hf-rocm-kernels, RMS norm, SwiGLU, FP8

## Related posts

- [Hugging Face on AMD Instinct MI300 GPU](https://swe.quest/articles/hugging-face-on-amd-instinct-mi300-gpu-f116bf43c7c06916.md): Hugging Face · 2024-05-21 · Easy · 7 min read · Inference & serving, Hardware, LLMs, Performance engineering, Model training
  Hugging Face's transformers and text-generation-inference (TGI) now run on AMD Instinct MI300X GPUs with no code changes, backed by a Kubernetes-scheduled CI pipeline that runs tens of thousands of unit tests on MI250 and MI300 hardware.
- [AMD + 🤗: Large Language Models Out-of-the-Box Acceleration with AMD GPU](https://swe.quest/articles/amd-large-language-models-out-of-the-box-acceleration-with-amd-gpu-fa18508c54402fa1.md): Hugging Face · 2023-12-05 · Easy · 7 min read · Inference & serving, Hardware, LLMs, Performance engineering
  Hugging Face Transformers now runs all models and tasks on AMD Instinct GPUs with no code changes versus NVIDIA, backed by ROCm support for Flash Attention v2, vLLM Paged Attention, DeepSpeed, GPTQ via AutoGPTQ, ONNX Runtime's ROCMExecutionProvider, and Optimum-Benchmark.
- [RCCLX: Innovating GPU Communications on AMD Platforms](https://swe.quest/articles/rcclx-innovating-gpu-communications-on-amd-platforms-cbbc7a0f8ee29a3b.md): Meta Engineering · 2026-02-24 · Hard · 5 min read · Inference & serving, Hardware, Performance engineering, Open source, Distributed systems
  Meta is open-sourcing RCCLX, an enhanced fork of AMD's RCCL collective communication library integrated with the Torchcomms API, bringing its CTran transport (including the GPU-resident AllToAllvDynamic collective) to AMD GPUs.
- [Fine-tuning Llama 2 70B using PyTorch FSDP](https://swe.quest/articles/fine-tuning-llama-2-70b-using-pytorch-fsdp-0e8dde34b4ad3fd0.md): Hugging Face · 2023-09-13 · Hard · 10 min read · Model training, LLMs, Hardware, Python
  Full fine-tuning of Llama 2 70B across two nodes of 8×A100 80GB GPUs with PyTorch FSDP, Hugging Face Accelerate, Transformers and TRL, addressing three obstacles.
- [How to serve trillions of tokens for trillion-parameter coding agents](https://swe.quest/articles/how-to-serve-trillions-of-tokens-for-trillion-parameter-coding-agents-0508c7c515fa8a14.md): Modal · 2026-09-23 · Hard · 32 min read · Inference & serving, LLMs, Caching, Performance engineering, Hardware
  Modal describes how it serves Moonshot AI's trillion-parameter Kimi K2.6 model for coding-agent traffic at trillions of tokens.

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)
