Table of Contents
Fetching ...

Agile-Quant: Activation-Guided Quantization for Faster Inference of LLMs on the Edge

Xuan Shen, Peiyan Dong, Lei Lu, Zhenglun Kong, Zhengang Li, Ming Lin, Chao Wu, Yanzhi Wang

TL;DR

The paper tackles the challenge of running large language models on edge devices by enabling activation quantization in addition to weight quantization. It introduces Agile-Quant, an activation-guided quantization framework complemented by an edge-oriented accelerator that includes a SIMD-based 4-bit multiplier and TRIP matrix multiplication, plus activation-aware token pruning. The approach preserves task performance close to weight-only quantization while delivering practical on-device speedups, achieving up to $2.55\times$ faster inference across multiple edge devices for LLMs such as LLaMA, OPT, and BLOOM. This work demonstrates a viable path toward widespread on-device LLM deployment, reducing latency and energy consumption without retraining, and lays groundwork for even lower-bit quantization in future hardware.

Abstract

Large Language Models (LLMs) stand out for their impressive performance in intricate language modeling tasks. However, their demanding computational and memory needs pose obstacles for broad use on edge devices. Quantization is then introduced to boost LLMs' on-device efficiency. Recent works show that 8-bit or lower weight quantization is feasible with minimal impact on end-to-end task performance, while the activation is still not quantized. On the other hand, mainstream commodity edge devices still struggle to execute these sub-8-bit quantized networks effectively. In this paper, we propose Agile-Quant, an activation-guided quantization framework for popular Large Language Models (LLMs), and implement an end-to-end accelerator on multiple edge devices for faster inference. Considering the hardware profiling and activation analysis, we first introduce a basic activation quantization strategy to balance the trade-off of task performance and real inference speed. Then we leverage the activation-aware token pruning technique to reduce the outliers and the adverse impact on attentivity. Ultimately, we utilize the SIMD-based 4-bit multiplier and our efficient TRIP matrix multiplication to implement the accelerator for LLMs on the edge. We apply our framework on different scales of LLMs including LLaMA, OPT, and BLOOM with 4-bit or 8-bit for the activation and 4-bit for the weight quantization. Experiments show that Agile-Quant achieves simultaneous quantization of model weights and activations while maintaining task performance comparable to existing weight-only quantization methods. Moreover, in the 8- and 4-bit scenario, Agile-Quant achieves an on-device speedup of up to 2.55x compared to its FP16 counterparts across multiple edge devices, marking a pioneering advancement in this domain. Code: https://github.com/shawnricecake/agile-quant

Agile-Quant: Activation-Guided Quantization for Faster Inference of LLMs on the Edge

TL;DR

The paper tackles the challenge of running large language models on edge devices by enabling activation quantization in addition to weight quantization. It introduces Agile-Quant, an activation-guided quantization framework complemented by an edge-oriented accelerator that includes a SIMD-based 4-bit multiplier and TRIP matrix multiplication, plus activation-aware token pruning. The approach preserves task performance close to weight-only quantization while delivering practical on-device speedups, achieving up to faster inference across multiple edge devices for LLMs such as LLaMA, OPT, and BLOOM. This work demonstrates a viable path toward widespread on-device LLM deployment, reducing latency and energy consumption without retraining, and lays groundwork for even lower-bit quantization in future hardware.

Abstract

Large Language Models (LLMs) stand out for their impressive performance in intricate language modeling tasks. However, their demanding computational and memory needs pose obstacles for broad use on edge devices. Quantization is then introduced to boost LLMs' on-device efficiency. Recent works show that 8-bit or lower weight quantization is feasible with minimal impact on end-to-end task performance, while the activation is still not quantized. On the other hand, mainstream commodity edge devices still struggle to execute these sub-8-bit quantized networks effectively. In this paper, we propose Agile-Quant, an activation-guided quantization framework for popular Large Language Models (LLMs), and implement an end-to-end accelerator on multiple edge devices for faster inference. Considering the hardware profiling and activation analysis, we first introduce a basic activation quantization strategy to balance the trade-off of task performance and real inference speed. Then we leverage the activation-aware token pruning technique to reduce the outliers and the adverse impact on attentivity. Ultimately, we utilize the SIMD-based 4-bit multiplier and our efficient TRIP matrix multiplication to implement the accelerator for LLMs on the edge. We apply our framework on different scales of LLMs including LLaMA, OPT, and BLOOM with 4-bit or 8-bit for the activation and 4-bit for the weight quantization. Experiments show that Agile-Quant achieves simultaneous quantization of model weights and activations while maintaining task performance comparable to existing weight-only quantization methods. Moreover, in the 8- and 4-bit scenario, Agile-Quant achieves an on-device speedup of up to 2.55x compared to its FP16 counterparts across multiple edge devices, marking a pioneering advancement in this domain. Code: https://github.com/shawnricecake/agile-quant
Paper Structure (24 sections, 10 equations, 8 figures, 6 tables, 1 algorithm)

This paper contains 24 sections, 10 equations, 8 figures, 6 tables, 1 algorithm.

Figures (8)

  • Figure 1: The (a), (b), and (c) shows attention maps with 16 tokens in the first and last layer of the model. The activation is not quantized in (a) and (b), while it is quantized in (c). The (d) shows the distribution of outliers in one activation with 2048 tokens. The visualization is based on the LLaMA-7B model with the Wikitext-2 dataset.
  • Figure 2: Mobile Device profiling of one LLaMA block.
  • Figure 3: Activation Quantization Pipeline.
  • Figure 4: Activation Quantization With Token Pruning.
  • Figure 5: The paradigm of INT4 multiplier.
  • ...and 3 more figures