SnapMLA: Efficient Long-Context MLA Decoding via Hardware-Aware FP8 Quantized Pipelining

Yifan Zhang, Zunhai Su, Shuhao Hu, Rui Yang, Wei Wu, Yulei Qian, Yuchen Xie, Xunliang Cai

TL;DR

SnapMLA is an open-source, hardware-aware FP8 decoding framework designed specifically to accelerate the Multi-head Latent Attention (MLA) architecture used in state-of-the-art models like DeepSeek-V3. By co-optimizing quantization algorithms with custom CUDA kernels, SnapMLA achieves up to a 1.91× throughput improvement for long-context decoding while maintaining near-parity accuracy with the BF16 baseline.

What Problem Does This Paper Address?

As Large Language Models (LLMs) handle increasingly longer contexts, the Key-Value (KV) cache expands linearly, creating a massive memory bottleneck during the autoregressive decoding phase. To mitigate this, architectures like DeepSeek introduce Multi-head Latent Attention (MLA), which uses low-rank joint compression to reduce the KV cache footprint.

However, under high-concurrency scenarios, architectural compression alone isn't enough. Quantizing the KV cache to 8-bit floating-point (FP8) precision is a logical next step, but doing so for MLA introduces three severe challenges:

  1. Numerical Heterogeneity: MLA splits the KV cache into a compressed content component and a precision-sensitive Rotational Position Embedding (RoPE) component. Uniformly quantizing both leads to massive accuracy degradation.
  2. Quantization Scale Misalignment: On NVIDIA Hopper Tensor Cores, executing FP8 matrix multiplication (GEMM) requires a strict k-major layout constraint. Because the $V$ vector in MLA inherits per-token quantization scales along the reduction dimension, standard post-GEMM dequantization becomes mathematically unfeasible.
  3. System-Level Overheads: Fully unlocking FP8 requires minimizing memory access overhead and kernel launch latencies.

Methods

SnapMLA tackles these challenges through an algorithm-kernel co-optimization framework consisting of three main pillars:

  • RoPE-Aware Per-Token KV Quantization: Instead of quantizing everything, SnapMLA applies FP8 quantization exclusively to the latent content components while keeping the highly sensitive RoPE components in high-precision BF16. To avoid mixed-precision accumulation bottlenecks in the QK GEMM, the authors introduce Pre-Scaled Domain Alignment, which pre-scales the BF16 RoPE terms by the inverse of the content quantization scale, effectively "disguising" them as quantized values for uniform processing.
  • Quantized PV Computation Pipeline Reconstruction: To circumvent the layout mismatch, SnapMLA leverages the associative property of multiplication to fuse the quantization scale of $V$ directly into the attention probability matrix $P$ ($P' = P \odot S_V$). It then applies block-wise dynamic quantization to $P'$ and integrates the scaling factors into the online Softmax accumulation states for implicit dequantization.
  • End-to-End Dataflow Optimization: The framework introduces specialized atomic CUDA kernels (Fused-Q-Quant, Fused-K-Append, and Fused-Fetch-Dequant) to eliminate intermediate memory buffers. It also expands the tiling size along the content dimension from 64 to 128 to align perfectly with Hopper's 128-byte L2 cache lines and utilizes the Register File for zero-overhead data layout transformations.
Figure 2: Overview of the scale fusion pipeline in SnapMLA. Note that K and V content share the latent cache (cKV ). Key Step 1 illustrates RoPE-Aware Per-Token KV Quantization, where the BF16 RoPE part of the QK is pre-scaled with the quantization scale of the content part, thereby unifying the numerical domains of the quantized content part and unquantized RoPE part. Key Step 2 demonstrates Quantized PV Computation Pipeline Reconstruction, where the scale of V is pre-fused into the P, circumventing quantization dimension mismatch.

Datasets

The authors evaluated SnapMLA using state-of-the-art MLA-based models (DeepSeek-V3.1 and LongCat-Flash-Thinking) across a comprehensive suite of standard benchmarks:

  • General QA: MMLU-Pro, MMLU-Redux
  • Alignment: IFEval, Arena-Hard
  • Mathematical Reasoning: MATH-500, AIME-24, AIME-25, BeyondAIME
  • General Reasoning: GPQA-Diamond, ZebraLogic
  • Coding: LiveCodeBench (LCB), OJBench

Key Insights and Ideas

  • Divergent Quantization Sensitivity: The authors discovered that the RoPE component spans a significantly wider dynamic range ($\pm10^3$) with distinct outlier tails compared to the tightly concentrated content component ($\pm10^1$). Quantizing RoPE causes an order-of-magnitude increase in Mean Squared Error (MSE), justifying the mixed-precision approach.
Figure 3: Analysis of the numerical value distribution and quantization error comparison for the content and RoPE components of MLA KV cache in LongCat-Flash-Thinking.
  • Order Enforcement for Stability: Traditional FlashMLA uses an inverted execution order in its double-buffered pipeline to hide memory latency. However, in FP8, this creates a "scale hazard" where rescaling the accumulator disrupts the value distribution of already quantized matrices. Enforcing a strictly monotonic execution order resolves this instability without sacrificing performance, thanks to fine-tuned synchronization barriers.

Key Results

  • Throughput Gains: SnapMLA consistently outperforms the standard BF16 FlashMLA baseline across various tensor/data parallelism configurations and context lengths (from 16k to 128k), achieving up to a 1.91× speedup in end-to-end decoding throughput.
Figure 1: End-to-end decoding throughput comparison. We evaluate the generation throughput of SnapMLA on LongCat-Flash-Thinking and DeepSeek-V3.1 across various parallelization configura- tions and context lengths. For additional details please refer to Section 4.3.
  • Accuracy Preservation: As shown in the benchmark evaluation, SnapMLA maintains near-parity quality with the BF16 baseline, even slightly outperforming it on certain alignment and coding tasks due to the robustness of its per-token quantization strategy.
Table 1: Benchmark evaluation results across various task domains.

Limitations and Future Work

SnapMLA is heavily tailored to the architectural features of NVIDIA Hopper-class GPUs (leveraging specific instructions like WGMMA and TMA). Adapting these hardware-aware design principles to earlier GPU architectures or alternative accelerators (like AMD or Intel) would require significant, architecture-specific modifications. Additionally, the authors note that exploring more aggressive precision formats or alternative calibration policies for even longer context lengths remains an open area for future research.

Summary updated

BibTeX
@inproceedings{zhang2026snapmla,
  author = {Yifan Zhang and Zunhai Su and Shuhao Hu and Rui Yang and Wei Wu and Yulei Qian and Yuchen Xie and Xunliang Cai},
  title = {{SnapMLA: Efficient Long-Context MLA Decoding via Hardware-Aware FP8 Quantized Pipelining}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=vkrSWou03u},
}
Figure