Manuscript Offprint

arXiv:2610.37645

Multi-State Linear Attention with Generalized Second-Order Routing

Hee Seung Hwang, Sanghyuk Chun, Xindi Wu, Olga Russakovsky, Zhiwei Deng

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

ABSTRACT

Self-attention plays a key role in long-sequence modeling, but its quadratic time complexity fundamentally limits the scaling of Large Language Models. Recently, Multi-State Linear Attention (MSLA) mechanisms have been proposed to make sequence modeling more efficient by splitting the context into segments and compressing each in its own memory state. MSLA aggregates the information extracted from each memory state using only the mean alignment between a query and each segment's keys, ignoring how the alignment is distributed within the segment. In order to model the relevance of a segment to a query more comprehensively and incorporate the variance of the alignment in the aggregation, we propose MERLIN (MomEnt Routing for multi-state LINear attention), a method that tracks the first and second moments of each segment's keys. Using the moments of keys, a query can recover both the mean and the variance of its alignment with each segment to perform a more content-aware aggregation of per-state readouts. Experiments on multi-state variants of Gated DeltaNet-1.3B and Mamba-2-780M show that MERLIN consistently outperforms existing aggregation methods on various long-context tasks. In particular, MERLIN outperforms baselines on RULER needle-in-a-haystack and long-context QA (+8.3% for Gated DeltaNet-1.3B and +7.0% for Mamba-2-780M) and diverse subtasks in LongBench (+13.5% and +12.0%). It even outperforms baselines that consume 4x more memory. MERLIN provides a simple and general routing mechanism for improving long-context capabilities of MSLA models.

1 INTRODUCTION

The self-attention mechanism is a core operation in long-sequence modeling (Vaswani et al., 2017). However, its quadratic computational complexity and linearly growing key-value (KV) cache have become a key bottleneck in scaling compute and data (Keles et al., 2023). Linear attention (Katharopoulos et al., 2020; Sun et al., 2023; Peng et al., 2023) addresses these limitations by reformulating attention to operate in sub-quadratic complexity. For example, DeltaNet (Yang et al., 2024) and Gated DeltaNet (Yang et al., 2025) remove the softmax in standard attention and replace the KV cache with a single fixed-size memory state. However, a single fixed-size memory state is inherently limited in memory capacity and may lead to information loss when compressing longer contexts (Arora et al., 2024b; Jelassi et al., 2024; Kuratov et al., 2024). As a result, models based on single-state linear attention still underperform standard attention in practice.

Recently, Multi-State Linear Attention (MSLA) mechanisms (Behrouz et al., 2026; Guo et al., 2026; Wang et al., 2026) have been introduced to improve the long-context capabilities of single-state linear attention. MSLA partitions the context into segments and compresses each segment into its own memory state. Each token extracts segment-level outputs from preceding memory states and then aggregates them to produce its final output representation (Fig. 1a). Operating in the multi-state regime therefore introduces two novel challenges: how to divide the context into segments (separation), and how to combine the segment-level outputs (aggregation).

We study aggregation, which is relatively underexplored compared to separation. Existing methods aggregate segment-level outputs via a weighted sum (Behrouz et al., 2026; Guo et al., 2026; Wang et al., 2026), where the weights represent each segment's relevance to the query: closely aligned seg-

Figure

(a) Multi-State Linear Attention (MSLA)

Figure

(b) Aggregation Weight on GT

Figure 1: (a) A multi-state linear attention (MSLA) model aggregates segment-level outputs via a weighted sum. Prior methods compute the weights λt,i\lambda_{t,i} from position or from the mean of each segment's keys. MERLIN instead reads both the first and second moments of the keys. (b) On retrieval-augmented generation samples in HELMET (Yen et al., 2025), we measure the aggregation weight each method places on the ground truth (GT) segment at the query token. Position-based aggregation largely misses the GT and mean-based aggregation recovers more, while MERLIN places the most weight on it.

ments contribute more to the final output than others. However, prior works derive the weights either from position (Guo et al., 2026; Wang et al., 2026), assuming recency as the source of relevance, or from the mean (first-order) alignment between each segment's keys and the query (Behrouz et al., 2026). They overlook the variance (second-order) of the alignment, which captures sharply aligned keys that the mean alone cannot distinguish from a segment of uniformly weak ones.

To analyze why the variance matters, we examine how an MSLA model assigns aggregation weights on a long-sequence reasoning task. Fig. 1b shows that the segment containing the ground truth, which is the segment most relevant to the response, receives the highest aggregation weight when the weights are derived from both the mean and variance of the alignment, compared to the mean or position alone. This motivates an aggregation method that incorporates the variance of the alignment in deriving the weights.

We propose MERLIN (MomEnt Routing for multi-state LINear attention), a method that leverages the mean and variance of key-query alignment to improve aggregation in multi-state linear attention. MERLIN stores the first and second moments of each segment's keys. Using the moments, a query recovers both the mean (first-order) and variance (second-order) of its alignment with each segment's keys to derive the weights for the weighted sum of segment-level outputs. Our experiments show that MERLIN improves the long-context capabilities of multi-state linear attention models.

References (51)