Gating
Gating lets a model modulate information flow with learned multiplicative controls. It appears in RNNs, GLUs, state-space models, mixture-of-experts routers, and some attention variants.
A simple gate is:
where controls how much of passes through.
Gated residual updates often have the form:
where controls whether the state changes or is preserved. In GLU-style feed-forward blocks such as GLU Variants Improve Transformer:
The multiplicative path gives the model a data-dependent way to suppress, pass, or route features.
Gate Types
| Gate type | Formula sketch | Appears in |
|---|---|---|
| feature gate | GLU, gated MLP | |
| state update gate | GRU, LSTM-like memory | |
| routing gate | mixture-of-experts | |
| selective scan gate | input-dependent transition or mixing | state-space models |
| attention gate | content-dependent weighted aggregation | attention variants, Mega |
The shared idea is multiplicative control. The difference is what is being controlled: feature magnitude, memory update, expert choice, or sequence dynamics.
Gradient Behavior
For sigmoid gates:
When is very positive or negative, becomes small. Saturated gates can preserve or block information, but they also reduce gradient signal through the gate.
| Regime | Behavior | Risk |
|---|---|---|
| suppress path | useful feature blocked | |
| pass path | gate stops modulating | |
| high sensitivity | unstable if scale is poorly normalized | |
| sparse routing | few paths active | load imbalance or expert collapse |
Gating vs Attention
Gating modulates a representation, while attention chooses or mixes information from a set of positions.
Both can be content-dependent, but they answer different questions:
| Mechanism | Question |
|---|---|
| gating | should this feature/state/path pass? |
| attention | which other positions should this position read? |
| routing | which expert/path should process this token? |
Failure Modes
- Saturation: gates stay near 0 or 1 and reduce gradient signal.
- Routing collapse: a small set of experts or paths receives most tokens.
- Spurious interpretability: gate value is treated as explanation without intervention or ablation.
- Instability: multiplicative interactions amplify activation scale when normalization is weak.
- Confused explanation: a large gate value is not automatically causal evidence.
Where It Appears
- LSTM and GRU update gates in RNNs.
- Selective updates in Mamba and other state-space models.
- Gated linear units in feed-forward networks.
- Gated attention blocks in Mega, where moving-average memory is combined with gated content mixing.
- Routing weights in Mixture of experts.
Checks
- Is the gate scalar, channel-wise, token-wise, or expert-wise?
- Does the gate saturate near 0 or 1?
- Is gating used for memory, routing, feature modulation, or output control?
- Does the gate create an interpretation claim that needs verification?
- Are gate logits normalized or regularized enough to avoid collapse?
- Is the gate measured by distribution, ablation, or only visual inspection?