Runtime Adaptive Pruning for LLM Inference

Huanrong Liu, Chunlin Tian, Xuyang Wei, Qingbiao Li · Submission to ICLR 2026 · Rejected

TL;DR

Researchers have introduced RAP (Runtime-Adaptive Pruning), a framework that uses reinforcement learning to dynamically prune Large Language Models (LLMs) during inference. Unlike static methods that apply a fixed compression ratio, RAP adjusts the model's size on the fly based on real-time memory availability and the specific demands of a user's request (like batch size and sequence length), jointly optimizing both model weights and the memory-intensive KV cache.

What Problem Does This Paper Address?

Deploying LLMs on edge devices or shared cloud environments is a nightmare because memory demands are a moving target. There are two main culprits for this "runtime variance":

  1. Input-driven variance: In autoregressive inference, the Key-Value (KV) cache grows linearly with batch size and sequence length. For a model like Llama-7B, a large batch can require 32GB of KV cache—dwarfing the 14GB needed for the model parameters themselves.
  2. System-level variance: On mobile or edge devices, available memory fluctuates as other applications open and close.

Existing pruning methods are "static"—they prune the model once and call it a day. This is inefficient: if you have plenty of memory, you’re using a degraded model for no reason; if memory is tight, the model might crash (Out-of-Memory). Furthermore, most methods focus only on weights, ignoring the massive dynamic footprint of the KV cache.

Methods

RAP treats pruning as a sequential decision-making problem solved by a Reinforcement Learning (RL) agent. The framework consists of two main stages:

  • Greedy Sequential Importance (GSI): Before deployment, the authors use GSI to rank the importance of different transformer blocks (MHA and FFN). Unlike "one-shot" methods that look at blocks in isolation, GSI removes blocks iteratively and re-evaluates the model. This accounts for the complex inter-dependencies between layers, preventing a "cascade of errors" that often happens when you prune too aggressively.
  • The RL-Guided Controller: At runtime, a lightweight RL agent (a simple 2-layer MLP) observes the "Execution State"—which includes the current batch size, sequence length, and available system memory. The agent then selects a pruning policy from the GSI rankings to fit the current memory budget while maximizing "utility" (a balance of low perplexity and high memory savings).

By choosing which Multi-Head Attention (MHA) or Feed-Forward Network (FFN) blocks to drop for each specific request, RAP ensures the model always fits in memory while staying as "smart" as possible.

Datasets

The authors evaluated RAP across several popular LLM families, including Llama2-7B, Llama3-8B, Qwen1.5-7B, and Qwen2.5-7B.

To measure performance, they used:

  • Language Modeling: WikiText2 and Penn Treebank (PTB) to measure perplexity.
  • Commonsense Reasoning: A suite of zero-shot benchmarks including BoolQ, PIQA, HellaSwag, WinoGrande, ARC (easy and challenge), and OpenbookQA.
  • Calibration: The Alpaca dataset was used for the GSI importance scoring.

Key Insights and Ideas

  • The Asymmetric Strategy: The RL agent learned a clever trick: when the KV cache is the bottleneck (long sequences), it prioritizes pruning MHA blocks. When static parameters are the bottleneck, it targets the FFN blocks. This "architectural awareness" allows it to navigate trade-offs that static heuristics miss.
  • One-Shot is a Lie: The paper demonstrates that one-shot pruning scores are "misleadingly optimistic." Because layers in a transformer are deeply coupled, removing one block changes the importance of all others. RAP’s iterative GSI approach is crucial for maintaining accuracy under high compression.
  • Negligible Overhead: Despite the complexity of RL, the controller is tiny (only 18K parameters). It adds less than 1% latency overhead to the inference process, making it highly practical for real-world deployment.

Key Results

RAP consistently outperformed state-of-the-art baselines like LLMPruner, ShortGPT, and SliceGPT:

  • Accuracy Retention: Under an 80% memory budget, RAP preserved 86% of the dense model's accuracy on Llama2-7B, outperforming the next best baseline by 7.7%.
  • Resilience under Pressure: Under a harsh 60% memory budget, RAP was the only method to retain over 50% of the original model's performance. Most other methods saw their perplexity explode (indicating the model became incoherent).
  • Generalization: The results held steady across different model architectures (Llama vs. Qwen), proving that the strategy is backbone-agnostic.

Limitations and Future Work

While promising, the authors note a few hurdles:

  • Calibration Dependence: The GSI process requires a representative calibration dataset (like Alpaca). If the model is deployed in a very niche domain not covered by the calibration set, the importance rankings might be off.
  • Training Time: The offline RL training stage takes several hundred GPU seconds. While this is a one-time cost, it does require tuning for new hardware profiles.
  • State Representation: Currently, the RL agent only looks at batch size, sequence length, and memory. The authors suggest that future versions could incorporate latency and energy consumption to provide a more holistic optimization for mobile devices.

Summary updated

BibTeX
@misc{liu2025runtime,
  author = {Huanrong Liu and Chunlin Tian and Xuyang Wei and Qingbiao Li and Li Li},
  title = {{Runtime Adaptive Pruning for LLM Inference}},
  year = {2025},
  eprint = {2505.17138},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.17138},
}
Figure