SwiGLU MLP

Down projection

×

Map 12,288 gated features back to 6,144 features.

Δffn=hW2{\htmlData{light=output down}{\Delta_{\mathrm{ffn}}}}={\htmlData{light=h product}{h}}W_{2}
in
hh [B batch, T positions, 12288 d_ff]
out
Δffn\Delta_{\mathrm{ffn}} [B batch, T positions, 6144 d]
Parameters75,497,472 × 3 layers

75,497,472 parameters per instance.

ComponentCalculationParameters
Weight matrix12,288 × 6,14475,497,472

This projection has no bias parameter.

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

One in each of the 3 dense layers, each with its own weights.

Sources

In codeself.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))

Open pinned code ↗

Direct evidence

The dense feed-forward network is a SwiGLU MLP, down(silu(gate x) ⊙ up x), computed in the input’s precision.

modeling_glm_moe_dsa.py 454–467 ↗ · huggingface/transformers @ c4c4605f9618

Excerpt
class GlmMoeDsaMLP(nn.Module):
    def __init__(self, config, intermediate_size=None):
        super().__init__()
        self.config = config
        self.hidden_size = config.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

Attention projections have no bias (attention_bias is false) and the checkpoint stores its weights in bfloat16.

config.json 5–7 ↗ · zai-org/GLM-5.2 @ cf457fa734ab

Excerpt
  "attention_bias": false,
  "attention_dropout": 0.0,
  "dtype": "bfloat16",