Inferensys

Glossary

Expert Capacity

Expert capacity is the maximum number of tokens that can be assigned to a single expert in a Mixture of Experts forward pass, a critical parameter balancing computational efficiency against the risk of dropping tokens.
Risk analyst performing AI risk assessment on laptop, risk matrices visible, casual office risk session.
MIXTURE OF EXPERTS INFERENCE

What is Expert Capacity?

A core implementation parameter in Mixture of Experts (MoE) models that controls computational batching and token handling.

Expert capacity is the maximum number of tokens that can be assigned to a single expert in a Mixture of Experts (MoE) model during a forward pass. It is a critical hyperparameter that balances computational efficiency—achieved by processing tokens in fixed-size batches per expert—against the risk of dropped tokens. Capacity is typically set as a multiple of the average expected load, providing a buffer to handle variance in the router's token distribution.

Setting expert capacity involves a direct trade-off. A low capacity minimizes memory and compute waste from padding but increases the probability of tokens exceeding the limit and being dropped or bypassed. A high capacity reduces this drop risk but creates inefficient computation from excessive padding in underutilized expert batches. This parameter is intrinsically linked to the capacity factor and is a key consideration in systems using expert parallelism, where it influences communication volume and GPU memory allocation.

IMPLEMENTATION PARAMETER

Key Characteristics of Expert Capacity

Expert capacity is a critical hyperparameter in Mixture of Experts (MoE) models that defines the maximum number of tokens a single expert can process in a forward pass. It acts as a buffer to manage computational load and prevent token dropping.

01

Core Definition & Purpose

Expert capacity is the maximum number of tokens that can be assigned to a single expert in a Mixture of Experts forward pass. Its primary purpose is to enable efficient batched computation on hardware (like GPUs) by creating fixed-size, dense tensors from sparse token assignments. Without a defined capacity, a variable and unpredictable number of tokens could be routed to each expert, making parallelization inefficient. Setting this parameter involves a direct trade-off: higher capacity reduces the risk of dropped tokens but increases memory usage and computational waste for underutilized experts.

02

Relationship to Capacity Factor

Expert capacity is typically set using a derived hyperparameter called the capacity factor. The calculation is:

  • expert_capacity = (batch_size * sequence_length * k) / num_experts * capacity_factor

Where k is the number of experts selected per token (e.g., top-2). A capacity factor greater than 1.0 (e.g., 1.25, 2.0) provides a buffer above the theoretical average load. This buffer accommodates the natural imbalance in token routing, preventing tokens from being dropped when an expert receives slightly more than its 'fair share' of assignments. The capacity factor directly controls the trade-off between computational efficiency and model accuracy.

03

Token Dropping & Fallback

When the number of tokens routed to an expert exceeds its predefined expert capacity, the system must handle the overflow. The standard solution is token dropping, where excess tokens are not processed by the expert. Common handling strategies include:

  • Pass-through: The token's representation is passed unchanged to the next layer.
  • Sent to a fallback expert (e.g., a shared expert or the first expert).
  • Scaling router scores to fit within capacity. Dropped tokens represent a direct loss of information and degrade model performance. Therefore, setting expert capacity is an optimization to minimize dropping while controlling memory overhead.
04

Impact on Memory & Computation

Expert capacity has a direct, linear impact on GPU memory consumption during inference. Each expert's activation buffer must be allocated to hold the maximum possible number of tokens (expert_capacity * hidden_dim). Overallocating capacity leads to:

  • Increased memory footprint: Storing large, partially empty buffers.
  • Computational waste: Performing matrix multiplications on zero-padded sections of the buffer. Underallocating capacity leads to dropped tokens and accuracy loss. Systems like vLLM with MoE support and Fused MoE Kernels optimize this by managing memory pools and combining operations to reduce the overhead of this fixed-size allocation.
05

Interaction with Load Balancing

Expert capacity works in tandem with load balancing techniques during training. The router is trained with an auxiliary load balancing loss to encourage a uniform distribution of tokens across experts. Effective load balancing reduces the variance in tokens per expert, which allows for a lower capacity factor to be used safely. Without good load balancing, a few 'popular' experts would consistently hit their capacity limit, forcing a higher capacity setting to avoid excessive dropping, thereby increasing memory waste. Thus, the required expert capacity is a reflection of the router's imbalance.

06

System-Level Optimization

In production serving systems, expert capacity is a key lever for inference cost optimization. Engineers tune it based on:

  • Observed routing distributions from production traffic.
  • Target latency and throughput SLAs.
  • GPU memory constraints. Advanced systems may employ dynamic capacity strategies, where the capacity is adjusted per request batch based on real-time router statistics, or use expert parallelism to scale capacity across multiple devices. The goal is to find the minimal capacity that keeps the rate of dropped tokens below an acceptable threshold for the application.
IMPLEMENTATION PARAMETERS

Expert Capacity: Trade-offs and Configuration

Comparison of configuration strategies for the expert capacity parameter in Mixture of Experts models, balancing computational efficiency against token dropping risk.

Configuration Metric / BehaviorLow Capacity (Conservative)Balanced Capacity (Recommended)High Capacity (Aggressive)Dynamic Capacity (Adaptive)

Capacity Factor Value

1.0 - 1.2

1.25 - 1.5

2.0

N/A (Algorithmic)

Token Dropping Risk

Very High

Low

Very Low

Controlled

GPU Utilization (Batching Efficiency)

Poor

Good

Excellent

Variable

Memory Overhead per Expert

Low

Moderate

High

Variable

Router Latency Impact

Low (simple assignment)

Moderate

High (complex shuffling)

High (runtime decisions)

Typical Use Case

Research / Debugging

Production Inference

Offline Batch Processing

Latency-Sensitive Serving

Compatibility with Continuous Batching

Poor

Good

Excellent

Complex

All-to-All Communication Volume

Minimal

Optimized

High

Variable

EXPERT CAPACITY

Frequently Asked Questions

Expert capacity is a critical hyperparameter in Mixture of Experts (MoE) models that directly controls computational efficiency and token throughput. These questions address its definition, configuration, and impact on production inference systems.

Expert capacity is the maximum number of tokens that can be assigned to a single expert in a Mixture of Experts (MoE) layer during a forward pass. It is a predefined, fixed buffer allocated per expert to enable efficient batched computation. The gating network (router) assigns tokens to experts, but if an expert receives more tokens than its capacity, the excess tokens are dropped—typically passed through the layer unchanged or re-routed to a fallback. Capacity is calculated as capacity = (batch_size * sequence_length * top_k) / num_experts * capacity_factor, where the capacity factor (e.g., 1.25, 2.0) provides a safety margin to minimize drops.

In practice, before computation, tokens are sorted by their assigned expert and packed into fixed-size tensors up to the capacity limit. This allows the system to execute a batched matrix multiplication across all experts, even if some experts have fewer tokens than capacity (the batch is padded). This design trades off some computational waste (padding) against the severe performance penalty of processing tokens sequentially.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.