Liger Kernel is an open-source set of Triton kernels for LLM training. It fuses operations and chunks inputs, and its authors report an average 20% increase in training throughput and a 60% reduction in GPU memory against the Hugging Face implementations of popular models. That headline needs reading carefully. The gain is mainly a memory-movement win. It comes from no longer materialising large intermediate tensors (above all the cross-entropy logits). It is not a general speedup, and the number that decides your fine-tuning bill is your own before-and-after on your model, your sequence length and your hardware.
What Does Liger Kernel Do to the Cost of an LLM Fine-Tuning Run?
Fine-tuning cost on a fixed GPU budget comes down to three numbers: peak activation memory, the batch size or context length that fits, and step time. Liger Kernel works mostly on the first, and the second follows from it. In the paper’s LLaMA 3-8B results, a 54.8% memory reduction at batch size 64 came with a 42.8% throughput increase, and the authors say this lets teams train on smaller GPUs or with larger batches and longer sequences. In the PyTorch team’s torchtune experiments, Liger cut peak memory allocation by 47% at batch size 256, which allowed batch size 512 with torch.compile and Liger together.
The budget question, then, is not “how much faster is each step”. It is whether the memory you free removes a GPU from the job or buys a longer context at the same spend. Adoption is cheap: the PyTorch blog describes it as a single line of code. If the patch worked on one model and the reason it worked is not understood, the next model, sequence length or GPU can show no gain, and nobody will be able to say why.
Which Operations Does Liger Kernel Fuse, and Why Does That Cut Memory Rather than FLOPs?
Hugging Face’s documentation lists the fused layers as RMSNorm, RoPE, SwiGLU, CrossEntropy and FusedLinearCrossEntropy, each turned into a single Triton kernel, and notes compatibility with FlashAttention, FSDP and DeepSpeed. The paper also covers GeGLU and LayerNorm kernels.
In PyTorch eager mode every operation runs step by step, which adds dispatch and kernel-launch overhead, and every intermediate activation is materialised for the backward pass. Fusion combines several operations into one kernel, so intermediate results stay in registers instead of making a round trip through global memory. The Liger authors frame their design around the gap between large, slow high-bandwidth memory (HBM) and fast, small on-chip SRAM: while data crawls between the two, the cores sit idle. Fusion reduces how many times GPU memory is read and written.
The Cross-Entropy Logits Are Where Most of the Memory Goes
The PyTorch blog says the bulk of Liger’s improvement comes from Fused Linear Cross Entropy (FLCE). With large vocabularies the logit tensor dominates: for Gemma with a 256k vocabulary, batch size 8 and sequence length 4096, the logits alone come to 16.8 GB in bfloat16. The Apple team behind Cut Cross-Entropy (CCE) goes further, finding that the cross-entropy loss is responsible for up to 90% of the memory footprint of modern LLM training. FLCE flattens the hidden states to two dimensions, applies the projection head chunk by chunk, computes the partial loss and logit gradient with the Liger CE kernel, and accumulates the projection-head gradients. The full logits tensor never exists at once.
Per-Kernel Figures from the Liger Paper
The Liger paper (Hsu et al., 2024) reports these kernel-level micro-benchmarks. They are kernel-level figures at the stated shapes, separate from the paper’s end-to-end results:
| Kernel | What fusion avoids | Reported result |
|---|---|---|
| CrossEntropy | Separate logit and gradient tensors (online softmax, gradients written in place) | About 3× faster and about 5× less memory at vocabulary size 163,840 |
| SwiGLU / GeGLU | Storing activation outputs for backward (SiLU and GELU recomputed instead) | Speed parity with baseline, about 1.6× lower peak memory at sequence length 16,384 |
| RMSNorm | Repeated data transfers (normalisation and scaling fused, RMS cached) | About 7× faster, about 3× lower peak memory at hidden size 16,384 |
| LayerNorm | Recomputing the inverse RMS (cached instead) | About 30% less execution time, minimal memory overhead |
| RoPE | Growth in latency with hidden size (flattened rotation matrix) | About 8× faster, about 3× lower memory at hidden size 16,384 |
The SwiGLU row shows the trade. Its memory saving comes from doing some arithmetic twice, so fusion here buys memory with compute rather than saving FLOPs.
How Much Memory and Step-Time Improvement Should I Expect on My Own Model?
Expect a wide spread across models. The paper’s end-to-end results show this. Qwen2 at batch size 48 gained 25.5% throughput with a 56.8% memory reduction. Gemma at batch size 48 gained 11.9% throughput with a 51.8% reduction. Mistral at batch size 128 gained 27% throughput but only a 21% memory reduction, and Phi3 at batch size 128 gained 17% throughput. Embedded LLM’s ROCm study on AMD GPUs found memory reductions across all models, peaking at 59.8% for Qwen2 7B, with throughput gains between 10.3% and 26.6%.
The baseline matters too. The paper compares against Hugging Face’s implementations. In the CCE paper’s loss-layer benchmark, torch.compile cut memory by 43% and computation time by 33% against the baseline row.
Measuring the Before and After Honestly
Profile before you optimise, and let your own trace validate the kernel optimisation, not the best practice someone published for a different setup. A comparison only means something when the one variable is the kernel library.
- Fix everything except the patch: the same model, tokenizer, sequence length, batch size, precision and optimiser settings. The Liger authors ran their kernel benchmarks at real training dimensions, such as batch size 4 and hidden size 2048.
- Record peak allocated memory with PyTorch memory snapshots. These capture allocated CUDA memory and, optionally, the history of allocation events, which you can inspect in the viewer at pytorch.org/memory_viz. Allocations made outside PyTorch’s allocator, such as NCCL buffers, do not appear in the profiler, so compare against raw device figures (for example, from pynvml) on multi-GPU runs.
- Measure step time or tokens per second over many steps and repeated runs, leaving out the first steps, where Triton JIT-compiles each kernel on its first execution. In its Medusa benchmarks, the Liger paper reports standard errors from repeated runs too small to see on most plots.
- Check loss-curve parity against the unpatched run over enough steps to catch drift. While deploying their RoPE kernel in production training, the Liger authors saw significant loss divergence because a non-contiguous gradient tensor reached a kernel that works directly on physical memory.
- Then spend the freed memory: raise the batch size or context length and measure again, because that is where the cost saving actually happens.
Which Model Architectures and Sequence Lengths Are Covered, and What Happens When My Workload Falls Outside the Supported Kernel Set?
Coverage is per kernel. The fused set is the one listed above: the norms, RoPE, SwiGLU and GeGLU, and the cross-entropy losses. It also includes post-training losses such as DPO, CPO, ORPO, SimPO and JSD, which the project reports cut memory by about 80%. In our view, treat a model as unsupported until a memory snapshot shows the fused kernels actually running.
Sequence length and vocabulary size move the gain. The logit tensor grows with tokens per batch times vocabulary size, and that is the tensor FLCE avoids materialising. Liger sets its cross-entropy chunk size from the ratio of vocabulary size to hidden dimension: the lower that ratio, the larger the chunks and the better it uses the GPU. A model whose vocabulary is large relative to its hidden dimension therefore gets smaller chunks.
Do Triton-Authored Fused Kernels Help or Hurt Portability Across NVIDIA, AMD and Intel?
Triton-authored kernels carry source code across vendors, but not tuned performance. On source code the evidence is good. Embedded LLM ran Liger on AMD GPUs under ROCm through Triton after a small adjustment for AMD’s different warp size. Intel’s Triton backend compiles kernels through the same SIMT path AMD and NVIDIA use, with an extra SIMD path for dense operations. An IBM team built a paged-attention kernel in Triton that reaches state-of-the-art performance on both NVIDIA and AMD GPUs from the same source.
Performance is a different matter. The same IBM paper says Triton kernels still need hand optimisation for specific workloads and do not perform equally well across GPU platforms. Its generic kernel started at 19.7% of state of the art and reached 105.9% only after algorithmic work, autotuning and server integration. A separate autotuning study found that using a kernel configuration tuned for a different GPU costs at least 20% of performance and up to an order of magnitude. NVIDIA makes the same point about hand-written CUDA kernels: control comes with high maintenance cost and limited portability across GPU architectures.
So adopting Liger is a portability decision as well as a performance one. It belongs inside the GPU compute API choice, not beside it. Triton code runs on GPUs from more than one vendor. Whether the tuned fusion still pays there is something you measure again on that hardware, never something you assume.
How Does Liger Kernel Relate to the CUDA vs OpenCL vs SYCL Decision: An Alternative to a Compute API, or a Layer Above It?
Triton is a layer above the compute API, not an alternative to one. It is a Python-embedded kernel-authoring language that compiles through LLVM down to the vendor compute layer, today mostly NVIDIA targets, with other backends still maturing. On NVIDIA that lowering produces PTX, and other backends produce their own target representation. A team using Liger has therefore still chosen a compute stack underneath, namely whatever its Triton backend lowers to. For the authoring choice itself, see our Triton vs CUDA comparison.
Triton also has limits a lower layer does not. The CCE authors note that Triton control flow is specified at block level, and they expect a CUDA implementation could gain further from finer-grained control. A fused Triton kernel gets fusion with simpler, Python-like code than CUDA.
When Is Kernel Fusion the Wrong Lever for a Training Job?
Fusion is the wrong lever whenever activation materialisation is not what limits the job, and only a profile tells you that. Three cases are worth checking.
TechnoLynx’s GPU Performance Audit first finds out whether a training job is bound by activation materialisation, and only then recommends a kernel-fusion library.
Optimiser state. With Adam, 32-bit optimiser state takes 8 bytes per parameter (8 GB for a 1B-parameter model), and 8-bit block-wise quantisation brings that down to 2 GB. Dettmers et al. report optimiser states using 33% to 75% of the total memory footprint during training. If that is where your memory goes, an 8-bit optimiser or sharded state will do more than fused norms.
Data loading and interconnect. We have no measured source for these here, so treat this as judgement: if the GPUs wait on the input pipeline, or step time is dominated by gradient all-reduce over a slow fabric, shrinking activations changes nothing in that wait. A timeline trace showing idle gaps between steps, or communication kernels dominating, rules fusion out before you install anything.
Latency-sensitive loss computation. Liger’s chunking has a cost. In the CCE paper’s benchmark, Liger’s cross-entropy used 95% less memory than the baseline but more than doubled the wall-clock time for that computation. The authors attribute this to heavy chunking that leaves the kernel bound by launch overhead, not computation. Liger also computes loss and gradient together, so any transform on the loss, such as masking, has to live inside the kernel. If memory was never your constraint, that trade only costs you time. More fusion is not always better either: the IBM team found that merging its separate attention kernels to save launches dropped performance by at least 2×, with software pipelining producing no useful pipelines.
When a job is memory-bound in the loss layer but step time matters, it is worth asking whether a different algorithm beats a fused version of the current one. CCE computes the loss without materialising logits and reduced Gemma 2 (2B) loss memory from 24 GB to 1 MB. That is the general question of when algorithmic restructuring gives bigger GPU speedups than kernel tuning.
Deciding Whether the Triton Dependency Is Worth It
Settle two questions before committing. First, on your own trace, does the freed memory turn into fewer GPUs or a longer context, or does it just sit unused while step time stays the same? Second, does your hardware roadmap include a second vendor? If it does, the fused kernels’ tuned performance has to be measured again there, because a configuration tuned for one GPU can lose a fifth or more of its speed on another. Liger works for the layers it covers; whether it pays depends on whether your bottleneck sits in those layers, and only measurement shows that.