ForgeMegakernel: A General Framework for Efficient Auto-Regressive Model Decode Megakernels
Leshan Li, Zhui Zhu, Xianglong Deng, Yaojian Chen, Qingfeng He, Yuxuan Li, Rong Zhao, Xu Han,
Key points
From the paper's conclusion- We evaluated ForgeMegakernel on 14 representative decoding operations across eight model families spanning 0.6B-13B parameters.
Abstract
Auto-regressive model decode is bandwidth-bound, since every weight and key/value-cache byte crosses high-bandwidth memory once per token. A megakernel is an ideal solution, but existing automatic megakernel generation approaches cannot achieve both generalization across models and correctness guarantees. We present ForgeMegakernel, which generates a per-model high-performance decode megakernel using coding agents. ForgeMegakernel pairs a universal knowledge base of ten progressive milestones with an independent mid-state test oracle. The milestones provide the megakernel's structural properties: a fine-grained instruction stream for each SM, dependency counters replacing the global synchronization, and a shared-memory buffer pool for workload balance across SMs and greater parallelism. The test oracle derives the mid-states of the megakernel and checks the performance, error and precision during the generation process, guaranteeing a correct and trustworthy forged megakernel. We evaluated ForgeMegakernel on 14 representative decoding operations across eight model families spanning 0.6B-13B parameters. The generated megakernels achieved 50.5-85.9% MBU and geometric mean speedups of 1.21x over SGLang 0.5.18 and 1.54x over a megakernel compiler under identical configurations. Inside SGLang, evaluated on GSM8K with ragged prompts, all 14 megakernels decoded faster than the SGLang engine at comparable answer accuracy.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- MaxKernel: Agentic Kernel Generation for TPUsarXiv · 2026
- ForgeKernel: Self-Evolving Kernels Catching and Surpassing Experts and AgentsarXiv · 2026
- High-Throughput Serving of Nemotron 3.5 Transcribe with Regime-Aware Megakernels and Kernel FusionarXiv · 2026
- God Does Not Play Dice: Enforcing Batch Invariance in Agentic Kernel GenerationarXiv · 2026
- One Megakernel is Not Enough: Predicting Where to Cut for Streaming InferencearXiv · 2026
- BitNest: Bit-Nested Speculative Decoding for Memory-Efficient LLM Inference AccelerationarXiv · 2026