SnapMLA: 通过硬件感知的FP8量化流水线实现高效的长上下文MLA解码
SnapMLA: Efficient Long-Context MLA Decoding via Hardware-Aware FP8 Quantized Pipelining
AI总结:
SnapMLA通过硬件感知的FP8量化流水线优化,提升长上下文解码效率,实验显示在长输出解码任务中吞吐量提升达1.91倍,同时在推理和代码生成基准上与BF16基线表现相近。
摘要:
尽管FP8注意力在创新如FlashAttention-3中展现了显著潜力,但将其整合到DeepSeek多头潜伏注意力(MLA)架构的解码阶段带来了显著挑战。这些挑战包括由于位置嵌入解耦导致的数值异质性、FP8 PV GEMM中量化尺度不匹配以及对优化系统级支持的需求。在本文中,我们引入SnapMLA,一种优化的FP8 MLA解码框架,通过以下硬件感知的算法-内核协同优化技术提高长上下文效率:(i)RoPE感知的每token KV量化:受MLA KV缓存中固有异构量化敏感性的分析启发,该方法在高精度下保留RoPE部分。此外,采用每token粒度以对齐自回归解码过程并维持量化精度。(ii)量化PV计算流水线重建:解决由于MLA共享KV结构导致的FP8 PV计算中量化尺度不匹配问题。(iii)端到端数据流优化:利用专用内核建立高效的读写工作流,确保数据流流畅并提高性能。对最先进的MLA LLMs进行的大量实验表明,SnapMLA在长输出解码任务中实现了高达1.91倍的吞吐量提升,同时在评估的推理和代码生成基准上与BF16基线表现相近。代码可在https://github.com/meituan-longcat/SGLang-FluentLLM上获得。
英文摘要:
While FP8 attention has shown substantial promise in innovations like FlashAttention-3, its integration into the decoding phase of the DeepSeek Multi-head Latent Attention (MLA) architecture presents notable challenges. These challenges include numerical heterogeneity arising from the decoupling of positional embeddings, misalignment of quantization scales in FP8 PV GEMM, and the need for optimized system-level support. In this paper, we introduce SnapMLA, an FP8 MLA decoding framework optimized to improve long-context efficiency through the following hardware-aware algorithm-kernel co-optimization techniques: (i) RoPE-Aware Per-Token KV Quantization: Motivated by our analysis of the heterogeneous quantization sensitivity inherent to the MLA KV cache, this approach preserves the RoPE part in high precision. Furthermore, per-token granularity is employed to align with the autoregressive decoding process and maintain quantization accuracy. (ii) Quantized PV Computation Pipeline Reconstruction: Addresses the misalignment of quantization scales in FP8 PV computation caused by the shared KV structure of the MLA. (iii) End-to-End Dataflow Optimization: Establishes an efficient data read-and-write workflow using specialized kernels, ensuring streamlined data flow and improved performance. Extensive experiments on state-of-the-art MLA LLMs show that SnapMLA achieves up to a 1.91x improvement in throughput on long-output decoding workloads while maintaining near-parity benchmark quality compared with the BF16 baseline on the evaluated reasoning and code-generation benchmarks. Code is available at https://github.com/meituan-longcat/SGLang-FluentLLM.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。