SwiGLU MLP
×A dense SwiGLU of 18,432 hidden features, used in the first 3 layers.
All 5 steps
- in
- [B batch, T positions, 7168 d]
- out
- [B batch, T positions, 7168 d]
Parameters396,361,728 × 3 layers
396,361,728 parameters per instance, across its learned components
| Component | Calculation | Parameters |
|---|---|---|
| Gate projection | 7,168 × 18,432 | 132,120,576 |
| Up projection | 7,168 × 18,432 | 132,120,576 |
| Down projection | 18,432 × 7,168 | 132,120,576 |
| Per-instance total | 396,361,728 | |
One in each of the 3 dense layers, each with its own weights.
Explanation
The first 3 layers use this dense MLP; the other 58 replace it with the mixture of experts.
Sources
In codeself.ffn
Direct evidence
The dense feed-forward network is a SwiGLU MLP: w2(silu(w1 x) ⊙ w3 x).
model.py 629–643 ↗ · deepseek-ai/DeepSeek-V3.2-Exp @ 87e509a2e5a1
Excerpt
self.w1 = ColumnParallelLinear(dim, inter_dim)
self.w2 = RowParallelLinear(inter_dim, dim, reduce_output=reduce_output)
self.w3 = ColumnParallelLinear(dim, inter_dim)… lines 632–642 omitted …
return self.w2((F.silu(self.w1(x).float()) * self.w3(x).float()).type_as(x))A layer applies attention-norm, MLA, ffn-norm and the FFN; the first n_dense_layers layers use the dense MLP, the rest MoE. Residual additions happen inside the next normalization.
model.py 826–851 ↗ · deepseek-ai/DeepSeek-V3.2-Exp @ 87e509a2e5a1
Excerpt
self.attn = MLA(args)
self.ffn = MLP(args.dim, args.inter_dim) if layer_id < args.n_dense_layers else MoE(args)
self.attn_norm = RMSNorm(args.dim)
self.ffn_norm = RMSNorm(args.dim)… lines 830–843 omitted …
if residual is None:
x, residual = self.attn_norm(x), x
else:
x, residual = self.attn_norm(x, residual)
x = self.attn(x, start_pos, freqs_cis, mask)
x, residual = self.ffn_norm(x, residual)
x = self.ffn(x)
return x, residual