Routed expert

Up projection

×

Map 5,120 input features to 1,536 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, 1536 expert d_ff]
Parameters7,864,320 × 9,440 experts

7,864,320 parameters per instance.

ComponentCalculationParameters
Weight matrix5,120 × 1,5367,864,320

This projection has no bias parameter.

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

One in each of 9,440 experts: 160 in each of 59 MoE layers.

Sources

In codeself.up_proj(x)

Open pinned code ↗

Direct evidence

Each routed expert is its own SwiGLU MLP of moe_intermediate_size hidden features.

modeling_deepseek.py 531–558 ↗ · deepseek-ai/DeepSeek-V2 @ 4461458f186c

Excerpt
        if hasattr(config, "ep_size") and config.ep_size > 1:
            assert config.ep_size == dist.get_world_size()
            self.ep_size = config.ep_size
            self.experts_per_rank = config.n_routed_experts // config.ep_size
            self.ep_rank = dist.get_rank()
            self.experts = nn.ModuleList(
                [
                    (
                        DeepseekV2MLP(
                            config, intermediate_size=config.moe_intermediate_size
                        )
                        if i >= self.ep_rank * self.experts_per_rank
                        and i < (self.ep_rank + 1) * self.experts_per_rank
                        else None
                    )
                    for i in range(config.n_routed_experts)
                ]
            )
        else:
            self.ep_size = 1
            self.experts_per_rank = config.n_routed_experts
            self.ep_rank = 0
            self.experts = nn.ModuleList(
                [
                    DeepseekV2MLP(config, intermediate_size=config.moe_intermediate_size)
                    for i in range(config.n_routed_experts)
                ]
            )

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",