Speeding up Log-Sum-Exp: Kernel Fusion at the Memory Wall, Integer Arithmetic at the Compute Wall
Lingyun Yao, Martin Andraud, Niki Loppi, Andrea Pilzer, Anji Liu, Guy Van den Broeck, Martin Trapp
NeurIPS page · OpenReview · Open on the map
Category: LLM Agents, Evals & Benchmarks › GPU Kernel Optimization and Benchmarking · Type: new method · Keywords: Log-Sum-Exp acceleration, GPU kernel fusion, integer arithmetic approximation, high-performance computing, numerical primitives
Areas: Model Architectures & Sequence Modeling › Language Model Architectures › Efficient Attention
Summary
The paper introduces FuseLSE and IntLSE, two drop-in kernels that accelerate Log-Sum-Exp computation on GPUs via a single-pass fused kernel using the GPU's Special Function Unit and on CPUs via approximated integer arithmetic, achieving up to 11× speedups over PyTorch for small workloads and 6× for larger ones, with 3-6× gains on CPUs.
Explained to a 5-year-old
Computers sometimes need to add up many tiny numbers safely. Doing this can be slow because they have to move lots of data around. The researchers made two new tricks: one uses a special fast part of the GPU, and another uses simple integer math for the CPU. These tricks make the old way much faster. Now computers can do the math quicker and use less energy.
Explained to a 5-year-old, longer
Computers often need to combine many very small numbers while keeping the result safe. This process is called log-sum-exp and is used in many machine learning programs. The current way to do it uses several separate steps, which makes it slow and uses a lot of memory. The researchers looked at how this works on two kinds of hardware: GPUs and CPUs. They discovered that GPUs have a special fast unit that can handle math quickly, while CPUs are better at simple integer calculations. They created two new kernels: one that fuses the steps into a single fast pass for GPUs, and another that replaces the floating-point math with integer approximations for CPUs. Both kernels can be used as drop-in replacements, meaning existing code can be updated without major changes. In tests, the new kernels were much faster than the old PyTorch implementation, cutting the time needed for small tasks by about ten to eleven times and for larger tasks by about six times. On CPUs, the integer-based kernel was three to six times faster than the GPU-oriented fused kernel. These improvements mean that machine learning models can run quicker, use less power, and scale better on a variety of hardware platforms.
For a technical reader
The paper addresses the performance bottleneck of the Log-Sum-Exp operation, which is widely used in stable log-domain computations. On GPUs, the existing implementation launches nine separate sub-kernels, causing high memory traffic and launch overhead. The authors propose FuseLSE, a single-pass fused kernel that leverages the GPU’s Special Function Unit for exp and log operations. On CPUs, where no SFU is available, they introduce IntLSE, which approximates the LSE computation using integer arithmetic to reduce computational cost. Benchmarks across various workload sizes and hardware platforms demonstrate speedups of roughly 10-11× for small workloads and 6× for larger workloads on GPUs, and 3-6× on CPUs compared to the fused GPU kernel. Both kernels are drop-in replacements, enabling straightforward integration into existing PyTorch-based pipelines.
Problem
Efficient computation of the log-sum-exp function on CPUs and GPUs is challenging because current implementations incur high memory bandwidth usage and expensive floating-point operations, creating performance bottlenecks for large-scale machine learning workloads.
Method
The approach provides a single-pass fused kernel that evaluates log-sum-exp using the GPU's special function unit and a CPU-oriented kernel that approximates the computation with integer arithmetic, both designed as direct replacements for existing implementations.
Results
The approach achieves roughly 10-11× speedups over PyTorch for small workloads and about 6× speedups for larger workloads on GPUs, while on CPUs it runs 3-6× faster than the fused GPU kernel.
Contributions
It offers two drop-in kernels that reduce memory traffic and computational cost for log-sum-exp on both GPUs and CPUs, delivering substantial speedups across a range of workload sizes and hardware platforms.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction