Beyond a Forward Pass · Part 5 of 5 · LLM inference · July 2026

Part 5: Sharding & Mixture of Experts

Part 5 of 5. When the unit of scale is no longer a full model replica — tensor/pipeline shards and sparsely activated experts with dynamic routing.

Series · Beyond a Forward PassPart 5 of 5MoE / shardingJul 28, 2026

Classic scale-out: replicate the model

For “regular” models, horizontal scale is boring in a good way: copy the weights to N independent replicas; load-balance requests. Each replica is a full model. That still exists for LLMs — and for dense midsize models it is often the right answer.

But frontier LLMs break the “one GPU, one replica” story in two directions:

  1. The model is bigger than one GPU → weight sharding (tensor / pipeline / expert parallel).
  2. The model is sparse MoE → only a subset of experts activate per token; routing becomes dynamic inside the forward pass.
“Model sharding strategies can be quite different… Large mixture-of-experts models interweave attention layers with layers that have large numbers of experts… One example is to replicate attention across GPUs and shard the expert layers… a query is routed dynamically to the appropriate GPU based on which experts are activated. It’s not ten distinct replicas — it’s one big replica with crazy routing inside.” — Robert Nishihara

Parallelism taxonomy (dense models)

ModeWhat splitsCommunicationTypical use
Data / replica parallel Requests across full copies None between replicas Throughput scale-out
Tensor parallel (TP) Matrices inside a layer All-reduce / all-gather per layer Fit wide layers; low latency within node
Pipeline parallel (PP) Layers across stages Point-to-point activations Very deep / multi-node
Sequence parallel Sequence dim for norms/dropout activations With TP Activation memory relief

Inference cares about different costs than training: you may accept less perfect FLOPs efficiency to hit latency SLOs. TP within a node (NVLink) is common; PP across nodes needs careful microbatching or you bubble. Engines (vLLM, TensorRT-LLM, Megatron-derived stacks) expose these as deployment-time parallel configs.

Mixture of Experts — sparse capacity

An MoE layer replaces a single MLP with E expert MLPs plus a router (gating network). For each token, the router selects top-k experts (often k=1 or 2). FLOPs scale with activated experts, not E. Parameter count can be huge (hundreds of B) while active parameters stay closer to a dense 10–30B-class forward.

Why serving MoE is a systems problem

A common pattern Nishihara described: replicate attention (or keep it densely parallelized) while sharding experts. Tokens fan out to expert GPUs, compute, and fan in. From the outside it looks like one logical model; inside it is a routed fabric.

EP vs TP for experts (and hybrids)

In vLLM-style deployments, enabling EP often sets \[ \mathrm{EP\_SIZE} = \mathrm{TP\_SIZE} \times \mathrm{DP\_SIZE} \] Expert layers then shard across EP ranks while attention uses DP (replicate when TP=1) or TP. Multi-node EP uses specialized all-to-all backends (high-throughput paths for prefill, low-latency for decode). SGLang reports order-of-magnitude decode wins for large sparse MoEs when PD disaggregation is combined with EP versus pure wide TP baselines (config-specific; e.g. multi-× vs TP16 on DeepSeek-V3-class stacks).

Expert Parallelism Load Balancer (EPLB)

Hot experts overheat; cold experts waste memory bandwidth elsewhere. Production EP systems (vLLM, SGLang, TensorRT-LLM Wide-EP) run EPLB: re-place or replicate hot experts from activation statistics. That costs redundant-expert memory (on the order of ~GB per redundant expert per rank for DeepSeek-V3-class models) to buy balanced all-to-all and stable latency.

Models you already use that force this

Modern open weights are full of MoE: Mixtral-class, DeepSeek-V3-class, Qwen-MoE, Llama MoE variants, coding models like Laguna-class sparse designs. If you serve them:

Putting all five together

The five differences are one system:

  1. Continuous batching keeps the GPU full under variable lengths.
  2. Prefill/decode awareness (and maybe disaggregation) matches phase to hardware.
  3. Paged KV makes memory allocatable at iteration granularity.
  4. Prefix cache + routing amortizes shared stems across the fleet.
  5. Sharding / MoE makes models that do not fit — or should not fully activate — serveable.

That is why “just run model.generate” is a demo, and vLLM/SGLang/TRT-LLM + an orchestration layer (Ray, k8s, Dynamo-style) is a product.

Operator checklist for MoE + sharding

Mastery test: explain, for a single chat token in a multi-tenant MoE cluster, which GPU holds its KV block, which experts fire, and why that request was routed to that replica. If you can, you understand this series.

Sources & further reading

← Part 4: Prefix Caching & Routing