Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Time

About

Large language models (LLMs) with hundreds of billions of parameters have sparked a new wave of exciting AI applications. However, they are computationally expensive at inference time. Sparsity is a natural approach to reduce this cost, but existing methods either require costly retraining, have to forgo LLM's in-context learning ability, or do not yield wall-clock time speedup on modern hardware. We hypothesize that contextual sparsity, which are small, input-dependent sets of attention heads and MLP parameters that yield approximately the same output as the dense model for a given input, can address these issues. We show that contextual sparsity exists, that it can be accurately predicted, and that we can exploit it to speed up LLM inference in wall-clock time without compromising LLM's quality or in-context learning ability. Based on these insights, we propose DejaVu, a system that uses a low-cost algorithm to predict contextual sparsity on the fly given inputs to each layer, along with an asynchronous and hardware-aware implementation that speeds up LLM inference. We validate that DejaVu can reduce the inference latency of OPT-175B by over 2X compared to the state-of-the-art FasterTransformer, and over 6X compared to the widely used Hugging Face implementation, without compromising model quality. The code is available at https://github.com/FMInference/DejaVu.

Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, Beidi Chen• 2023

Related benchmarks

TaskDatasetResultRank
Commonsense ReasoningHellaSwag
Accuracy26.68
1460
Commonsense ReasoningWinoGrande
Accuracy50.83
776
Language UnderstandingMMLU
Accuracy25.2
756
Question AnsweringOBQA
Accuracy29
276
Question AnsweringGPQA
Accuracy26.31
258
Medical Question AnsweringMedMCQA
Accuracy28.16
253
Question AnsweringARC-E
Accuracy25.71
242
Question AnsweringBoolQ
Accuracy44.25
240
Question AnsweringARC-C
Accuracy26.27
166
Natural language generationXsum
GFLOPs/token7.92
5
Showing 10 of 12 rows

Other info

Follow for update