DeepSeek V4-Pro

Heavily compressed layers, routed by token ID

Read the streams

×

Collapse the four streams into one vector per position, weighted by the reading weights.

hffn=∑jpjffn Xn,j′{\htmlData{light=ffn-read-streams}{h_{\mathrm{ffn}}}}=\sum_{j}{\htmlData{light=ffn-read-weights ffn-weights}{p^{\mathrm{ffn}}_{j}}}\,X'_{n,j}
in
Xn′X'_n [B batch, T positions, 4 streams, 7168 d]pffnp^{\mathrm{ffn}} [B batch, T positions, 4 streams]
out
hffnh_{\mathrm{ffn}} [B batch, T positions, 7168 d]
Sources

In codetorch.sum(pre.unsqueeze(-1) * x.view(shape), dim=2) · 680

Open pinned code ↗

Direct evidence

hc_pre: flatten the streams, project them to the mix numbers divided by their root mean square, split them by Sinkhorn, and read the streams with the reading weights; hc_post: each new stream is the writing weight times the sublayer’s output plus the streams combined by a column of the combination.

model.py 673–686 ↗ · deepseek-ai/DeepSeek-V4-Pro @ b5968e9190ef

Excerpt
    def hc_pre(self, x: torch.Tensor, hc_fn: torch.Tensor, hc_scale: torch.Tensor, hc_base: torch.Tensor):
        # x: [b,s,hc,d], hc_fn: [mix_hc,hc*d], hc_scale: [3], hc_base: [mix_hc], y: [b,s,hc,d]
        shape, dtype = x.size(), x.dtype
        x = x.flatten(2).float()
        rsqrt = torch.rsqrt(x.square().mean(-1, keepdim=True) + self.norm_eps)
        mixes = F.linear(x, hc_fn) * rsqrt
        pre, post, comb = hc_split_sinkhorn(mixes, hc_scale, hc_base, self.hc_mult, self.hc_sinkhorn_iters, self.hc_eps)
        y = torch.sum(pre.unsqueeze(-1) * x.view(shape), dim=2)
        return y.to(dtype), post, comb

    def hc_post(self, x: torch.Tensor, residual: torch.Tensor, post: torch.Tensor, comb: torch.Tensor):
        # x: [b,s,d], residual: [b,s,hc,d], post: [b,s,hc], comb: [b,s,hc,hc], y: [b,s,hc,d]
        y = post.unsqueeze(-1) * x.unsqueeze(-2) + torch.sum(comb.unsqueeze(-1) * residual.unsqueeze(-2), dim=2)
        return y.type_as(x)