Grafy News
Try Grafy free

New MLP Cache method trades memory for faster Transformer inference

Researchers have introduced MLP Cache, a post-hoc method to speed up Transformer inference by storing compact predictors for recurring activation regions.

Illustration for the news story: New MLP Cache method trades memory for faster Transformer inferenceSource: Grafy Research Lab

Researchers have developed a method called MLP Cache that can significantly accelerate Transformer inference by replacing expensive computations with compact, stored predictors. This approach addresses the high cost of Multi-Layer Perceptron (MLP) layers by identifying and caching recurring patterns in the model's input space.

How does MLP Cache optimize Transformer inference?

In standard Transformer architectures, MLP layers apply a high-capacity transformation to every single token processed. According to the research paper by Yang et al., this imposes a substantial computational burden. However, in real-world deployments, models often encounter recurring patterns, such as common visual backgrounds in multimodal tasks or repetitive prompt structures in text.

MLP Cache leverages this "deployment locality" by storing small, local functions that approximate the behavior of the full, frozen MLP within specific regions of the activation space. Figure 1 illustrates this concept: instead of running the full-capacity function for every input, the system looks up a saved local function for recurring inputs. Figure 2 shows that these cache entries store local functions over specific "trust regions" of the activation space. This allows the system to trade memory for compute, skipping the heavy weight reads and mathematical operations of the original layer when a cache hit occurs.

Figure 2: Cache entries store local functions over trust regions.
Figure 2. Cache entries store local functions over trust regions. Figure 2 of “MLP Cache: A Post-Hoc Memory-Compute Trade-off for Transformer Inference” by Huzheng Yang, Yiqiao Huang, Qingqiao Hu et al. (arXiv.org), CC BY-SA 4.0.
Figure 1: A standard MLP use full-capacity function for every input, MLP Cache lookup a saved local function for recurring inputs, thus trade memory for compute. Cache hi…
Figure 1. A standard MLP use full-capacity function for every input, MLP Cache lookup a saved local function for recurring inputs, thus trade memory for compute. Cache hits appear on recurring image background and question-option templates, non-recurring question content don’t use cache. Figure 1 of “MLP Cache: A Post-Hoc Memory-Compute Trade-off for Transformer Inference” by Huzheng Yang, Yiqiao Huang, Qingqiao Hu et al. (arXiv.org), CC BY-SA 4.0.

What is the trade-off between memory and compute?

The effectiveness of the system depends on how limited memory is allocated between the scale of the regions and the capacity of the predictors. The researchers describe a central challenge: broader regions can cover more inputs but require more complex, larger predictors to maintain accuracy. Conversely, finer, smaller regions are easier to approximate with simple predictors but require more individual entries, consuming more memory.

To solve this, the authors use a coarse-to-fine hierarchy based on graph-spectral coordinates. These coordinates serve a dual purpose: their continuous values act as features for the predictors, while their signs define the boundaries of candidate regions. The system uses tree dynamic programming to select the optimal combination of region scale and predictor capacity to maximize workload coverage while staying within predefined memory and error budgets.

What are the performance gains in practice?

The researchers tested the method on a frozen Qwen3.5-9B model. According to the study, MLP Cache replaced between 24% and 28% of MLP calls in the cached layers during testing on MME-Coarse and MMStar-Coarse benchmarks.

The speed improvements vary depending on the hardware and the batch size. On an Apple M5 Pro, a cache utilizing 1.2 GiB of memory resulted in a 1.20\times speedup for batch-one decoding, with a minor 0.56-point change in MME-Coarse accuracy. Increasing the cache to approximately 8 GiB improved the speedup to 1.38\times and maintained this advantage even up to batch 8. On an A100 GPU, the method achieved a 1.09\times to 1.15\times speedup for batch-one decoding compared to a baseline using CUDA graphs. The researchers noted that the benefits are most pronounced during batch-one decoding because a cache hit allows the system to skip the time-consuming process of reading the layer's weights from memory.

Can this method be applied to existing models?

A significant advantage of MLP Cache is that it is a "post-hoc" method. This means it can be applied to a model that is already trained and frozen. Unlike other learned-memory systems that require the model to be retrained to allocate memory, MLP Cache works by observing the serving workload and deciding which parts of the existing MLP are worth materializing in memory. This makes it highly adaptable to specific deployment scenarios where the distribution of inputs is known or can be sampled.

How can researchers explore these concepts?

While MLP Cache is a specialized optimization for model deployment and inference engines, the underlying concepts of activation patterns and model behavior are central to AI research. Researchers looking to dive deeper into the technical nuances of Transformer architectures or the specific papers mentioned in this study can use Grafy Reader to upload and query the original arXiv PDFs, allowing for a structured exploration of the mathematical proofs and experimental data provided by the authors.

Frequently asked questions

Does MLP Cache require retraining the model?

No, MLP Cache is designed as a post-hoc optimization for frozen models. It does not require retraining the backbone Transformer. Instead, it builds a cache of local predictors that approximate the existing, frozen MLP layers based on the specific workloads the model encounters during deployment.

Why is the speedup most significant at batch one?

At batch one, the primary bottleneck is often the time taken to read large weight matrices from memory. When a cache hit occurs, the system can skip the heavy weight reads of the MLP layer entirely, using the much smaller, compact predictor instead. This provides a more dramatic reduction in latency compared to larger batches where compute might be more saturated.

What determines the accuracy of the cache?

Accuracy is determined by the relationship between the region scale and the predictor capacity. If a region is too broad, the predictor may struggle to approximate the complex MLP function accurately. If the predictor is too small, it cannot capture the necessary variation. The system manages this through a budget-driven selection process that balances error against memory usage.


Source: Grafy Research Lab — MLP Cache: A Post-Hoc Memory-Compute Trade-off for Transformer Inference