LLMFolder: Revisiting Constant Folding in Large Language Models
Gansen Hu, Zhaoguo Wang, Wei Huang, Jinglin Wei, Haibo Chen
Abstract
Large language models (LLMs) demonstrate remarkable capabilities but face deployment challenges due to their massive parameter counts. While pruning can reduce model size, it leads to significant accuracy degradation under high compression ratios. We present a novel perspective inspired by constant folding in compiler optimization. Our approach enables parameter reduction by treating activation functions in LLMs as linear functions.
However, recent LLMs use complex non-linear activations like GELU that prevent direct application of this technique. We propose LLMFolder, which enables optimization of LLMs with non-linear activations by partially approximating them with linear functions in frequently occurring input ranges. For outlier inputs, LLMFolder employs an online predictor to dynamically fall back to original computations.
Our experiments demonstrate that LLMFolder achieves 80% parameter reduction in feed-forward networks, while significantly outperforming state-of-the-art pruning methods with up to 65% higher accuracy. When combined with quantization and pruning, LLMFolder can further achieve 92.5% parameter reduction with only 4.4% average accuracy drop for a 7B model, where neither technique alone or combination can achieve. In practical deployments for
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Builds on22
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra et al.NeurIPS 2022 · 5,493 citations
- PIQA: Reasoning about Physical Commonsense in Natural LanguageYonatan Bisk, Rowan Zellers, Ronan Le Bras, Jianfeng Gao et al.AAAI 2020 · 2,916 citations
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 citations
- Fast Inference from Transformers via Speculative DecodingYaniv Leviathan, Matan Kalman, Yossi MatiasICML 2023 · 1,472 citations
Related papers
- Learning Semi-Structured Sparsity for LLMs via Shared and Context-Aware HypernetworkLu Sun, Jun SakumaICLR 2026
- NLI : Non-uniform Linear Interpolation Approximation of Nonlinear Operations for Efficient LLMs InferenceJiangyong Yu, Xiaomeng Han, Xing Hu, Chen Xu et al.ICLR 2026 · 2 citations
- Beyond Linear Approximations: A Novel Pruning Approach for Attention MatrixYingyu Liang, Jiangxuan Long, Zhenmei Shi, Zhao Song et al.ICLR 2025
- A Simple Linear Patch Revives Layer-Pruned Large Language ModelsXinrui Chen, Haoli Bai, Tao Yuan, Ruikang Liu et al.NeurIPS 2025 · 7 citations
- Outlier Weighed Layerwise Sparsity (OWL): A Missing Secret Sauce for Pruning LLMs to High SparsityLu Yin, You Wu, Zhenyu Zhang, Cheng-Yu Hsieh et al.ICML 2024 · 183 citations
