HyQuant:面向LLM注意力的混合精度量化

·

研究论文 · 2026/09/11

量化已被广泛用于LLM训练和推理以降低成本和提升效率。然而,注意力模块的低比特量化在极低比特宽度下常引入较大误差,导致性能下降。现有方法主要依赖平滑技术处理离群值,而我们提出一种混合量化设计以更好地平衡精度与效率。具体而言,我们提出HyQuant,一种高效的LLM注意力混合量化框架。HyQuant将大多数注意力状态量化为低比特格式,同时保留少量垂直线token和局部窗口状态为高精度。这些精度关键区域通过轻量级垂直线感知注意力模式信号选取,以有限开销减少量化误差。在Prefill阶段,HyQuant使用混合精度量化注意力算子,将垂直线token和局部滑动窗口保持全精度,同时量化其余上下文。在Decode阶段,HyQuant将相同原则应用于KV缓存压缩,并将KV反量化与注意力计算融合,以提高内存和硬件效率。在不同任务、模型和数据集上,HyQuant以极其简单的设计保持近乎无损的精度,展示了LLM注意力混合量化的效率和实际可行性。代码见:https://github.com/jerrysfls/HyQuant 。

该工作提出了一种简单而有效的混合量化方法,在极低比特下保持LLM注意力近乎无损的精度,同时提升内存和硬件效率,对LLM高效推理与训练具有实际应用价值。

Quantization has been widely adopted in LLM training and inference to reduce cost and improve efficiency. However, low-bit quantization of the attention module often introduces large errors at very low bit-widths, causing performance degradation. Existing methods mainly rely on smoothing techniques to handle outliers, while we propose a hybrid quantization design to better balance accuracy and efficiency. Specifically, we propose HyQuant, an efficient hybrid quantization framework for LLM attention. HyQuant quantizes most attention states into low-bit formats while retaining a small set of vertical-line tokens and local-window states in high precision. These accuracy-critical regions are selected using lightweight vertical-line-aware attention-pattern signals, reducing quantization error with limited overhead. In the Prefill stage, HyQuant uses a hybrid-precision quantized attention operator that preserves vertical-line tokens and a local sliding window in full precision while quantizing the remaining context. In the Decode stage, HyQuant applies the same principle to KV-cache compression and fuses KV dequantization with attention computation to improve memory and hardware efficiency. Across diverse tasks, models, and datasets, HyQuant maintains nearly lossless accuracy with an extremely simple design, demonstrating the efficiency and practical feasibility of hybrid quantization for LLM attention. Code is available at: https://github.com/jerrysfls/HyQuant .

阅读原文

参与讨论