SharQ:桥接激活稀疏性与FP4量化用于LLM推理
SharQ: Bridging Activation Sparsity and FP4 Quantization for LLM Inference
AI总结:
提出SharQ方法,通过在线稀疏-稠密分解结合N:M稀疏性与FP4量化,无需训练即可恢复NVFP4与FP16之间43-63%的精度差距,并在RTX 5090上实现2.2-2.4倍延迟降低。
摘要:
低比特浮点格式和半结构化稀疏性日益得到现代加速器的支持,但将它们结合用于LLM激活压缩仍然具有挑战性:激活包含输入相关的异常值,这些异常值主导了FP4量化中的块尺度,而直接应用N:M稀疏掩码会丢弃中等值,将稀疏化损失与量化误差耦合。我们提出了SharQ,一种无需训练的推理方法,通过在线稀疏-稠密分解桥接激活稀疏性与FP4量化。对于每个激活张量,SharQ生成一个输入自适应的N:M掩码,提取出以异常值主导的稀疏骨干,将其量化为FP4,并定义一个相对于量化稀疏骨干(而非未量化的稀疏值)的稠密残差。一个稀疏FP4 GEMM处理骨干,而一个稠密FP4 GEMM补偿掩码引起的激活损失和稀疏路径量化误差。两条路径共享一个FP4权重负载,具有路径特定的尺度视图,一个融合的准备内核将掩码生成、残差构建和层归一化合并为一个算子。SharQ不需要校准数据、重新训练或模型特定调优。在Llama-3.1-8B、Qwen2.5-7B、Qwen3-30B-A3B和Qwen3-VL-8B上的评估表明,SharQ在语言和视觉-语言任务中恢复了NVFP4到FP16精度差距的43-63%,并泛化到NVFP4、HiF4和MXFP4格式。在RTX 5090上,SharQ在语言模型服务中相比FP16实现了2.2-2.4倍的延迟降低,相比FP8实现了1.2-1.4倍的吞吐量提升,并在结合SageAttention的Wan2.2-T2V-A14B视频生成中实现了高达1.58倍的加速。我们的代码可在该网址获取。
英文摘要:
Low-bit floating-point formats and semi-structured sparsity are increasingly supported by modern accelerators, yet combining them for LLM activation compression remains challenging: activations contain input-dependent outliers that dominate block scales in FP4 quantization, and directly applying N:M sparsity masks discards moderate values, coupling sparsification loss with quantization error. We introduce SharQ, a training-free inference method that bridges activation sparsity and FP4 quantization through an online sparse--dense decomposition. For each activation tensor, SharQ generates an input-adaptive N:M mask to extract an outlier-dominated sparse backbone, quantizes it to FP4, and defines a dense residual relative to the quantized sparse backbone rather than the unquantized sparse values. A sparse FP4 GEMM processes the backbone while a dense FP4 GEMM compensates for both mask-induced activation loss and sparse-path quantization error. The two paths share a single FP4 weight payload with path-specific scale views, and a fused preparation kernel absorbs mask generation, residual construction, and layer normalization into one operator. SharQ requires no calibration data, retraining, or model-specific tuning. Evaluated on Llama-3.1-8B, Qwen2.5-7B, Qwen3-30B-A3B, and Qwen3-VL-8B, SharQ recovers 43--63% of the NVFP4-to-FP16 accuracy gap across language and vision-language tasks, and generalizes across NVFP4, HiF4, and MXFP4 formats. On an RTX 5090, SharQ delivers 2.2--2.4$\times$ latency reduction over FP16 and 1.2--1.4$\times$ throughput improvement over FP8 in language model serving, and up to 1.58$\times$ speedup on Wan2.2-T2V-A14B video generation when combined with SageAttention. Our code is available at https://github.com/actypedef/SharQ.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。