Introduces sparse top-k gating over many experts, with auxiliary losses for uneven expert use, and discusses the batching and network costs of spreading experts across devices (ICLR 2017).
MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.
Intuition
The idea in plain words, before the symbols.
A mixture-of-experts (MoE) layer sends each token to only a few of its experts. Serving such a model requires dispatching tokens to their selected experts and collecting the outputs. We compare uneven expert loads and count remote bytes for a small routed batch. The figure checks when load imbalance or communication limits the layer. Sparse computation alone does not establish low latency.
In serving, MoE also becomes a scheduling problem:
- Tokens are routed unevenly, so some experts receive far more work than others, and the whole layer waits for the busiest one (a straggler).
- When experts are spread across GPUs (expert parallelism), each MoE layer must send token activations to the GPUs holding their selected experts and gather the results. When every GPU holds both attention and experts, this is an all-to-all exchange; when attention and experts run on separate pools of GPUs, as in MegaScale-Infer, it becomes an M-to-N exchange between the pools (Zhu et al., 2025).
- During decoding the KV cache also has to fit in memory, so the system manages memory and communication at once.
Sparse FLOPs alone do not make MoE serving fast. The gains come from the scheduling, batching and communication plan around the experts.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Mathematics
Definitions, assumptions and the derivation.
Token dispatch communication (why layout matters)
Per MoE layer, tokens are sent to their experts and the results are sent back. A rough count of the bytes moved is:
where:
- is tokens in the microbatch,
- is top- experts per token,
- is hidden width,
- is bytes per element (e.g., 2 for fp16),
- the factor of 2 is dispatch + combine.
The traffic grows with , not with the number of experts: going from top-1 to top-2 routing doubles it. This rough count also assumes every token leaves its GPU; tokens whose expert sits on the same GPU move nothing. If communication is the bottleneck, spreading experts over more GPUs or slower links can make the layer slower even though each token's expert computation is small.
Stragglers from routing skew
Let be the number of tokens routed to expert in a microbatch. If expert compute time is proportional to token count, then layer time is dominated by:
Even if the average load is small, the maximum load can be much larger when routing is skewed. Every token in the layer waits for the busiest expert, so one overloaded expert slows the whole batch.
Disaggregation (separate pools)
One recent response is disaggregation: run attention on one pool of GPUs and the experts on another, and pipeline microbatches between them so that both pools stay busy (Zhu et al., 2025). Each pool can then be sized and parallelized for its own work, at the cost of extra communication between the pools.
Worked example: only served, remote assignments move
The count assumes that every token's choices are served and that every one leaves its GPU. Neither need hold. Take tokens on GPU D0, top-2 routing over three experts, and a capacity of two tokens per expert, filled in token order:
- T0 and T1 choose E0 and E1, and both are served;
- T2 chooses E0 and E2, but E0 is full, so only E2 serves it;
- T3 chooses E1 and E2, but E1 is full, so only E2 serves it.
Six of the eight choices are served, two per expert; the two that overflow move nothing (the mixture-of-experts page works through capacity). Now place E1 on D0 and E0 and E2 on D1. A served assignment is remote when its expert's GPU differs from its token's GPU, and each remote assignment sends one activation out and receives one result back. Four are remote (T0→E0, T1→E0, T2→E2, T3→E2), so with and ,
half of the rough count, bytes. Move only E2 onto D0: the same six assignments are served and every expert still holds two tokens, but only T0→E0 and T1→E0 are remote, and the payload halves to KiB.
These are the bytes the dispatch and return must carry, not measured traffic. Real systems pad and pack buffers, add metadata, choose different collective operations, overlap communication with computation and pay a fixed cost per message, so neither the bytes nor their halving translate directly into time.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
import numpy as np
rng = np.random.default_rng(0)
E = 16 # experts
T = 4096 # tokens in a microbatch
# A skewed routing distribution (one "popular" expert)
p = np.ones(E) * 0.9
p[0] = 6.0
p = p / p.sum()
choices = rng.choice(E, size=T, p=p) # top-1 for simplicity
counts = np.bincount(choices, minlength=E)
print("avg tokens/expert:", round(float(counts.mean()), 2))
print("max tokens/expert:", int(counts.max()))
print("straggler factor max/mean:", round(float(counts.max() / counts.mean()), 2))
print("top-5 expert loads:", np.sort(counts)[-5:][::-1].tolist())
Count the remote bytes
This standard-library Python code serves the top-2 choices under the capacity limit, then counts the remote assignments and their bytes for both placements in the worked example.
TOP2 = {"T0": ("E0", "E1"), "T1": ("E0", "E1"), "T2": ("E0", "E2"), "T3": ("E1", "E2")}
CAPACITY, SOURCE, D_MODEL, BYTES = 2, "D0", 4096, 2
def serve(capacity=CAPACITY):
load, served = {"E0": 0, "E1": 0, "E2": 0}, []
for token, experts in TOP2.items(): # fill in token order
for expert in experts:
if load[expert] < capacity:
load[expert] += 1
served.append((token, expert))
return served
def remote_bytes(served, placement):
remote = [(t, e) for t, e in served if placement[e] != SOURCE]
return remote, 2 * len(remote) * D_MODEL * BYTES # out and back
served = serve()
placed = {"E0": "D1", "E1": "D0", "E2": "D1"}
moved = {**placed, "E2": "D0"}
assert len(served) == 6
for name, placement in (("E2 on D1", placed), ("E2 on D0", moved)):
remote, size = remote_bytes(served, placement)
print(name, "remote:", remote, "bytes:", size, "KiB:", size // 1024)
assert remote_bytes(served, placed)[1] == 65_536
assert remote_bytes(served, moved)[1] == 32_768
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism, then open its guide.
The demo below asks you to predict the bottleneck before it shows the expert loads and the bytes sent to and from the experts. The point is that sparse computation does not guarantee low latency: uneven routing and dispatch-and-combine traffic can each limit the layer. The practice after the demo counts, by hand, which expert assignments leave their GPU and how many bytes they carry.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Practice
Decide which served expert assignments leave the tokens' GPU, count their bytes out and back, then move one expert and count again.
Concept: MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
What is the smallest example of MoE Serving & Scheduling you can work through by hand, and what does it show?
DetailsLLM Systems
Reference id
concept:llm-systems/moe-servingAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Uses top-1 routing, sets each expert's capacity with a capacity factor, and discusses the communication cost and training instability that come with sparse experts (Journal of Machine Learning Research 23, 2022).
Runs attention and experts on separate GPU pools, pipelines micro-batches between them and uses an M2N library for token dispatch; reports that sparse activation leaves expert computation memory-bound (arXiv preprint).
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.
The checks were made by this site, not by an independent reviewer.
Shazeer supports sparse top-k MoE routing plus importance/load-balancing losses for uneven expert use. Fedus supports top-1 routing, expert-capacity overflow, auxiliary load balancing, and communication-cost...
This covers sparse routing, uneven expert load and the scheduling they force. Shazeer et al. and Fedus et al. describe the model and its training; MegaScale-Infer describes serving. The byte count, straggler...
Shazeer et al. (2017) support sparse top-k MoE routing and load- and importance-balancing losses for uneven expert use. Fedus et al. (2022) support top-1 routing, capacity overflow, auxiliary load balancing and communication-cost tradeoffs. MegaScale-Infer (2025) supports, for serving, MoE decoding, token dispatch, under-used expert computation caused by sparsity, separating attention from experts, M2N/N2M communication in that design, and uneven expert load in production.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
Try the idea in your own words
Serving a mixture-of-experts model turns sparse computation into a scheduling problem: uneven routing creates stragglers and sending tokens to experts costs communication, which motivates careful scheduling and, in systems such as MegaScale-Infer, separate GPU pools for attention and experts.
Concept · Selected for practice
MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
What it rests on: Sources: Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer; Switch Transformers: Scaling to Trillion Parameter Models...
Context and links
LLM Systems
Explain the mechanism
For MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism: What is the smallest example of MoE Serving & Scheduling you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
assert len(served) == 6Your question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
MoE Serving & Scheduling: Token Dispatch, All-to-All, Disaggregated Parallelism
What is the smallest example of MoE Serving & Scheduling you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 3 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 3 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/llm-systems/moe-serving
concept:llm-systems/moe-serving