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.
#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's local derivative multiplies the incoming loss gradient. Smoothness does not mean every derivative is positive or below one.
Every position using a shared weight contributes to its gradient. These contributions add; parallel processing does not create independent weight copies.
#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 , up value be , and their product be . Let be the loss derivative arriving at that product from the down projection. The local derivatives are:
Read this as: the gate's correction is the incoming derivative multiplied by the content and the slope of SiLU; the content's correction is 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 , and , the forward product is . The gate correction is , and the content correction is . Neither is zero. Swapping the branches changes both the output and this derivative route.
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.