Manuscript Offprint

arXiv:2608.29539

LoGo: Token-Level Dynamic Local-Global Attention

Yuqi Pan, Zheng Li, Bohao Tang, Zhen Qin, Guoqi Li

Abstract

As context lengths scale, attention increasingly becomes a primary computational bottleneck in large language models. Standard Transformers remain powerful but computationally inefficient, as they allocate the same attention budget to every token regardless of its contextual demand. Existing local-global hybrids provide a more efficient alternative by mixing restricted- and full-context attention, but they typically allocate span statically across layers or heads. To address these limitations, we propose LoGo, a token-level dynamic local-global attention mechanism that uses attention span as a direct proxy for attention budget allocation. Each LoGo layer contains coupled local and global branches: all tokens receive efficient local attention over a restricted context window, while a learned gate activates global attention with full-context access only for tokens requiring long-range information. A threshold-based budget controller maintains a target global ratio without auxiliary losses, and a progressive masking schedule stabilizes training before sparse routing takes effect. We further implement query-sparse Triton kernels that convert reduced global-attention computation into practical speedups. Extensive experiments validate LoGo's effectiveness, showing that it preserves the scaling behavior of full-attention Transformers across model sizes. In controlled comparisons, LoGo improves over the full-attention Transformer and matched-budget static local-global hybrids, with clear gains on long-range retrieval. Analysis further shows that LoGo learns interpretable span allocation patterns. These results suggest that learned token-level span allocation is an effective and scalable way to improve the long-context performance-compute trade-off.

Date: September 1, 2026

Correspondence: panyuqi2024@ia.ac.cn, lizheng.m@bytedance.com, guoqi.li@ia.ac.cn

1 Introduction

Large language models (LLMs) have advanced rapidly through continual improvements in performance under fixed compute budgets. As context lengths scale, attention becomes an increasingly dominant source of computational cost. Yet standard Transformers [48] allocate this computation uniformly across tokens, despite substantial variation in prediction difficulty and contextual demand. Conditional computation [7] offers a natural way to address this mismatch by allocating compute on demand. In long-context modeling, this motivates dynamic attention-budget allocation across tokens as a path toward more efficient long-context scaling.

The key challenge is how to estimate the attention budget to assign to each token before attention is computed. We argue that attention span is a natural proxy for this budget: it controls both accessible context and

Figure

Figure 1 Overview of LoGo. Each layer applies local attention to all tokens while activating the global branch only for selected query routes. A token-level gate predicts global-span preference, an adaptive threshold converts this preference into binary routing decisions under a target global ratio, and P-mask gradually introduces sparse routing during training.

cost, and its demand can often be anticipated from linguistic context. Tokens in fixed phrases may be predictable from local evidence, whereas tokens involved in long-range retrieval require global access. However, existing local-global hybrids allocate span statically, either across layers (inter-layer hybrids; [1, 46]) or across heads (intra-layer hybrids; [11]). In both cases, all tokens follow the same span pathway regardless of their contextual needs. Such static layouts impose preset per-token budgets, often wasting global computation on locally predictable tokens. Existing dynamic variants remain limited, as they typically switch among attention mechanisms rather than allocate span directly [38], rely on handcrafted routing [27, 28], or lack matched-budget evaluation at scale [2]. These gaps motivate three questions:

RQ1. Can a model learn token-level local/global span allocation, spending global attention on tokens that require long-range context?

RQ2. As a pretrained backbone, can such a model preserve the scaling behavior of standard Transformers?

RQ3. Under matched parameters and FLOPs, can token-level span allocation improve the performance-compute trade-off over static local-global hybrids?

To answer these questions, we propose LoGo (Looking far, Glancing only), a token-level dynamic local-global attention mechanism. Figure 1 illustrates the overall design. Each LoGo layer contains local and global branches with the same attention form but different accessible spans, sharing the main attention parameters while being decoupled by lightweight transformations. A learned scalar gate predicts each token's preference for global span: selected tokens combine local and global outputs, whereas unselected tokens bypass the global branch and remain purely local. The gate is compared with an adaptive threshold that maintains a target global activation ratio, and a progressive masking schedule delays sparse routing until the gate has learned meaningful preferences. Because LoGo sparsifies only global queries while preserving all key-value states, selected tokens retain exact full-context access. We further implement query-sparse Triton kernels that translate reduced global-attention computation into practical speedups.

Extensive experiments validate LoGo's effectiveness. First, scaling runs from 200M to 3.3B parameters show that LoGo consistently matches or improves standard Transformers on language modeling, indicating that token-level span allocation preserves backbone scalability. Second, in controlled 1.5B comparisons under matched parameters and attention FLOPs, LoGo improves the performance-compute trade-off over the standard Transformer and static inter- and intra-layer hybrids: it achieves the best language-modeling results, remains competitive on short-context recall, and provides clear gains on long-range retrieval after context extension. Third, kernel benchmarks show that our implementation converts reduced FLOPs into practical speedups, with near-proportional gains at long sequence lengths. Additional ablations validate the main design choices, show robustness across global ratios, and demonstrate compatibility with static hybrids for reducing both memory and computation. Finally, analysis shows that LoGo learns interpretable allocation patterns, assigning more global span to tokens requiring long-range access.

References (54)