TL;DR
MPCache is a novel framework that slashes the massive latency and communication overhead of private LLM inference using Secure Multi-Party Computation (MPC). By combining "MPC-friendly" static pruning and dynamic token selection, it achieves up to a 2x speedup and an 8x reduction in communication while maintaining high model accuracy.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly deployed as services (MLaaS), but this raises a massive privacy red flag: users must upload sensitive prompts to the cloud. Secure Multi-Party Computation (MPC) offers a solution, allowing a user and a server to compute results jointly without ever seeing each other's private data (neither the prompt nor the model weights).
However, MPC is notoriously slow. The "Attention" mechanism in LLMs requires a Key-Value (KV) cache that grows linearly with the sequence length, causing communication costs to skyrocket. In a plaintext environment, we can simply "evict" (delete) unimportant tokens to speed things up. But in MPC, the operations used to decide which tokens to delete—like sorting (Top-$k$) or gathering specific data points—are computationally expensive and generate massive amounts of network traffic between parties. Ironically, standard eviction methods can actually make private inference slower than doing nothing at all.
Methods
To overcome these bottlenecks, the authors introduce MPCache, a framework specifically designed to navigate the constraints of MPC. It uses a hybrid two-step approach:
- Look-Once Static Eviction: During the initial "prefill" stage, the model identifies tokens that are globally unimportant (Unimportant-to-All or UIA tokens) and discards them once. This reduces the search space for all subsequent steps without requiring repeated, expensive communication.
- Query-Aware Dynamic Selection: For the remaining tokens, the model dynamically selects a small, highly relevant subset for each decoding step.
To make this dynamic selection "MPC-friendly," the authors implemented three key optimizations:
- Hierarchical Clustering: Instead of evaluating every single token, MPCache groups adjacent tokens into clusters. This drastically reduces the number of comparisons needed.
- Similarity Approximation: They replaced the MPC-unfriendly "Max" operation (typically used to find the most relevant cluster) with a clever linear approximation ($\alpha \cdot \text{max} + (1-\alpha) \cdot \text{min}$) that is much faster to compute in a secure setting.
- Cross-Layer Index Sharing: Observing that adjacent layers in a Transformer often look at the same tokens, MPCache computes the selection indices for one layer and reuses them for the next, cutting the selection overhead in half.
Datasets
The researchers evaluated MPCache across several challenging benchmarks for long-context LLMs:
- LongBench: A comprehensive suite for long-context understanding (including tasks like summarization and multi-hop QA).
- XSUM: A standard document summarization dataset.
- Needle-in-a-Haystack: A retrieval test designed to see if the model can find a specific piece of information buried in a massive context.
- Models Tested: LLaMA-2 (7B/13B), LongChat-7B, and LLaMA-3.1-8B.
Key Insights and Ideas
- The MPC Paradox: In standard computing, we care about FLOPs. In MPC, we care about rounds of communication and non-linear operations. A method that reduces FLOPs but adds a "Top-$k$" sort is a net loss for MPC efficiency.
- Attention is Sparse but Local: LLM attention maps are naturally sparse, but they also show "token-wise locality." This means if one token is important, its neighbors likely are too, justifying the use of token clustering.
- Static + Dynamic is the Sweet Spot: Static eviction handles the "bulk" pruning, while dynamic selection handles the "nuance" of specific queries. This hybrid approach provides the best balance of efficiency and accuracy.
- Linearization is King: By turning a "Max" search into a weighted sum of Max/Min values, the authors bypassed one of the biggest bottlenecks in secure computation.
Key Results
- Efficiency Gains: Compared to full-cache private inference, MPCache achieved a 1.8x to 2.01x reduction in latency and a staggering 3.39x to 8.37x reduction in communication overhead.
- Superiority over Baselines: MPCache outperformed existing plaintext eviction methods (like H2O and LongCache) when those methods were adapted for MPC. For example, on the NarrativeQA task, MPCache maintained high F1 scores while baselines saw significant performance drops at low KV cache budgets.
- Accuracy Preservation: Even when keeping only 5% to 10% of the KV cache, MPCache remained competitive with full-cache models, even on difficult retrieval tasks like "Needle-in-a-Haystack."
Limitations and Future Work
- Recall-Intensive Tasks: For certain tasks requiring perfect recall of every single token, static eviction might accidentally prune a critical piece of information.
- 2PC Bottlenecks: While highly effective for 3-party computation (3PC), the communication costs in 2-party computation (2PC) remain higher. The authors suggest exploring Random Projections (Johnson-Lindenstrauss Lemma) in future work to further compress the dimensionality of the KV cache in 2PC settings.
- Training-Free Constraint: MPCache is designed to be training-free for easy deployment. Future work could investigate if light fine-tuning could make models even more resilient to aggressive MPC-friendly pruning.
Summary updated