[论文解读] LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
引入 LLM.int8(),一种两阶段量化方法,将向量级的 8 位量化与混合精度分解相结合,使变换器模型在高达 175B 参数时也能进行 8 位推理且不降低精度;为在消费级 GPU 上使用大型模型打开了获取途径。
Large language models have been widely adopted but require significant GPU memory for inference. We develop a procedure for Int8 matrix multiplication for feed-forward and attention projection layers in transformers, which cut the memory needed for inference by half while retaining full precision performance. With our method, a 175B parameter 16/32-bit checkpoint can be loaded, converted to Int8, and used immediately without performance degradation. This is made possible by understanding and working around properties of highly systematic emergent features in transformer language models that dominate attention and transformer predictive performance. To cope with these features, we develop a two-part quantization procedure, LLM.int8(). We first use vector-wise quantization with separate normalization constants for each inner product in the matrix multiplication, to quantize most of the features. However, for the emergent outliers, we also include a new mixed-precision decomposition scheme, which isolates the outlier feature dimensions into a 16-bit matrix multiplication while still more than 99.9% of values are multiplied in 8-bit. Using LLM.int8(), we show empirically it is possible to perform inference in LLMs with up to 175B parameters without any performance degradation. This result makes such models much more accessible, for example making it possible to use OPT-175B/BLOOM on a single server with consumer GPUs. We open-source our software.
研究动机与目标
- 动机:在大规模 Transformer 推理中实现内存缩减并量化对性能的影响。
- 开发一种 8 位量化方法,确保在多十亿参数模型中保持全精度。
- 识别并量化在规模扩展时对量化构成挑战的高幅度离群特征。
- 提出混合精度分解,以在不牺牲 8 位效率的前提下隔离离群特征。
- 提供开源工具与集成,促成广泛应用。
提出的方法
- 提出带有每个内积归一化常数的向量级 8 位量化以提高精度。
- 引入混合精度分解,将罕见的离群特征维度分离到 16 位路径,同时 99.9% 保持在 8 位。
- 将矩阵乘法分解为离群部分(16 位)和常规部分(8 位),并使用外积常数进行去归一化。
- 分析随着模型规模增长,出现的高幅度离群特征及其对量化的影响。
- 在 perplexity (C4) 上对 125M–13B 的模型以及 OPT 模型高达 175B 的 zeroshot 准确度进行评估。
- 开源 bitsandbytes,并与 Hugging Face Transformers 集成。
实验结果
研究问题
- RQ18 位量化在多大规模下仍能保留 Transformer 推理的模型性能?
- RQ2在大规模下出现的离群特征是什么,以及它们如何影响量化精度?
- RQ3混合精度分解能否在对离群特征使用 16 位的同时,对其他部分使用 8 位量化以维持全 16 位精度?
- RQ4随着模型规模的扩大,向量级量化是否优于其他 8 位量化方案?
- RQ5在消费级 GPU 上部署 175B+ 模型的实际意义是什么?
主要发现
- LLM.int8() 在 125M 到 13B 的模型上保持 perplexity,与随规模增长而降级的 absmax/row-wise/zeropoint 基线不同。
- 对于 zeroshot 任务在 OPT 模型高达 175B,LLM.int8() 维持完整的 16 位性能,而基线的 8 位方法则下降。
- 在约 6.7B 参数处出现显著的大幅离群特征;每个序列约 150k 个离群,集中在大约 6 个特征维度。
- 混合精度分解(离群使用 16 位,其余使用 8 位)使推理在高达 175B 参数时实现无退化。
- 内存缩减显著(BLOOM-176B 约 2x),运行时影响温和,对于非常大模型,在消费级 GPU 上实现 8 位推理成为可行。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。