I. A High-Level Overview

A Transformer model processes information in a sequence. It begins with token embedding, where an input token (represented as a one-hot vector) is mapped to an embedding vector via an embedding matrix . This vector then passes through a series of residual blocks. Finally, the output of the last block, , undergoes token unembedding, where it is mapped to a vector of logits via an unembedding matrix .
In the pre-normalized decoder-only architecture used as our running model, each residual block (or Transformer block) consists of an attention layer followed by an MLP layer. Both sublayers read their input from the residual stream—the central pathway carrying vectors like —and subsequently write their results back to it. Suppressing normalization for the moment, each write has the residual form .
II. The Residual Stream as a Communication Channel
If we conceptualize a Transformer as a complex computational device, the residual stream is one of its most critical components (analogous to the cell state in LSTMs or the identity skip path in a residual network). In a pre-normalized Transformer, it is the initial token embedding plus the cumulative sum of the updates written by preceding sublayers: a sublayer reads but still writes its update additively to . A post-normalized block, which normalizes after the addition, does not admit this literal cumulative-sum unrolling across blocks.
Intuition (Communication Channel Analogy)
We can view the residual stream as a communication channel because the skip path itself only adds updates. The components connected to it are not linear in general: attention weights depend nonlinearly on the stream, MLPs contain activations, and practical models usually normalize before or after a sublayer. Subject to those qualifications, attention heads and MLP layers read information from the shared stream, process it, and write updates that later components can access.
A defining feature of the residual stream is its additive skip path. This is closely related to a ResNet: in the usual residual block, the skip path is the identity while nonlinearities live in the residual branch, although some variants also apply an activation after the addition. Transformer sublayers likewise contain nonlinear computation, even when their first and last learned maps are linear projections.
- Attention Layer: To process an input vector from the residual stream, the layer projects it into query, key, and value vectors using weight matrices . These are the “read” transformations. After computing the attention head’s output, this result is projected back into the residual stream’s dimension via the output matrix . This is the “write” transformation.
- MLP Layer: A standard Transformer MLP consists of two linear transformations with a non-linearity between them. Using column vectors in this subsection, the first linear layer, , reads from the residual stream. The second, , projects the activated hidden layer back into the stream. The full operation is .
These descriptions omit LayerNorm or RMSNorm. When normalization is present, the projections read the normalized stream rather than directly.
In the simplified architecture analyzed by Elhage et al.—where every operation that touches the residual stream is transformed consistently and there is no fixed coordinatewise normalization on that stream—the residual space has no privileged basis 1. In that setting, we can change the basis of the residual stream and transform the matrices that interact with it without changing the model’s computational behavior. Ordinary LayerNorm, RMSNorm with learned per-coordinate gains, or other coordinate-dependent operations restrict this symmetry, so the exact claim should not be transferred to every Transformer unchanged.
1. Understanding the Privileged Basis
Definition (Basis).For an -dimensional vector space , a basis is a set of linearly independent vectors, , such that any vector in can be uniquely expressed as a linear combination of these basis vectors. In the context of neural networks, the hidden state space is a vector space of dimension , and the most common basis is the standard basis , where each is a vector of zeros with a 1 in the -th position. Each standard basis vector corresponds to the activation of a single neuron.
The concept of a “privileged basis” is defined in 1 as follows:
“A privileged basis occurs when some aspect of a model’s architecture encourages neural network features to align with basis dimensions, for example because of a sparse activation function such as ReLU.”
Let’s dissect this with an example.
Following the work of Olah et al.
The critical distinction is how these features are represented:
- In a privileged basis, the architecture treats its coordinate axes specially, which can encourage learned features to align with individual neurons or small sparse sets of neurons.
- In a non-privileged basis, the architecture does not prefer those coordinate axes. A feature may therefore be represented by a dense direction rather than by a single neuron, but basis freedom alone does not determine what training will learn.
Consider a simple MLP trained to classify shapes. Let’s focus on a hidden layer with neurons, whose activation space is . The standard basis vectors are .
-
Case 1: No Sparse Activation (e.g., Linear Layer)
- The feature for “square” might be represented by the dense vector
[1.2, -0.9, 0.8, 1.1]. - The feature for “triangle” might be represented by
[-0.8, -1.1, 1.3, -0.9]. - Here, each feature is a complex combination of all four neurons. No single neuron is the “square detector.” The features are not aligned with the basis vectors. This is a non-privileged basis.
- The feature for “square” might be represented by the dense vector
-
Case 2: With a Sparse Activation (e.g., ReLU)
- The pre-activation vector for “square,”
[1.2, -0.9, 0.8, 1.1], becomes[1.2, 0, 0.8, 1.1]after passing through ReLU. Because ReLU is applied coordinate by coordinate, rotating the coordinates generally changes the function; the architecture therefore singles out the neuron basis. Training might also produce a sparser representation like[1.5, 0, 0, 0], but ReLU alone does not prove that this will happen or that Neuron 1 is a reliable square detector. - Similarly, “triangle” might activate Neuron 3, becoming
[0, 0, 1.3, 0]. - The justified architectural claim is that ReLU privileges the coordinate basis and can produce sparse activations by zeroing negative coordinates. Whether learned features actually align with individual neurons is an empirical question, and even an aligned activation does not by itself establish a causal or exclusive detector.
- The pre-activation vector for “square,”
The bare additive skip path has no coordinatewise activation and therefore does not itself create this pressure. Features can occupy arbitrary directions, although normalization and other operations around the stream may still privilege or restrict particular coordinates.
2. Rotational Invariance
Intuition (Why Rotate the Basis?)
- A model with a non-privileged basis is like an alien that speaks an unintelligible language. It computes the correct answers, but its internal representations—the features it uses—are encoded along arbitrary, dense directions in its high-dimensional state space.
- The standard basis (neuron activations) is the language we humans can directly read. But inspecting individual neuron activations is meaningless if features aren’t aligned with them.
The hope behind “rotating the basis” is to find a coordinate system whose axes better align with useful learned features. A candidate direction can then be tested as, say, a circle-related feature. This direction is not literally a neuron in the original network, and finding a rotation does not by itself establish a clean or causal interpretation.
Under the simplified assumptions stated above, we can apply rotations without changing the model’s output. Let’s see why.
Let be an arbitrary orthogonal rotation matrix, meaning and . Suppose we rotate a vector on the residual stream to get . For the model’s behavior to remain unchanged, every component that interacts with the stream must adapt.
Consider an attention component:
- Read Operation: The component reads from the stream using matrices . To preserve the computation, we need new matrices such that:
Substituting , we get . For this to hold for all , we must have , which implies . Thus, the new weight matrices simply “un-rotate” the input before applying the original transformation: . The underlying logic is unchanged.
- Write Operation: The layer writes its output back to the rotated stream:
Since all vectors on the stream must be consistently rotated, and . Substituting these into the original update rule gives:
This requires . The output projection is simply rotated along with the rest of the space.
Since the internal calculations of each component in this simplified model remain invariant after applying these compensatory rotations to the weight matrices, we call its residual stream rotationally invariant or basis-free. A normalized production architecture needs a separate symmetry analysis; the calculation above is not a proof for it.
III. Virtual Weights

The additive structure of the residual stream has another useful implication: for a direct write from one component followed by a linear read from a later component, we can compose their projection matrices into a “virtual weight.” This describes that direct path, not the complete nonlinear computation between the components.
Note (Virtual Weights Induced by the Residual Stream)
The additive residual path implicitly defines virtual weights between the writes and later linear reads of components, regardless of how far apart they are in depth. Such a virtual weight matrix is the product of the earlier component’s output projection and the later component’s input projection. If the later component first applies normalization, this fixed matrix no longer represents its entire read; it is best understood as the corresponding direct linear path in the normalization-free analysis.
Let be the computation of component (e.g., an attention head or MLP), with input weights and output weights . The update rule at step is:
Now, consider how the next component, , reads from the stream:
The term is a virtual weight matrix. It directly maps the output of component to the input of component . This shows that information written by layer is read by layer through this composite matrix.
We can extend this bookkeeping across multiple layers. In the normalization-free model, the input projection of component receives the direct contribution of component (where ) through . This supports the useful picture of later components reading earlier writes through the shared stream, while nonlinearities, attention patterns, normalization, and intervening writes still determine the actual computation.
IV. Subspaces and Bandwidth of the Residual Stream
The residual stream is a high-dimensional vector space (e.g., for BERT-base, for Gemma-2B). This dimensionality makes it possible for different layers and attention heads to use partly distinct subspaces, but the architecture does not require those subspaces to be disjoint or orthogonal.
Subspaces form an internal direct sum when every vector in their sum has a unique decomposition with . Equivalently,
We write their sum as . If they also span all of , then
For more than two subspaces, the weaker condition is not sufficient. Orthogonal subspaces do form a direct sum, but a direct sum need not be orthogonal.
In a multi-head attention layer, each head has a relatively small value dimension (often, but not always, ). After its output projection, head can write only into the image of , a subspace of dimension at most . Different heads may learn partly separated or nearly orthogonal write subspaces, but this is an empirical property of a trained model rather than a guarantee of multi-head attention. Overlap can also be useful because it lets heads reinforce or cancel one another.
Because later updates are added, an earlier write remains as an algebraic summand of the residual stream. That does not guarantee that the information remains decodable: later writes, normalization, or cancellation can obscure or erase it. With this caveat, is a useful analogy for communication bandwidth or working memory, and a larger stream offers more representational degrees of freedom without giving a simple capacity formula.
The framework paper further notes that embedding and unembedding maps can leave directions that are weakly constrained by direct token input or logit output 2. Calling these directions “free” is an intuition, not a guarantee that trained intermediate layers reserve or independently allocate them; the relevant ranks and usage must be measured in the model being analyzed.

Definition (Computational Dimension).Here, the term refers to the dimensionality of components that perform active computation, such as the MLP or the Attention Heads (in contrast, the residual stream primarily serves as an information carrier rather than a site of computation). For example, the output dimensionality of an Attention layer can match (after concatenating the multiple attention heads). In contrast, the hidden layer of the MLP typically has a dimensionality that is 4 times larger than .
This shared bandwidth can nevertheless constrain communication between sublayers. The computational dimensions of components can exceed the residual stream’s dimension; for instance, many MLP hidden layers are wider than . This makes the residual stream a bottleneck in the dimensional sense defined below, although dimensionality alone does not show that useful information is lost.
Definition (Bottleneck Activations).An activation vector is a dimensional bottleneck when its dimension is smaller than those of the representations on either side. The map must pass through a lower-dimensional space, although useful information need not be lost when the relevant data occupy a sufficiently low-dimensional set.
-
For example, the residual stream can be regarded as a form of bottleneck activation. MLP layers at different depths (which typically have activations of higher dimensionality than the residual stream) must communicate with one another through the residual stream. Consequently, the residual stream acts as an intermediary between two MLP layers whose hidden activations may have much larger dimensionality. Moreover, the residual stream is the only pathway through which any given MLP layer can communicate with subsequent layers. It must also carry forward information originating from other MLP layers along the path toward the extreme bottleneck.
-
Similarly, a value vector (in the decomposition of an attention head) also constitutes a bottleneck activation.
- In the common equal-width parameterization, each value vector has dimensionality , where denotes the number of attention heads. More generally, is an architectural choice.
- Let denote the residual stream at token position . The corresponding value vector is . This value vector is then used to update the residual stream at another position :
- In this way, information from residual state is projected into and contributes to the update at position . When , that projection is a dimensional bottleneck. Within the standard Transformer block covered here, attention’s weighted value path is the mechanism for cross-token communication; token-wise MLPs and normalizations do not themselves mix positions. Architectures with convolutions, recurrence, routing, or other mixing layers need not satisfy this claim.
In a particular trained model, an MLP neuron or attention head that writes the negative of an earlier component’s contribution can be interpreted as performing a memory-management-like operation. The algebra makes cancellation possible, but it does not imply that components generally allocate named dimensions or deliberately “free memory”; that interpretation requires causal evidence from the model.
V. Attention Heads Contribute Parallel Updates
A multi-head attention layer computes each head from the same input in parallel. Conditional on that input, one head’s forward calculation does not consume another head’s result, and the projected head outputs are summed. The heads are not statistically or functionally independent in general: they are trained jointly, share the residual input, and can interact through their summed write and through later layers.
Using row vectors for tokens, let and let denote the row at token position . For head , define
Here is the weight with which query position reads value position ; masked entries with are zero. Using for layer depth avoids overloading the token index .
Let be the result row vector from head , with dimension . In the original Transformer paper, the head results are concatenated and then projected by . Partition into row blocks , one for each head. Then
This decomposition shows that the total output is the sum of the separately projected head results. Each head contributes an update vector, but, as noted above, this algebraic decomposition does not imply that the learned head functions are independent.
VI. Attention Heads as Information Movers

Within the standard Transformer architecture covered here, an attention head is the component that moves information between token positions. It reads value information from residual states at source positions and contributes a weighted update at each query position.
To formalize this, let’s analyze the computation for a single head.
- Let be the matrix of input row vectors from the residual stream, with shape , where is sequence length.
- The head computes value vectors . This is a per-token operation.
- It computes an attention matrix (shape ), where is the softmax score from query to key .
- The result vectors are computed by mixing values: . This is an across-token operation, where the result for token , , is .
- Finally, with , the output written to the stream is .
This sequence of operations—per-token projection, across-token mixing, per-token projection—can be expressed using the Kronecker product (), following the notation in the framework paper 3.
A bilinear map is a function that combines elements from two vector spaces into an element of a third vector space. Moreover, a bilinear map is linear in each of its arguments when the other is fixed. Formally, a bilinear map satisfies:
A tensor product is a vector space together with a canonical bilinear map that is universal with respect to bilinear maps (i.e., for any bilinear map , there exists a unique linear map such that ).
If is an matrix and is a matrix, then their Kronecker product (denoted ) is the block matrix of size given by
- The Kronecker product is a concrete realization of the tensor product when and are regarded as linear maps between vector spaces.
- Define , where the ordinary stacks columns. Thus stacks the rows of into a column, matching our convention that tokens are rows. For compatible matrices , the useful identity is
If we stack the rows of into , then, conditional on holding the attention matrix fixed, the value-and-output path can be written as a linear transformation:
Using the mixed-product rule for Kronecker products, this becomes
This compact form separates the fixed pattern of movement between token positions, , from the value-output map applied in feature space. It is not a global linearization of self-attention: normally because queries and keys are computed from , so the full map is nonlinear.
We will stop at this general decomposition. To go further, we would need to study how is formed in a one-layer attention-only Transformer; that is a question for another note.
Citation
BIBTEX
@misc{ln2025residual, author={Nguyen Le}, title={Residual Stream is Key to Transformer Interpretability}, year={2025}, url={https://lenguyen.vercel.app/note/math-transformers}}References
- [Elhage et al., 2021]A Mathematical Framework for Transformer Circuits[HTML]Elhage, Nelson, Nanda, Neel, Olsson, Catherine, et al., 2021. Transformer Circuits Thread.
- [Olah et al., 2020]Olah, Chris, Cammarata, Nick, Schubert, Ludwig, et al., 2020. Distill.