Computer Science > Machine Learning
Title:MLP Cache: A Post-Hoc Memory-Compute Trade-off for Transformer Inference
Abstract:MLPs impose substantial inference cost in Transformers by applying a full, high-capacity transformation to every token. Deployed workloads revisit recurring regions of the MLP input space, which creates an opportunity for compute reuse beyond exact-match caching. We introduce MLP Cache, a post-hoc cache that stores compact local predictors of a frozen MLP without retraining the backbone. The central challenge is to allocate limited memory across region scale and predictor capacity: broader regions cover more inputs but may require larger predictors, while finer regions are easier to approximate but require more entries. MLP Cache constructs a coarse-to-fine hierarchy using shared graph-spectral coordinates, whose signs define candidate regions and whose continuous values provide features for region-specific predictors. Tree dynamic programming selects region-predictor pairs to maximize workload coverage under memory and approximation-error budgets. On frozen Qwen3.5-9B, MLP Cache replaces 24-28% of MLP calls in the cached layers on MME-Coarse and MMStar-Coarse. A cached layer saves time when its hit rate times the time one hit saves exceeds its fixed cost of routing and lookup, so the gain is largest in batch-one decoding, where a hit skips the layer's weight reads. At batch one on an Apple M5 Pro, a cache that holds 1.2 GiB in memory makes decoding 1.20x faster with a 0.56-point change in MME-Coarse accuracy, and one that holds about 8 GiB makes it 1.38x faster at a cost of about 3 points; with this larger cache, decoding stays faster up to batch 8. On an A100, batch-one decoding is 1.09-1.15x faster against a baseline that runs each decode step as one CUDA graph. A controlled single-MLP benchmark shows that the gain grows with the size of the MLP. Project page: this https URL
| Comments: | 65 pages, 24 figures, 41 tables. Project page: this https URL Code: this https URL |
|---|---|
| Subjects: | Machine Learning (cs.LG) ; Artificial Intelligence (cs.AI) |
| Cite as: | arXiv:2612.02874 [cs.LG] |
| (or arXiv:2612.02874v1 [cs.LG] for this version) | |
| https://doi.org/10.48550/arXiv.2612.02874 arXiv-issued DOI via DataCite (pending registration) |
Submission history
Access Paper:
- HTML (experimental)
Additional Features
- Audio Summary
Current browse context:
References & Citations
- Google Scholar
- Semantic Scholar
BibTeX formatted citation
Bookmark
Bibliographic and Citation Tools
Code, Data and Media Associated with this Article
Demos
Recommenders and Search Tools
arXivLabs: experimental projects with community collaborators
arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.
Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.
Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.