Accelerating Long-Context LLM Prefill via Layer-wise Progressive Token Pruning in Local Deployment

Zhongxiang Wei, Zhaohan Wang, Zhixiong Zhang, Jin Zhao, Xiaoming FuNeurIPS 2026

TL;DR

Running a Large Language Model (LLM) locally on a long document often comes with an agonizing pause before the first word appears—a bottleneck known as the "prefill" stage. FastPrefill breaks this bottleneck on consumer GPUs by progressively discarding unimportant tokens layer-by-layer using a mathematically optimized schedule and custom sparse GPU kernels. It delivers up to a 2.13× faster Time-to-First-Token and 3.03× faster end-to-end generation over state-of-the-art baselines without degrading answer quality.

What Problem Does This Paper Address?

Picture yourself feeding a 30,000-word PDF into a local LLM running on a single consumer GPU (like an RTX 4090) for privacy. Before generating a single word, the model must read the entire prompt in one massive parallel sweep called the prefill stage, which dictates your Time-to-First-Token (TTFT).

Why haven't existing tricks solved this for local setups?

  1. Sparse attention isn't enough: Many methods only speed up the attention mechanism. However, on memory-bound consumer GPUs, the Feed-Forward Network (FFN)—the dense layers after attention—takes up roughly half the prefill time!
Figure 1: Latency contribution of Attention vs. FFN across dif- ferent prompt lengths.
  1. Helper models lose nuance: Using a tiny "assistant" model to trim the prompt beforehand saves memory, but small models frequently throw away the wrong words.
  2. Hand-crafted pruning backfires later: Dropping tokens layer-by-layer reduces both attention and FFN work. Yet existing methods guess how much to prune using rigid rules, forcing them to fetch dropped tokens back from CPU memory during generation—creating massive traffic jams.

The authors ask: Can we permanently prune tokens layer-by-layer—with zero recovery overhead—without ruining the model's intelligence?

Methods

FastPrefill pairs an offline search algorithm with a custom runtime engine:

Figure 4: The workflow of offline opti- mization and online attention workflow in FastPrefill.
  • Offline Data-Driven Optimizer: Deciding what percentage of tokens to drop at each of an LLM's 32+ layers is tricky because early cuts affect later layers, and testing candidates with full LLM runs takes forever. FastPrefill builds a fast mathematical stand-in (surrogate objective): it tracks accumulated attention scores on a small calibration set to estimate "lost importance" alongside theoretical FLOPs for speed. Using an evolutionary algorithm (CMA-ES), it finds an optimal pruning schedule for a given speed budget in ~60 seconds.
  • Head-Specific Token Selection: Different attention heads look for different things. FastPrefill lets each Key-Value (KV) head choose its own top tokens—measured cheaply using only a tiny window of recent queries rather than materializing memory-crushing full attention matrices—while sharing a unified set of important Query tokens across heads.
Figure 2: QKV token retention patterns in a layer (50% spar- sity). Red indicates retained po- sitions.
  • Boundary-Aware Sparse Kernel & Path Selection: Standard GPU kernels (like FlashAttention) can't skip irregularly pruned tokens. FastPrefill physically packs surviving KV tokens into contiguous memory and uses a custom GPU kernel with binary search to process only causally valid blocks. Because compaction adds overhead on short prompts or tiny pruning ratios, a lightweight polynomial model predicts latency on the fly and switches between standard dense attention and the sparse path.

Datasets

No new benchmarks were introduced; the authors evaluated and calibrated across five established long-context benchmarks:

  • LongBench: Real-world tasks across six categories (QA, summarization, code, etc.). 390 samples were held out for offline calibration, and the rest used for testing.
  • RULER: A synthetic benchmark extending "needle-in-a-haystack" tests with multi-hop tracking and aggregation (4K to 32K tokens).
  • L-Eval, BookSum, and Tau2: Used as out-of-distribution calibration sets to test whether schedules learned on one domain generalize to others.

Key Insights and Ideas

  • FFNs are the silent killer—and biggest prize: Because token pruning shrinks the sequence fed into dense FFN matrix multiplications, FFN reduction actually accounts for 50.6% to 65.0% of FastPrefill's total latency savings!
  • Less can be more: On Multi-Document QA and synthetic tasks, FastPrefill slightly outperformed the unpruned model, likely because stripping out noisy tokens helps later layers focus on relevant signal.
  • Smart schedules eliminate "token regret": Replacing FastPrefill's learned schedule with a hand-crafted exponential curve caused the sharpest accuracy drop in ablations. Getting the layer-wise schedule right upfront removes the need to ever recover dropped tokens during decoding.

Key Results

Tested on Llama3.1-8B-Instruct and Qwen2.5-7B-Instruct on a single RTX 4090 against seven baselines (including MInference, DuoAttention, SpecPrefill, and SlimInfer):

  • Speedup: Achieves up to 2.13× TTFT speedup and 3.03× end-to-end speedup (generating 32 tokens) over state-of-the-art baselines. Unlike recovery-based SlimInfer, FastPrefill's end-to-end advantage holds steady during text generation.
  • Quality: At a 0.5 latency target on Llama3.1-8B, FastPrefill scores 51.47 on LongBench—virtually identical to the unpruned model's 51.56, while crushing prompt-compression baselines like LLMLingua (45.76). On RULER at 32K context, it scores 81.98 vs. the original's 81.66.
  • Domain Robustness: Schedules calibrated on completely different datasets (BookSum, Tau2, L-Eval) retained 97.8%–99.0% of the LongBench-calibrated score.

Limitations and Future Work

  • Struggles with diffuse information: Tasks where every word matters equally—like full-document Summarization (dropping from 26.18 to 23.48 on Llama3.1-8B) and Aggregation/Counting on RULER—suffer noticeable accuracy drops when low-attention tokens are pruned.
  • Fixed speed budgets per deployment: Users currently pick a fixed target latency ratio (e.g., $\alpha = 0.5$) offline. Automatically adapting the pruning aggressiveness per query (e.g., backing off when a user asks for a summary) is left for future work, alongside integrating the kernels into production engines like vLLM and SGLang.

Summary updated

Abstract

Long-context inference is increasingly important for privacy-sensitive local LLM deployment. In this setting, the prefill stage dominates Time-to-First-Token (TTFT), yet existing acceleration methods struggle to balance speed and quality. Sparse-attention methods accelerate only the attention module, leaving Feed-Forward Network (FFN) costs unchanged, while auxiliary-model-based compression often compromises quality under tight memory budgets. Recent layer-wise token pruning methods reduce both attention and FFN computation, but they typically rely on heuristic pruning schedules or token-recovery mechanisms that introduce decoding overhead. We propose FastPrefill, a recovery-free layer-wise token pruning system for efficient local long-prompt inference. FastPrefill employs an offline data-driven optimizer to determine layer-wise pruning schedules that maximize fidelity under a latency constraint, and executes these schedules via an algorithm–system co-design supporting head-specific sparse attention at runtime, where each head dynamically attends to its own selected key/value tokens. Evaluations on LongBench and RULER show that FastPrefill maintains comparable inference quality while achieving up to 2.13x TTFT speedup and 3.03x end-to-end speedup over state-of-the-art baselines.
BibTeX
@inproceedings{wei2026accelerating,
  author = {Zhongxiang Wei and Zhaohan Wang and Zhixiong Zhang and Jin Zhao and Xiaoming Fu},
  title = {{Accelerating Long-Context LLM Prefill via Layer-wise Progressive Token Pruning in Local Deployment}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=AEnl58AdSd},
}

Loading related content...

Figure