0

0

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

    Published 10/30/2024 by Saleh Ashkboos, Amirkeivan Mohtashami, Maximilian L. Croci, Bo Li, Pashmina Cameron, Martin Jaggi, Dan Alistarh, Torsten Hoefler, James Hensman

    Overview

    • A new technique called \carrot QuaRot that enables 4-bit inference in rotated large language models (LLMs) without accuracy loss
    • Addresses the problem of outliers that can degrade performance when LLMs are quantized to low bitwidths
    • Achieves state-of-the-art accuracy on various benchmarks compared to prior quantization methods

    Llama 2-7B FFN activations show improved quantization after QuaRot processing.

    1/2

    Llama 2-7B FFN activations show improved quantization after QuaRot processing.

    Original caption: Figure 1: The distributions of activations at the input to the FFN block in Llama 2-7B model, in the tenth layer. Left: using the default configuration as downloaded from Hugging Face. Right: after processing using QuaRot. The processed distribution has no outliers, leading to superior quantization.

    Perplexity of WikiText-2 on 4-bit quantized Llama-2 models with 2048 sequence length. SmoothQuant and OmniQuant results are shown.

    1/2

    Method Weight #Outlier Llama-2 7B 13B 70B
    Quantization Features 7B 13B 70B
    Baseline - - 5.47 4.88 3.32
    SmoothQuant RTN 0 83.12 35.88 -
    OmniQuant RTN 0 14.26 12.30 -
    QUIK-4B GPTQ 256 8.87 7.78 6.91
    QuaRot GPTQ 0 6.10 5.40 3.79
    Atom-128G GPTQ-128G 128 6.03 5.26 -
    QuaRot-128G 0 5.93 5.26 3.61

    Original caption: Table 1: WikiText-2 perplexity results on 4-bit quantization of Llama- 2 models with 2048 sequence length. We extract the results for SmoothQuant and OmniQuant results of (Shao et al., 2023). 128G shows the group-wise quantization with group size 128.Here, we quantize all weights, activations, and caches in 4-bits in QuaRot.

    Plain English Explanation

    Large language models (LLMs) like GPT-3 are powerful AI systems that can generate human-like text. However, these models require a lot of memory and computing power to run, which can make them difficult to use on devices with limited resources like phones or embedded systems.

    One way to make LLMs more efficient is to quantize them - that is, to represent the model's weights and activations using fewer bits (e.g. 4 bits instead of 32 bits). This reduces the memory and computation required, but can also degrade the model's accuracy if not done carefully.

    The key challenge is that LLMs often have some "outlier" values that are much larger or smaller than the typical range. When these outliers are quantized, they can get "clipped" and lose important information.

    The \carrot QuaRot technique [internal link: Background] addresses this by first rotating the model's weights and activations using a special kind of matrix. This has the effect of spreading out the outliers so they are no longer as extreme. Then the rotated values can be quantized to 4 bits without as much accuracy loss.

    The researchers show that \carrot QuaRot achieves state-of-the-art accuracy on several language understanding benchmarks, outperforming prior quantization methods. This makes it possible to run high-performance LLMs on a wider range of hardware, from cloud servers to edge devices.

    Key Findings

    • \carrot QuaRot enables 4-bit inference in rotated LLMs with no accuracy loss compared to the full-precision model [internal link: Results]
    • Outperforms prior quantization techniques on various language understanding benchmarks [internal link: Results]
    • Reduces the memory footprint and computational requirements of LLMs, enabling them to run on a wider range of hardware [internal link: Implications]

    Technical Explanation

    The key innovations in \carrot QuaRot are:

    1. Orthogonal Rotation: The model's weights and activations are rotated using an orthogonal matrix, which preserves the norms and directions of the vectors [internal link: Orthogonal, Rotation and Hadamard Matrices]. This helps spread out the outlier values.

    2. Hadamard Rotation: A special type of orthogonal matrix called a Hadamard matrix is used, which has efficient implementation and can be easily learned.

    3. Outlier-Aware Quantization: After rotation, the values are quantized to 4 bits using a quantization scheme that is designed to handle outliers [internal link: Outlier-Aware Quantization].

    The researchers evaluate \carrot QuaRot on language understanding benchmarks like GLUE and find it outperforms prior quantization methods like DoReFa and PACT. This demonstrates the effectiveness of the orthogonal rotation and outlier-aware quantization in preserving model accuracy.

    Implications for the Field

    The \carrot QuaRot technique represents an important advance in making large language models more efficient and deployable on a wider range of hardware. By enabling 4-bit inference with no accuracy loss, it opens the door for LLMs to be used in resource-constrained environments like mobile devices, embedded systems, and edge computing.

    This has significant implications for the field of natural language processing. It means high-performance language models can now be brought closer to end users, enabling new real-world applications that rely on language AI. It also lays the groundwork for more efficient training and deployment of ever-larger language models in the future.

    Critical Analysis

    The paper provides a thorough experimental evaluation of \carrot QuaRot and compares it against several state-of-the-art quantization techniques. However, it would be helpful to see an analysis of the computational and memory savings enabled by the 4-bit quantization, as well as the tradeoffs in terms of latency or throughput.

    Additionally, the authors acknowledge that \carrot QuaRot is designed for inference-only scenarios, and it's unclear how the technique would perform during fine-tuning or training of the language model. Further research may be needed to understand the broader applicability of the method.

    Conclusion

    The \carrot QuaRot technique represents an important step forward in making large language models more efficient and accessible. By enabling 4-bit inference with no accuracy loss, it opens the door for deploying high-performance NLP models on a much wider range of hardware, from cloud servers to edge devices. This has significant implications for the real-world application of language AI, and lays the groundwork for continued advances in model efficiency and accessibility.

    Full paper

    Loading...

    Loading PDF viewer...

    Read original: arXiv:2404.00456



    This summary was produced with help from an AI and may contain inaccuracies - check out the links to read the original source documents!

    Total Score

    0

    Follow @aimodelsfyi on 𝕏 →

    Related Papers

    🌿

    Total Score

    0

    SpinQuant -- LLM quantization with learned rotations

    Zechun Liu, Changsheng Zhao, Igor Fedorov, Bilge Soran, Dhruv Choudhary, Raghuraman Krishnamoorthi, Vikas Chandra, Yuandong Tian, Tijmen Blankevoort

    Post-training quantization (PTQ) techniques applied to weights, activations, and the KV cache greatly reduce memory usage, latency, and power consumption of Large Language Models (LLMs), but may lead to large quantization errors when outliers are present. Rotating activation or weight matrices helps remove outliers and benefits quantization. In this work, we identify a collection of applicable rotation parameterizations that lead to identical outputs in full-precision Transformer architectures while enhancing quantization accuracy. In addition, we find that some random rotations lead to much better quantization than others, with an up to 13 points difference in downstream zero-shot reasoning performance. As a result, we propose SpinQuant, a novel approach that incorporates learned rotation matrices for optimal quantized network accuracy. With 4-bit quantization of weight, activation, and KV-cache, SpinQuant narrows the accuracy gap on zero-shot reasoning tasks with full precision to merely 2.9 points on the LLaMA-2 7B model, surpassing LLM-QAT by 19.1 points and SmoothQuant by 25.0 points. Furthermore, SpinQuant also outperforms concurrent work QuaRot, which applies random rotations to remove outliers. In particular, for LLaMA-3 8B models that are hard to quantize, SpinQuant reduces the gap to full precision by up to 45.1% relative to QuaRot.

    Read more

    10/8/2024

    DFRot: Achieving Outlier-Free and Massive Activation-Free for Rotated LLMs with Refined Rotation
    Total Score

    0

    DFRot: Achieving Outlier-Free and Massive Activation-Free for Rotated LLMs with Refined Rotation

    Jingyang Xiang, Sai Qian Zhang

    Rotating the activation and weight matrices to reduce the influence of outliers in large language models (LLMs) has recently attracted significant attention, particularly in the context of model quantization. Prior studies have shown that in low-precision quantization scenarios, such as 4-bit weights and 4-bit activations (W4A4), randomized Hadamard transforms can achieve significantly higher accuracy than randomized orthogonal transforms. Notably, the reason behind this phenomena remains unknown. In this paper, we find that these transformations show substantial improvement in eliminating outliers for common tokens and achieve similar quantization error. The primary reason for the accuracy difference lies in the fact that randomized Hadamard transforms can slightly reduce the quantization error for tokens with massive activations while randomized orthogonal transforms increase the quantization error. Due to the extreme rarity of these tokens and their critical impact on model accuracy, we consider this a long-tail optimization problem, and therefore construct a simple yet effective method: a weighted loss function. Additionally, we propose an optimization strategy for the rotation matrix that involves alternating optimization of quantization parameters while employing orthogonal Procrustes transforms to refine the rotation matrix. This makes the distribution of the rotated activation values more conducive to quantization, especially for tokens with massive activations. Our method enhances the Rotated LLMs by achieving dual free, Outlier-Free and Massive Activation-Free, dubbed as DFRot. Extensive experiments demonstrate the effectiveness and efficiency of DFRot. By tuning the rotation matrix using just a single sample, DFRot achieves a perplexity improvement of 0.25 and 0.21 on W4A4KV4 and W4A4KV16, respectively, for LLaMA3-8B, a model known for its quantization challenges.

    Read more

    12/4/2024

    Rotation and Permutation for Advanced Outlier Management and Efficient Quantization of LLMs
    Total Score

    0

    Rotation and Permutation for Advanced Outlier Management and Efficient Quantization of LLMs

    Haokun Lin, Haobo Xu, Yichen Wu, Jingzhi Cui, Yingtao Zhang, Linzhan Mou, Linqi Song, Zhenan Sun, Ying Wei

    Quantization of large language models (LLMs) faces significant challenges, particularly due to the presence of outlier activations that impede efficient low-bit representation. Traditional approaches predominantly address Normal Outliers, which are activations across all tokens with relatively large magnitudes. However, these methods struggle with smoothing Massive Outliers that display significantly larger values, which leads to significant performance degradation in low-bit quantization. In this paper, we introduce DuQuant, a novel approach that utilizes rotation and permutation transformations to more effectively mitigate both massive and normal outliers. First, DuQuant starts by constructing the rotation matrix, using specific outlier dimensions as prior knowledge, to redistribute outliers to adjacent channels by block-wise rotation. Second, We further employ a zigzag permutation to balance the distribution of outliers across blocks, thereby reducing block-wise variance. A subsequent rotation further smooths the activation landscape, enhancing model performance. DuQuant simplifies the quantization process and excels in managing outliers, outperforming the state-of-the-art baselines across various sizes and types of LLMs on multiple tasks, even with 4-bit weight-activation quantization. Our code is available at https://github.com/Hsu1023/DuQuant.

    Read more

    11/4/2024

    RoLoRA: Fine-tuning Rotated Outlier-free LLMs for Effective Weight-Activation Quantization
    Total Score

    0

    RoLoRA: Fine-tuning Rotated Outlier-free LLMs for Effective Weight-Activation Quantization

    Xijie Huang, Zechun Liu, Shih-Yang Liu, Kwang-Ting Cheng

    Low-Rank Adaptation (LoRA), as a representative Parameter-Efficient Fine-Tuning (PEFT)method, significantly enhances the training efficiency by updating only a small portion of the weights in Large Language Models (LLMs). Recently, weight-only quantization techniques have also been applied to LoRA methods to reduce the memory footprint of fine-tuning. However, applying weight-activation quantization to the LoRA pipeline is under-explored, and we observe substantial performance degradation primarily due to the presence of activation outliers. In this work, we propose RoLoRA, the first LoRA-based scheme for effective weight-activation quantization. RoLoRA utilizes rotation for outlier elimination and proposes rotation-aware fine-tuning to preserve the outlier-free characteristics in rotated LLMs. Experimental results show RoLoRA consistently improves low-bit LoRA convergence and post-training quantization robustness in weight-activation settings. We evaluate RoLoRA across LLaMA2-7B/13B, LLaMA3-8B models, achieving up to 29.5% absolute accuracy gain of 4-bit weight-activation quantized LLaMA2- 13B on commonsense reasoning tasks compared to LoRA baseline. We further demonstrate its effectiveness on Large Multimodal Models (LLaVA-1.5-7B). Codes are available at https://github.com/HuangOwen/RoLoRA

    Read more

    9/30/2024