Normalization, Activations, and Position Revisited
local graph
Chapter 15 — Normalization, Activations, and Position Revisited
Section titled “Chapter 15 — Normalization, Activations, and Position Revisited”The headline innovations — MoE, MLA, MTP, sparse attention — are where models differ most dramatically. But families also diverge in the smaller components we have so far treated as settled: exactly how they normalize, which gated activation they use, and how they handle position. These choices are individually minor and collectively define a model’s “feel” and stability. This short chapter revisits each, family by family, and ends with the synthesis the whole book has been building toward: a single table comparing the complete architecture of every major model side by side.
15.1 Normalization, in Detail
Section titled “15.1 Normalization, in Detail”Every modern model uses RMSNorm in a pre-norm arrangement (Chapter 8), but the details vary. QK-norm, adopted by Qwen3 among others, applies RMSNorm to the queries and keys before the attention dot product; this bounds the scale of the scores and noticeably stabilizes training of very large models. It is a two-line addition:
# inside attention, after projecting q, k and before RoPE/attention:q = self.q_norm(q) # RMSNorm over the head dimensionk = self.k_norm(k) # keeps attention scores well-scaledPython — qk-norm: normalize q and k before attention (Qwen3-style)
Other families add their own touches. Gemma places a normalization layer both before and after each sublayer (a “sandwich” arrangement) and historically applied logit soft-capping — squashing attention and output logits through a scaled tanh to prevent extreme values — though this was relaxed in later versions. These are small stabilizers, but at the scale of a frontier training run, “small stabilizers” are often the difference between a run that converges and one that diverges (Chapter 21). Table 15.1 collects the normalization choices.
| Family | Normalizer | Placement | Extras |
|---|---|---|---|
| DeepSeek-V3 | RMSNorm | pre-norm | — |
| Qwen3 | RMSNorm | pre-norm | QK-norm |
| Llama 3 / 4 | RMSNorm | pre-norm | — |
| Gemma 2 / 3 | RMSNorm | pre + post (sandwich) | logit soft-cap (early) |
| gpt-oss | RMSNorm | pre-norm | attention sinks |
Table 15.1 — Normalization choices across families
15.2 Activations and the Gated FFN
Section titled “15.2 Activations and the Gated FFN”The feed-forward activation has effectively standardized on a gated linear unit: two parallel projections, one passed through an activation and used to gate the other (Chapter 8). The families differ only in which activation fills the gate — SwiGLU (SiLU gate) in Llama, DeepSeek, Qwen, and Mistral; GeGLU (GELU gate) in Gemma. The quality difference between them is small; the important shared decision is gating itself, and the accompanying reduction of the hidden dimension to roughly 8/3 of the model width to keep the parameter count fixed despite the extra projection. In an MoE model, this same gated FFN is simply replicated as each expert (Chapter 11). There is little left to innovate here — which is itself worth noting, given how much the rest of the architecture has churned.
15.3 Position, Revisited
Section titled “15.3 Position, Revisited”RoPE (Chapter 9) is universal, but its configuration is a meaningful knob. The base frequency theta controls how quickly rotations cycle and therefore the effective context the rotations can distinguish; long-context models raise it (NTK-aware scaling) or apply YaRN to stretch the trained range. Some models apply RoPE to only a fraction of each head’s dimensions (“partial RoPE”), leaving the rest position-free. DeepSeek’s MLA uses the decoupled-RoPE split of Chapter 12. And, as noted, parts of Llama 4 omit positional encoding entirely on some layers (“NoPE”) to improve length generalization. The lesson is that position, long considered solved, is an active area: the assumption that every layer needs the same positional treatment is being questioned across the board.
15.4 The Cumulative Picture
Section titled “15.4 The Cumulative Picture”We can now assemble the comparison the book has built incrementally. Table 15.2 is the synthesis: for each major family, the complete set of architectural choices covered across Part IV. Read across a column to see a single model’s design; read across a row to see how the field diverges on one decision. The convergences are as striking as the differences — RMSNorm and gated FFNs everywhere, RoPE everywhere, MoE for nearly every flagship — and the remaining differences (the attention mechanism above all) are exactly where competitive advantage is currently sought.
| Decision | DeepSeek-V3 | Qwen3 | Llama 4 | Gemma 3 | gpt-oss |
|---|---|---|---|---|---|
| Attention | MLA (latent KV) | GQA + QK-norm | GQA (+NoPE) | GQA local/global | GQA + sinks |
| Long context | DSA (V3.2) | hybrid (3.5) | chunked, 10M | sliding window | YaRN |
| Position | RoPE (decoupled) | RoPE | RoPE / NoPE | RoPE | RoPE (YaRN) |
| Norm | RMSNorm pre | RMSNorm pre | RMSNorm pre | RMSNorm sandwich | RMSNorm pre |
| FFN | MoE 256/8 +1 | dense or MoE | MoE 16 or 128 | dense GeGLU | MoE 128/4 |
| Activation | SwiGLU | SwiGLU | SwiGLU | GeGLU | SwiGLU |
| Train precision | FP8 | BF16 | FP8 | BF16 | BF16 / MXFP4 |
| Extra objective | MTP | — | — | — | — |
Table 15.2 — The complete architecture, family by family (the synthesis of Part IV)
Simplified; configurations vary across sizes and revisions within a family, and ”—” means not a defining feature rather than strictly absent. The single biggest differentiator is the attention column — MLA versus GQA versus the various sparse and hybrid schemes — which is where the most active research now concentrates.
Key point A modern LLM is the sum of a dozen decisions, most of which the field now agrees on. The disagreements are concentrated and identifiable: how to attend (and how to attend over long contexts), whether and how to be sparse, and what precision to train in. If you understand this one table, you understand the design space of every open model shipping today.
Every component is now accounted for, in isolation and in comparison. The final chapter of Part IV does the assembly: it combines MLA and MoE into a single block, stacks them into the complete DeepSeek-style model, and traces a forward pass end to end — turning the baseline GPT of Chapter 10 into a frontier-class architecture with a remarkably small set of changes.
15.5 Worked Example: RMSNorm versus LayerNorm
Section titled “15.5 Worked Example: RMSNorm versus LayerNorm”Normalization keeps the scale of activations in check as they pass through dozens of layers, and modern models have almost universally replaced LayerNorm with the simpler RMSNorm. The difference is exactly one operation: LayerNorm subtracts the mean and divides by the standard deviation; RMSNorm skips the centering and rescales by the root-mean-square alone:
def rmsnorm(x, weight, eps=1e-6): rms = x.pow(2).mean(-1, keepdim=True).add(eps).rsqrt() return x * rms * weight # scale only; no mean, no biasPython — norm/rmsnorm.py: normalization without centering
Dropping the mean subtraction removes a reduction, a subtraction, and the learned bias term, which at the scale of a frontier model — applied twice per layer across dozens of layers and trillions of tokens — is a measurable saving. The empirical surprise, established across many large models, is that quality does not suffer: the centering operation LayerNorm performs turns out to be largely redundant for transformer training. RMSNorm is thus a small, clean example of a recurring pattern in this book — a simplification that is also an optimization, kept because it is both cheaper and no worse.
Where the norm sits matters as much as which norm it is. Pre-normalization (normalizing the input to each sublayer rather than its output) is what makes very deep transformers trainable at all, keeping the residual stream’s scale stable so gradients neither vanish nor explode across depth — the stability concern that Chapter 21 returns to when the same residual stream misbehaves at scale.
Less is the same, for less RMSNorm keeps LayerNorm’s scaling and discards its centering, costing fewer operations for indistinguishable quality. It is the canonical case of a frontier simplification that survives precisely because it is free.
15.6 Where to Place the Norm: Pre-Norm, Post-Norm, and QK-Norm
Section titled “15.6 Where to Place the Norm: Pre-Norm, Post-Norm, and QK-Norm”Section 15.5 settled which norm (RMSNorm); equally consequential is where it goes, and the answer has shifted as models grew deeper. The original transformer used post-norm: normalize the output of each sublayer, after the residual is added. This works for shallow networks but makes very deep ones hard to train, because the residual stream’s scale is not controlled going into each block and gradients destabilize across many layers.
The modern default is pre-norm: normalize the input to each sublayer, before it computes, leaving the residual addition itself untouched (Section 8.5). This keeps the residual stream’s scale stable through depth and is what makes today’s dozens-of-layers models trainable at all. A third, more recent placement addresses a specific failure at scale: QK-norm normalizes the queries and keys just before the attention dot product, directly bounding the attention logits whose uncontrolled growth (Section 21.8) can destabilize large-model training. These placements are not mutually exclusive — a large model commonly uses pre-norm throughout and adds QK-norm inside attention — and each targets a distinct instability: pre-norm for the residual stream’s depth-wise scale, QK-norm for the attention logits’ magnitude. Choosing where to normalize is, in effect, choosing which quantity you are most worried will grow out of control.
Placement targets a specific instability Post-norm normalizes outputs and struggles at depth; pre-norm normalizes inputs and makes deep models trainable; QK-norm bounds the attention logits at scale. They stack, each guarding a different quantity from growing unchecked.
15.7 Could We Remove Normalization?
Section titled “15.7 Could We Remove Normalization?”Normalization is so ubiquitous (Section 15.2) that it is easy to assume it is indispensable — but a line of research asks exactly whether it is, and the answer illuminates what normalization really does. The motivation is concrete: normalization layers add computation and can become a bottleneck, particularly in distributed settings where they involve coordination, so a transformer that trained well without them would be appealing.
The work on normalization-free networks shows it is sometimes possible. By combining careful initialization (Section 21.10) with deliberate scaling — for instance, scaling down the residual branches by depth so their summed contributions stay controlled (Section 8.5) — deep transformers can be trained without explicit normalization layers, the controlled initialization and scaling doing the job that normalization otherwise does. The clarifying lesson is what this reveals about normalization’s actual role: it is there to keep the scale of activations under control as they flow through a deep network, and that control can in principle be achieved by other means. Normalization nonetheless remains the standard choice, because it is cheap, robust, and forgiving — it controls activation scale automatically without the delicate tuning that norm-free approaches demand — so the practical cost-benefit still favors keeping it. But the research is a useful reminder that even the most “standard” components of the architecture are choices rather than necessities, included because they earn their place, not because no alternative exists. Understanding why a component is there — what specific problem it solves — is what lets you reason about when it could be replaced.
Standard is not the same as mandatory Normalization exists to control activation scale through depth, and careful initialization and residual scaling can sometimes do the same job without it. Norms remain standard because they are cheap and forgiving — but knowing what they actually do is what reveals them as a choice.