Module 6. Normalization, activations, and the anatomy of a Transformer block
Try each exercise first. Expand worked answers or project guidance when needed; their open state is shared between RU/EN.
Download course files (.zip) 2588.1 KBThe archive preserves the source folder structure, both languages, and supporting files.
E1. Exact block accounting
Compute the matrix-only and full counts for the Llama-3.1-8B block.
Show answer and solution
Solution. In GQA, and are , while K/V width is one quarter of . The two K/V matrices therefore contribute , giving
SwiGLU has gate, up, and down projections. With , their count is . Thus
Two RMSNorm scales add , yielding 218,112,000. Biases are excluded by this architecture contract.
E2. Epsilon and gain
Compare the RMSNorm multipliers at input RMS for and .
Show answer and solution
Solution. RMSNorm divides by . Here the signal-square term is , so
The larger epsilon more than halves the gain because it dominates this small signal. Epsilon must therefore reflect reduction precision and expected activation scale, not dtype machine epsilon alone.
E3. The negative gpt-oss branch
Explain why the up-branch clip still changes the case.
Show answer and solution
Solution. Use , , and :
| -9 | -9 | -7 | 0.000012019 |
| -2 | -2 | -2 | 0.064341377 |
| 0 | 0 | 0 | 0 |
| 2 | 2 | 2 | 5.806975869 |
| 7 | 7 | 7 | 55.999625026 |
| 9 | 7 | 7 | 55.999625026 |
At , the gate is not lower-clipped and its sigmoid nearly suppresses it, but the up branch is still changed to and enters as . The output is small because of the gate, not because the clip is irrelevant. At 7 and 9, both used branches are identical, so the outputs match.
E4 [project]
Compare RMSNorm, DyT, and DyISRU on one small language model with matched seeds, optimizer, data order, and a learning-rate sweep. Do not extrapolate one run to 100B scale.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 6, section “Demo 1”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.
E5 [project]
Compare Q/K score distributions for two open models with different stabilization mechanisms. Record the exact code path; do not merge L2 normalization, Q/K RMSNorm, and logit soft-capping into one label.
Project demos and guidance
Demo for this project exercise: English project-demo notebook for Module 6, section “Demo 2”. It shows a compact reproducible example on small inputs, not a completed solution to the full-scale project.
E6. Scaling and reduction axes
Why does fixed positive epsilon break exact scale invariance? How does changing one head affect per-head and whole-projection RMSNorm?
Show answer and solution
Solution. For a positive scale , factor it out of the denominator:
Keeping fixed therefore changes the normalization. With a single value , , and unit learned scale, the output is . Doubling the input gives . The stabilizer is comparable to the squared signal, so the difference is substantial.
When RMS is reduced over all heads together, scaling one head changes the shared denominator and hence the untouched heads too. Separate head-wise reductions keep their denominators independent. Predict which heads will change before comparing the two notebook calculations.
E7. Doubly stochastic does not mean identity
Verify the example in §12. Does satisfying both sum constraints imply ?
Show answer and solution
Solution. Each row and column of the matrix in §12 sums to . Its first output is ; its second is . Thus .
Nonnegative entries and unit row sums make each output a convex combination, bounded between 2 and 6. The output range can shrink: here it is 3 to 5. Unit column sums additionally preserve the sum across streams: . Neither property preserves each stream separately. After a finite number of Sinkhorn–Knopp iterations, check both sum residuals before treating these properties as exact.