↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Layer 4 of 48 · the first full-attention layer; layers 1–3 are Gated DeltaNet q, k norm · RoPE 64/256 16 query heads share 2 key-value heads · 256-D · scale 1/√256 · causal · mean gate 0.0000
Loading recorded attention…

What gated attention is

Gated attention multiplies each head's attention output by a gate computed from the token's own input, before the output projection mixes the heads:

The gate is a sigmoid with one value per head and per dimension of the head, so it can scale each output coordinate anywhere between 0 and 1. Qiu et al. (2025), from the Qwen team, compared 30 ways of adding gates to softmax attention in 15B mixture-of-experts and 1.7B dense models trained on 3.5 trillion tokens. This one, a head-specific elementwise sigmoid right after scaled dot-product attention, consistently improved performance, made training more stable, tolerated larger learning rates and scaled better. The paper received a best paper award at NeurIPS 2025.

This tab records the gate in a model that ships it, Qwen3-Next-80B-A3B-Instruct: its layer 4, the first full-attention layer, run with the model's own weights on its own input for two prompts.

Where the gate sits in Qwen3-Next

The gate shares a matrix with the query. Qwen3-Next's q_proj produces two head widths per head: the first 256 values are the query and the second 256 are the gate logits . The Q · K · V · G column shows the four projections for each token, the Gated Attention card the softmax weights of the chosen head, and the Output gate column the head output, its 256 gate scores and the gated result for every token, which is what enters in the Output column.

The rest of the layer is ordinary modern attention: grouped-query attention with 16 query heads sharing 2 key-value heads (the GQA tab), head dimension 256, an RMSNorm on each query and key head, and RoPE on only the first 64 of the 256 dimensions. Values get neither norm nor rotation.

A sparse gate that depends on the query

The paper traces the gain to two things. The first is non-linearity: without a gate, a head's value projection and its slice of multiply into one low-rank linear map, and the gate puts a non-linearity between them. The second is sparsity: the trained gate scores are mostly close to zero, and they are computed from the query token, so each token decides which heads and which dimensions it lets through.

The recording shows that sparsity directly. The toolbar's mean gate, over every recorded gate score, is 0.0122. The Gate scores panel gives the chosen head's mean score, the share of its scores below 0.1 and its largest score, a histogram on a log scale, and every head's mean; for the selected token it compares the size (root mean square) of the head output before and after the gate. Most of what the heads compute in this layer is scaled far down before it reaches , and what passes is decided token by token.

No need for an attention sink

Softmax weights must sum to one, so a head with nothing useful to add for some query still has to put its weight somewhere. Trained models learn to park it on the first token, which then collects large attention from many heads and positions: the attention sink (see the Sinks tab, and Xiao et al., 2023). A gate after the softmax gives a head another way to add nothing: close the gate. Qiu et al. find that the gate mitigates the attention sink and improves extrapolation to longer contexts, hence the paper's title, Attention-Sink-Free.

Qwen3-Next's hybrid stack

Qwen3-Next uses full attention in only one layer of every four, layers 4, 8, …, 48. The three layers between are Gated DeltaNet (Yang et al., 2024), a linear-attention layer whose fixed-size state is updated with a gated delta rule, and every layer's feed-forward part is a mixture of experts. To produce layer 4's real input, the recorder ran layers 1–3 with their routed experts, reading only the 401 experts the two prompts used, so the 80-billion-parameter model was never loaded whole.

Where it came from

Gates are among the oldest tools in sequence models: the LSTM's input, forget and output gates; gated linear units in convolutional language models (Dauphin et al., 2017); and the GLU feed-forward layers of most current Transformers (Shazeer, 2020). Linear-attention and state-space layers such as Mamba and Gated DeltaNet gate their recurrences (see the Mamba, Mamba-2 and Linear tabs). Qiu et al. brought a gate back to softmax attention and measured where it helps; Qwen3-Next ships it in every full-attention layer.

Papers

  1. Gated Attention for Large Language Models: Non-linearity, Sparsity, and Attention-Sink-Free Zihan Qiu et al. · NeurIPS 2025 The study behind this tab: a head-specific sigmoid gate after scaled dot-product attention, and why it helps.
  2. Qwen3-Next-80B-A3B-Instruct Qwen Team · 2025 The model card of the recorded model: gated attention every fourth layer, Gated DeltaNet between, mixture-of-experts feed-forward layers.
  3. Gated Delta Networks: Improving Mamba2 with Delta Rule Songlin Yang, Jan Kautz, Ali Hatamizadeh · ICLR 2025 Gated DeltaNet, the linear-attention layer in the three layers before the one recorded here.
  4. Efficient Streaming Language Models with Attention Sinks Guangxuan Xiao et al. · ICLR 2024 Names and explains the attention sink that the output gate removes the need for (the Sinks tab).
  5. GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints Joshua Ainslie et al. · EMNLP 2023 Grouped-query attention, the 16 : 2 head sharing of the recorded layer.
  6. Language Modeling with Gated Convolutional Networks Yann N. Dauphin, Angela Fan, Michael Auli, David Grangier · ICML 2017 Gated linear units: one projection gating another through a sigmoid.
  7. GLU Variants Improve Transformer Noam Shazeer · arXiv 2020 Gated feed-forward layers, the form of gating most Transformers already use outside attention.

See also