Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

Liger-Kernel

> AI 编程
Open source

Efficient Triton Kernels for LLM Training

6.5K stars0 likes1 views
WebsiteGitHub

About

Efficient Triton Kernels for LLM Training

Liger Kernel: Efficient Triton Kernels for LLM Training

Stable Nightly Discord
        </a>
    </td>
    <td style="padding: 10px;">
        <a href="https://pypi.org/project/liger-kernel">
            
        </a>
    </td>
    <td style="padding: 10px;">
        <a href="https://pepy.tech/project/liger-kernel-nightly">
            
        </a>
    </td>
    <td style="padding: 10px;">
        <a href="https://pypi.org/project/liger-kernel-nightly">
            
        </a>
    </td>
    <td style="padding: 10px;">
        <a href="https://discord.gg/X4MaxPgA">
            
        </a>
    </td>
</tr>

Installation | Getting Started | Examples | High-level APIs | Low-level APIs | Cite our work

Latest News
  • [2025/12/19] We announced a liger kernel discord channel at https://discord.gg/X4MaxPgA; We will be hosting Liger Kernel x Triton China Meetup in mid of January 2026
  • [2025/03/06] We release a joint blog post on TorchTune × Liger - Peak Performance, Minimized Memory: Optimizing torchtune’s performance with torch.compile & Liger Kernel
  • [2024/12/11] We release v0.5.0: 80% more memory efficient post training losses (DPO, ORPO, CPO, etc)!
  • [2024/12/5] We release LinkedIn Engineering Blog - Liger-Kernel: Empowering an open source ecosystem of Triton Kernels for Efficient LLM Training
  • [2024/11/6] We release v0.4.0: Full AMD support, Tech Report, Modal CI, Llama-3.2-Vision!
  • [2024/10/21] We have released the tech report of Liger Kernel on Arxiv: https://arxiv.org/pdf/2410.10989
  • [2024/9/6] We release v0.2.1 (X post). 2500+ Stars, 10+ New Contributors, 50+ PRs, 50k Downloads in two weeks!
  • [2024/8/31] CUDA MODE talk, Liger-Kernel: Real-world Triton kernel for LLM Training, Slides
  • [2024/8/23] Official release: check out our X post

Liger Kernel is a collection of Triton kernels designed specifically for LLM training. It can effectively increase multi-GPU training throughput by 20% and reduces memory usage by 60%. We have implemented Hugging Face Compatible RMSNorm, RoPE, SwiGLU, CrossEntropy, FusedLinearCrossEntropy, and more to come. The kernel works out of the box with Flash Attention, PyTorch FSDP, and Microsoft DeepSpeed. We welcome contributions from the community to gather the best kernels for LLM training.

We've also added optimized Post-Training kernels that deliver up to 80% memory savings for alignment and distillation tasks. We support losses like DPO, CPO, ORPO, SimPO, KTO, JSD, and many more. Check out how we optimize the memory.

You can view the documentation site for additional installation, usage examples, and API references:https://linkedin.github.io/Liger-Kernel/

You can view the Liger Kernel Technical Report: https://openreview.net/forum?id=36SjAIT42G

Supercharge Your Model with Liger Kernel

With one line of code, Liger Kernel can increase throughput by more than 20% and reduce memory usage by 60%, thereby enabling longer context lengths, larger batch sizes, and massive vocabularies.

Speed Up Memory Reduction

Note:

  • Benchmark conditions: LLaMA 3-8B, Batch Size = 8, Data Type = bf16, Optimizer = AdamW, Gradient Checkpointing = True, Distributed Strategy = FSDP1 on 8 A100s.
  • Hugging Face models start to OOM at a 4K context length, whereas Hugging Face + Liger Kernel scales up to 16K.

Optimize Post Training with Liger Kernel

We provide optimized post training kernels like DPO, ORPO, SimPO, and more which can reduce memory usage by up to 80%. You can easily use them as python modules.

python
from liger_kernel.chunked_loss import LigerFusedLinearORPOLoss
orpo_loss = LigerFusedLinearORPOLoss()
y = orpo_loss(lm_head.weight, x, target)

Examples

Use Case Description
Hugging Face Trainer Train LLaMA 3-8B ~20% faster with over 40% memory reduction on Alpaca dataset using 4 A100s with FSDP
Lightning Trainer Increase 15% throughput and reduce memory usage by 40% with LLaMA3-8B on MMLU dataset using 8 A100s with DeepSpeed ZeRO3
Medusa Multi-head LLM (Retraining Phase) Reduce memory usage by 80% with 5 LM heads and improve throughput by 40% using 8 A100s with FSDP
Vision-Language Model SFT Finetune Qwen2-VL on image-text data using 4 A100s with FSDP
Liger ORPO Trainer Align Llama 3.2 using Liger ORPO Trainer with FSDP with 50% memory reduction

Key Features

  • Ease of use: Simply patch your Hugging Face model with one line of code, or compose your own model using our Liger Kernel modules.
  • Time and memory efficient: In the same spirit as Flash-Attn, but for layers like RMSNorm, RoPE, SwiGLU, and CrossEntropy! Increases multi-GPU training throughput by 20% and reduces memory usage by 60% with kernel fusion, in-place replacement, and chunking techniques.
  • Exact: Computation is exact—no approximations! Both forward and backward passes are implemented with rigorous unit tests and undergo convergence testing against training runs without Liger Kernel to ensure accuracy.
  • Lightweight: Liger Kernel has minimal dependencies, requiring only Torch and Triton—no extra libraries needed! Say goodbye to dependency headaches!
  • Multi-GPU supported: Compatible with multi-GPU setups (PyTorch FSDP, DeepSpeed, DDP, etc.).
  • Trainer Framework Integration: Axolotl, LLaMa-Factory, SFTTrainer, Hugging Face Trainer, SWIFT, oumi

Installation

Dependencies

CUDA

  • torch >= 2.1.2
  • triton >= 2.3.0

ROCm

  • torch >= 2.5.0 Install according to the instruction in Pytorch official webpage.
  • triton >= 3.0.0 Install from pypi. (e.g. pip install triton==3.0.0)
bash
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.2

Ascend NPU

  • torch == 2.9.0
  • torch_npu == 2.9.0
  • triton-ascend == 3.2.2 Install from the Ascend PyPI mirror (not on default PyPI).
  • CANN == 9.1.0
bash
pip install -e ".[dev]" --extra-index-url https://triton-ascend.osinfra.cn/pypi/simple

Optional Dependencies

  • transformers >= 4.x: Required if you plan to use the transformers models patching APIs. The specific model you are working will dictate the minimum version of transformers.
  • cuda-tile: Required when enabling the optional cuTile backend on CUDA. Use this when your environment already provides CUDA Toolkit 13.1 or newer, or an existing tileiras compiler installation.
  • cuda-tile[tileiras]: Required when enabling the optional cuTile backend with the tileiras compiler installed directly into your Python environment.
  • nvidia-cutlass-dsl >= 4.6.0: Required when enabling the optional CuTe DSL backend on CUDA (the CUDA-only Python DSL shipped with NVIDIA CUTLASS, import cutlass.cute). Targets Hopper (SM90) and Blackwell (SM100/SM110).
  • liger-cute-kernels: Native CUTLASS + NVSHMEM kernels for Hopper and Blackwell, installed at the exact matching Liger version by the lck extra.

Note: Our kernels inherit the full spectrum of hardware compatibility offered by Triton.

To install the stable version:

bash
$ pip install liger-kernel

To also install the matching native Liger communication kernels:

bash
$ pip install "liger-kernel[lck]"

To install the nightly version:

bash
$ pip install liger-kernel-nightly

To install from source:

…

Enable cuTile Backend

cuTile is an optional CUDA-only DSL implementation. After installing the cutile or cutile-tileiras extra, enable it explicitly:

bash
LIGER_KERNEL_IMPL=cutile python your_script.py

LIGER_KERNEL_IMPL selects an opt-in implementation registered with Liger (currently cutile and cutedsl). Selecting one on an unsupported device, or without the required dependencies installed, raises an error.

Enable CuTe DSL Backend

CuTe DSL is the optional, CUDA-only Python DSL shipped with NVIDIA CUTLASS (import cutlass.cute), targeting Hopper (SM90) and Blackwell (SM100/SM110). After installing the cutedsl extra, enable it explicitly:

bash
pip install "liger-kernel[cutedsl]"
LIGER_KERNEL_IMPL=cutedsl python your_script.py

It currently provides genuine cutlass.cute implementations of:

  • RMSNorm
  • RoPE
  • SwiGLU
  • Cross entropy
  • Fused linear cross entropy (with an SM90-specialized variant)
  • Fused scaled cross entropy (SM90)

Ops without a CuTe DSL kernel transparently fall back to the default Triton kernel.

The cutedsl extra also pulls in apache-tvm-ffi, which lets compiled kernels take PyTorch tensors directly rather than marshalling each one per call. It is optional — every kernel falls back to the marshalling launch without it — but short kernels are dominated by that per-call cost, so installing it is strongly recommended.

Fused Scaled Cross Entropy

LigerFusedLinearScaledCrossEntropyFunction is an additional per-token operator, not a replacement for the reduction-oriented Triton LigerFusedLinearCrossEntropyFunction. It takes input[M, H], weight[V, H], and target[M], applies logits / temperature, and returns FP32 negative log-likelihood [M] plus optional differentiable vocabulary entropy [M] in the input dtype. Reductions remain in PyTorch, and rows whose target equals ignore_index contribute zero outputs and gradients.

python
from liger_kernel.ops import LigerFusedLinearScaledCrossEntropyFunction

nll, entropy = Lige

Issues· 231 open

View all issuesOpen on GitHub
  • #156

    [fun] mamba.triton

    funUpdated Sep 23, 2026
  • #857

    Multi-token attention

    Updated Sep 23, 2026
  • #1483

    Blocked Triton RMSNorm forward overflows int32 row offsets

    Updated Sep 23, 2026
  • #969

    [NPU Roadmap, Updated to 2026-Q2] NPU support for Liger-Kernel

    Updated Sep 22, 2026
  • #1481

    [NPU] Track reverting Ascend Atlas 950 workarounds after triton-ascend upstream fixes (#1464)

    Updated Sep 22, 2026
  • #1453

    JSD kernel returns NaN for interior beta when a vocabulary entry underflows under both distributions

    Updated Sep 10, 2026
  • #1432

    fused_linear_jsd rounds logits to the input dtype before the documented FP32 cast, costing up to 23% gradient error in bf16

    Updated Sep 1, 2026
  • #623

    [transformers] support DeepSeek V3

    enhancementgood first issuehelp wantedhuggingfacefeatureUpdated Aug 30, 2026
  • #1082

    LigerFusedLinearGRPOLoss produces ~100x larger grad_norm than TRL's non-Liger-Kernel path due to missing vLLM IS correction and other differences

    Updated Aug 30, 2026
  • #1393

    [RFC] Migrate Nvidia CI from Modal to HF Jobs

    Updated Aug 17, 2026

> Tags

Pythonfinetuninggemma2hacktoberfestllama

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 24, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.