SmoothQuant:大型语言模型的准确高效训练后量化

SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models

韩松 Song Han · MIT · 2022-11-18 · arXiv:2211.10438 ↗ · 被引 1705

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

大型语言模型(LLM)表现出色,但计算和内存密集。量化可以减少内存并加速推理。然而,现有方法无法同时保持准确性和硬件效率。我们提出 SmoothQuant,一种无需训练、保持精度且通用的训练后量化(PTQ)解决方案,为 LLM 实现 8 位权重、8 位激活(W8A8)量化。基于权重易于量化而激活不易的事实,SmoothQuant 通过离线将量化难度从激活迁移到权重(使用数学等价变换)来平滑激活异常值。SmoothQuant 实现了 LLM 中所有矩阵乘法的 INT8 权重和激活量化,包括 OPT、BLOOM、GLM、MT-NLG、Llama-1/2、Falcon、Mistral 和 Mixtral 模型。我们展示了高达 1.56 倍的加速和 2 倍的内存减少,且精度损失可忽略。SmoothQuant 使得在单个节点内服务 530B LLM 成为可能。我们的工作提供了一种交钥匙解决方案,降低了硬件成本并普及了 LLM。代码可在 https://github.com/mit-han-lab/smoothquant 获取。

Large language models (LLMs) show excellent performance but are compute- and memory-intensive. Quantization can reduce memory and accelerate inference. However, existing methods cannot maintain accuracy and hardware efficiency at the same time. We propose SmoothQuant, a training-free, accuracy-preserving, and general-purpose post-training quantization (PTQ) solution to enable 8-bit weight, 8-bit activation (W8A8) quantization for LLMs. Based on the fact that weights are easy to quantize while activations are not, SmoothQuant smooths the activation outliers by offline migrating the quantization difficulty from activations to weights with a mathematically equivalent transformation. SmoothQuant enables an INT8 quantization of both weights and activations for all the matrix multiplications in LLMs, including OPT, BLOOM, GLM, MT-NLG, Llama-1/2, Falcon, Mistral, and Mixtral models. We demonstrate up to 1.56x speedup and 2x memory reduction for LLMs with negligible loss in accuracy. SmoothQuant enables serving 530B LLM within a single node. Our work offers a turn-key solution that reduces hardware costs and democratizes LLMs. Code is available at https://github.com/mit-han-lab/smoothquant.

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 13)

阅读逐段中英对照全文 →