Skip to content

13 · Map

End-to-end map and catalogue

The stacked forward equation, the train path, the infer path, Jacobians, and what each piece is for.

Stacked forward map

x₁:Ttokens
H⁽⁰⁾embed + RoPE
H⁽ⁿ⁾n blocks
Zlogits
p₁:Tsoftmax

Forward map. Training attaches CE → Jacobians → AdamW after p. Inference samples from p.

(13.1)

Train path

(13.2)

Infer path

(13.3)

Jacobian catalogue

Reverse-mode AD never materializes most of these as matrices. It computes the vector-Jacobian products. Written out, they are the whole backward pass.

MapJacobian / VJP
softmaxdiag(a) − aaᵀ
CE + softmaxp − y
Y = XW∂L/∂X = G Wᵀ, ∂L/∂W = Xᵀ G
RMSNormr⁻¹ (I − uuᵀ / (d r²))
LayerNormsame, after P = I − 11ᵀ/d
residual H ↦ H + F(H)I + J_Fᵀ
RoPERᵀ = R⁻¹
SiLUσ(z) + z σ(z)(1 − σ(z))
embedding lookupscatter into row x_t

What each piece is for

The whole machine is one differentiable map from token IDs to next-token distributions. Training differentiates that map and walks θ downhill on cross-entropy. Use-time throws the derivative away and only evaluates the map.

PieceJob
Tokenizer / BPEDiscrete interface to text. Frozen. Defines the units of loss.
Embedding + positionPut tokens into a space where order exists
Residual streamCommon currency every layer reads and writes
NormControl scale so depth does not explode
Causal attentionMove information from past tokens to the current one
√dₕ scaleKeep scores O(1) so softmax does not saturate
GQA / MQAShare KV heads so the cache, not the matmul, stays small
MLP / SwiGLUPer-token computation and stored features
Unembed + softmaxTurn vectors into a distribution over V
Cross-entropy = MLEScalar “how wrong was the next-token guess”
Entropy + KLFloor versus avoidable error
Softmax–CE gradient p − yError signal into logits
Jacobians / backpropRoute that scalar error to every weight
Skip-connection Jacobian IMake deep nets trainable
AdamW + schedule + clipStable updates at billion-parameter scale
C ≈ 6ND / Chinchilla ECompute unit and the fitted floor
Validation lossMeasure generalization; zero is not the target
Sampling + KV cacheUse the trained pθ without changing it