Raindrop lab · Glossary · draft

residual stream

How to explain it

Inside the model, each token has its own long list of numbers - its residual stream - climbing up through the model's 32 layers. Each layer reads the list, works out an update, and adds its result on top, never wiping the list clean. What reaches the top is the starting list plus everything the 32 layers added.

For each token, the model keeps one running list of numbers - 2,560 of them in Qwen3.5-4B - that acts as its working state. The list starts as the token's embedding. Each of the model's 32 layers reads the list, works out a 2,560-number update of its own, and adds it on number by number, while the incoming list skips straight past the layer (a skip connection). What reaches the top is scored against the dictionary to give the odds for the next token.

Each position carries a vector, 2,560 numbers wide in Qwen3.5-4B. Its embedding row starts it, and every layer adds to it rather than replacing it: x←x+f(x)x \leftarrow x + f(x), not x←f(x)x \leftarrow f(x). Each of the 32 layers adds twice: once from its part that mixes information between positions (attention, or a linear-attention layer) and once from its feed-forward part, each reading a normalised copy of the stream. The bypass around each part is the skip connection. Skip connections made deep networks trainable: in image recognition, stacks of layers that replaced their input trained worse as they grew deeper, and adding let networks reach 152 layers. Each position's stream reads only the positions up to its own and ends in a guess at the next token; in training every position is scored on its guess, which is why one pass over a text gives a guess at every position.

Pre-norm: x0=E[t]x_0 = E[t]; at each layer x←x+Mix(RMSNorm(x))x \leftarrow x + \mathrm{Mix}(\mathrm{RMSNorm}(x)), then x←x+FFN(RMSNorm(x))x \leftarrow x + \mathrm{FFN}(\mathrm{RMSNorm}(x)); the output is RMSNorm(xL)\mathrm{RMSNorm}(x_L), scored against the tied table (logits). Qwen3.5-4B is 2,560 wide, with 32 layers in 8 groups of 3 Gated DeltaNet (linear-attention) layers and 1 full-attention layer, and feed-forward blocks that expand to 9,216. The identity shortcut is ResNet's (He et al., 2015, Deep Residual Learning for Image Recognition): plain networks of 56 layers trained worse than networks of 20, while residual networks kept improving up to 152 layers. Highway Networks (Srivastava et al., 2015) gate the shortcut, so a layer can scale its input down; Qwen3.5 adds with no gate, and the input always passes through unchanged. Lesson 3's probe checks the sum: at space, “rain” in its sentence, the row plus the 32 layers' updates, added in float32, lands within 0.11 of the model's own top in every number (the model rounds the stream to bfloat16 after every addition), and scored alike both give the same prediction. Taking one layer out (its update dropped, the layers above run again) leaves “drop” first at space, “rain” for 30 of the 32 layers; layer 1, whose update is four times the row it joins, is the one that breaks it (Veit et al., 2016, found the same robustness in ResNets; Lad et al., 2024, in transformers).

Lesson 3 pictures the stream as a communication bus, like the shared wiring inside a computer: one channel that all 32 layers read from and write to. Layers have no private wires to one another, so the only way an early layer can pass something on to a later one is by adding it to the stream.

Lesson 3 pictures the stream as a communication bus: like the shared wires inside a computer, it is one channel that every layer reads from and writes to. No layer has a private wire to another, so a later layer can only learn what an earlier one worked out by reading it off the stream.

Where the bus picture breaks. On a computer's bus a new value replaces the old one; here every update is added, so everything every layer wrote is still on the stream at the top, though a layer can cancel something by adding its opposite. And the stream has no separate wires: its 2,560 numbers are not lanes, one per message; messages are spread across directions of the vector and overlap. Because the stream keeps one size and one form from the row to the top, it can be read partway up the way the top is read, which is what the logit lens does.

The view of the stream as a shared channel is Elhage et al.'s (2021, A Mathematical Framework for Transformer Circuits): every layer reads the stream through a linear map and writes to it by adding, the stream is the only path from one layer to another, and it has no privileged basis, so its 2,560 numbers are not channels. An instance of cancelling, from lesson 3's probe: at space, “rain”, number 0 of the stream is about +18.0 before layer 32, layer 32's update puts −18.6 there, and the top has −0.6. Because the stream is a sum and the final RMSNorm divides the whole top by one number, a score at the top splits exactly into the row's share and each layer's (direct logit attribution); at space, “rain”, 88% of “drop”'s score, measured from the vocabulary's mean, comes from layers 23 to 32. Partway up, the norm's divisor differs, so the logit lens is a reading, not a decomposition.