LLMs Optimizing LLMs: Automated MegaKernel Generation for Inference Acceleration
Weiqiang Xiong, Shaohui Peng, Wenyi Li, Hao Lu, Qirui Zhou, Congying Ma, Ziming Ye, Zhenyu Yi, Yunji Chen, Qi Guo, Ling Li
NeurIPS page · OpenReview · Open on the map
Category: LLM Agents, Evals & Benchmarks › GPU Kernel Optimization and Benchmarking · Type: new method · Keywords: LLM-driven kernel generation, inference acceleration, MegaKernel fusion, CUDA code generation, GPU optimization
Summary
AutoMegaKernel is an LLM-driven framework that automatically generates fused kernels for inference acceleration, delivering speedups up to 5.04× over vLLM, 2.42× over SGLang, and 1.92× over MPK while supporting diverse models and GPUs.
Explained to a 5-year-old
Big computer programs need to think a lot before they can answer questions. They break their thinking into many tiny steps, and each step takes time to start. This new idea helps combine many tiny steps into one big step, so the program works faster. It uses a smart robot that learns how to make these big steps automatically. Now the big programs can answer questions quicker, like magic!
Explained to a 5-year-old, longer
Big computer programs, like the ones that power chatbots, have to think a lot before they can answer questions. They break their thinking into many tiny steps, and each step is like a small recipe that the computer follows. Because there are many tiny steps, the computer has to start each one separately, which takes extra time. A new idea helps by taking many of those tiny steps and combining them into one big step, so the computer does less starting up. This big step is called a MegaKernel, but you can think of it as a super-recipe that does a lot at once. Instead of people manually writing these super-recipes for each program, a smart robot learns how to write them automatically. The robot looks at the program’s needs and decides which steps can be merged safely. It then writes the code for the big step and checks that it works correctly. This way, the program runs faster and uses less energy. The robot also works for many different kinds of programs and different computer chips, making it useful for everyone. It helps small teams and big companies speed up their AI services without hiring many experts. In short, this robot makes big programs think faster by creating big, efficient steps for them to follow.
For a technical reader
The system uses a large language model to generate fusion instructions that combine many fine-grained kernels into a single MegaKernel, producing optimized CUDA code. It jointly reasons about fusion strategies and validates the generated code through hierarchical checks. This automation removes the need for manual engineering and works across diverse model types and GPU architectures. The result is a noticeable reduction in kernel launch overhead and memory traffic, leading to substantial speedups over existing inference engines and compilers.
Problem
Accelerating inference for large models is hindered by the overhead of many fine-grained kernels, leading to high latency and redundant memory accesses. Existing manual kernel-fusion approaches are limited to specific models and architectures, making them hard to scale.
Method
The approach uses an LLM to generate fusion instructions that decompose large fused kernels into executable CUDA code, performing joint reasoning of fusion strategies and code generation with hierarchical correctness verification.
Results
The approach achieves speedups of up to 5.04× over vLLM, 2.42× over SGLang, and 1.92× over MPK, and supports dense, MoE, and VLA models on Hopper, Ampere, and Ada GPUs.
Contributions
It introduces an LLM-driven automated kernel-fusion framework that decouples fusion from specific models and architectures and provides a hierarchical verification process for correctness.
Practical relevance
The framework enables faster inference for large models on commodity GPUs, reducing latency for latency-sensitive applications.
Research questions this paper is counted under
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