Routed expert

Element-wise product

×

Gate the up features by the activated gate, feature by feature.

h=a⊙u{\htmlData{light=h product}{h}}={\htmlData{light=a silu}{a}}\odot {\htmlData{light=u up}{u}}
in
aa [B batch, T positions, 2048 expert d_ff]uu [B batch, T positions, 2048 expert d_ff]
out
hh [B batch, T positions, 2048 expert d_ff]
Sources

In codeself.act_fn(self.gate_proj(x)) * self.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 503–523 ↗ · moonshotai/Kimi-K2.5 @ 4d01dfe0332d

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([
                (DeepseekV3MLP(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([
                DeepseekV3MLP(config,
                              intermediate_size=config.moe_intermediate_size)
                for i in range(config.n_routed_experts)
            ])