Gated Linear Units › Key Parameters

Michael BrenndoerferUpdated June 14, 20252 min read
Language AI HandbookAll chapters
Part 15 of 67Transformer Blocks
Chapter 109Gated Linear Units › Key Parameters
Reading section 15 of 16 · Key Parameters · 2 minSection 15 of 16 · 2 min

Book contents

Section 15 of 16 · 2 min read

Gated Linear Units › Key ParametersOne section · Sections in this chapter15 / 16 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

When implementing or configuring GLU-based feed-forward networks:

  • d_model (input/output dimension): The embedding dimension, unchanged from standard FFNs. Must match the attention layer output for proper residual connections.

  • d_ff (hidden dimension): The dimension of the gated intermediate representation. For parameter parity with standard FFNs, use dff=23×4×dmodel=83×dmodeld_{ff} = \frac{2}{3} \times 4 \times d_{\text{model}} = \frac{8}{3} \times d_{\text{model}}. LLaMA rounds this to the nearest multiple of 256 for hardware efficiency. Higher ratios (3.5x or 4x) trade parameters for expressiveness.

  • glu_variant: The choice of activation function for gating. SwiGLU (Swish(xW)⊗xV\text{Swish}(xW) \otimes xV) is the dominant choice. GeGLU uses GELU instead. ReGLU uses ReLU but is less common due to ReLU's sharp transitions.

  • use_bias: Whether to include bias terms. Modern architectures (LLaMA, Mistral, PaLM) typically omit biases entirely, reducing parameters and simplifying quantization. The impact on model quality is minimal.

  • multiple_of (LLaMA-specific): Round dffd_{ff} to a multiple of this value (typically 256) for GPU memory alignment. The formula used is:

dff=m×⌈23×4×dmodelm⌉d_{ff} = m \times \left\lceil \frac{\frac{2}{3} \times 4 \times d_{\text{model}}}{m} \right\rceil

where mm is the multiple_of value and ⌈⋅⌉\lceil \cdot \rceil denotes the ceiling function. For example, with dmodel=4096d_{\text{model}} = 4096 and m=256m = 256: the raw value is 83×4096=10922.67\frac{8}{3} \times 4096 = 10922.67, and rounding up to the nearest multiple of 256 gives dff=11008d_{ff} = 11008.