ChatPaper.aiChatPaper

MInference 1.0: Versnelling van voorafvullen voor lange-context LLM's via dynamische sparse aandacht

MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention

July 2, 2024
Auteurs: Huiqiang Jiang, Yucheng Li, Chengruidong Zhang, Qianhui Wu, Xufang Luo, Surin Ahn, Zhenhua Han, Amir H. Abdi, Dongsheng Li, Chin-Yew Lin, Yuqing Yang, Lili Qiu
cs.AI

Samenvatting

De computationele uitdagingen van inferentie met Large Language Models (LLM's) blijven een aanzienlijke belemmering voor hun brede inzet, vooral omdat de lengte van prompts blijft toenemen. Door de kwadratische complexiteit van de aandachtberekening duurt het 30 minuten voor een 8B LLM om een prompt van 1M tokens te verwerken (d.w.z. de pre-filling fase) op een enkele A100 GPU. Bestaande methoden om pre-filling te versnellen slagen er vaak niet in om aanvaardbare nauwkeurigheid of efficiëntie te behouden wanneer ze worden toegepast op LLM's met lange contexten. Om deze kloof te overbruggen, introduceren we MInference (Milliontokens Inference), een sparse berekeningsmethode die is ontworpen om pre-filling van lange sequentieverwerking te versnellen. Specifiek identificeren we drie unieke patronen in aandachtmatrices met lange contexten—het A-vormige, Verticale-Slash en Blok-Sparse patroon—die kunnen worden benut voor efficiënte sparse berekeningen op GPU's. We bepalen het optimale patroon voor elke aandachtskop offline en bouwen dynamisch sparse indices op basis van het toegewezen patroon tijdens de inferentie. Met het patroon en de sparse indices voeren we efficiënte sparse aandachtberekeningen uit via onze geoptimaliseerde GPU-kernels om de latentie in de pre-filling fase van LLM's met lange contexten aanzienlijk te verminderen. Onze voorgestelde techniek kan direct worden toegepast op bestaande LLM's zonder wijzigingen aan de pre-trainingsopzet of aanvullende fine-tuning. Door evaluatie op een breed scala aan downstream taken, waaronder InfiniteBench, RULER, PG-19 en Needle In A Haystack, en modellen zoals LLaMA-3-1M, GLM4-1M, Yi-200K, Phi-3-128K en Qwen2-128K, tonen we aan dat MInference de inferentielatentie voor pre-filling op een A100 effectief met tot wel 10x vermindert, terwijl de nauwkeurigheid behouden blijft. Onze code is beschikbaar op https://aka.ms/MInference.
English
The computational challenges of Large Language Model (LLM) inference remain a significant barrier to their widespread deployment, especially as prompt lengths continue to increase. Due to the quadratic complexity of the attention computation, it takes 30 minutes for an 8B LLM to process a prompt of 1M tokens (i.e., the pre-filling stage) on a single A100 GPU. Existing methods for speeding up prefilling often fail to maintain acceptable accuracy or efficiency when applied to long-context LLMs. To address this gap, we introduce MInference (Milliontokens Inference), a sparse calculation method designed to accelerate pre-filling of long-sequence processing. Specifically, we identify three unique patterns in long-context attention matrices-the A-shape, Vertical-Slash, and Block-Sparsethat can be leveraged for efficient sparse computation on GPUs. We determine the optimal pattern for each attention head offline and dynamically build sparse indices based on the assigned pattern during inference. With the pattern and sparse indices, we perform efficient sparse attention calculations via our optimized GPU kernels to significantly reduce the latency in the pre-filling stage of long-context LLMs. Our proposed technique can be directly applied to existing LLMs without any modifications to the pre-training setup or additional fine-tuning. By evaluating on a wide range of downstream tasks, including InfiniteBench, RULER, PG-19, and Needle In A Haystack, and models including LLaMA-3-1M, GLM4-1M, Yi-200K, Phi-3-128K, and Qwen2-128K, we demonstrate that MInference effectively reduces inference latency by up to 10x for pre-filling on an A100, while maintaining accuracy. Our code is available at https://aka.ms/MInference.
PDF274November 28, 2024