Very Large MoE Models Explained: Sparse Activation and Compute Adaptation
This article examines how very large Mixture-of-Experts models separate total parameter scale from per-token compute, using a 671B-total/37B-active example. It covers memory constraints, routing imbalance, long-context KV cache versus attention cost, dual-version operator strategies, FP8 quantization, and deployment and cost considerations in heterogeneous compute environments.
Introduction: Parameter Scale vs. Inference Cost
Large language models become more capable as parameter scale increases, but more parameters also raise inference latency and compute cost. The industry has already seen very large MoE models with 671B total parameters and only 37B activated per token. The key is sparsity: it separates total parameter scale from per-inference compute. Using this class of models as an example, this article explains the principles of sparse activation, memory pressure in long contexts, the role of low-level operators and data formats, and deployment and cost issues in heterogeneous compute environments.
MoE Sparse Activation: Large Total Parameters Do Not Mean Large Per-Step Compute
MoE (Mixture of Experts) splits the feed-forward network into multiple expert subnetworks. A router decides which experts each token should be sent to, while the other experts do not participate in the current forward computation.
With 671B total parameters and 37B activated parameters, the parameters actually involved in processing a single token account for about 5.5% of the total (37 ÷ 671 ≈ 5.5%). Per-step compute is therefore far lower than that of a dense model with the same total parameter count.
Two points need attention. First, sparse activation reduces compute, but it does not reduce all memory requirements. The weights of all experts still need to be loaded into memory or distributed across multiple GPUs, so memory capacity remains a hard deployment constraint. Second, routing may be imbalanced: some experts may be selected frequently while others sit idle. In engineering practice, load-balancing losses or auxiliary strategies are usually needed to mitigate this.
For developers, the criterion can be: whether all weights fit within an acceptable hardware scale, and whether, at the target throughput, the compute savings from activated parameters are sufficient to offset routing and communication overhead.
Long-Context Memory Pressure: Treat KV Cache and Attention Compute Separately
Long context is the foundation for moving from single-turn question answering to complex task planning. This model claims support for a 160K context; the exact limit should be based on the officially released model configuration and documentation. Before deployment, the maximum position encoding length in the configuration file should be checked, and testing should be performed with real business data.
The cost of long context mainly comes from two parts, which need to be analyzed separately.
- KV Cache memory: During inference, every token that has been input or generated must cache the Key and Value of each layer. Cache occupancy is roughly linear with context length and is also related to the number of layers, KV heads, head dimension, and data precision. If context length doubles, KV Cache roughly doubles.
- Attention compute: Standard attention needs to compute scores between every pair of tokens, and compute grows quadratically with sequence length. Operators such as FlashAttention reduce the overhead of writing intermediate results to memory through tiled computation, but compute still grows quadratically with length.
Therefore, the statement that “memory grows quadratically with length” is not accurate. A more precise formulation is: KV Cache memory grows approximately linearly, while attention compute grows approximately quadratically. The optimization methods for the two are also different.
Common optimizations include: PagedAttention, which manages KV Cache in pages to reduce memory fragmentation; chunked or ring attention such as RingAttention, which splits long sequences across multiple GPUs for computation; and tensor parallelism and pipeline parallelism, which distribute weights and activations across multiple GPUs.
Dual-Version Operators and FP8 Data Format
Dual-Version Operators: Ecosystem Compatibility and Performance Tuning in Parallel
GPU operator efficiency directly affects training and inference throughput. One end of the dual-version strategy uses the CUDA ecosystem, making it easy to run directly on mainstream GPU clusters; the other end uses hardware-oriented programming approaches such as TileLang to write custom operators for tapping the performance potential of specific hardware.
The choice between the two versions can reference the following conditions:
- For fast validation, feature alignment, and teams familiar with CUDA: prefer the general operator version.
- When target hardware is fixed and throughput or latency is a core metric: evaluate the custom operator version and perform numerical alignment tests against the general version.
- When migration across multiple chips is needed: prefer solutions with mature abstraction layers and good community support, and reserve porting cost.
FP8 Quantization: Reduce Memory and Bandwidth Pressure While Preserving Accuracy
Compared with FP16 and BF16, FP8 halves the storage bit width and can reduce weight footprint and memory access pressure. Low-bit representations have more limited dynamic range and precision, so the quantization method matters more than the format itself.
The section also references UE8M0.
