Name what wraps the attention sub-layer in every transformer block.
Every transformer block wraps attention in two things: a normalization (LayerNorm or RMSNorm) on the input and a residual skip that adds the attention output back to the original input.
Picture a really long assembly line where each station does something to a product, but the product is also carried past every station on a conveyor belt. Each station gets to see the product, do its little adjustment, and then add that adjustment to whatever was on the belt. If the station messes up, the original product still arrives at the end. That conveyor belt is the residual stream. And before any station touches the product, an inspector standardizes its size so the station gets predictable input, that is the normalization. Both wrappers exist because without them deep stacks of stations would either break the product completely or fail to train at all.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name the two wrappers, distinguish pre-norm and post-norm, explain why the residual is load-bearing for depth, note LayerNorm vs RMSNorm, give modern LLM examples.
Real products, models, and research that use this idea.
- Llama 4 Maverick uses pre-norm RMSNorm wrapping attention and FFN sub-layers across all 80+ blocks.
- Mistral Large 2 ships pre-norm RMSNorm with sliding-window attention inside the wrapper.
- GPT-2, GPT-3, GPT-4 all use pre-norm with LayerNorm in the original implementations.
- The original 2017 Vaswani transformer used post-norm LayerNorm, which required learning-rate warmup to train stably.
- DeepSeek V4 uses pre-norm RMSNorm wrapping MLA-style attention sub-layers.
What an interviewer would ask next. Try answering before peeking at the approach.
QWalk through how the gradient flows through a residual connection and explain why this prevents vanishing gradients.
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Forgetting the residual or treating it as 'just nice to have'. Without the residual, gradients vanish across stacked layers and the network does not train.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.