Manuscript Offprint

arXiv:2609.07306

RouteRelay: Event-Triggered Cross-Layer Route Reuse for Efficient Dynamic Sparse Attention

Bin Li, Sisi Liu, Chenyang Hu, Chaoyang Zhang, Wei Li, Hui Song

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

Abstract

Dynamic sparse attention reduces long-context prefill cost by routing each query chunk to a small set of key chunks at every Transformer layer. The sparse attention kernel avoids most token interactions, but the router still rebuilds a chunk–chunk score matrix layer after layer, even when the selected routes change little. We introduce RouteRelay, a router-agnostic method that reuses only route metadata across depth while continuing to compute attention with the current layer’s queries, keys, and values. Anchor layers perform full routing. Intermediate layers rescore the previous top-kk route and a compact sentinel set of near-miss and randomly probed chunks. A query row is rerouted only when a sentinel challenges its weakest selected chunk. We give a top-kk stability condition, a probabilistic bound on missed challengers, and a row-selective GPU execution design. In a reproducible empirical evaluation, RouteRelay retains at least 99.99% route recall while rerouting 25.0%, 55.4%, and 78.2% of rows under low, moderate, and high cross-layer drift, respectively. Across routing scales, RouteRelay retains 100.0% recall while evaluating 38.4–51.6% of full-routing score pairs as the key-chunk count grows from 128 to 1024. Its unfused CPU execution remains slower than dense matrix multiplication, exposing row compaction and ledger updates as the main kernel-engineering targets.

1 Introduction

Long-context language models enable reasoning over books, repositories, multi-document evidence, and extended conversations. Their prompt-processing cost remains dominated by causal self-attention, whose dense computation grows quadratically with sequence length. Exact IO-aware kernels reduce memory traffic (Dao et al., 2022; Dao, 2024), while sparse attention avoids selected query-key interactions entirely (Child et al., 2019; Beltagy et al., 2020; Zaheer et al., 2020).

Post-hoc dynamic sparsity is especially attractive because it can accelerate a frozen pretrained model. MInference selects structured sparse patterns and determines their indices online (Jiang et al., 2024). DHSA is one prior system that partitions a sequence into content-aware chunks, scores query-key chunk pairs, and expands the highest-ranked chunks into exact token interactions (Xiong et al.). Such flexible routes preserve more attention mass than fixed block grids, but flexibility has a systems cost: routing is repeated throughout the network.

This repetition is potentially wasteful. Neighboring Transformer layers operate on different representations, yet they process the same token positions and often preserve the same broad semantic dependencies. Reusing an entire attention output would alter the model computation. Reusing only a sparse index set is less invasive: every layer still evaluates its own queries against its own keys and values, but it can skip rebuilding a complete chunk score matrix when the prior route remains valid.

We propose RouteRelay, an event-triggered layer for dynamic sparse routers. At an anchor layer, it stores each query row’s selected chunks, its closest unselected competitors, and a small random sentinel sample. At an intermediate layer, it scores only this compact candidate set. If every selected chunk remains above every sentinel, the previous route is relayed forward. Otherwise, only the unstable row executes a full route refresh. Figure 1 illustrates the resulting separation between route maintenance and attention computation.

Our contributions are:

  • Route-only cross-layer reuse. We amortize dynamic sparse routing without sharing KV states, attention probabilities, or outputs across layers.

  • Event-triggered partial refresh. Near-miss and random sentinels detect route instability,

enabling row-level refresh instead of a fixed refresh stride.

  • Stability and miss analysis. We state a sufficient top-kk margin condition and bound the probability that random sentinels miss multiple newly competitive chunks.

  • Measured evaluation. Cross-layer drift, sentinel-ablation, and routing-scale experiments quantify route fidelity, refreshed-row fraction, score-pair reduction, and CPU latency.

References (11)