LAPrune: Logits-Aligned Scoring Proxy for KV Pruning via Vector Quantization

Mingyang Yu, Rong-Cheng Tu, Yifu Ding, Hanqing Zhao, Yongcheng Jing, Xiao Luo, Dacheng TaoNeurIPS 2026

TL;DR

When Large Language Models (LLMs) generate text over massive documents, their memory traffic grinds to a halt because every new word has to check every previous word in the context. LAPrune speeds this up by using a classic compression trick—Additive Vector Quantization—to turn heavy vector math into ultra-fast table lookups, letting the model cherry-pick only the most relevant past tokens on the fly. Without needing any model fine-tuning, it doubles generation speed at a 128K context length while keeping accuracy remarkably close to full, unpruned attention.

What Problem Does This Paper Address?

Imagine writing a sequel to a 500-page novel, and for every single word you type, you pause to re-read the entire manuscript from page one. That is essentially what an LLM does during autoregressive decoding. To avoid recomputing past states, models store past tokens in a KV (Key-Value) cache. As the context grows to 128,000 tokens or more, hauling this massive cache from GPU memory to the compute cores for every new token becomes a brutal bandwidth bottleneck.

KV cache pruning solves this by only attending to the top-$k$ most important cached tokens at each step. The catch? Knowing which tokens have the highest attention scores (query-key dot products, $q^\top k$) normally requires computing all those dot products in the first place!

To dodge this paradox, researchers use lightweight "scoring proxies," which currently fall into two flawed camps:

  1. Static heuristics: Evicting tokens based on past attention habits. This is fast, but blind to what the current query actually needs.
  2. Hashing-based retrieval: Compressing queries and keys into binary codes and ranking them via Hamming distance (counting matching bits). While dynamic, Hamming space doesn't naturally align with inner-product space—meaning a token that looks close in binary might actually have a mediocre attention score, causing the model to drop crucial context.
Figure 1: Motivation of LAPrune. (Left) LLM attention exhibits dynamic, query-dependent sparsity. (Center) Hashing-based retrieval fails due to the misalignment of space (selecting k3 and k6 instead of k4 and k5). (Right) LAPrune maintains high fidelity by operating directly in the native feature space.

Methods

Instead of inventing a surrogate distance metric, the authors ask: can we approximate the exact inner product directly, using almost no memory bandwidth?

Their answer is LAPrune, which repurposes Additive Quantization (AQ). While vector quantization is usually used in LLMs just to shrink memory footprints, LAPrune uses it as a high-speed computational proxy for token selection:

  • Additive Key Decomposition: Every cached key vector $k_i$ is approximated as the sum of $M$ learned "codewords" ($k_i \approx \sum_{m=1}^M c_{m,i}$), each chosen from a small codebook of $C$ vectors (by default, $M=32$ codebooks of $C=256$ entries). Each key's proxy index takes just 32 bytes.
  • Lookup-and-Add Scoring: Because dot products distribute over addition ($q^\top k_i \approx \sum_{m=1}^M q^\top c_{m,i}$), a new query $q$ only needs to compute dot products against the codebook entries once per step, storing the results in a tiny Lookup Table (LUT). Scoring all 128,000 cached tokens is then reduced to fetching 32 numbers per token from the LUT and adding them up!
  • Gradient-Free Calibration & CUDA Kernels: Rather than expensive end-to-end training, codebooks are calibrated offline using whitened key vectors, KMeans++, and closed-form least-squares updates. The authors also build custom fused CUDA kernels to make encoding and LUT lookups blazingly fast.
Figure 2: LAPrune Framework Overview. (Left) Key Approximation: AQ-based decomposition via iterative residual fitting. (Top-Right) Dynamic Pruning: Query-level token selection for sparse attention. (Bottom-Right) LUT Optimization: Scoring via lookup-and-add operations.

Datasets

No new benchmarks were introduced; instead, LAPrune was tested across standard calibration and long-context suites:

  • Calibration: Small 4K-token windows sampled from ArXiv and Book datasets (plus ProofPile for sensitivity ablations).
  • Language Modeling (Perplexity): PG19 (long books), ProofPile (math), and CodeParrot (code).
  • Long-Context Retrieval & Downstream Tasks: Custom offline Needle-In-A-Haystack (NIAH) (1K–8K context), seven tasks from LongBench (QA, summarization, classification, code completion), and four retrieval tasks from RULER evaluated at a massive 128K context.

Key Insights and Ideas

  • Quantize Post-RoPE Keys via Superposition: Modern LLMs inject position info via Rotary Position Embeddings (RoPE). Quantizing before RoPE forces you to re-apply rotations to the entire cache at every step ($O(N)$ overhead). Quantizing after RoPE avoids this, though rotations twist the data manifold in tricky ways. Unlike rigid Product Quantization (PQ), AQ sums full-dimensional codewords, flexibly capturing these rotated shapes (achieving 0.65 selection overlap vs. PQ's 0.50).
  • Sharing Codebooks Beats Going Solo: Sharing a single set of codebooks across all attention heads in a layer actually yields more uniform accuracy than giving each head its own codebook. Pooling keys across heads gives the calibration step a richer, more stable statistical distribution while saving memory.
  • Domain-Agnostic Calibration: Calibrating codebooks on math (ProofPile) vs. general text (Books + ArXiv) yields virtually identical code perplexity (5.375 vs. 5.370), showing AQ captures fundamental geometric structures of the model's key space rather than memorizing domain quirks.

Key Results

Tested across LLaMA-2 (7B, 13B), LLaMA-3-8B, LLaMA-3.1-8B-Instruct, and Qwen-2.5-7B, LAPrune shines under an extreme 98% pruning budget (attending to only 2% of cached tokens!):

  • Selection Fidelity: On LLaMA2-7B at 98% pruning, LAPrune recovers 0.65 IoU (overlap with exact-attention top-$k$ tokens), beating MLP-based hashing baseline Spotlight (0.42 IoU).
  • Stability Under Extreme Pruning: At 98% pruning on LLaMA3-8B, block-based Quest suffers a perplexity explosion (27.51 on PG19) and LSH-based MagicPIG collapses into NaNs, whereas LAPrune holds steady at 8.89—nearly identical to exact Oracle top-$k$ (8.88).
  • 128K Retrieval: On RULER (128K context, 98% pruned), LAPrune scores 0.850, matching exact Oracle top-$k$ (0.850) and outperforming Spotlight (0.778) and MagicPIG (0.355).
  • Real-World Speedups: At 128K context on an RTX PRO 6000D, LAPrune delivers 2.07×, 3.27×, and 4.41× decoding speedups over FlashAttention-2 at batch sizes 1, 2, and 4. Prefill overhead is just ~3.8%, and peak GPU memory increases by a negligible 0.18% (0.081 GiB).

Limitations and Future Work

While the authors do not include a dedicated "Limitations" section in the main text, a few practical trade-offs are evident from their design:

  • No Memory Compression: Because LAPrune keeps the original KV cache in VRAM and only uses AQ indices as a selection filter to save bandwidth during decoding, it adds a small persistent memory overhead (~3.61% / 1.1 GiB at 128K context) rather than shrinking total VRAM capacity.
  • Upfront Prefill Cost: Encoding keys into AQ indices adds ~3.8% latency to the initial prefill phase—a worthwhile investment for long generations, though less impactful if only generating a handful of tokens.

Looking ahead, the authors highlight objective-aligned pruning proxies—designing compressed representations that mathematically mirror native attention operations—as a rich avenue for accelerating next-generation long-context inference.

Summary updated

Abstract

Long-context inference in Large Language Models (LLMs) suffers from high latency because attention computation and memory traffic scale linearly during decoding. KV cache pruning reduces this cost by retaining only a subset of cached tokens, but its effectiveness depends on whether the pruning proxy can recover the tokens with the largest exact attention logits under the current query. Existing proxies suffer from ranking misalignment: static heuristics rely on historical statistics and thus ignore the current query, while hashing-based retrieval proxies rank candidates in a discrete metric space that does not coincide with attention's inner product. To avoid these problems, we propose LAPrune, a KV pruning framework that uses additive vector quantization to build an efficient attention-logit-aligned proxy. LAPrune represents each cached key as a sum of learned codewords and decomposes the query-key dot product into lookup-and-add operations over query-codeword inner products. This replaces high-dimensional dot products with lightweight scalar lookups while preserving fidelity to the original attention ranking. LAPrune requires no base-model finetuning and can be integrated into long-context decoding with minimal modification. Across long-context evaluations, LAPrune improves exact-logit Top-$k$ recovery and perplexity over hashing-based pruning proxies, achieving a $2.07\times$ decoding speedup over FlashAttention-2 at 128K context with batch size 1.
BibTeX
@inproceedings{yu2026laprune,
  author = {Mingyang Yu and Rong-Cheng Tu and Yifu Ding and Hanqing Zhao and Yongcheng Jing and Xiao Luo and Dacheng Tao},
  title = {{LAPrune: Logits-Aligned Scoring Proxy for KV Pruning via Vector Quantization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=YCnekVg1si},
}
Figure