arXiv(opens in a new tab)cs.CLAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.29058

RouteSparse: Input-Conditional Pattern Routing for Budgeted Long-Context Prefilling

Chao Zhang, Yifan Ji, Ziyan Zhang, Kai Song, Fei Lin

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Dynamic sparse attention can reduce the quadratic cost of long-context prefilling without changing model weights. MInference assigns each attention head one pattern offline and estimates that pattern's sparse indices for every prompt. This design is efficient, but it assumes that a head's preferred pattern and sparsity budget remain suitable across inputs. We introduce ROUTESPARSE, which routes each head and prompt segment among a small library of GPU-efficient sparse patterns. A low-cost probe estimates pattern utility and uncertainty; a latency-aware router then selects a pattern and budget, while uncertain cases fall back to a denser mask. We formulate routing as constrained risk minimization, derive an attention-output error certificate from omitted probability mass, and evaluate the method on long-context retrieval, question answering, summarization, and language modeling. On Llama 3.1-8B-Instruct with 128K-token prompts, ROUTES-PARSE achieves 6.5× dense prefill speed with a 0.2-point RULER drop relative to dense attention, compared with 7.3× speed and a 1.6-point drop for fixed per-head routing. Ablations confirm that input-conditional routing, hardware profiling, and selective dense fallback each contribute to the quality-latency tradeoff.

1 Introduction

Long-context language models enable document question answering, repository understanding, and retrieval over hundreds of thousands of tokens (Xiong et al., 2026). Their context windows, however, expose the quadratic cost of self-attention during prefilling, the phase that processes a prompt before the first token is generated. Existing models obtain longer windows through position interpolation and rescaling (Chen et al., 2023; Peng et al., 2024; Ding et al., 2024), or distribute exact blockwise attention across devices (Liu et al., 2024). These techniques expand capacity without

removing the per-device systems bottleneck. Even memory-efficient exact kernels such as FlashAttention and FlashAttention-2 (Dao et al., 2022; Dao, 2024) still compute every causal query-key pair. Consequently, time to first token can become the dominant user-visible cost (Fu, 2024).

Sparse attention avoids work by evaluating only selected pairs. Patterns such as local windows, global tokens, and strided connections are effective when incorporated during training (Child et al., 2019; Beltagy et al., 2020; Zaheer et al., 2020). Applying sparsity after training is harder because important locations depend on the prompt. Dynamic sparse attention (Liu et al., 2022) and query-aware key selection (Tang et al., 2024; Ribar et al., 2024) provide evidence that these locations can be approximated online. MInference (Jiang et al., 2024) addresses this problem with three GPU-efficient pattern families: A-shape, vertical-slash, and block-sparse attention. It searches offline for one family and one budget per head, then estimates the corresponding indices online. Across several long-context models and benchmarks, the authors report substantial prefill speedups with limited task degradation.

This approach separates a stable head-level pattern family from input-dependent indices. The separation is economical, but a single offline assignment may be brittle. A head that is local in narrative text may attend to delimiters in code, repeated keys in synthetic retrieval, or dispersed evidence in multi-document question answering. Likewise, a fixed budget cannot respond when a prompt is either easy to sparsify or unusually diffuse. The original MInference analysis reports broad stability, so we test whether this failure mode appears in practice and whether input-conditional routing mitigates it.

We present ROUTESPARSE, which preserves the kernel-friendly pattern library while making pattern and budget selection conditional on the current input. ROUTESPARSE uses a sampled attention probe to score candidate masks, estimates uncertainty from omitted attention mass, and solves a small per-layer routing problem under a measured latency budget. High-uncertainty heads receive a larger budget or dense fallback. Our contributions are:

  • We propose an input-conditional router over structured sparse kernels, with selection overhead included in the latency objective;

  • We design a computable certificate that upper-bounds attention-output error using omitted probability mass and value-vector norms; and

  • We perform an empirical evaluation that tests quality, latency, calibration, and robustness under domain and length shift, with preregistered ablations and stress tests.

References (12)