Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI and machine learning / Language models / Keeping values in range

Gated RMSNorm: controlling the layer's output

Gated RMSNorm combines RMS normalisation with a SiLU gate. Could the current token control how much of each coordinate reaches the residual stream?

In a whole LLM, layer by layer, attention collects information from earlier tokens. An output projection turns that result into an update for the residual stream.

Before that projection, could we control both the result’s scale and how much of it passes through?

Could normalisation do both?

Suppose attention returns [3, 4]. RMSNorm divides by its root-mean-square, about 3.54, giving [0.85, 1.13] before learned gains.

That controls the scale, but it still passes the result onwards. What if the current token would benefit from a smaller contribution?

We could multiply by a gate. A gate of [½, ½] would halve the normalised result to about [0.42, 0.57]. Different gate coordinates could change different parts of the result.

Which should come first?

Try halving [3, 4] before normalising it. We get [1.5, 2], but its RMS is also halved. Dividing by that smaller RMS brings us back to [0.85, 1.13]. The reduction we wanted has disappeared.

Calculated valuesLearned parameters
Calculated vectors and learned projectionsNormalise, then apply the gate34RMSNormGate × ½0.420.57Apply the gate, then normalise34Gate × ½RMSNorm0.851.13
The same input and uniform gate, in two orders. Normalising after gating cancels this uniform reduction; gating after normalisation preserves it.

To keep that reduction, normalise first, then gate. A non-uniform gate would also change the proportions, but normalising afterwards would still rescale its result.

Could the token choose the gate?

As in attention gating, a separate learned projection of the current token can produce a gate vector. It needs one coordinate for each coordinate of the result. Multiplying them together keeps the same vector size.

Here is that change inside a familiar attention head. The dimension labels follow the model selected above. The Attention box links to its full explanation. Both new steps sit between collecting the values and the output projection:

Calculated valuesLearned parameters
Calculated vectors and learned projectionsCurrent tokenEarlier context is dimmed; outlined columns are current.Current token computation.AttentionWgEarlier context is dimmed; outlined columns are current.Current token computation.RMSNormGainEarlier context is dimmed; outlined columns are current.Current token computation.Earlier context is dimmed; outlined columns are current.Current token computation.SiLUEarlier context is dimmed; outlined columns are current.Current token computation.Gate×Earlier context is dimmed; outlined columns are current.Current token computation.WoEarlier context is dimmed; outlined columns are current.Current token computation.Update+Updated token representation7,1681281281281281281287,1681281287,1687,168
Normalise the attention result, multiply by the token’s gate, then project the update back to the residual stream.

The gate branch uses SiLU, which can reduce or amplify coordinates and can produce small negative values. Unlike sigmoid, it is not limited to 0–1.

The same output arrangement can follow a state read instead of attention. Qwen3-Next uses it after Gated DeltaNet: normalise the read, multiply by a SiLU gate, then project back to the residual stream. This controls the current output; it does not erase the memory being read.

Sources and assumptions
  • Qwen3-Next implementation, Qwen3NextRMSNormGated and Qwen3NextGatedDeltaNet: RMS normalisation, learned coordinate gain, then multiplication by SiLU of the separate gate projection, before the output projection.
  • Falcon-H1 implementation: a related gated-normalisation use in its Mamba path; grouping and surrounding scales are model-specific.

The complete diagram is an illustrative extension of ordinary attention, not a claim that Qwen3-Next uses this exact attention block. Its labels use the selected model’s token and attention-head widths; the coloured cells are schematic. Wo represents one head’s slice of the output projection; the full update sums contributions from all heads. The numeric examples omit epsilon and set the learned norm gains to 1. The gate [½, ½] illustrates operation order, not a particular gate projection. Qwen3-Next normalises each value head’s result over its value coordinates. Its gate projection can be packed with other input projections; separate branches show their roles, not a required implementation layout. The result vectors and gate vectors use the same calculated-data cell representation. Blue/orange marks calculated data, not sign; violet boxes are learned parameters. The output gate is unrelated to linear attention’s contribution vector z, even though source code may reuse the letter z for the gate projection.

← Browse all subjectsBack to the beginning ↑