Expert scores
×One learned score vector per expert: 256 scores per position.
- in
- [B batch, T positions, 7168 d]
- out
- [B batch, T positions, 256 experts]
Held in bfloat16, the default type (generate.py 109), and applied in float32; the other linear weights in the layer are FP8 (model.py 674, 687, 876).
Parameters1,835,008 × 58 layers
1,835,008 parameters per instance.
| Component | Calculation | Parameters |
|---|---|---|
| Weight matrix | 7,168 × 256 | 1,835,008 |
This projection has no bias parameter.
The reference module holds the weight output by input, [out, in].
One in each of the 58 MoE layers, each with its own weights.
Sources
In codelinear(x.float(), self.weight.float())
Direct evidence
The router owns one score vector per routed expert and, at this width, a per-expert bias used only for selection.
model.py 668–675 ↗ · deepseek-ai/DeepSeek-V3.2-Exp @ 87e509a2e5a1
Excerpt
self.dim = args.dim
self.topk = args.n_activated_experts
self.n_groups = args.n_expert_groups
self.topk_groups = args.n_limited_groups
self.score_func = args.score_func
self.route_scale = args.route_scale
self.weight = nn.Parameter(torch.empty(args.n_routed_experts, args.dim))
self.bias = nn.Parameter(torch.empty(args.n_routed_experts, dtype=torch.float32)) if self.dim == 7168 else NoneRouting: sigmoid scores, bias added for selection, the best groups kept by their top-two scores, the top-8 experts chosen, their unbiased scores renormalized and scaled.
model.py 687–709 ↗ · deepseek-ai/DeepSeek-V3.2-Exp @ 87e509a2e5a1
Excerpt
scores = linear(x.float(), self.weight.float())
if self.score_func == "softmax":
scores = scores.softmax(dim=-1)
else:
scores = scores.sigmoid()
original_scores = scores
if self.bias is not None:
scores = scores + self.bias
if self.n_groups > 1:
scores = scores.view(x.size(0), self.n_groups, -1)
if self.bias is None:
group_scores = scores.amax(dim=-1)
else:
group_scores = scores.topk(2, dim=-1)[0].sum(dim=-1)
indices = group_scores.topk(self.topk_groups, dim=-1)[1]
mask = scores.new_ones(x.size(0), self.n_groups, dtype=bool).scatter_(1, indices, False)
scores = scores.masked_fill_(mask.unsqueeze(-1), float("-inf")).flatten(1)
indices = scores.topk(self.topk, dim=-1)[1]
weights = original_scores.gather(1, indices)
if self.score_func == "sigmoid":
weights /= weights.sum(dim=-1, keepdim=True)
weights *= self.route_scale
return weights, indices