Switch Attention: Towards Dynamic and Fine-grained Hybrid Transformers
cs.CL
Submitted: 2026-03-27
Updated: 2026-08-29
Comments: EMNLP 2026 main
License: http://creativecommons.org/licenses/by-nc-nd/4.0/
The gist: The attention mechanism has been the core component in modern transformer architectures.
Terminology
Abstract
The attention mechanism has been the core component in modern transformer architectures. However, the computation of standard full attention scales quadratically with the sequence length, serving as a major bottleneck in long-context language modeling. Sliding window attention restricts the context length for better efficiency at the cost of narrower receptive fields. While existing efforts attempt to take the benefits from both sides by building hybrid models, they often resort to static, heuristically designed alternating patterns that limit efficient allocation of computation in various scenarios. In this paper, we propose Switch Attention (SwiAttn), a novel hybrid transformer that enables dynamic and fine-grained routing between full attention and sliding window attention. For each token at each transformer layer, SwiAttn dynamically routes the computation to either a full-attention branch for global information aggregation or a sliding-window branch for efficient local pattern matching. An adaptive regularization objective is designed to encourage the model towards efficiency. Moreover, we adopt continual pretraining to optimize the model, transferring the full attention architecture to the hybrid one. Extensive experiments are conducted on twenty-three benchmark datasets across both regular (4K) and long (32K) context lengths, demonstrating the effectiveness of the proposed method.
Sources
- Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads
- Composer: A Search Framework for Hybrid Neural Architecture Design
- Generating Long Sequences with Sparse Transformers
- Gemini: A Family of Highly Capable Multimodal Models
- Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge
- Just read twice: closing the recall gap for recurrent language models
- Language Models Enable Simple Systems for Generating Structured Views of Heterogeneous Data Lakes
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
- Longformer: The Long-Document Transformer
- Native Hybrid Attention for Efficient Sequence Modeling
- Better & Faster Large Language Models via Multi-token Prediction
- Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search
- Log-Linear Attention
- R2R: Efficiently Navigating Divergent Reasoning Paths with Small-Large Model Token Routing
- Mixture of Attention Spans: Optimizing LLM Inference Efficiency with Heterogeneous Sliding-Window Lengths
- RULER: What's the Real Context Size of Your Long-Context Language Models?
- HySparse: A Hybrid Sparse Attention Architecture with Oracle Token Selection and KV Cache Sharing
- Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs
- Gemma 2: Improving Open Language Models at a Practical Size
- Mistral 7B
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering