arXiv:2505.20839cs.LG2025-05被引 3

FireQ通过混合精度量化与优化内核,大幅加速大模型推理。

FireQ: Fast INT4-FP8 Kernel and RoPE-aware Quantization for LLM Inference Acceleration

  • 采用INT4/FP8混合量化,分层优化权重与激活值
  • 在Llama2-7B上前馈层提速1.68倍,Llama3-8B预填充阶段快1.26倍
  • 针对RoPE设计新缩放策略,减少量化误差,适合部署场景

随着大语言模型日益普及,内存带宽瓶颈严重制约推理吞吐量,推动后训练量化(PTQ)的发展。本文提出FireQ,一种协同设计的PTQ框架与INT4-FP8矩阵乘法内核,可加速所有线性层的LLM推理。具体而言,FireQ将线性层权重和键值对量化为INT4,激活值和查询量化为FP8,显著提升吞吐量。此外,我们改进FlashAttention-3内核,引入三阶段流水线处理预填充阶段,有效降低首个输出令牌的延迟。为最小化量化带来的精度损失,我们设计了针对线性层和注意力层的新型异常值平滑技术:在线性层中,采用逐张量缩放防止FP8量化因INT4缩放因子导致的下溢,并使用通道级缩放补偿INT4粗粒度问题;在注意力层中,通过结合预RoPE与后RoPE缩放策略应对旋转变换嵌入(RoPE)带来的量化挑战。FireQ显著优于现有最优方法,在Llama2-7B的前馈网络层实现1.68倍加速,在Llama3-8B的预填充阶段相比QServe提升1.26倍,且精度损失极小。

原文摘要 · Abstract (English)

As large language models become increasingly prevalent, memory bandwidth constraints significantly limit inference throughput, motivating post-training quantization (PTQ). In this paper, we propose FireQ, a co-designed PTQ framework and an INT4-FP8 matrix multiplication kernel that accelerates LLM inference across all linear layers. Specifically, FireQ quantizes linear layer weights and key-values to INT4, and activations and queries to FP8, significantly enhancing throughput. Additionally, we introduce a three-stage pipelining for the prefill phase, which modifies the FlashAttention-3 kernel, effectively reducing time-to-first-token in the prefill phase. To minimize accuracy loss from quantization, we develop novel outlier smoothing techniques tailored separately for linear and attention layers. In linear layers, we explicitly use per-tensor scaling to prevent underflow caused by the FP8 quantization scaling factor of INT4 quantization, and channel-wise scaling to compensate for coarse granularity of INT4. In attention layers, we address quantization challenges posed by rotary positional embeddings (RoPE) by combining pre-RoPE and post-RoPE scaling strategies. FireQ significantly outperforms state-of-the-art methods, achieving 1.68x faster inference in feed-forward network layers on Llama2-7B and 1.26x faster prefill phase performance on Llama3-8B compared to QServe, with negligible accuracy loss.

大模型推理量化混合精度RoPE

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。