Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs

Ben Athiwaratkun, Sujan Kumar Gonugondla, Sanjay Krishna Gouda, Haifeng Qian, Hantian Ding +8 more
3/13/2024
cs.LGcs.AI

No confident code implementation found for this paper.

Abstract

This study introduces bifurcated attention, a method designed to enhance language model inference in shared-context batch decoding scenarios. Our approach addresses the challenge of redundant memory IO costs, a critical factor contributing to latency in high batch sizes and extended context lengths. Bifurcated attention achieves this by strategically dividing the attention mechanism during incremental decoding into two separate GEMM operations: one focusing on the KV cache from prefill, and another on the decoding process itself. While maintaining the computational load (FLOPs) of standard attention mechanisms, bifurcated attention ensures precise computation with significantly reduced memory IO. Our empirical results show over 2.1$\times$ speedup when sampling 16 output sequences and more than 6.2$\times$ speedup when sampling 32 sequences at context lengths exceeding 8k tokens on a 7B model that uses multi-head attention. The efficiency gains from bifurcated attention translate into lower latency, making it particularly suitable for real-time applications. For instance, it enables massively parallel answer generation without substantially increasing latency, thus enhancing performance when integrated with post-processing techniques such as re-ranking.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{athiwaratkun2024bifurcated,
  title  = {Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs},
  author = {Ben Athiwaratkun and Sujan Kumar Gonugondla and Sanjay Krishna Gouda and Haifeng Qian and Hantian Ding and Qing Sun and Jun Wang and Jiacheng Guo and Liangfu Chen and Parminder Bhatia and Ramesh Nallapati and Sudipta Sengupta and Bing Xiang},
  year   = {2024},
  eprint = {2403.08845},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2403.08845v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2403.08845.svg)](https://codeofpaper.com/paper/2403.08845)

Discussion