Home Knowledge Base Mixture of Experts (MoE) Routing and Load Balancing

Mixture of Experts (MoE) Routing and Load Balancing is an architecture paradigm where only a sparse subset of model parameters is activated for each input token, with a learned routing mechanism selecting which expert subnetworks to engage — enabling models with trillion-parameter capacity while maintaining computational costs comparable to much smaller dense models.

MoE Architecture Fundamentals

<svg viewBox="0 0 760 470" xmlns="http://www.w3.org/2000/svg" font-family="-apple-system,Segoe UI,Roboto,sans-serif">
  <rect x="0" y="0" width="760" height="470" fill="#0d1117"/>
  <text x="380" y="28" fill="#e6edf3" font-size="21" font-weight="700" text-anchor="middle">Mixture of Experts (MoE) — Sparse Activation</text>
  <text x="380" y="48" fill="#8b98a5" font-size="12" text-anchor="middle">N experts per layer, router selects top-K per token — massive params, small active compute</text>

  <!-- Main architecture -->
  <rect x="30" y="65" width="700" height="230" rx="6" fill="#080d14" stroke="#233043" stroke-width="1"/>
  <text x="380" y="86" fill="#e6edf3" font-size="11" font-weight="600" text-anchor="middle">MoE Layer (replaces dense FFN)</text>

  <!-- Input token -->
  <rect x="55" y="140" width="70" height="40" rx="4" fill="#0b1220" stroke="#60a5fa" stroke-width="1"/>
  <text x="90" y="158" fill="#93c5fd" font-size="8" text-anchor="middle">token x</text>
  <text x="90" y="172" fill="#6b7684" font-size="7" text-anchor="middle">[d=4096]</text>

  <!-- Router -->
  <path d="M127,160 L165,160" fill="none" stroke="#3a4453" stroke-width="1"/>
  <polygon points="163,157 169,160 163,163" fill="#3a4453"/>

  <rect x="172" y="125" width="100" height="70" rx="6" fill="#0b1220" stroke="#f59e0b" stroke-width="1.2"/>
  <text x="222" y="145" fill="#fbbf24" font-size="9" font-weight="600" text-anchor="middle">Router</text>
  <text x="222" y="162" fill="#8b98a5" font-size="7.5" text-anchor="middle">softmax(W_r · x)</text>
  <text x="222" y="178" fill="#8b98a5" font-size="7.5" text-anchor="middle">select top-K=2</text>
  <text x="222" y="190" fill="#6b7684" font-size="6.5" text-anchor="middle">learned gating</text>

  <!-- Expert FFNs -->
  <path d="M274,140 L320,110" fill="none" stroke="#f59e0b" stroke-width="0.8"/>
  <path d="M274,150 L320,145" fill="none" stroke="#f59e0b" stroke-width="0.8" stroke-dasharray="3,2"/>
  <path d="M274,160 L320,180" fill="none" stroke="#f59e0b" stroke-width="0.8" stroke-dasharray="3,2"/>
  <path d="M274,170 L320,215" fill="none" stroke="#f59e0b" stroke-width="0.8" stroke-dasharray="3,2"/>
  <path d="M274,180 L320,250" fill="none" stroke="#34d399" stroke-width="1.2"/>

  <!-- Expert boxes (8 experts, 2 active) -->
  <rect x="325" y="95" width="110" height="28" rx="3" fill="#14261f" stroke="#34d399" stroke-width="1.2"/>
  <text x="380" y="113" fill="#6ee7b7" font-size="8" text-anchor="middle">Expert 0 (FFN) ✓ active</text>

  <rect x="325" y="130" width="110" height="28" rx="3" fill="#0b1220" stroke="#334155" stroke-width="0.5"/>
  <text x="380" y="148" fill="#6b7684" font-size="8" text-anchor="middle">Expert 1 (FFN)</text>

  <rect x="325" y="165" width="110" height="28" rx="3" fill="#0b1220" stroke="#334155" stroke-width="0.5"/>
  <text x="380" y="183" fill="#6b7684" font-size="8" text-anchor="middle">Expert 2 (FFN)</text>

  <rect x="325" y="200" width="110" height="28" rx="3" fill="#0b1220" stroke="#334155" stroke-width="0.5"/>
  <text x="380" y="218" fill="#6b7684" font-size="8" text-anchor="middle">...</text>

  <rect x="325" y="235" width="110" height="28" rx="3" fill="#14261f" stroke="#34d399" stroke-width="1.2"/>
  <text x="380" y="253" fill="#6ee7b7" font-size="8" text-anchor="middle">Expert 7 (FFN) ✓ active</text>

  <!-- Weighted sum -->
  <path d="M437,109 L480,175" fill="none" stroke="#34d399" stroke-width="1"/>
  <path d="M437,249 L480,185" fill="none" stroke="#34d399" stroke-width="1"/>

  <rect x="485" y="160" width="90" height="40" rx="4" fill="#0b1220" stroke="#a78bfa" stroke-width="1"/>
  <text x="530" y="177" fill="#c4b5fd" font-size="8" text-anchor="middle">Weighted Sum</text>
  <text x="530" y="192" fill="#6b7684" font-size="7" text-anchor="middle">g₀·E₀(x) + g₇·E₇(x)</text>

  <!-- Output -->
  <path d="M577,180 L615,180" fill="none" stroke="#3a4453" stroke-width="1"/>
  <polygon points="613,177 619,180 613,183" fill="#3a4453"/>
  <rect x="622" y="160" width="70" height="40" rx="4" fill="#0b1220" stroke="#60a5fa" stroke-width="1"/>
  <text x="657" y="180" fill="#93c5fd" font-size="8" text-anchor="middle">output</text>
  <text x="657" y="193" fill="#6b7684" font-size="7" text-anchor="middle">[d=4096]</text>

  <!-- Annotation -->
  <text x="380" y="280" fill="#8b98a5" font-size="8" text-anchor="middle">8 experts × 4096×14336 params each, but only 2 active → 2/8 = 25% compute per token</text>

  <!-- Bottom: numbers + load balancing -->
  <rect x="30" y="305" width="345" height="125" rx="6" fill="#080d14" stroke="#233043" stroke-width="1"/>
  <text x="202" y="325" fill="#e6edf3" font-size="10" font-weight="600" text-anchor="middle">MoE in Practice</text>
  <text x="50" y="348" fill="#60a5fa" font-size="8.5" font-weight="600">Mixtral 8×7B:</text><text x="160" y="348" fill="#8b98a5" font-size="8">47B total, 13B active/token</text>
  <text x="50" y="366" fill="#34d399" font-size="8.5" font-weight="600">GPT-4 (rumored):</text><text x="170" y="366" fill="#8b98a5" font-size="8">~1.8T total, ~220B active</text>
  <text x="50" y="384" fill="#a78bfa" font-size="8.5" font-weight="600">DeepSeek-V2:</text><text x="155" y="384" fill="#8b98a5" font-size="8">236B total, 21B active (160 experts)</text>
  <text x="50" y="402" fill="#f59e0b" font-size="8.5" font-weight="600">Switch Transformer:</text><text x="175" y="402" fill="#8b98a5" font-size="8">top-1 routing (simplest)</text>
  <text x="50" y="420" fill="#6b7684" font-size="7.5">quality ≈ 2–3× dense model at same compute budget</text>

  <rect x="390" y="305" width="340" height="125" rx="6" fill="#080d14" stroke="#233043" stroke-width="1"/>
  <text x="560" y="325" fill="#e6edf3" font-size="10" font-weight="600" text-anchor="middle">Load Balancing Challenge</text>
  <text x="410" y="348" fill="#f87171" font-size="8.5" font-weight="600">Problem:</text><text x="470" y="348" fill="#8b98a5" font-size="8">router sends all tokens to same expert</text>
  <text x="410" y="366" fill="#34d399" font-size="8.5" font-weight="600">Aux loss:</text><text x="468" y="366" fill="#8b98a5" font-size="8">penalize uneven expert utilization</text>
  <text x="410" y="384" fill="#60a5fa" font-size="8.5" font-weight="600">Expert capacity:</text><text x="510" y="384" fill="#8b98a5" font-size="8">cap tokens per expert (drop overflow)</text>
  <text x="410" y="402" fill="#a78bfa" font-size="8.5" font-weight="600">Shared expert:</text><text x="505" y="402" fill="#8b98a5" font-size="8">1 expert always active (DeepSeek)</text>
  <text x="410" y="420" fill="#6b7684" font-size="7.5">balance = all experts equally utilized → max throughput</text>

  <text x="380" y="452" fill="#6b7684" font-size="11" text-anchor="middle">MoE decouples model capacity from compute cost — bigger models, same inference speed.</text>
</svg>

MoE replaces the standard feed-forward network (FFN) in transformer blocks with multiple parallel expert FFNs and a gating (routing) network. For each input token, the router selects the top-k experts (typically k=1 or k=2 out of 8-128 experts), and the token is processed only by the selected experts. The expert outputs are combined via weighted sum using router-assigned probabilities. This achieves conditional computation: a 1.8T parameter model with 128 experts and top-2 routing activates only ~28B parameters per token, matching a 28B dense model's compute while accessing a much larger knowledge capacity.

Router Design and Gating Mechanisms

Load Balancing Challenges

Prominent MoE Models

Expert Parallelism and Distribution

MoE Training Dynamics

Mixture of Experts architectures represent the most successful approach to scaling language models beyond dense parameter limits, with innovations in routing algorithms and load balancing enabling models like Mixtral and DeepSeek-V2 to deliver frontier-class performance at a fraction of the inference cost of equivalently capable dense models.

mixture of experts moe routingmoe load balancingsparse mixture expertsswitch transformer moeexpert parallelism routing

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.