Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 4 min read

Mixture of Experts Explained: Why a 560B Model Only Uses 25B per Token

A model with 560 billion parameters that uses only 25 billion of them for each word sounds like a contradiction. It isn't. It's Mixture of Experts (MoE), the architecture behind many of today's largest language models.

A model with 560 billion parameters that uses only 25 billion of them for each word sounds like a contradiction. It isn't. It's Mixture of Experts (MoE), the architecture behind many of today's largest language models.

Here's the 90-second animated version, if you'd rather watch first:

Below is the engineer's version: how it works, where the savings come from, and the catch that most explainers skip.

1. The problem with dense models

In a classic dense transformer, every parameter takes part in processing every token. Ask it "what's 2 + 2" or ask it to write a sonnet, and the whole network fires either way.

That's simple and it works, but cost grows directly with size. If you double the parameters, you roughly double the compute per token. At hundreds of billions of parameters, that gets slow and expensive to serve.

2. The MoE idea: many experts, one router

MoE swaps some of the dense feed-forward layers in a transformer for a group of smaller feed-forward networks, called experts, plus a tiny network called the router (or gating network).

For each token, at each MoE layer:

  1. The router looks at the token's hidden state and gives every expert a score.
  2. It keeps the top-k experts, often just k = 2.
  3. Only those experts run. Their outputs are combined using the router's weights.
  4. Every other expert does nothing for that token.

In simplified PyTorch-style code:

import torch
import torch.nn.functional as F

def moe_layer(x, router, experts, k=2):
    # x: [tokens, d_model]
    logits = router(x)                       # [tokens, num_experts]
    weights, idx = torch.topk(logits, k)     # top-k experts per token
    weights = F.softmax(weights, dim=-1)     # normalise the k scores

    out = torch.zeros_like(x)
    for slot in range(k):
        for e, expert in enumerate(experts):
            mask = idx[:, slot] == e         # tokens routed to expert e
            if mask.any():
                out[mask] += weights[mask, slot, None] * expert(x[mask])
    return out

Real implementations batch this far more efficiently, but the logic is the same: each token only touches k experts.

The hospital analogy

Think of a hospital with 100 doctors. You don't get examined by all 100. The receptionist sends you to the two specialists you need. The hospital has all the knowledge, but each patient only uses a small part of it.

  • Hospital = the full model
  • Doctors = experts
  • Receptionist = router
  • Patient = a token

3. A real example: 560B total, 25B active

Ant's recently released Ling Sante Flash model is described as having 560 billion parameters in total, with about 25 billion active per token.

That's roughly 4.5% of the model working on each token (25 รท 560). That's where MoE's efficiency comes from: you get the capacity of a huge model, but the compute per token of a much smaller one.

4. The catch: MoE saves compute, not memory

This is the part people often miss.

The router decides which experts run at inference time, token by token. Any token might need any expert, so all the experts have to stay loaded in GPU memory, ready to go.

Dense model MoE model
Parameters stored in memory All All
Parameters used per token All Only the top-k experts
Compute (FLOPs) per token High Much lower
GPU memory needed High Still high

So a 560B MoE model still needs enough GPU memory for roughly 560B parameters, even though it computes like a ~25B model. In practice, teams spread experts across many GPUs (expert parallelism), and moving tokens between GPUs adds its own communication cost.

Rule of thumb: MoE is a compute optimisation, not a memory optimisation.

5. Things that make MoE hard in practice

  • Load balancing. If the router keeps sending most tokens to the same few experts, those experts get overloaded and the rest barely learn anything. Training usually adds an extra load-balancing loss to spread tokens more evenly.
  • Expert capacity. Each expert can only handle so many tokens per batch. When too many tokens pick the same expert, some can overflow, depending on the implementation.
  • Serving complexity. Routing, batching and cross-GPU communication make MoE inference more complicated to engineer than a dense model of the same compute size.

6. What do the experts actually learn?

Nobody tells an expert "you're the math expert" or "you're the Hindi expert". Specialisation emerges during training, from the router and experts learning together.

And it often isn't as neat as human topics. Analyses of open MoE models have found that routing often tracks token-level and syntactic patterns (things like code syntax, punctuation or numbers) more than clean subject areas.

That's what Part 2 of the video series will dig into.

TL;DR

  • MoE splits parts of the model into many experts plus a router.
  • For each token, the router picks the top-k experts (often 2). The rest stay idle.
  • You get a huge total parameter count with small per-token compute. Example: 560B total, ~25B active.
  • Memory doesn't shrink: every expert still has to be loaded.
  • Expert roles emerge from training, often at the level of token patterns rather than tidy topics.

If this helped, I make 90-second explainers on AI and system design from a software architect's point of view. Follow along on YouTube at @arorahiman87, where Part 2 is coming soon.

The animation was coded by me. The narration in the video is AI-generated.

๐Ÿ’ฌ Question for you: in real deployments, which matters more to you, the lower compute or the memory cost? Let me know in the comments.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.