Skip to content

Build1 publisher3 min readPublished

Top-k gating decouples DeepSeek-V3's 671B parameter count from its 37B of per-token compute

A top-k selection inside the gate, described in a 2017 Google Brain paper, is what skips the other experts, and the memory floor still tracks all 671 billion parameters because each one stays resident.

The Engineer · Build desk

Illustration accompanying Top-k gating decouples DeepSeek-V3's 671B parameter count from its 37B of per-token compute

What happened

  • A dev.to walkthrough of mixture-of-experts architecture puts DeepSeek-V3 at 671 billion parameters, with only around 37 billion of them used on any given token.
  • Shazeer et al.'s 2017 Google Brain paper made the gate sparse, scoring the whole pool and running only the top 4 of 4,096 experts.
  • Trained on task loss alone the sparse gate collapses onto a few experts, and the 2017 paper answers that with an auxiliary loss penalising uneven expert usage across a batch.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • capability A lab can raise total parameter count without raising the compute of a forward pass, so parameter count no longer predicts what one token costs to generate.
  • constraint Routing does not shrink the memory requirement. The full expert pool sits in vRAM, so the hardware floor for a deployment is set by the stored parameter count.
  • decision Anyone quoting a serving figure for an MoE has to choose which parameter count it is quoted against, because activated and total answer different questions.
  • exposure Balanced routing is enforced by a loss term during training, so an operator serving the model inherits whatever distribution the trained gate produces.

Call a sparse mixture-of-experts layer and the first thing that runs is one matrix multiply: `logits = x @ gate_weights`, a raw score per expert. Then `topk` takes the k highest, softmax renormalises over just those k, and the layer runs only the selected experts, weighting each output by its renormalised score [9]. In Shazeer et al.'s 2017 paper from Google Brain, k was 4 and the pool held 4,096 experts [8]. That is one expert in 1,024, about 0.1 percent of the pool per token [14].

DeepSeek-V3 sits at a milder ratio. It holds 671 billion parameters and uses roughly 37 billion of them each time, which is 5.5 percent activated and an 18-fold gap between what is stored and what runs [3][13].

Whether that gap turns into money depends on what you are paying for. In a dense model every parameter activates on every token, and the compute of a forward pass scales about linearly with parameter count [1]. Sparse routing breaks that link on the compute side, so the 18x is a FLOPs ratio. Converting it into a lower cost per GPU-hour needs enough concurrent traffic that the resident weights are amortised across a lot of tokens. The model still carries hundreds of billions of parameters in vRAM while activating a small fraction per run [4].

The routing idea is older than the saving. Jacobs, Jordan, Nowlan and Hinton's 1991 paper, Adaptive Mixtures of Local Experts, trained several small expert networks alongside a separate gating network that learned to weight and combine their outputs, all jointly [5]. The test was vowel discrimination, competing experts plus a gate against one monolithic network, and the learning procedure decomposed the hard problem into sub-problems each expert could handle [6]. The gate emitted a weight for every expert and every expert computed on every input, so nothing was skipped [7].

What breaks is the gate itself, during training. A small random edge at initialisation makes one expert respond marginally better to some input, and the gate routes slightly more traffic there. That expert collects more gradient updates than its neighbours, improves, and the gate favours it further [10]. The 2017 fix adds an auxiliary loss on top of the task loss, penalising uneven expert usage across a batch [11]. It is computed as the expert count times the sum over experts of routed fraction times average gate probability [12]. Both factors are batch statistics, so the penalty is only as informative as the batch is large [12].

The write-up does not give serving costs or latency for any of these models. Per-token compute follows the 37 billion, and the hardware you have to buy follows the 671 billion [3][4].

What to watch

  • Published per-token cost or latency for a 671B-parameter MoE at a stated batch size and concurrency.
  • Measurements of how evenly a trained gate routes real inference traffic, as opposed to training batches.
  • Whether later MoE designs replace the auxiliary loss with a routing method that does not depend on batch statistics.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories