Frontier releases · 6
Amazon Ergo
A residual that turns instead of adds
Official release: .byhand release:
Amazon Ergo does not add its layers' outputs to the residual stream. It turns the stream toward them.
The key idea: each layer's output is weighted by the sine of a learned angle and the stream by its cosine, one angle per channel. The two weights' squares sum to one, so the stream keeps its size through all 128 half-layers.
Amazon's Frontier Model Research team released Ergo on December 1: a mixture of experts of 1.1 trillion parameters, 55 billion active, 64 layers, a context of 1M tokens, built for software engineering and agents. Gating a residual goes back to Highway Networks (2015).
The rest of it is familiar: three layers in four attend to the last 512 tokens with rotary positions, the fourth to everything with no positions at all; 256 experts, 8 per token; RMSNorm before and after each half-layer. What stands out is the line that joins each half-layer to the stream.
Double-click a box to open it, or select it and press Enter. The gate is in every Sublayer, under Residual.
- 1
The residual gate
block Residual residual[s,d], branch[s,d] => y[s,d] {
w[d8192]
w | Angle => sine, cosine
branch * sine => moved
residual * cosine => kept
kept + moved => y
}A transformer's residual is x + f(x): whatever a layer computes is added to the stream at full weight, 128 times in Ergo's case. Ergo weights the two sides instead, the layer's output by a sine and the stream by a cosine, one angle for each of the 8192 channels, learned.
Amazon's code does not say it is an angle. It writes the stream's weight as sqrt(1 + sigmoid(w)) * exp(-softplus(w) / 2). Work it through and that is sqrt(1 - sigmoid(w)^2): with sigmoid(w) as the sine, it is the cosine of the same angle.
| w | sine σ(w) | Amazon's form √(1+σ(w))·e^(−softplus(w)/2) | cosine √(1 − sine²) |
|---|---|---|---|
| −3 | 0.0474 | 0.9989 | 0.9989 |
| −1 | 0.2689 | 0.9632 | 0.9632 |
| 0 | 0.5000 | 0.8660 | 0.8660 |
| 1 | 0.7311 | 0.6823 | 0.6823 |
| 3 | 0.9526 | 0.3043 | 0.3043 |
The program says so:
block Angle w[d] => sine[d], cosine[d] {
w | sigmoid => sine
w
| scale factor=-1
| sigmoid
=> rest
sine + 1 => more
more * rest
| sqrt
=> cosine
}((1 + sigmoid(w)) * sigmoid(-w) is 1 - sigmoid(w)^2, written so that it keeps its digits where the sine is close to 1.)
Three things follow from the angle.
The sum keeps its size. The squares of the two weights add to one. Where the stream and a layer's output are of a size and unrelated, the stream comes out of each half-layer as large as it went in. A plain residual grows with depth and needs a norm or a scale to hold it; this one holds itself, channel by channel.
Every channel chooses its own mix. A channel with a small angle keeps its stream and takes a little of the layer; one near 90° is nearly replaced. The sigmoid keeps the angle between 0° and 90°, so a layer never subtracts from the stream and never flips it.
At zero it is 30°. The code initialises w at zero, where the sine is one half: a fresh layer writes at 30°, and training moves each channel from there.
Highway Networks weighted the two sides by T and 1 − T, which sum to one. Ergo's weights' squares sum to one.
We verified the program against Ergo's implementation in Hugging Face Transformers, in PyTorch and JAX.