Deja Vu: Kontextuelle Sparsamkeit für effiziente LLMs zur Inferenzzeit
Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Time
October 26, 2023
Autoren: Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, Beidi Chen
cs.AI
Zusammenfassung
Große Sprachmodelle (LLMs) mit Hunderten von Milliarden Parametern haben eine neue Welle spannender KI-Anwendungen ausgelöst. Allerdings sind sie zum Zeitpunkt der Inferenz rechenintensiv. Sparsity ist ein natürlicher Ansatz, um diese Kosten zu reduzieren, aber bestehende Methoden erfordern entweder kostspieliges Retraining, müssen auf die Fähigkeit des LLMs zum In-Context-Learning verzichten oder führen zu keiner Beschleunigung der Echtzeit auf moderner Hardware. Wir stellen die Hypothese auf, dass kontextuelle Sparsity, bei der es sich um kleine, eingabeabhängige Mengen von Attention-Heads und MLP-Parametern handelt, die für eine gegebene Eingabe annähernd dieselbe Ausgabe wie das dichte Modell liefern, diese Probleme lösen kann. Wir zeigen, dass kontextuelle Sparsity existiert, dass sie genau vorhergesagt werden kann und dass wir sie nutzen können, um die LLM-Inferenz in Echtzeit zu beschleunigen, ohne die Qualität oder die Fähigkeit zum In-Context-Learning des LLMs zu beeinträchtigen. Basierend auf diesen Erkenntnissen schlagen wir DejaVu vor, ein System, das einen kostengünstigen Algorithmus verwendet, um kontextuelle Sparsity on-the-fly für die Eingaben jeder Schicht vorherzusagen, sowie eine asynchrone und hardwarebewusste Implementierung, die die LLM-Inferenz beschleunigt. Wir validieren, dass DejaVu die Inferenzlatenz von OPT-175B im Vergleich zum state-of-the-art FasterTransformer um mehr als das 2-fache und im Vergleich zur weit verbreiteten Hugging-Face-Implementierung um mehr als das 6-fache reduzieren kann, ohne die Modellqualität zu beeinträchtigen. Der Code ist verfügbar unter 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.