Revisiting Block-based Quantisation: What is Important for Sub-8-bit LLM Inference?
作者: Cheng Zhang, Jianyi Cheng, Ilia Shumailov, George A. Constantinides, Yiren Zhao
分类: cs.LG
发布日期: 2023-10-08 (更新: 2023-10-21)
备注: Accepted by EMNLP2023
DOI: 10.18653/v1/2023.emnlp-main.617
💡 一句话要点
提出块状量化方法以解决LLM推理中的数值缩放问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 量化方法 大型语言模型 数值缩放 块状量化 内存优化 算术密度 无损量化 机器学习
📋 核心要点
- 现有的LLM量化方法主要集中在8位,未能有效解决数值缩放偏移问题,导致性能瓶颈。
- 本文提出块状量化方法,通过在打包数字之间共享缩放因子,减少数值缩放偏移,优化LLM的量化过程。
- 实验结果表明,6位量化LLM在算术密度和内存密度上分别比float32基线高出19倍和5倍,且4位LLM在下游任务中几乎无损。
📝 摘要(中文)
大型语言模型(LLMs)的推理需要巨大的计算和内存资源。为降低这些成本,量化成为一种有前景的解决方案,但现有的LLM量化主要集中在8位。本文探讨了LLM层的统计和学习特性,并将LLM量化的瓶颈归因于数值缩放偏移。为此,我们为LLM适配了块状量化方法,这是一种在打包数字之间共享缩放因子的技术。我们的6位量化LLM在算术密度和内存密度上分别比float32基线高出19倍和5倍,超越了先前的8位量化方法,且无需数据校准或再训练。我们还分享了对8位以下LLM量化的见解,包括激活和权重分布的不匹配、最佳微调策略以及LLM固有的较低量化粒度。
🔬 方法详解
问题定义:本文旨在解决大型语言模型推理中的数值缩放偏移问题。现有的8位量化方法未能有效应对这一挑战,导致性能不足。
核心思路:我们提出块状量化方法,通过在多个数字之间共享缩放因子,优化数值表示,从而减少数值缩放偏移的影响。这种方法从算术角度出发,避免了在计算路径中增加额外处理。
技术框架:整体架构包括对LLM层的统计特性分析、块状量化的实施以及对激活和权重分布的优化。主要模块包括数据预处理、量化实施和性能评估。
关键创新:最重要的创新点在于块状量化方法的提出,它通过共享缩放因子显著提高了算术密度和内存密度,且无需额外的数据校准或再训练。
关键设计:在设计中,我们关注于量化粒度的选择、激活与权重分布的匹配,以及优化微调策略,以实现几乎无损的4位量化效果。具体参数设置和损失函数设计在实验中进行了详细验证。
🖼️ 关键图片
📊 实验亮点
实验结果显示,6位量化的LLM在算术密度上比float32基线高出19倍,内存密度高出5倍,超越了先前的8位量化方法,分别提高了2.5倍和1.2倍。此外,4位LLM在下游任务中实现了几乎无损的性能,展示了该方法的有效性。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理、对话系统和机器翻译等。通过优化LLM的量化过程,能够显著降低推理时的计算和内存开销,从而使得在资源受限的设备上运行大型语言模型成为可能,具有重要的实际价值和广泛的应用前景。
📄 摘要(原文)
The inference of Large language models (LLMs) requires immense computation and memory resources. To curtail these costs, quantisation has merged as a promising solution, but existing LLM quantisation mainly focuses on 8-bit. In this work, we explore the statistical and learning properties of the LLM layer and attribute the bottleneck of LLM quantisation to numerical scaling offsets. To address this, we adapt block quantisations for LLMs, a family of methods that share scaling factors across packed numbers. Block quantisations efficiently reduce the numerical scaling offsets solely from an arithmetic perspective, without additional treatments in the computational path. Our nearly-lossless quantised 6-bit LLMs achieve a $19\times$ higher arithmetic density and $5\times$ memory density than the float32 baseline, surpassing the prior art 8-bit quantisation by $2.5\times$ in arithmetic density and $1.2\times$ in memory density, without requiring any data calibration or re-training. We also share our insights into sub-8-bit LLM quantisation, including the mismatch between activation and weight distributions, optimal fine-tuning strategies, and a lower quantisation granularity inherent in the statistical properties of LLMs. The latter two tricks enable nearly-lossless 4-bit LLMs on downstream tasks. Our code is open-sourced.