Core

The feed-forward block & where knowledge lives

After the mixer moves information between positions, a wide gated network transforms each position independently — and in Qwen3.8-27B this block holds most of the 27B parameters.

Updated

01 · Concept

Concept

Start with an accounting question. Qwen3.8-27B is marketed at roughly 27 billion parameters — so where do they physically sit? Attention earns the publicity because it draws visible links between tokens, but if you open the checkpoint and add up tensor sizes, the answer is unglamorous: around 17 billion parameters, the clear majority of the model, live in the feed-forward network (FFN) repeated in every one of the 64 layers. Attention routes information; the FFN transforms it; and the FFN is where most of the learned capacity resides.

The original Transformer block applies two linear maps with a nonlinearity between them:

FFN(x)=W2σ(W1x+b1)+b2.\operatorname{FFN}(x)=W_2\,\sigma(W_1x+b_1)+b_2.

The first projection expands from model width dmodeld_{model} to a larger intermediate width dffd_{ff}; the second projects back so the result can rejoin the residual stream. The same weights apply at every sequence position, positions are processed in parallel, and no information moves between tokens inside the block.

Qwen3.8-27B uses the gated descendant of this idea. Its FFN forms three projections instead of two:

FFN(x)=Wdown(SiLU(Wgatex)Wupx).\operatorname{FFN}(x)=W_{down}\left(\operatorname{SiLU}(W_{gate}\,x)\odot W_{up}\,x\right).

WgateW_{gate} and WupW_{up} both expand the 5120-dimensional hidden state to an intermediate width of 17,408. The gate path passes through SiLU — the smooth activation zσ(z)z\,\sigma(z), where σ\sigma is the logistic sigmoid — and multiplies the up path element-wise. One projection proposes candidate features; the other decides, feature by feature, how strongly each one fires. WdownW_{down} then compresses the 17,408 activations back to 5120 for the residual addition.

Now count parameters, and count them the way most people first get it wrong. The instinct trained on the two-matrix formula says: two matrices of 5120×1740889.15120\times 17408\approx 89.1 million entries each, so about 178 million parameters per layer. That misses the gate. The gated block holds three matrices — gate and up at 5120×174085120\times 17408, down at 17408×512017408\times 5120 — each around 89.1 million parameters, giving approximately 267 million per layer. Multiply by 64 layers and the FFNs alone account for roughly 17 billion parameters of the ~27 billion total. The attention-side projections, by comparison, are a small fraction of a layer’s budget. Each FFN matrix also costs about 89.1 million multiply-adds per token, so this block dominates compute as well as storage for typical context lengths.

Why spend the budget on width? A wide intermediate space is a large bank of pattern detectors. A row of WgateW_{gate} or WupW_{up} responds strongly when the incoming residual vector aligns with its learned direction; the gate suppresses or admits that response; columns of WdownW_{down} then write combinations of surviving features back into the 5120-dimensional model space. The block behaves less like a generic “extra layer” and more like a learned feature dictionary consulted at every position.

Research has sharpened that intuition into the key–value memory lens: input directions act as keys that recognize patterns, output directions as values that write associated information. It is a productive picture. A hidden activation can respond to a pattern like “capital of France is” assembled by attention at the token “Paris” and add a feature that the output head associates with a likely continuation. It also helps explain why targeted FFN edits can change factual behavior.

Notice what the FFN never sees: position. The block applies identical weights at token 3 and token 200,000, and it performs no operation across positions. Everything positional you studied in the last lessons — RoPE rotating queries and keys, ALiBi adding distance-dependent penalties to attention scores — acts inside the mixing sublayer, never here. If the FFN at one position behaves differently from another, that is because attention delivered different residual content, not because the FFN knows where it is.

Later architectural choices reshape this block’s economics rather than its role. Sparse mixture-of-experts models replace one dense FFN with a router and several expert FFNs, activating a subset per token; Qwen3.8-27B does not do this — its FFNs are dense, and every token pays the full 267 million parameters per layer. When you inspect a real FFN, track both shapes and residual effects: which directions activate, what they write, how large the update is against the existing stream, and whether later layers preserve it. Activation alone is not causation; ablation and controlled intervention give stronger evidence.

The stable mental model is a factory rhythm. Attention is the courier bringing each address its selected notes. The FFN is the machine shop: it expands the local state across 17,408 workbenches, gates each bench with SiLU, and compresses an update back onto the shared conveyor. Sixty-four shops in a row, holding seventeen billion of the twenty-seven billion parts — this is, quite literally, where most of the model lives.

02 · Analogy

Analogy

Attention is a courier network bringing each workshop a bundle of selected notes. The feed-forward block is the machine shop at every address: each shop expands the notes across thousands of workbenches, a valve at every bench decides how hard its press strikes, and the results are compressed into one package for the main conveyor. Couriers move information between addresses; workshops transform what arrives — and the workshops hold most of the factory's machinery.

03 · Teach it back

Teach it back

Describe the shape and gating of Qwen3.8-27B's feed-forward block, show why it dominates the parameter count, and explain why saying all factual knowledge lives there is too strong.

Minimum: 80 characters and 15 words. Your writing stays only in this browser.

Waiting for your explanation.

Compare with a model answer

Each Qwen3.8-27B layer has a gated FFN with three projections: gate and up map the 5120-dimensional hidden state to width 17408, SiLU applied to the gate path multiplies the up path element-wise, and down projects back to 5120. Each matrix is about 89.1M parameters, so one layer's FFN is roughly 267M parameters, and 64 layers give about 17B of the ~27B total. The block acts independently at every position with no token mixing. Some FFN directions correlate with factual associations, but behavior emerges from embeddings, mixers, residual composition, and depth, so the FFN is not a standalone database.

04 · Check your understanding

Check your understanding

01A colleague counts Qwen3.8-27B's FFN as two 5120×17408 matrices, about 178M parameters per layer. What did they miss?
Answer and explanation

The third projection: gate and up both expand, plus a down projection back to 5120, giving about 267M per layer — A SiLU-gated FFN uses gate, up, and down projections; each is roughly 89.1M parameters, so the per-layer total is about 267M, not 178M.

02Where does an ALiBi-style relative position bias act, and why can the FFN not replace it?
Answer and explanation

On the attention score matrix before softmax; the FFN processes each position independently and never compares positions — ALiBi adds distance-dependent penalties to attention scores. The FFN performs no cross-position operation, so position information must enter through the mixing sublayer.

03What role does SiLU gating play in the block?
Answer and explanation

One expanded projection proposes candidate features while the gated path scales each one element-wise before the down projection — The gate path passes through SiLU and multiplies the up path feature by feature, selecting how much of each candidate feature survives.

Complete the teach-back and answer the quiz correctly to finish this lesson.

◎ · Evidence marker

Sources

  1. Ashish Vaswani et al. (2017). Attention Is All You Need.
  2. Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy (2021). Transformer Feed-Forward Layers Are Key-Value Memories.
  3. Qwen Team (2026). Qwen3.8-27B Model Card.