Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 31 min read Case study hardMaster

Creating custom kernels for the AMD MI300

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.

Related posts

  • Hugging Face on AMD Instinct MI300 GPU

    Hugging Face easyNovice

    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. TGI optimizations for MI300 include Flash Attention v2, Paged Attention, GPTQ/AWQ kernels, fused kernels, and PyTorch's ROCm TunableOp. TunableOp tunes GEMMs during server warmup and gives an 8-10% decode latency gain on small inputs. On Llama 3 70B, MI300X on Azure delivers 2-3x faster time to first token and 2x faster decoding than MI250, and roughly 2x faster LoRA fine-tuning. Its 192 GB HBM3 also fits the full ~140 GB fp16 model on a single GPU.

  • AMD + 🤗: Large Language Models Out-of-the-Box Acceleration with AMD GPU

    Hugging Face easyNovice

    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. Text Generation Inference gains initial MI210/MI250 support through a ROCm Docker image, with GeMM kernel tuning to reach performance parity. Benchmarks show one MI250 (two 64 GB ROCm devices) delivering over 2.33x the decode throughput and half the prefill latency of an A100 at large batch sizes. Its 128 GB memory also fits Llama 70B workloads that run out of memory on two A100-80GBs.

  • RCCLX: Innovating GPU Communications on AMD Platforms

    Meta Engineering hardMaster

    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. Direct Data Access (DDA) speeds up intra-node AllReduce for tensor-parallel LLM inference. Its flat algorithm cuts latency to O(1) at the cost of O(n²) data exchange, and its tree variant uses direct access in reduce-scatter and all-gather phases, beating RCCL by 10-50% on decode and 10-30% on prefill on MI300X for roughly a 10% reduction in time-to-incremental-token. Low-precision collectives quantize FP32/BF16 to FP8 over a P2P mesh on Infinity Fabric while computing in FP32. For large single-node messages they deliver about 9-10% lower latency and 7% higher throughput end to end with a ~0.3% GSM8K delta, enabled via RCCL_LOW_PRECISION_ENABLE=1.

  • Fine-tuning Llama 2 70B using PyTorch FSDP

    Hugging Face hardMaster

    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. CPU RAM exhaustion (~2TB if every rank loads the model) is avoided by loading weights only on rank 0 via the meta device and broadcasting with sync_module_states. Slow, NCCL-timeout-prone checkpointing is fixed by saving intermediate checkpoints as SHARDED_STATE_DICT and switching to FULL_STATE_DICT only for the final save. Flash Attention V2 (kernel fusion, tiling, online softmax) plus gradient checkpointing cut VRAM and time; the run finished in ~13.5 hours, with a paged AdamW optimizer needed on a single node.

  • How to serve trillions of tokens for trillion-parameter coding agents

    Modal hardMaster

    Modal describes how it serves Moonshot AI's trillion-parameter Kimi K2.6 model for coding-agent traffic at trillions of tokens. In that workload, requests average about 100k input to 500 output tokens with heavy prefix overlap across session turns. Their approach was to optimize a single replica first, raising interactivity and then throughput, and to scale out afterward. The changes included NVFP4 quantization on B200/B300 GPUs, tensor parallelism within 8-GPU NVLink domains, DFlash speculative decoding, freeing and quantizing HBM intermediates, and extending the KV cache into CPU RAM with SGLang HiCache. Together they improved per-replica performance 2.8x per user and 5.6x across users, and the post argues that small 8-GPU replicas match larger NVL72 deployments on per-GPU throughput while being far easier to schedule.

The quest for software engineering knowledge.

Look:
Layout: