A Training-free Sub-quadratic Cost Transformer Model Serving Framework With Hierarchically Pruned Attention

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Lee, Heejun, Park, Geon, Lee, Youngwan, Suh, Jaduk, Kim, Jina, Jeong, Wonyoung, Kim, Bumsik, Lee, Hyemin, Jeon, Myeongjae, Hwang, Sung Ju
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866929684300693504
author Lee, Heejun
Park, Geon
Lee, Youngwan
Suh, Jaduk
Kim, Jina
Jeong, Wonyoung
Kim, Bumsik
Lee, Hyemin
Jeon, Myeongjae
Hwang, Sung Ju
author_facet Lee, Heejun
Park, Geon
Lee, Youngwan
Suh, Jaduk
Kim, Jina
Jeong, Wonyoung
Kim, Bumsik
Lee, Hyemin
Jeon, Myeongjae
Hwang, Sung Ju
contents In modern large language models (LLMs), increasing the context length is crucial for improving comprehension and coherence in long-context, multi-modal, and retrieval-augmented language generation. While many recent transformer models attempt to extend their context length over a million tokens, they remain impractical due to the quadratic time and space complexities. Although recent works on linear and sparse attention mechanisms can achieve this goal, their real-world applicability is often limited by the need to re-train from scratch and significantly worse performance. In response, we propose a novel approach, Hierarchically Pruned Attention (HiP), which reduces the time complexity of the attention mechanism to $O(T \log T)$ and the space complexity to $O(T)$, where $T$ is the sequence length. We notice a pattern in the attention scores of pretrained LLMs where tokens close together tend to have similar scores, which we call ``attention locality''. Based on this observation, we utilize a novel tree-search-like algorithm that estimates the top-$k$ key tokens for a given query on the fly, which is mathematically guaranteed to have better performance than random attention pruning. In addition to improving the time complexity of the attention mechanism, we further optimize GPU memory usage by implementing KV cache offloading, which stores only $O(\log T)$ tokens on the GPU while maintaining similar decoding throughput. Experiments on benchmarks show that HiP, with its training-free nature, significantly reduces both prefill and decoding latencies, as well as memory usage, while maintaining high-quality generation with minimal degradation. HiP enables pretrained LLMs to scale up to millions of tokens on commodity GPUs, potentially unlocking long-context LLM applications previously deemed infeasible.
format Preprint
id arxiv_https___arxiv_org_abs_2406_09827
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle A Training-free Sub-quadratic Cost Transformer Model Serving Framework With Hierarchically Pruned Attention
Lee, Heejun
Park, Geon
Lee, Youngwan
Suh, Jaduk
Kim, Jina
Jeong, Wonyoung
Kim, Bumsik
Lee, Hyemin
Jeon, Myeongjae
Hwang, Sung Ju
Computation and Language
Computer Vision and Pattern Recognition
Distributed, Parallel, and Cluster Computing
Machine Learning
In modern large language models (LLMs), increasing the context length is crucial for improving comprehension and coherence in long-context, multi-modal, and retrieval-augmented language generation. While many recent transformer models attempt to extend their context length over a million tokens, they remain impractical due to the quadratic time and space complexities. Although recent works on linear and sparse attention mechanisms can achieve this goal, their real-world applicability is often limited by the need to re-train from scratch and significantly worse performance. In response, we propose a novel approach, Hierarchically Pruned Attention (HiP), which reduces the time complexity of the attention mechanism to $O(T \log T)$ and the space complexity to $O(T)$, where $T$ is the sequence length. We notice a pattern in the attention scores of pretrained LLMs where tokens close together tend to have similar scores, which we call ``attention locality''. Based on this observation, we utilize a novel tree-search-like algorithm that estimates the top-$k$ key tokens for a given query on the fly, which is mathematically guaranteed to have better performance than random attention pruning. In addition to improving the time complexity of the attention mechanism, we further optimize GPU memory usage by implementing KV cache offloading, which stores only $O(\log T)$ tokens on the GPU while maintaining similar decoding throughput. Experiments on benchmarks show that HiP, with its training-free nature, significantly reduces both prefill and decoding latencies, as well as memory usage, while maintaining high-quality generation with minimal degradation. HiP enables pretrained LLMs to scale up to millions of tokens on commodity GPUs, potentially unlocking long-context LLM applications previously deemed infeasible.
title A Training-free Sub-quadratic Cost Transformer Model Serving Framework With Hierarchically Pruned Attention
topic Computation and Language
Computer Vision and Pattern Recognition
Distributed, Parallel, and Cluster Computing
Machine Learning
url https://arxiv.org/abs/2406.09827