TL;DR
Long-context Large Language Model (LLM) inference is severely bottlenecked by the memory footprint of the Key-Value (KV) cache. Standard channel pruning breaks the positional semantics of Rotary Position Embeddings (RoPE) by dropping individual channels from rotated pairs, leading to catastrophic accuracy collapse. RoPE-Aligned Pruning (RAP) solves this by pruning at the granularity of whole RoPE pairs, enabling 30% KV cache reduction with minimal accuracy loss and zero runtime reconstruction overhead.
What Problem Does This Paper Address?
To handle long text sequences, LLMs store past key and value states in a "KV cache" to avoid recomputing them at every step. At long contexts (e.g., 100K tokens), this cache grows massive, easily consuming tens of gigabytes of GPU memory.
One direct way to shrink the cache is structured pruning—dropping the least important channels in the projection weights ($W_k, W_v$). However, modern LLMs use Rotary Position Embeddings (RoPE), which injects positional information by rotating feature dimensions in pairs (2D blocks).
If a standard pruning algorithm drops an individual channel, it leaves its rotation partner "orphaned." This mismatch silently corrupts the model's positional understanding, causing accuracy to tank. While alternative low-rank decomposition methods preserve RoPE structure, they introduce a "reconstruction tax"—requiring the model to expand keys back to full dimensions on-the-fly at every single decoding step.
Methods
RAP introduces a weight-side structured pruning pipeline that respects RoPE pairing constraints by construction.
The method consists of four main steps:
- RoPE Pair Scoring: Instead of evaluating individual channels, RAP groups the columns of the key projection matrix ($W_k$) into RoPE-aligned pairs. It computes a saliency score for each pair using Fisher information gathered from a small calibration dataset. Channels in the value matrix ($W_v$) are scored individually since RoPE is not applied to the value path.
- Budget Allocation: RAP distributes the pruning budget using three principles: layer-adaptive (allocating more budget to highly sensitive early and late layers), head-uniform (keeping the same number of channels per head to allow batched matrix multiplications), and balanced K/V (splitting the budget equally between K and V).
- Pruning & Offline Fusion: RAP drops the lowest-scoring RoPE pairs from $W_k$ and channels from $W_v$. Crucially, because the pruning matrix is pair-preserving, it commutes with RoPE. This mathematical property allows the pruning transformation to be fused into the query projection matrix ($W_q$) offline. As a result, the query dimension shrinks to match the key dimension, making the entire decoding process completely reconstruction-free.
- Accuracy Recovery: The pruned model is fine-tuned using a lightweight Knowledge Distillation (KD) process with LoRA adapters (<1% of model parameters) to recover any lost accuracy.
Datasets
The authors evaluated RAP across several standard benchmarks:
- WikiText-2: Used for calibration during pruning, LoRA knowledge distillation, and evaluating language modeling perplexity (PPL).
- Zero-Shot Tasks: Six standard multiple-choice benchmarks (OpenBookQA, HellaSwag, PIQA, ARC-Easy, ARC-Challenge, WinoGrande) to test general knowledge.
- LongBench: A suite of long-context tasks (including TriviaQA, Qasper, TREC, SAMSum, and LCC) to evaluate performance on long-range dependencies.
Key Insights and Ideas
- The Silent Killer: The paper highlights that breaking RoPE pairs doesn't trigger runtime errors; the code executes perfectly fine, but the positional semantics are destroyed. Standard channel pruning (like KVPruner) breaks up to 77% of RoPE pairs at high compression ratios, explaining its severe performance collapse.
- Commutativity Matters: Low-rank methods fail to fuse offline because dense matrices do not commute with RoPE. RAP's binary, pair-preserving selection matrix does commute, which eliminates the need for per-step runtime reconstruction.
- Long-Wavelength Preference: When scoring pairs with Fisher information, RAP naturally tends to keep pairs with larger indices. In RoPE, these indices correspond to slower rotation frequencies (long wavelengths), proving that the model naturally prioritizes channels responsible for long-range context tracking.
Key Results
RAP was tested on Llama-3-8B, Mistral-7B, and Qwen2.5-14B models. At a practical operating point of 30% compression (retain ratio $\rho = 0.7$):
- Accuracy Preservation: RAP maintains near-baseline perplexity and zero-shot accuracy. On LongBench, RAP scores 51.4 on Llama-3-8B (vs. 60.0 for dense), whereas RoPE-blind channel pruning (KVPruner) collapses entirely to 3.4.
- True Compute Scaling: Unlike low-rank methods whose attention parameters and FLOPs remain high, RAP's compute and parameter costs scale linearly with the cache savings.
- Latency Reduction: RAP cuts attention-module prefill latency to 83% and decode latency to 77% of the dense baseline.
- Quantization Compatibility: RAP successfully composes with 4-bit weight quantization (RTN), showing that weight pruning and activation/weight quantization can be stacked effectively.
Limitations and Future Work
- Aggressive Compression Limits: At extreme compression ratios ($\rho = 0.5$), RAP's performance degrades more sharply than low-rank methods (like PaLU). This is because pruning discards dimensions entirely, whereas low-rank methods can still compress global information into a smaller latent space.
- RoPE Specificity: The pair-constraint logic is strictly tied to RoPE's 2D block-diagonal rotation structure. It provides no benefit for models using absolute position embeddings or ALiBi.
- Serving Infrastructure: While RAP reduces memory footprint, translating this directly into end-to-end serving throughput gains requires a custom, fully fused attention kernel that can handle non-contiguous RoPE indexing efficiently. The authors note this as an important direction for future engineering work.
Summary updated