Shared experts

Down projection

×

Map 6,144 gated features back to 7,168 features.

yshared=hWdown{\htmlData{light=output down}{y^{\mathrm{shared}}}}={\htmlData{light=h product}{h}}W_{\mathrm{down}}
in
hh [B batch, 1 position, 6144 shared d_ff]
out
ysharedy^{\mathrm{shared}} [B batch, 1 position, 7168 d]
Parameters44,040,192 × 24 layers

44,040,192 parameters per instance.

ComponentCalculationParameters
Weight matrix6,144 × 7,16844,040,192

This projection has no bias parameter.

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

One in each of the 24 MLA layers, each with its own weights.

Sources

In codeself.down_proj(…) · 297

Open pinned code ↗

Direct evidence

The dense feed-forward network: down(SiTU(gate x, up x)).

modeling_kimi_linear.py 273–301 ↗ · moonshotai/Kimi-K3 @ f831ab668142

Excerpt
class KimiMLP(nn.Module):
    def __init__(self, config: KimiLinearConfig, 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)
        if config.hidden_act == "situ":
            beta, linear_beta = _get_situ_activation_params(config)
            self.act_fn = SituAndMul(
                beta=beta,
                linear_beta=linear_beta,
            )
        else:
            self.act_fn = ACT2FN[config.hidden_act]

    def forward(self, x):
        if self.config.hidden_act == "situ":
            gate_up = torch.cat([self.gate_proj(x), self.up_proj(x)], dim=-1)
            down_proj = self.down_proj(self.act_fn(gate_up))
        else:
            down_proj = self.down_proj(self.act_fn(
                self.gate_proj(x)) * self.up_proj(x))
        return down_proj