Dense layer

SwiGLU MLP

×

A dense SwiGLU of 18,432 hidden features, used in the first 3 layers.

h=a⊙uh=a\odot u
Δffn=hW2\Delta_{\mathrm{ffn}}=hW_{2}
All 5 steps
g=xffnW1g=x_{\mathrm{ffn}}W_{1}
u=xffnW3u=x_{\mathrm{ffn}}W_{3}
a=g σ(g)a=g\,\sigma(g)
h=a⊙uh=a\odot u
Δffn=hW2\Delta_{\mathrm{ffn}}=hW_{2}
in
xffnx_{\mathrm{ffn}} [B batch, T positions, 7168 d]
out
Δffn\Delta_{\mathrm{ffn}} [B batch, T positions, 7168 d]
Parameters396,361,728 × 3 layers

396,361,728 parameters per instance, across its learned components

ComponentCalculationParameters
Gate projection7,168 × 18,432132,120,576
Up projection7,168 × 18,432132,120,576
Down projection18,432 × 7,168132,120,576
Per-instance total396,361,728

One in each of the 3 dense layers, each with its own weights.

Weights · one MLP

DeepSeek-V3.2-Exp MLP · FP8378 MiB
GELU, same width · FP8252 MiB

3 × 7,168 × 18,432 parameters in FP8, block scales left out.

A GELU MLP of the same width has two matrices, 264,241,152 parameters.

config_671B_v3.2.json 3–4, 21model.py 629–631, 643, 876, 183–187
Explanation

The first 3 layers use this dense MLP; the other 58 replace it with the mixture of experts.

Sources

In codeself.ffn

Open pinned code ↗

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