A Transformer produces a new vector at every attention or MLP sublayer, then adds it to the residual stream. The next sublayer receives the sum. It can read the features in that sum, but it cannot ask for the output of layer 3 by itself.
Working on Hyper-Connections brought me back to that addition. We spend most of the computation producing new features; the connection between layers decides which results remain separately available. Keeping two contributions apart lets a later layer choose between them. Adding them together makes that choice earlier.
A residual stream carries a running sum
Follow one token position through a Pre-LN Transformer. Count each attention or MLP sublayer as one step:
Both and have coordinates. An attention sublayer still reads other token positions; we are following what happens to its output at this position as depth increases.
Unrolling the additions gives
Every earlier output enters this expression with coefficient one. The next sublayer receives this accumulated state, followed by normalization.
Suppose two earlier computations produced and . Once only remains, a later layer cannot generally choose to read alone. The pairs and produce the same sum for any . A network can learn to encode contributions in distinguishable feature directions, but the connection itself supplies one vector, with no separate address for each contribution.
The point where we add vectors determines which choices remain available later. Hyper-Connections changes that point by carrying several states between sublayers.
HC separates reading, mixing, and writing
Hyper-Connections maintains residual streams for each token. Stack them as rows:
Each row is a full -dimensional state at the same token position. Three sets of coefficients connect it to the next sublayer:
| Coefficient | Shape | What it controls |
|---|---|---|
| Which combination of streams the sublayer reads | ||
| How the existing streams mix with each other | ||
| How much of the new output each stream receives |
The read and computation are
The state update is
The attention or MLP still processes one -dimensional input. The extra streams expand the state carried between sublayers. Static HC learns fixed coefficients for each sublayer; dynamic HC generates coefficients from the current state, allowing different tokens to use different mixtures.
For a concrete two-stream example, take
The sublayer reads , computes , and leaves
The next read can select , select , or combine them. Reading one stream did not force the output back into that same stream. This is a possible routing pattern, rather than an assigned meaning for either stream.
An old output reaches deeper layers through learned coefficients
Two steps of the HC recurrence give
The first output is still present, but its coefficients across streams have changed from to . Reading with assigns that output the scalar coefficient .
More generally, define
Then
The coefficient of in the next read is . The write determines where a result starts; subsequent mixing determines where it travels; the read determines how much reaches the next computation.
This expansion also holds along a dynamic HC forward pass, using the coefficients produced on that pass. Those coefficients depend on the states, so the expansion does not turn the model into a linear function of its input.
One output gives every stream the same write direction
In HC, the newly added state is
Every stream receives a multiple of the same output vector. Increasing adds destinations, but this write still supplies only one feature direction. Outputs from different sublayers can accumulate into a higher-rank state; the restriction is on the new contribution from one sublayer.
This suggested a simple change for our experiments: keep the contributions inside a sublayer separate until they reach the streams. Split the MLP’s hidden activations into groups and partition the down-projection’s columns to match:
Each is a contribution to the full output. In ordinary HC, stream receives : the same scalar multiplies every group. Our change gives each stream a separate coefficient for each group. Collect these coefficients in , where weights group for stream . With the contributions stacked as rows of , the write becomes
For two groups, the contribution added to stream is
Originally, changing scales both groups together. With separate coefficients, the stream can emphasize one group without scaling the other. We change which coefficients must be shared; training determines their values. As with HC, they can be learned directly or generated from the current state by a learned mapping. Setting for every group recovers the original write.
Attention allows the same change: each head contributes through its slice of the output projection. We write these projected contributions separately, while keeping Q/K/V and attention over tokens unchanged.