Exercises
Practice residual traces, normalization statistics, norm ordering, MLP shapes, position independence, GELU, gated parameter counts, dropout modes, and silent block failures.
Use the stated convention in each problem. Show intermediate values when a problem asks for a calculation.
Q1. Trace both residual additions
For one token, , attention returns , and the MLP returns . Calculate and .
Answer it first, then check.
Hint
Solution
Q2. Calculate LayerNorm statistics
Ignoring epsilon, calculate the mean and population variance of .
Answer it first, then check.
Hint
Solution
Q3. Separate LayerNorm from RMSNorm
Which operation is unchanged before learned affine parameters when the same constant is added to every coordinate: LayerNorm or RMSNorm?
Answer it first, then check.
Hint
Solution
Q4. Order a pre-norm block
Put these operations in order: MLP normalization, attention residual addition, MLP residual addition, attention normalization.
Select one choice, then check.
Hint
Solution
Q5. Derive MLP shapes
For and , give the shapes of and .
Answer it first, then check.
Hint
Solution
Q6. Test position-wise independence
An MLP receives four token records. You alter only record 3. Which output records may change in a correct position-wise implementation?
Answer it first, then check.
Hint
Solution
Q7. Calculate a GELU value
Using and , calculate GELU.
Compute it first, then check your number.
Hint
Solution
Q8. Count a gated MLP
Ignoring all biases, a gated MLP has two input projections and one output projection. How many parameters does it have for , ?
Compute it first, then check your number.
Hint
Solution
Q9. Compare dropout modes
With inverted dropout, , , and a retained mask entry, give the training value and evaluation value.
Answer it first, then check.
Hint
Solution
Q10. Design a block audit
A block has the correct final shape but changing token 2 changes token 1 during the MLP-only stage. Name the violated contract and the first implementation axis or operation to inspect.
Select one choice, then check.