Paper-explained Series 6

Interactive figure — needs JavaScript. Drag the relevance of the context to see why softmax cannot write nothing.

Transformers didn’t take over AI because they were perfect — they took over because they were parallelizable. Attention let models look everywhere at once, unlocking massive scale. But as models grew deeper and wider, a strange pattern emerged: attention wasn’t failing to look, it was failing to decide when to change.

These weren’t bugs in softmax or dot products. They were symptoms of something more subtle: Transformers always apply their updates, even when they shouldn’t.

The paper “Gated Attention for Large Language Models” makes a deceptively simple but profound move. It reframes attention outputs as \( \Delta \) (Delta)proposed changes to the model’s internal state — and introduces gating as a way to decide whether those changes should be applied at all.

This article tells that story properly:

What is Gating?

At its core, gating is the neural network equivalent of a faucet handle. Attention proposes an update; the gate decides how much of that update is allowed through. Mathematically, it is almost always an element-wise multiplication between the signal and a “gate score” (usually between 0 and 1).

This simple mechanism gives the model a superpower: Input-Dependent Sparsity. It allows the model to look at the data and say, “This specific part is noise. I am going to shut it off right now.”

Now, let’s look at how two different research teams applied this concept to fix the biggest problems in modern AI.

Part 1: Gated Attention for Transformers

Paper: Gated Attention for Large Language Models

Standard Transformers use Softmax Attention, which forces attention scores to sum to 1.0. This means the model must attend to something, even if the input is garbage. This creates “attention sinks” — useless tokens (like the first token) that hoard attention probability.

1. The Math: How It Is Calculated

The gating mechanism at G1 is calculated as:

$$Y' = Y \odot \sigma(X W_{\theta})$$

This effectively acts as a dynamic filter. If \( \sigma(X W_{\theta}) \) outputs close to 0, the information from \( Y \) is erased.

2. The Architecture Search: Where Does the Gate Go?

The researchers didn’t just guess. They conducted a massive ablation study involving over 30 variants of 15B parameter Mixture-of-Experts (MoE) models and 1.7B dense models. They tested gating at five distinct positions:

Input X Q proj K proj V proj G4 G3 G2 Scaled Dot- Product Attn G1 winner Dense Wₒ G5 Y′
The five gate positions tested in the ablation: G4, G3, and G2 after the query, key, and value projections; G1 immediately after the SDPA output; G5 after the final dense projection \( W_o \). The SDPA output gate G1 was the definitive winner.

The Verdict: The SDPA Output Gate (G1) was the definitive winner.

Figure: ablation bar charts of average perplexity and MMLU deltas for the five gate positions (SDPA gate G1: −0.265 PPL, +2.03 MMLU) — view it in the original article on Towards AI.

3. The Arithmetic of Control: Multiplicative vs. Additive

One of the most critical design choices was how to apply the gate. The researchers compared two fundamental operations:

The Verdict: Multiplication Wins.

4. Why Sigmoid? Why Not SiLU?

Standard LLMs use SiLU (Swish) for activations. Why switch to Sigmoid?

5. Handling Multi-Head Attention

In Multi-Head Attention, the model has multiple “heads” looking at different things. The researchers tested two approaches:

The Verdict: Head-Specific gating is essential. Forcing heads to share a gate diminishes performance. This confirms that different heads capture different features — one head might be looking at critical context (Gate = 1) while another is looking at noise (Gate = 0) simultaneously.

6. Handling MoE Models

The study focused heavily on Mixture-of-Experts (MoE) models (15B total params, 2.5B activated).

Part 2: Gated Delta Networks for Linear Models

Paper: Gated Delta Networks: Improving Mamba2 with Delta Rule

Models like Mamba replace quadratic attention with a state-space recurrence, updating an internal state through continuous decay. This design makes them fast and memory-efficient, but it also means information is gradually washed away: older signals fade whether they are still relevant or not. The result feels like writing on a whiteboard that is constantly being erased — scalable, but imprecise.

Delta Rule doesn’t learn by forgetting — it learns by correcting memory. Instead of gradually decaying memory, the Delta Rule maintains an explicit internal memory that is updated through correction-based writes. When new information arrives, the model first checks what its memory already contains for a similar situation. It then updates memory by adding only the difference between what was stored and what was just observed. This makes memory updates precise and additive, changing exactly what is necessary while leaving unrelated information untouched — more like editing a document than erasing a whiteboard.

However, the same mechanism that makes the Delta Rule precise also exposes its central limitation. Because memory updates are purely additive, information is never removed unless it is explicitly corrected later. Once written, a memory entry persists indefinitely, even if it becomes irrelevant to the current context. Over long sequences, this can cause memory to accumulate outdated or distracting information, cluttering the state and reducing effectiveness.

1. The Architecture: Gating Meets Delta

The researchers proposed Gated DeltaNet, which fuses Mamba’s forgetting capability with DeltaNet’s writing precision. The core state update equation is:

$$S_t = S_{t-1}\left(\alpha_t\left(I - \beta_t k_t k_t^{\top}\right)\right) + \beta_t v_t k_t^{\top}$$

2. Hardware Efficiency: Chunkwise Parallelism

You cannot train this equation loop-by-loop — it is too slow for GPUs. To make it viable, the authors derived a Hardware-Efficient Chunkwise Algorithm.

3. Why It Wins: The “Needle” Test

The authors tested this on the “Single Needle in a Haystack” (S-NIAH) benchmark:

Part 3: The Unified Connection

Why are two different papers — one on Softmax Attention and one on Linear SSMs — landing on the exact same solution?

1. Input-Dependent Sparsity is the Universal Fix

2. Non-Linearity at the Crucial Junction

3. Training Stability Both papers report that gating stabilizes training.

In summary: Gating is not just a feature; it is the necessary control mechanism for noise. Whether that noise is the “attention sink” in a Transformer or “irrelevant history” in an SSM, the solution is the same: give the model a mathematically precise way to multiply the signal by zero.

Link to original papers:
- Gated Attention for Large Language Models: Non-linearity, Sparsity, and Attention-Sink-Free
- Gated Delta Networks: Improving Mamba2 with Delta Rule

Until next time folks…
El Psy Congroo