QET:通过元素替换和残差聚类增强量化 LLM 参数与 KV cache 压缩
QET: Enhancing Quantized LLM Parameters and KV cache Compression through Element Substitution and Residual Clustering
AI总结:
本文提出 QET,通过元素交换形成局部有序矩阵并按列分组量化,结合残差量化及掩码批处理优化,显著降低 LLM 参数与 KV cache 压缩的 MSE。
摘要:
矩阵量化是指以更节省空间的形式表示矩阵元素,以减少存储占用,并通过反量化恢复原始矩阵以供使用。我们将量化误差最小化(Quantization Error Minimization,QEM)问题形式化为:在量化后矩阵占用相同内存空间的条件下,最小化矩阵在量化前后的距离。矩阵量化在多种应用中至关重要,包括大语言模型(Large Language Models,LLMs)权重量化、向量数据库、KV cache 量化、图压缩和图像压缩。LLMs 的最新进展,例如 GPT-4 和 BERT,由于以矩阵形式存储的参数和 KV cache 规模巨大,凸显了矩阵压缩的重要性。我们提出 Quantum Entanglement Trees(QET)来解决 QEM 问题:该方法利用矩阵元素的局部有序性,通过迭代式元素交换形成局部有序矩阵,随后按列对该矩阵进行分组和量化。为增强 QET,我们引入两项优化:进一步量化残差以降低 MSE,以及使用掩码和批处理来加速算法。实验结果表明,在 LLM 数据集、K cache 和 V cache 上,QET 可有效将 MSE 分别降至当前最佳方法的 5.05%、13.33% 和 11.89%。我们的贡献包括对 QEM 问题的抽象、QET 算法的设计,以及为提升精度和速度提出的两项优化。
英文摘要:
The matrix quantization entails representing matrix elements in a more space-efficient form to reduce storage usage, with dequantization restoring the original matrix for use. We formulate the Quantization Error Minimization (QEM) problem as minimizing the distance between a matrix before and after quantization, under the condition that the quantized matrix occupies the same memory space. Matrix quantization is crucial in various applications, including Large Language Models (LLMs) weight quantization, vector databases, KV cache quantization, graph compression, and image compression. Recent advancements in LLMs, such as GPT-4 and BERT, have highlighted the importance of matrix compression due to the large size of parameters and KV cache, which are stored as matrices. We propose Quantum Entanglement Trees (QET) to address the QEM problem by leveraging the local orderliness of matrix elements, involving iterative element swapping to form a locally ordered matrix. This matrix is then grouped and quantized by columns. To enhance QET, we introduce two optimizations: further quantizing residuals to reduce MSE, and using masking and batch processing to accelerate the algorithm. Experimental results demonstrate that QET can effectively reduce MSE to 5.05%, 13.33%, and 11.89% of the current best method on the LLM dataset, K cache, and V cache, respectively. Our contributions include the abstraction of the QEM problem, the design of the QET algorithm, and the proposal of two optimizations to improve accuracy and speed.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。