Deja Vu: Contextuele Sparsity voor Efficiënte LLMs tijdens Inferentie
Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Time
October 26, 2023
Auteurs: Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, Beidi Chen
cs.AI
Samenvatting
Grote taalmodelen (LLMs) met honderden miljarden parameters hebben een nieuwe golf van spannende AI-toepassingen op gang gebracht. Ze zijn echter rekenkundig kostbaar tijdens het uitvoeren van inferentie. Sparsity is een natuurlijke aanpak om deze kosten te verlagen, maar bestaande methoden vereisen ofwel kostbare hertraining, moeten afzien van het in-context leervermogen van LLMs, of leveren geen snelheidswinst in wall-clock time op moderne hardware. We stellen de hypothese op dat contextuele sparsity, waarbij kleine, invoerafhankelijke sets van aandachtskoppen en MLP-parameters ongeveer dezelfde uitvoer opleveren als het dichte model voor een gegeven invoer, deze problemen kan aanpakken. We tonen aan dat contextuele sparsity bestaat, dat deze nauwkeurig voorspeld kan worden, en dat we deze kunnen benutten om de inferentie van LLMs in wall-clock time te versnellen zonder in te leveren op de kwaliteit of het in-context leervermogen van LLMs. Op basis van deze inzichten stellen we DejaVu voor, een systeem dat een kostenefficiënt algoritme gebruikt om contextuele sparsity on-the-fly te voorspellen op basis van de invoer voor elke laag, samen met een asynchrone en hardwarebewuste implementatie die de inferentie van LLMs versnelt. We valideren dat DejaVu de inferentielatentie van OPT-175B met meer dan 2X kan verminderen in vergelijking met de state-of-the-art FasterTransformer, en met meer dan 6X in vergelijking met de veelgebruikte Hugging Face-implementatie, zonder in te leveren op modelkwaliteit. De code is beschikbaar op https://github.com/FMInference/DejaVu.
English
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.