Skip to content
The Chat Archive
gpt-4o-2024-05-13· OpenAI WildChat-4.8M (AI2)

다음 영어를 한글로 자연스럽게 번역해주세요. 첨 QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs Abstract…

  1. User

    다음 영어를 한글로 자연스럽게 번역해주세요. 첨 QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs

    Abstract

    We introduce QuaRot, a new Quantization scheme based on Rotations, which is able to quantize LLMs end-to-end, including all weights, activations, and KV cache in 4 bits. QuaRot rotates LLMs in a way that removes outliers from the hidden state without changing the output, making quantization easier. This computational invariance is applied to the hidden state (residual) of the LLM, as well as to the activations of the feed-forward components, aspects of the attention mechanism and to the KV cache. The result is a quantized model where all matrix multiplications are performed in 4-bits, without any channels identified for retention in higher precision. Our quantized Llama 2-70B model has losses of at most 0.29 WikiText-2 perplexity and retains 99% of the zero-shot performance. Code is available at: https://github.com/spcl/QuaRot.

    1 Introduction

    Large language models (LLMs) have become increasingly important due to their countless applications. However, their inference requires a significant amount of computations, memory, and energy. LLM inference has two main phases: during the prefill phase, the prompt is processed and cached in each layer, and then in the decoding phase the output tokens are generated one-by-one. The prefill phase is usually compute-bound while the decoding phase is known to be memory-bound.

    Quantization is among the most important techniques to solve both memory and compute issues during LLM inference. Joint quantization aims to reduce the precision of parameters and KV cache (which results in lower memory usage) as well as inputs (known as activations) and compute the forward pass in low precision. However, quantizing the activations is hard as they have large outlier elements (see Figure 1 for an illustrative example) with much larger values, making activation quantization more difficult than weight quantization, especially for the 4-bit case. Previous work relies on characterizing outlier features using a calibration set and keeping them in higher precision during the inference.

    In this work, we address the issue of outlier features by rotating the inputs of the model using randomized Hadamard transformations. We do this using the computational invariance idea (Ashkboos et al., 2024) and fuse Hadamard transformations into the weight matrices, resulting in an equivalent network without outlier features. This enables the weights, activations, and KV caches to be quantized to 4 bits with minimal accuracy drop. Our main contributions are:

    • Using computational invariance from SliceGPT (Ashkboos et al., 2024), we apply randomized Hadamard transformations to the weight matrices without changing the model. This completely eliminates the outlier features and makes the activations easy to quantize without changing the output of the model. • We also apply online Hadamard transformations to the attention module to remove outlier features in keys and values, enabling the KV cache to be quantized. • Using the above modifications, QuaRot enables 4-bit LLM inference by quantizing all the weights, activations, and KV caches using integer quantization. On Llama 2-7B model, QuaRot achieves up to 2.16x prefill speedups, and 3.39x memory saving during the decoding stage, with at most 0.63 WikiText-2 perplexity loss. QuaRot preserves 99% of the accuracy of zero-shot tasks. We show that our 6 and 8-bit quantization (weights and activations) is lossless.

  2. Assistant

    QuaRot: Outlier-Free 4-Bit Inference in Rotated LLMs

    초록

    우리는 QuaRot을 소개합니다. 이는 회전에 기반한 새로운 양자화 기법으로, 모든 가중치, 활성화 값, KV 캐시를 4비트로 양자화할 수 있습니다. QuaRot은 LLMs의 히든 상태에서 이상치를 제거하는 방식으로 회전시키며, 출력은 변하지 않고 양자화를 쉽게 만듭니다. 이러한 계산 불변성은 LLM의 히든 상태(잔여물)와 피드포워드 컴포넌트의 활성화 값, 주의 메커니즘의 일부 및 KV 캐시에 적용됩니다. 결과적으로 모든 행렬 곱셈이 4비트로 수행되는 양자화된 모델이 만들어지며, 높은 정밀도로 보존되는 채널은 없습니다. 우리의 양자화된 Llama 2-70B 모델은 최대 0.29 WikiText-2 당혹도를 가지며, 제로샷 성능의 99%를 유지합니다. 코드는 https://github.com/spcl/QuaRot 에서 확인할 수 있습니다.

    1. 소개

    대형 언어 모델(LLMs)은 다양한 응용 프로그램으로 인해 점점 더 중요해지고 있습니다. 하지만, 이들의 추론은 상당한 양의 계산, 메모리, 에너지를 필요로 합니다. LLM 추론에는 두 가지 주요 단계가 있습니다: 프리필 단계에서 프롬프트가 처리되고 각 층에 캐시되며, 디코딩 단계에서 출력 토큰이 하나씩 생성됩니다. 프리필 단계는 보통 계산에 의존적이고, 디코딩 단계는 메모리에 의존적인 것으로 알려져 있습니다.

    양자화는 LLM 추론 중 메모리 및 계산 문제를 해결하는 가장 중요한 기술 중 하나입니다. 공동 양자화는 매개변수와 KV 캐시의 정밀도를 줄여 메모리 사용량을 낮추고, 입력(활성화 값)의 정밀도를 낮춰 전진 패스를 계산하는 것을 목표로 합니다. 그러나, 활성화 값에는 큰 이상치 요소(도 1을 참고하세요)가 많아 이를 양자화하는 것이 더 어렵습니다. 특히 4비트의 경우 무게 양자화보다 더 어려운 문제입니다. 이전 연구는 캘리브레이션 세트를 사용하여 이상치 특징을 특징화하고, 추론 중 높은 정밀도로 보존하는 방식에 의존해 왔습니다.

    본 연구에서는 모델의 입력을 무작위 하다마드 변환을 사용해 회전시켜 이상치 특징 문제를 해결합니다. 이를 위해 계산 불변성 아이디어(Ashkboos et al., 2024)를 사용하고 하다마드 변환을 무게 행렬에 융합시켜, 이상치 특징이 없는 등가 네트워크를 결과적으로 얻습니다. 이는 가중치, 활성화 값, KV 캐시를 최소한의 정확도 저하와 함께 4비트로 양자화할 수 있게 합니다. 우리의 주요 기여는 다음과 같습니다:

    • SliceGPT에서의 계산 불변성을 사용하여, 무작위 하다마드 변환을 무게 행렬에 적용하면서 모델을 변경하지 않고 이상치 특징을 완전히 제거하고, 활성화 값 양자화를 쉽게 만들며 모델의 출력을 변경하지 않습니다.
    • 또한, 주의 모듈에 온라인 하다마드 변환을 적용하여 키와 값의 이상치 특징을 제거해, KV 캐시를 양자화할 수 있게 합니다.
    • 앞서 언급한 수정사항을 통해 QuaRot은 모든 가중치, 활성화 값, 그리고 KV 캐시를 정수 양자화를 사용하여 4비트 LLM 추론을 가능하게 합니다. Llama 2-7B 모델에서 QuaRot은 프리필 속도를 최대 2.16배, 디코딩 단계에서 메모리 절약을 3.39배 달성하며, 최대 0.63 WikiText-2 당혹도 손실을 보입니다. QuaRot은 제로샷 과제의 99% 정확도를 유지합니다. 우리는 6 및 8비트 양자화(가중치와 활성화 값)가 손실이 없음을 보여줍니다.