디자뷰: 추론 시점에서 효율적인 대형 언어 모델을 위한 문맥적 희소성
Deja Vu: Contextual Sparsity for Efficient LLMs at Inference Time
October 26, 2023
저자: Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, Beidi Chen
cs.AI
초록
수백억 개의 파라미터를 가진 대형 언어 모델(LLM)은 새로운 흥미로운 AI 애플리케이션의 물결을 일으켰습니다. 그러나 이러한 모델들은 추론 시점에 계산 비용이 많이 듭니다. 희소성은 이러한 비용을 줄이기 위한 자연스러운 접근 방식이지만, 기존 방법들은 비용이 많이 드는 재훈련을 요구하거나, LLM의 문맥 학습 능력을 포기해야 하거나, 현대 하드웨어에서 실제 시간 속도 향상을 제공하지 못합니다. 우리는 문맥적 희소성, 즉 주어진 입력에 대해 밀집 모델과 거의 동일한 출력을 생성하는 작은 입력 의존적 어텐션 헤드 및 MLP 파라미터 집합이 이러한 문제를 해결할 수 있다고 가정합니다. 우리는 문맥적 희소성이 존재하며, 이를 정확하게 예측할 수 있고, 이를 활용하여 LLM의 품질이나 문맥 학습 능력을 저하시키지 않으면서 실제 시간에서 LLM 추론 속도를 높일 수 있음을 보여줍니다. 이러한 통찰을 바탕으로, 각 레이어에 대한 입력이 주어졌을 때 문맥적 희소성을 실시간으로 예측하는 저비용 알고리즘과 LLM 추론을 가속화하는 비동기적이고 하드웨어를 고려한 구현을 포함한 DejaVu 시스템을 제안합니다. 우리는 DejaVu가 최신 FasterTransformer와 비교하여 OPT-175B의 추론 지연 시간을 2배 이상, 널리 사용되는 Hugging Face 구현과 비교하여 6배 이상 줄일 수 있음을 검증했으며, 모델 품질을 저하시키지 않았습니다. 코드는 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.