Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs
Fuente:
arXiv
Saved in:
| Main Authors: | , , , , , , , , , , , , |
|---|---|
| Format: | Preprint |
| Published: |
2024
|
| Subjects: | |
| Online Access: | |
| Tags: |
Add Tag
No Tags, Be the first to tag this record!
|
| _version_ | 1866929417940369408 |
|---|---|
| author | Athiwaratkun, Ben Gonugondla, Sujan Kumar Gouda, Sanjay Krishna Qian, Haifeng Ding, Hantian Sun, Qing Wang, Jun Guo, Jiacheng Chen, Liangfu Bhatia, Parminder Nallapati, Ramesh Sengupta, Sudipta Xiang, Bing |
| author_facet | Athiwaratkun, Ben Gonugondla, Sujan Kumar Gouda, Sanjay Krishna Qian, Haifeng Ding, Hantian Sun, Qing Wang, Jun Guo, Jiacheng Chen, Liangfu Bhatia, Parminder Nallapati, Ramesh Sengupta, Sudipta Xiang, Bing |
| contents | 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. |
| format | Preprint |
| id |
arxiv_https___arxiv_org_abs_2403_08845 |
| institution | arXiv |
| publishDate | 2024 |
| record_format | arxiv |
| spellingShingle | Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs Athiwaratkun, Ben Gonugondla, Sujan Kumar Gouda, Sanjay Krishna Qian, Haifeng Ding, Hantian Sun, Qing Wang, Jun Guo, Jiacheng Chen, Liangfu Bhatia, Parminder Nallapati, Ramesh Sengupta, Sudipta Xiang, Bing Machine Learning Artificial Intelligence 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. |
| title | Bifurcated Attention: Accelerating Massively Parallel Decoding with Shared Prefixes in LLMs |
| topic | Machine Learning Artificial Intelligence |
| url | https://arxiv.org/abs/2403.08845 |