arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2605.11581cs.CL
收藏

Ada-MK: 通过基于DAG的自动搜索实现适应性MegaKernel优化以用于LLM推理

Ada-MK: Adaptive MegaKernel Optimization via Automated DAG-based Search for LLM Inference

Baidu Inc.(百度公司)

Wenxin Dong, Mingqing Hu, Guanghui Yu, Qiang Fu, Peng Xu, Hui Xu, Yue Xing, Xuewu Jiao, Shuanglong Li, Lin Liu

AI总结:

本文提出Ada-MK,通过基于DAG的自动搜索优化MegaKernel,减少共享内存峰值使用50%,消除运行时分支,提升LLM推理吞吐量和效率。

摘要:

当大型语言模型(LLMs)在商业在线广告系统中提供实时推理时,端到端延迟必须严格限制在毫秒范围内。然而,解码阶段生成的每个标记都会触发数千次内核启动,而内核启动开销本身可能占端到端推理时间的14.6%。MegaKernel通过将多个操作符融合为单个持久内核来消除启动开销和操作符间HBM往返。然而,现有MegaKernel实现面临在资源受限的GPU(如NVIDIA Ada)上可移植性和效率之间的根本矛盾:手动调优的解决方案紧密耦合于特定架构且缺乏可移植性,而自动编译的方法引入了运行时动态调度,其分支惩罚在关键延迟设置中不可接受。我们观察到,在固定的部署配置下,MegaKernel的最优执行路径是唯一确定的,且运行时动态决策可以完全提升到编译时。基于这一见解,我们提出Ada-MK:(1)结合K维分割的三维共享内存约束模型,将峰值共享内存使用量减少50%;(2)基于MLIR的细粒度DAG离线搜索,固化最优执行路径,完全消除运行时分支;(3)一种异构混合推理引擎,将MegaKernel作为插件嵌入TensorRT-LLM中,结合高吞吐量的Prefill与低延迟的Decode。在NVIDIA L20上,Ada-MK比vanilla TensorRT-LLM单批吞吐量提高了23.6%,比vLLM提高了50.2%,在所有测试场景中均取得正收益——这是MegaKernel在商业在线广告系统中的首次工业部署。

英文摘要:

When large language models (LLMs) serve real-time inference in commercial online advertising systems, end-to-end latency must be strictly bounded to the millisecond range. Yet every token generated during the decode phase triggers thousands of kernel launches, and kernel launch overhead alone can account for 14.6% of end-to-end inference time. MegaKernel eliminates launch overhead and inter-operator HBM round-trips by fusing multiple operators into a single persistent kernel. However, existing MegaKernel implementations face a fundamental tension between portability and efficiency on resource-constrained GPUs such as NVIDIA Ada: hand-tuned solutions are tightly coupled to specific architectures and lack portability, while auto-compiled approaches introduce runtime dynamic scheduling whose branch penalties are unacceptable in latency-critical settings. We observe that under a fixed deployment configuration, the optimal execution path of a MegaKernel is uniquely determined, and runtime dynamic decision-making can be entirely hoisted to compile time. Building on this insight, we propose Ada-MK: (1) a three-dimensional shared-memory constraint model combined with K-dimension splitting that reduces peak shared memory usage by 50%; (2) MLIR-based fine-grained DAG offline search that solidifies the optimal execution path, completely eliminating runtime branching; and (3) a heterogeneous hybrid inference engine that embeds MegaKernel as a plugin into TensorRT-LLM, combining high-throughput Prefill with low-latency Decode. On an NVIDIA L20, Ada-MK improves single-batch throughput by up to 23.6% over vanilla TensorRT-LLM and 50.2% over vLLM, achieving positive gains across all tested scenarios--the first industrial deployment of MegaKernel in a commercial online advertising system.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑