HiP Attention: Sparse Sub-Quadratic Attention with Hierarchical Attention Pruning
<|reference_start|>HiP Attention: Sparse Sub-Quadratic Attention with Hierarchical Attention Pruning: In modern large language models (LLMs), increasing sequence lengths is a crucial challenge for enhancing their comprehension and coherence in handling complex tasks such as multi-modal question answering. However, handling long context sequences with LLMs is prohibitively costly due to the conventional attention mechanism's quadratic time and space complexity, and the context window size is limited by the GPU memory. Although recent works have proposed linear and sparse attention mechanisms to address this issue, their real-world applicability is often limited by the need to re-train pre-trained models. In response, we propose a novel approach, Hierarchically Pruned Attention (HiP), which simultaneously reduces the training and inference time complexity from $O(T^2)$ to $O(T \log T)$ and the space complexity from $O(T^2)$ to $O(T)$. To this end, we devise a dynamic sparse attention mechanism that generates an attention mask through a novel tree-search-like algorithm for a given query on the fly. HiP is training-free as it only utilizes the pre-trained attention scores to spot the positions of the top-$k$ most significant elements for each query. Moreover, it ensures that no token is overlooked, unlike the sliding window-based sub-quadratic attention methods, such as StreamingLLM. Extensive experiments on diverse real-world benchmarks demonstrate that HiP significantly reduces prompt (i.e., prefill) and decoding latency and memory usage while maintaining high generation performance with little or no degradation. As HiP allows pretrained LLMs to scale to millions of tokens on commodity GPUs with no additional engineering due to its easy plug-and-play deployment, we believe that our work will have a large practical impact, opening up the possibility to many long-context LLM applications previously infeasible.<|reference_end|>
@article{lee2024a,
    title={A Training-free Sub-quadratic Cost Transformer Model Serving Framework
  With Hierarchically Pruned Attention},
    author={Heejun Lee, Geon Park, Youngwan Lee, Jaduk Suh, Jina Kim, Wonyoung
  Jeong, Bumsik Kim, Hyemin Lee, Myeongjae Jeon, Sung Ju Hwang},
    journal={arXiv preprint arXiv:2406.09827},
    year={2024},
    archivePrefix={arXiv},
    eprint={2406.09827},
    primaryClass={cs.CL cs.CV cs.DC cs.LG}
}