arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.09297cs.LG
收藏

MLKV:用于内存高效Transformer解码的多层键值头

MLKV: Multi-Layer Key-Value Heads for Memory Efficient Transformer Decoding

Institut Teknologi Bandung(万隆理工学院);MBZUAI(穆罕默德·本·扎耶德人工智能大学)

Zayd Muhammad Kawakibi Zuhri, Muhammad Farid Adilazuarda, Ayu Purwarianti, Alham Fikri Aji

AI总结:

针对Transformer自回归推理中KV缓存导致的内存瓶颈,提出跨层共享KV的MLKV方法,在性能损失极小的前提下将内存占用较MQA降低6倍,助力模型高效部署。

摘要:

Transformer的自回归推理极大地受益于键值(KV)缓存,但随着模型规模、批大小和序列长度的大规模增长,可能导致严重的内存瓶颈。我们引入了多层键值(MLKV)共享,这是一种将KV共享扩展到Transformer各层的新方法,能够减少超出多查询注意力(MQA)和分组查询注意力(GQA)所能达到的内存使用量。在多个NLP基准和推理指标上,使用经过uptrained的Pythia-160M变体进行评估表明,MLKV在性能损失极小的情况下显著降低了内存使用,与MQA相比将KV缓存大小最多减少至6倍。这些结果突显了MLKV在大规模高效部署Transformer模型方面的潜力。我们在https://github.com/zaydzuhri/pythia-mlkv提供了代码。

英文摘要:

Auto-regressive inference of transformers benefit greatly from Key-Value (KV) caching, but can lead to major memory bottlenecks as model size, batch size, and sequence length grow at scale. We introduce Multi-Layer Key-Value (MLKV) sharing, a novel approach extending KV sharing across transformer layers to reduce memory usage beyond what was possible with Multi-Query Attention (MQA) and Grouped-Query Attention (GQA). Evaluations on various NLP benchmarks and inference metrics using uptrained Pythia-160M variants demonstrate that MLKV significantly reduces memory usage with minimal performance loss, reducing KV cache size down to a factor of 6x compared to MQA. These results highlight MLKV's potential for efficient deployment of transformer models at scale. We provide code at https://github.com/zaydzuhri/pythia-mlkv

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

↑