Large Language Model (LLM) deployment is increasingly shifting to cost-efficient accelerators like Google's Tensor Processing Units (TPUs), prioritizing both performance and total cost of ownership (TCO). However, existing LLM inference kernels and serving systems remain largely GPU-centric, and there is no well-established approach for efficiently mapping LLM workloads onto TPU architectures--particularly under the dynamic and ragged execution patterns common in modern serving. In this paper, we present Ragged Paged Attention (RPA), a high-performance and flexible attention kernel for TPUs, implemented using Pallas and Mosaic. RPA addresses these challenges through three key techniques: (1) fine-grained tiling to enable efficient dynamic slicing over ragged memory, (2) a custom software pipeline that fuses KV cache updates with attention computation, and (3) a distribution-aware compilation strategy that generates specialized kernels for decode, prefill, and mixed workloads. Evaluated on Llama 3 8B on TPU7x, RPA achieves up to 86% memory bandwidth utilization (MBU) in decode and 73% model FLOPs utilization (MFU) in prefill. Integrated as the primary TPU backend in vLLM and SGLang, RPA provides a production-grade foundation for efficient TPU inference and offers practical insights into kernel design.


翻译:大语言模型的部署正日益转向Google张量处理单元等成本高效的加速器,同时兼顾性能与总拥有成本。然而,现有大语言模型推理内核与服务系统仍以GPU为主导,缺乏将大语言模型工作负载高效映射至TPU架构的成熟方案——尤其面对现代服务中常见的动态与非连续执行模式。本文提出非连续分页注意力机制(RPA),一种基于Pallas和Mosaic实现的高性能灵活注意力内核。RPA通过三项关键技术解决上述挑战:(1)细粒度分块技术,实现对非连续存储的高效动态切片;(2)融合KV缓存更新与注意力计算的自定义软件流水线;(3)面向解码、预填充及混合工作负载生成专用内核的分布感知编译策略。在TPU7x上针对Llama 3 8B模型的评估显示,RPA在解码阶段达到86%的内存带宽利用率,预填充阶段达到73%的模型算力利用率。作为vLLM和SGLang系统中TPU后端的主要实现,RPA为高效TPU推理提供了生产级基础,并为内核设计提供了实践洞见。

0
下载
关闭预览

相关内容

推荐系统与大语言模型技术融合:EMNLP/NeurIPS相关论文导览
大模型的模型压缩与有效推理综述
专知会员服务
43+阅读 · 2024年7月8日
大型语言模型的模型压缩与高效推理:综述
专知会员服务
94+阅读 · 2024年2月17日
RecInterpreter:架起大语言模型与传统推荐模型的桥梁
专知会员服务
54+阅读 · 2023年11月9日
通过集成 XNNPACK 实现推理速度飞跃
TensorFlow
26+阅读 · 2020年7月30日
深度学习的下一步:Transformer和注意力机制
云头条
56+阅读 · 2019年9月14日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
7+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
8+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
11+阅读 · 2012年12月31日
Top
微信扫码咨询专知VIP会员