Up projection
×Map 5,120 input features to 12,288 features in parallel with the gate.
- in
- [B batch, T positions, 5120 d]
- out
- [B batch, T positions, 12288 d_ff]
Parameters62,914,560
62,914,560 parameters per instance.
| Component | Calculation | Parameters |
|---|---|---|
| Weight matrix | 5,120 × 12,288 | 62,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)
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_projEvery 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",