Highlights

Contents

Part I
01

Feature computation, now seen from training

Training must differentiate feature transformation as well as attention. Shared weights collect contributions from every position. Follow how activation and gating change those gradient routes and what backward must retain.

THE TRAINING CHAPTER: TEN PARTS, ONE COMPLETE MODEL1. features2. output3. examples + loss4. optimizer5. precision6. resume + loop7. evaluation8. experiments9. decoding10. whole pipelineforward computation → learn parameters → measure results → generate

#Section 1Feed-forward networks

Suppose bank has already collected context from river. The architectural reason to process that context locally is covered in why attention has an FFN beside it. Attention emphasizes token mixing, communication across positions; the FFN emphasizes feature mixing, transformation within each contextual token vector. Attention’s own projections and input-dependent weights also transform features, so “attention is linear” is not a sound argument for needing an FFN.

Standard Transformer FFN, expansion and projection back

An intermediate dimension expands each token’s features before activation and projection back to model width. Positions share the same FFN weights; separate blocks have separate parameters. Expansion creates features, not additional tokens.

Activation functions and the backward route

The training question is what the nonlinear operation does to a correction signal. An activation function changes a projected coordinate nonlinearly. Its derivative also changes the correction sent to the expansion matrix. ReLU sends zero derivative through a negative preactivation; SiLU has a smooth derivative that can be negative in part of its input range. A gate that looks nearly closed is not automatically a branch that never learns.

SiLU⁡′(u)=σ(u)+uσ(u)(1−σ(u)),σ(u)=11+e−u.\operatorname{SiLU}'(u)=\sigma(u)+u\sigma(u)\big(1-\sigma(u)\big),\qquad \sigma(u)=\frac{1}{1+e^{-u}}.

SiLU's local derivative multiplies the incoming loss gradient. Smoothness does not mean every derivative is positive or below one.

A LOCAL SLOPE IS THE MULTIPLIER USED BY BACKWARDSiLUu = -2slope -0.090784SiLUu = 0slope 0.500000SiLUu = 2slope 1.090784nearly closed does not mean unable to learn
Figure 3.1Calculated SiLU derivatives at three illustrative preactivations. Orange marks the local multipliers that transform a gradient; a negative preactivation can still receive a nonzero correction.

Every position using a shared weight contributes to its gradient. These contributions add; parallel processing does not create independent weight copies.

ALL POSITIONS CONTRIBUTE TO THE SAME WEIGHT GRADIENTx₁ = [1,2]r₁ = 0.5[0.5, 1]x₂ = [3,4]r₂ = -0.25[-0.75, -1]∇W column = [-0.25, 0]one column, reused twice
Figure 3.2Two illustrative positions contribute to one shared projection gradient. The orange sum is the update signal for one weight column, not a separate column for each token.

#Section 2From GELU to SwiGLU

A gate changes the derivative route as well as the forward value. For the architecture itself, follow ReLU, GELU, SiLU and Swish, GLU and SwiGLU's gate, and the family and implementation. These sections define the activation curves, gating intuition, and the separate gate, up and down projections. Swish with its parameter set to one equals SiLU; the general Swish family allows a different parameter.

Gating, three projections and intermediate width

Gate and up branches expand features, and the down projection returns their product to residual width. An extra projection raises cost, so hidden-width choices matter in a controlled comparison.

Why the two branches both learn

Let gate preactivation be gg, up value be uu, and their product be a=SiLU⁡(g)ua=\operatorname{SiLU}(g)u. Let rr be the loss derivative arriving at that product from the down projection. The local derivatives are:

∂L∂g=r u SiLU⁡′(g),∂L∂u=r SiLU⁡(g).\frac{\partial\mathcal L}{\partial g}=r\,u\,\operatorname{SiLU}'(g),\qquad \frac{\partial\mathcal L}{\partial u}=r\,\operatorname{SiLU}(g).

Read this as: the gate's correction is the incoming derivative rr multiplied by the content and the slope of SiLU; the content's correction is rr multiplied by the gate's activated value. These are scalar formulas applied independently to each expanded coordinate. The two projection matrices then receive gradients through their ordinary matrix multiplies.

For illustrative g=−2g=-2, u=3u=3 and r=1r=1, the forward product is −0.715218-0.715218. The gate correction is 3×(−0.090784)=−0.2723533\times(-0.090784)=-0.272353, and the content correction is −0.238406-0.238406. Neither is zero. Swapping the branches changes both the output and this derivative route.

PRODUCT RULE: THE TWO BRANCHES RECEIVE DIFFERENT CORRECTIONSincoming r = 1a = SiLU(g) × ugate: r × u × SiLU′(g)-0.272353content: r × SiLU(g)-0.238406g = -2, u = 3, a = -0.715218backward follows both learned branches
Figure 3.3One illustrative SwiGLU coordinate splits an incoming gradient into different gate and content corrections. The multipliers come from the product rule and the calculated SiLU derivative.

SwiGLU versus a standard FFN during training

The original gated-FFN experiments support the use of gated variants under their controlled setup. Llama 3’s reference implementation provides a specific modern example. This does not establish that SwiGLU is best for every workload, or that a model’s architecture is modern merely because its activation has that name. We will test architectural choices with seed spread and controlled budgets in Part VIII.

Backward may retain expanded branches and other intermediates. Fused kernels or recomputation change which tensors survive, so a named activation count is not peak memory.

TWO EXPANSION TENSORS, EACH WITH THE SAME TOKEN GRIDgate preactivation(2, 8, 1536)49,152 BF16 bytesup projection(2, 8, 1536)49,152 BF16 bytesdrawn depth is symbolic; full width is 1,536 channels
Figure 3.4Two named BF16 expansion tensors in one Finch-24 FFN. Each contains 24,576 values, or 49,152 bytes; the combined 98,304-byte subtotal excludes the product and other saved state.