arXiv:2501.01005cs.DCcs.AI2025-01中稿 · MLSys 2025, code a…被引 307

FlashInfer提升大模型推理效率,支持灵活部署与低延迟

FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving

论文配图:FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving
图 1 · 摘自论文原文
  • 采用分块稀疏和可组合格式优化内存访问,减少冗余
  • 通过即时编译实现注意力模板自定义,适配多种场景
  • 支持动态请求调度且兼容静态图,适合高并发推理服务

Transformer模型以注意力机制为核心,支撑大规模语言模型。随着模型规模扩大,高效的GPU注意力内核对实现高吞吐、低延迟推理至关重要。多样化的应用场景要求灵活且高性能的注意力解决方案。本文提出FlashInfer:一种面向大模型推理服务的可定制高效注意力引擎。FlashInfer通过分块稀疏格式和可组合格式应对键值缓存存储异构性,优化内存访问并减少冗余。其提供可定制注意力模板,支持通过即时编译(JIT)适应不同配置。此外,负载均衡调度算法能动态响应用户请求,同时保持与CUDAGraph的兼容性(需静态配置)。FlashInfer已集成至SGLang、vLLM和MLC-Engine等主流大模型推理框架。全面的内核级与端到端评估表明,相比现有先进方案,FlashInfer在多种推理场景中显著提升性能:相较于编译后端,在LLM推理基准测试中实现29%-69%的跨标记延迟降低;长上下文推理下延迟减少28%-30%;并行生成任务中提速13%-17%。

原文摘要 · Abstract (English)

Transformers, driven by attention mechanisms, form the foundation of large language models (LLMs). As these models scale up, efficient GPU attention kernels become essential for high-throughput and low-latency inference. Diverse LLM applications demand flexible and high-performance attention solutions. We present FlashInfer: a customizable and efficient attention engine for LLM serving. FlashInfer tackles KV-cache storage heterogeneity using block-sparse format and composable formats to optimize memory access and reduce redundancy. It also offers a customizable attention template, enabling adaptation to various settings through Just-In-Time (JIT) compilation. Additionally, FlashInfer's load-balanced scheduling algorithm adjusts to dynamism of user requests while maintaining compatibility with CUDAGraph which requires static configuration. FlashInfer have been integrated into leading LLM serving frameworks like SGLang, vLLM and MLC-Engine. Comprehensive kernel-level and end-to-end evaluations demonstrate FlashInfer's ability to significantly boost kernel performance across diverse inference scenarios: compared to state-of-the-art LLM serving solutions, FlashInfer achieve 29-69% inter-token-latency reduction compared to compiler backends for LLM serving benchmark, 28-30% latency reduction for long-context inference, and 13-17% speedup for LLM serving with parallel generation.

大模型推理注意力优化GPU加速

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。