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 typeFormula sketchAppears in
feature gateGLU, gated MLP
state update gateGRU, LSTM-like memory
routing gatemixture-of-experts
selective scan gateinput-dependent transition or mixingstate-space models
attention gatecontent-dependent weighted aggregationattention 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.

RegimeBehaviorRisk
suppress pathuseful feature blocked
pass pathgate stops modulating
high sensitivityunstable if scale is poorly normalized
sparse routingfew paths activeload 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:

MechanismQuestion
gatingshould this feature/state/path pass?
attentionwhich other positions should this position read?
routingwhich 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?