SwiGLU MLP

Up projection

×

Map 5,120 input features to 12,288 features in parallel with the gate.

u=xffnW3{\htmlData{light=u up}{u}}={\htmlData{light=x}{x_{\mathrm{ffn}}}}W_{3}
in
xffnx_{\mathrm{ffn}} [B batch, T positions, 5120 d]
out
uu [B batch, T positions, 12288 d_ff]
Parameters62,914,560

62,914,560 parameters per instance.

ComponentCalculationParameters
Weight matrix5,120 × 12,28862,914,560

This projection has no bias parameter.

The reference module holds the weight output by input, [out, in].

Sources

In codeself.up_proj(x)

Open pinned code ↗

Direct evidence

The dense feed-forward network is a SwiGLU MLP: down(silu(gate x) ⊙ up x).

modeling_deepseek.py 374–390 ↗ · deepseek-ai/DeepSeek-V2 @ 4461458f186c

Excerpt
class DeepseekV2MLP(nn.Module):
    def __init__(self, config, hidden_size=None, intermediate_size=None):
        super().__init__()
        self.config = config
        self.hidden_size = config.hidden_size if hidden_size is None else hidden_size
        self.intermediate_size = (
            config.intermediate_size if intermediate_size is None else intermediate_size
        )

        self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
        self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
        self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
        self.act_fn = ACT2FN[config.hidden_act]

    def forward(self, x):
        down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
        return down_proj

Every tensor is stored in bfloat16 (torch_dtype); the attention projections have no bias (attention_bias false).

config.json 5–54 ↗ · deepseek-ai/DeepSeek-V2 @ 4461458f186c

Excerpt
  "attention_bias": false,

… lines 6–53 omitted …

  "torch_dtype": "bfloat16",