Switch Attention: Towards Dynamic and Fine-grained Hybrid Transformers

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Zhao, Yusheng, Li, Hourun, Wu, Bohan, Yin, Yichun, Shang, Lifeng, Yuan, Jingyang, Zhang, Meng, Zhang, Ming
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911622342115328
author Zhao, Yusheng
Li, Hourun
Wu, Bohan
Yin, Yichun
Shang, Lifeng
Yuan, Jingyang
Zhang, Meng
Zhang, Ming
author_facet Zhao, Yusheng
Li, Hourun
Wu, Bohan
Yin, Yichun
Shang, Lifeng
Yuan, Jingyang
Zhang, Meng
Zhang, Ming
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2603_26380
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Switch Attention: Towards Dynamic and Fine-grained Hybrid Transformers
Zhao, Yusheng
Li, Hourun
Wu, Bohan
Yin, Yichun
Shang, Lifeng
Yuan, Jingyang
Zhang, Meng
Zhang, Ming
Computation and Language
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.
title Switch Attention: Towards Dynamic and Fine-grained Hybrid Transformers
topic Computation and Language
url https://arxiv.org/abs/2603.26380