Skip to main content
QUICK REVIEW

[Paper Review] Liger Kernel: Efficient Triton Kernels for LLM Training

Byron, Yun Dai|arXiv (Cornell University)|Oct 14, 2024
Image Processing and 3D ReconstructionComputer Science6 citations
TL;DR

Liger-Kernel is an open-source library of Triton kernels for LLM training that uses kernel fusion and input chunking to boost throughput and reduce GPU memory usage compared with HuggingFace implementations. It offers modular APIs, easy integration with frameworks, and benchmarks across multiple models.

ABSTRACT

Training Large Language Models (LLMs) efficiently at scale presents a formidable challenge, driven by their ever-increasing computational demands and the need for enhanced performance. In this work, we introduce Liger-Kernel, an open-sourced set of Triton kernels developed specifically for LLM training. With kernel optimization techniques like kernel operation fusing and input chunking, our kernels achieve on average a 20% increase in training throughput and a 60% reduction in GPU memory usage for popular LLMs compared to HuggingFace implementations. In addition, Liger-Kernel is designed with modularity, accessibility, and adaptability in mind, catering to both casual and expert users. Comprehensive benchmarks and integration tests are built in to ensure compatibility, performance, correctness, and convergence across diverse computing environments and model architectures. The source code is available under a permissive license at: github.com/linkedin/Liger-Kernel.

Motivation & Objective

  • Motivate the need for kernel-level optimizations to improve LLM training efficiency.
  • Introduce Liger-Kernel as a modular, easy-to-use Triton kernel library for LLMs.
  • Show how kernel fusion and input chunking reduce memory and increase throughput.
  • Demonstrate compatibility with popular frameworks and deployment environments.
  • Provide benchmarks and integration tests to ensure correctness and convergence.

Proposed method

  • Propose a library of Triton kernels for LLM training with an emphasis on fusion of common operations.
  • Describe kernel designs for RMSNorm, LayerNorm, RoPE, SwiGLU, GeGLU, CrossEntropy, and a fused Linear+CrossEntropy (FLCE) approach.
  • Explain the API design that supports AutoLigerKernelForCausalLM, model-specific patching APIs, and composition of custom kernels.
  • Present a chunked FLCE approach to reduce memory when computing logits for large vocabularies.
  • Detail testing best practices for correctness, performance, and convergence, including contiguity and large-dimension handling.
  • Summarize end-to-end benchmarking setup and integration with Hugging Face and other frameworks.
Figure 1 : Fused Linear Cross Entropy.
Figure 1 : Fused Linear Cross Entropy.

Experimental results

Research questions

  • RQ1Can Liger-Kernel kernels improve training throughput and reduce GPU memory vs. baseline HuggingFace implementations?
  • RQ2How do kernel fusion and input chunking affect memory usage and speed across common LLM operations?
  • RQ3Do integrations with PyTorch FSDP, DeepSpeed ZeRO, and ZeRO++ maintain convergence and correctness when using Liger kernels?
  • RQ4Is the API design of Liger-Kernel approachable for both novice and advanced users while remaining highly configurable?
  • RQ5What are the end-to-end performance gains for multiple LLMs (e.g., LLaMA, Qwen, Gemma, Mistral, Phi3) on standard benchmarks?

Key findings

  • Liger-Kernel achieves about 20% average training throughput gain and 60% GPU memory reduction vs. HuggingFace implementations.
  • CrossEntropy kernel with online softmax and in-place gradient replacement yields ~3x speedup and ~5x memory reduction at large vocab sizes.
  • RMSNorm and LayerNorm kernels fuse normalization with scaling and caching to reduce computation time by up to ~7x and ~30% respectively with modest memory impact.
  • RoPE kernel uses a flattened, repeated-block rotation matrix for efficiency, achieving ~8x speedup and ~3x memory savings at large hidden sizes.
  • GeGLU and SwiGLU kernels maintain speed parity with baselines while reducing peak memory by ~1.6x for long sequences.
  • End-to-end benchmarks show substantial improvements across models: LLaMA 3-8B throughput +42.8% and memory -54.8%; Qwen2 throughput +25.5% and memory -56.8%; Gemma throughput +11.9% and memory -51.8%; Mistral throughput +27% and memory -21%; Phi3 throughput +17% and memory -13%.
(a) CrossEntropy
(a) CrossEntropy

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.