Manuscript Offprint

arXiv:2609.31261

MoSAR: Mixture of Semantic Attention Regimes for Learning Adaptive and Approximable Attention Geometries

Michele Paolicelli, Alessandro Petruzzelli, Alessandro Franceso Maria Martina, Cataldo Musto, Giovanni Semeraro

Michele Paolicelli

Department of Computer Science

Università degli Studi di Bari Aldo Moro

Bari, 70121, Italy

m.paolicelli9@phd.uniba.it

Alessandro Petruzzelli

Department of Computer Science

Università degli Studi di Bari Aldo Moro

Bari, 70121, Italy

alessandro.petruzzelli@uniba.it

Alessandro Francesco Maria Martina

Department of Computer Science

Università degli Studi di Bari Aldo Moro

Bari, 70121, Italy

alessandro.martina@uniba.it

Cataldo Musto

Department of Computer Science

Università degli Studi di Bari Aldo Moro

Bari, 70121, Italy

cataldo.musto@uniba.it

Giovanni Semeraro

Department of Computer Science

Università degli Studi di Bari Aldo Moro

Bari, 70121, Italy

giovanni.semeraro@uniba.it

ABSTRACT

The quadratic complexity of dense self-attention remains a central bottleneck for long-context language modeling. Many efficient alternatives address this cost by deciding in advance where attention should be sparse or local. We argue that attention approximation should instead be approached as a geometric problem, with the relevant interaction geometry learned from data: natural-language dependencies are input-dependent and difficult to prescribe in advance, so the model should learn where positional relevance can decay and where broader interactions must be preserved. We introduce Mixture of Semantic Attention Regimes (MoSAR), which learns such an adaptive, controlled-decay geometry over query-key interactions. Input-conditioned query and key routers, applied after positional encoding, select mixtures over short, medium, and global regimes, inducing a continuous distance-dependent attention field rather than a fixed sparsity pattern. This geometry is learned during training and can subsequently be discretized through top-1 routing. In controlled pre-training experiments with matched 500M-parameter models, MoSAR learns a substantially lower-reach attention geometry without degrading language-modeling quality, improving perplexity over dense RoPE at the training context length. Under length extrapolation, MoSAR achieves the best perplexity among all evaluated variants, including strong baselines such as ALiBi. Moreover, the learned geometry remains stable under deterministic top-1 discretization, suggesting that it is not only adaptive, but also amenable to low-cost approximation at inference time.

1 INTRODUCTION

Self-attention (Vaswani et al., 2017) is a central component of modern Large Language Models (LLMs) (Minaee et al., 2024), but its quadratic complexity in sequence length remains a major obstacle to efficient long-context modeling. A large body of work has therefore explored a plethora of alternatives to dense attention (Tay et al., 2022). Many of these approaches reduce computation by

Figure

Example parameters: B=6.0, p=2.0, S=(128,128), M=(512,512), G=(2048,2048)

Figure 1: Illustrative MoSAR decay profiles for representative query–key regime pairs. Each pair induces a distance-dependent regime gmn(d)g_{mn}(d) with an initial unit plateau, a smooth decay region, and a finite floor; pairs involving broader regimes retain interactions over longer causal distances.

prescribing a fixed sparsity pattern, such as a sliding window or a predetermined set of admissible interactions (Beltagy et al., 2020; Zaheer et al., 2020; Chaplot, 2023). While effective, such strategies make a strong assumption: the same notion of locality is appropriate for every token, layer, and context. In practice, dense attention remains widely used in modern LLMs, supported by increasingly optimized implementations (Dao et al., 2022; Dao, 2023; Kwon et al., 2023).

On the other hand, standard positional mechanisms determine how token interactions depend on relative position and therefore induce a geometry over attention. Rotary Positional Encoding (RoPE) (Su et al., 2021), for instance, provides an effective relative positional geometry through rotations of queries and keys, but its positional interaction is oscillatory rather than explicitly decaying with distance (Barbero et al., 2024). This is not a limitation of RoPE itself—decay is not what RoPE was designed to provide—but it raises a natural question: how, and when, should positional relevance decay? A single decay law would still impose one universal attention geometry. Language dependencies occur at different scales, and there is no reason to assume that the same locality regime should be optimal for every token or at every layer. Therefore, we ask a different question: can the model learn from data where attention computation should remain local and where broader interactions are worth preserving?

In this work, we take a different perspective and argue that attention approximation is fundamentally a geometric problem: sparsity should not necessarily be imposed a priori; it can instead emerge from a distance-dependent decay geometry learned by the model. We therefore introduce Mixture of Semantic Attention Regimes (MoSAR), an adaptive attention mechanism in which post-RoPE query-key routers select among multiple smoothly decaying functions gmn(d)g_{mn}(d) called semantic regimes (Figure 1). Each regime defines three aspects of the resulting geometry: a locality region in which RoPE-based interactions are largely preserved, a transition region in which their contribution progressively decays, and a low-relevance region that can eventually be treated as computationally negligible. Thus, MoSAR replaces a single fixed sparse pattern with a family of approximable geometries selected dynamically by the model. We also study MoSAR-Cost, a cost-aware variant that explicitly biases the routers toward shorter expected reach. Throughout the paper, we use semantic to emphasize that regime selection is conditioned on learned contextual representations, rather than solely on position or a fixed sparsity pattern. Introducing distance-dependent decay can provide at least three desirable properties. First, it augments relative positional information with an inductive bias on relative relevance. Second, a smooth decay avoids the abrupt semantic discontinuity introduced by hard local masks, acting as a geometric regularizer. Third, sufficiently decayed interactions expose regions of the attention matrix that can be approximated or omitted altogether.

Our main contributions are:

Table 1: Comparison of methods that modify attention geometry or reduce attention computation. Columns refer to the mechanism introduced beyond standard content-based self-attention. ✓\checkmark denotes an explicit property, ×\times its absence, and △\triangle a partial, indirect, or inference-only property.

MethodData-learnedInput adaptiveToken-wiseAttention approx.Cost lossLearned routingDistance decayLearned decay
Efficient and approximate attention
REFORMER (Kitaev et al., 2020)△✓✓✓✕✕✕✕
LINFORMER (Wang et al., 2020)✓✕✕✓✕✕✕✕
LONGFORMER (Beltagy et al., 2020)✕✕✕✓✕✕✕✕
Positional and geometric modifications
ALiB1 (Press et al., 2021)✕✕✕✕✕✕✓✕
NoPE (Kazemnejad et al., 2023)△✕✕✕✕✕✕✕
XPos/LEX (Sun et al., 2023)✕✕✕△✕✕✓✕
YARN (Peng et al., 2024)✕✕✕✕✕✕✕✕
p-RoPE (Barbero et al., 2024)✕✕✕✕✕✕✕✕
CoPE (Amballa, 2025)△✕✕✕✕✕✕✕
HOPE (Dai et al., 2025)△✕✕✕✕✕✓△
Dynamic selection and sparsification
SELECTIVE ATTENTION (Leviathan et al., 2025)△✓✓△✕✕✕✕
FLEXPREFILL (Lai et al., 2025)✕✓△✓✕✕✕✕
ADAPTIVE ATTENTION SPAN (Sukhbaatar et al., 2019)✓△△✓✓✕✓△
MoBA (Lu et al., 2026)△✓✓✓✕△✕✕
NSA (Yuan et al., 2025)✓✓✓✓✕△✕✕
MoSAR family (ours)✓✓✓✓✓✓✓✓

Data-learned indicates that the relevant geometry or selection mechanism is learned end-to-end rather than fully prescribed. Attention approximation denotes an explicit reduction of evaluated query-key interactions or an equivalent low-rank/sparse computation. For MoSAR, decay and approximation are jointly induced by token-conditioned regime selection and an explicit attention-cost objective.

  1. We formulate efficient attention as a controlled-decay geometry problem, and introduce Mixture of Semantic Attention Regimes (MoSAR), in which post-RoPE bilinear query and key routers select adaptive decay geometries.

  2. We show, through controlled 500M-parameter from-scratch pre-training, that, among the evaluated variants, adaptive controlled decay improves over dense RoPE and fixed locality baselines, with MoSAR achieving the best perplexity at 4096 and 8192 tokens.

  3. We demonstrate that the learned soft geometry is amenable to approximation at inference time: deterministic top-1 routing substantially reduces the expected normalized reach while preserving competitive perplexity under length extrapolation; MoSAR-Cost further shows that explicit reach pressure can move this trade-off toward substantially lower expected reach.

References (83)