Summary
Tatsunori Hashimoto surveys modern transformer architectures by comparing what a large number of released models actually do, on the argument that no single paper gives enough detail and the design space is too large to explore directly. The lecture separates choices that have converged across nearly all models — normalization placement, RMSNorm, gated activations, RoPE — from those still in flux, mainly how position and long-range context are handled. It then descends into hyperparameter rules of thumb, training stability tricks, and the attention modifications driven by inference cost. A recurring theme is that architecture is a compromise between expressiveness, hardware efficiency, and not blowing up mid-training, which is why the result looks inelegant. Parallel attention/MLP blocks from GPT-J and PaLM are covered as an idea that has since fallen out of favor.
Key Takeaways
- The one thing everyone agrees the original transformer got wrong is normalization placement. Modern models move the norm out of the residual stream (pre-norm), keeping it clean so gradients propagate straight to the output; post-norm changes gradient norms at every block and produces more frequent spikes. The motivation was originally to remove learning-rate warmup, but it stuck for stability and depth. OPT-350M is the odd exception that kept post-norm in the residual stream.
- RMSNorm replaces LayerNorm almost everywhere: it drops the mean subtraction and bias, and although LayerNorm is strictly more expressive, there is no measured loss in quality. The reason is arithmetic intensity — normalization is roughly 0.17% of FLOPs but can be up to 25% of runtime because it is memory-movement bound. Bias terms in linear layers are dropped for the same reason.
- Gated linear units (SwiGLU in Llama descendants and PaLM, GeGLU in Gemma and T5) are near-universal. Gating adds a third matrix, so the feedforward dimension is scaled by 2/3 to keep the parameter count matched; Shazeer’s parameter-matched comparisons show small but consistent gains. Non-gated models still train fine — GPT-3 used GELU and Nemotron 340B used a squared ReLU.
- RoPE encodes position by rotation: split the vector into 2D pairs and rotate each pair by an angle proportional to absolute position, with different frequencies per pair so some capture local and some long-range structure. Inner products then depend only on relative offset. Earlier schemes fail this test — sine/cosine embeddings leak absolute position through cross terms, and additive relative biases (T5, Chinchilla) have no inner-product structure. Rotations are applied to queries and keys at each attention layer. Gemma 4’s p-RoPE rotates only the first coordinates.
- Hyperparameters sit in wide, forgiving basins. Feedforward ratio is 4× d_model, or about 2.67 for GLU models after the 2/3 correction (Llama 2 arbitrarily used ~3.5); head_dim × n_heads is kept equal to d_model; the aspect ratio d_model/n_layers is around 100 for nearly every model. Depth is constrained partly by systems concerns — splitting layers means pipeline parallelism, which people avoid, while width splits cleanly with tensor parallelism. Vocabulary is roughly 30k for older monolingual models and 100k–200k for multilingual and production ones. T5’s 64× feedforward multiplier is the great outlier, and T5 v1.1 quietly reverted to about 2.5.
- Regularization is counterintuitive here. Single-pass training over more data than compute allows means overfitting is essentially absent, yet weight decay remains common. The evidence is that weight decay acts as an optimization intervention rather than a regularizer: it does not shift the train/validation gap, but combined with learning-rate decay, stronger weight decay runs converge to better minima.
- Stability interventions cluster around the two softmaxes. The z-loss penalizes squared log-normalizer to keep the output softmax’s Z near 1 (Devlin 2014, revived by Baichuan, DCLM, OLMo). QK norm applies RMSNorm to queries and keys so the inputs to the attention softmax have consistent scale; it came from multimodal work (Chameleon, Idefics) and is now standard. Logit soft-capping with a tanh (Gemma 2/3/4) is a harder constraint, and NVIDIA’s systematic comparison found it costs quality, while QK norm slightly helps by allowing a higher learning rate.
- Attention modifications are driven by inference, not training. During decode the KV cache makes arithmetic intensity roughly n/d + 1/b, which is memory bound and hard to fix for small models. MQA shares one key and value across all heads, multiplying intensity by the head count but losing real expressive power; GQA keeps every query head and only reduces the number of key/value heads, which recovers nearly full quality at much lower inference cost and is why almost all current models use it.
- Sliding window attention has been revived for long context: alternate full attention layers with local banded ones, as GPT-3 did and Cohere Command A reintroduced with full attention every fourth layer. Llama 4, Gemma 4, and OLMo 3 all use some version of this; Qwen3.5 uses the same alternating structure but substitutes a gated DeltaNet state space layer for the cheap local layer. Managing the long-context cost/quality tradeoff is where most architecture work is still happening.
Extracted Notes
- None yet.