# Gated Attention for Large Language Models: Non-linearity, Sparsity, and Attention-Sink-Free

- **ID:** 535
- **Kind:** paper
- **URL:** https://arxiv.org/abs/2505.06708
- **Authors:** Zihan Qiu, Zekun Wang, Bo Zheng, Zeyu Huang, Kaiyue Wen, Songlin Yang, Rui Men, Le Yu, Fei Huang, Suozhi Huang, Dayiheng Liu, Jingren Zhou, Junyang Lin
- **Venue:** arXiv / Qwen Team / Alibaba
- **Published:** 2025
- **Tags:** gated-attention, attention-sink, sparsity, moe, qwen, alibaba, ruler
- **Topics:** attention, architecture, LLM pretraining
- **Added:** 2026-10-01
- **Research status:** done
- **Page:** https://papers.projxon.ai/entries/535

## Summary

Compares ~30 gating variants on 15B MoE (15A2B, 2.54B active) and 1.7B dense models trained on up to 3.5T tokens. A head-specific sigmoid gate after SDPA (G1) is best: MoE 400B-token Avg PPL 5.761 vs 6.026 baseline and MMLU 60.82 vs 58.79, beating parameter-matched KV-head/expert expansions. Gains come from non-linearity between low-rank Wv and Wo plus query-dependent sparse gates (mean score 0.116). First-token attention falls 46.7%→4.8%; YaRN-extended RULER at 128k is 58.82 vs 31.65. Gate also damps loss spikes and allows higher LR (8e-3) where the baseline diverges. Claims first attention-sink-free models.

## Attributes

- **Purpose:** Test a simple post-SDPA sigmoid gate as an upgrade to softmax attention
- **Scale:** 15B MoE (128 experts, top-8) and 1.7B dense; up to 3.5T tokens, seq 4096 then 32k+YaRN 128k; ~30 variants; RULER 4k–128k
- **Time period:** 2025-05-10 (arXiv 2505.06708 v1). HF paper publishedAt 2025-05-10.

## From the source (fetched 2026-10-03)

- **Published:** May 10, 2025 (arXiv)
- **arXiv categories:** cs.CL (arXiv)
- **Citations:** 334 (37 influential) (Semantic Scholar)
- **References:** 77 (Semantic Scholar)
- **Published in:** Neural Information Processing Systems (Semantic Scholar)

## Abstract

Gating mechanisms have been widely utilized, from early models like LSTMs and Highway Networks to recent state space models, linear attention, and also softmax attention. Yet, existing literature rarely examines the specific effects of gating. In this work, we conduct comprehensive experiments to systematically investigate gating-augmented softmax attention variants. Specifically, we perform a comprehensive comparison over 30 variants of 15B Mixture-of-Experts (MoE) models and 1.7B dense models trained on a 3.5 trillion token dataset. Our central finding is that a simple modification-applying a head-specific sigmoid gate after the Scaled Dot-Product Attention (SDPA)-consistently improves performance. This modification also enhances training stability, tolerates larger learning rates, and improves scaling properties. By comparing various gating positions and computational variants, we attribute this effectiveness to two key factors: (1) introducing non-linearity upon the low-rank mapping in the softmax attention, and (2) applying query-dependent sparse gating scores to modulate the SDPA output. Notably, we find this sparse gating mechanism mitigates 'attention sink' and enhances long-context extrapolation performance, and we also release related $\href{https://github.com/qiuzh20/gated_attention}{codes}$ and $\href{https://huggingface.co/QwQZh/gated_attention}{models}$ to facilitate future research.

## Research notes

- Primary: arxiv abs (cs.CL). License not stated on abs/HTML at check. Qwen Team/Alibaba with Edinburgh (Huang), Stanford (Wen), MIT (Yang), Tsinghua (S. Huang). Code https://github.com/qiuzh20/gated_attention (973 stars at check). HF paper page 11 upvotes; 10 linked models (unofficial) not copied into hf_* fields. Discord posted abs. Trains on an internal 3.5T mix; no new public corpus, so no datasets_local row. License field left blank per catalog convention.

## Cites, within this collection

- [Hymba: A Hybrid-head Architecture for Small Language Models](https://papers.projxon.ai/entries/918) (paper 2024, #918)

## Cited by, within this collection

- [Pretraining Latent Information Feedback Transformers with Teacher Supervision](https://papers.projxon.ai/entries/845) (paper 2026, #845)
- [Screening Is Enough](https://papers.projxon.ai/entries/529) (paper 2026, #529)
- [HRM-Text: Efficient Pretraining Beyond Scaling](https://papers.projxon.ai/entries/619) (paper 2026, #619)
- [HySparse2: Hybrid Sparse Attention with Two-Level KV Sharing](https://papers.projxon.ai/entries/1031) (paper 2026, #1031)

## Related entries

- Discussed in: [Mixture-of-experts language models: where the work is (overview)](https://papers.projxon.ai/entries/1206) (note, #1206)

## Similar entries

- [Attention Drift in Speculative Decoding (drafter attention sink → recent tokens)](https://papers.projxon.ai/entries/1082) (thread, #1082)
- [A Unified View of Attention and Residual Sinks: Outlier-Driven Rescaling is Essential for Transformer Training](https://papers.projxon.ai/entries/1257) (paper, #1257)
- [Sparser, Faster, Lighter Transformer Language Models](https://papers.projxon.ai/entries/528) (paper, #528)
- [Your Transformer Can Hold Two Thoughts at Once: Evidence of Linear Superposition in LLMs](https://papers.projxon.ai/entries/1073) (paper, #1073)
- [Scaling Laws for Looped Mixture of Experts](https://papers.projxon.ai/entries/847) (paper, #847)
- [Towards Physics of Multimodal Pretraining: Knowledge Flow, Modality Synergy, Early Unification, and Recipes](https://papers.projxon.ai/entries/449) (paper, #449)
