Open-Source MoE Architecture Breakdown: How MLA, Multi-Token Prediction, and Sparse Attention Save GPU Memory and Boost Speed
This article examines an open-source MoE architecture and three optimizations that address GPU memory, decoding throughput, and long-context compute: MLA for KV-cache compression, multi-token prediction for speculative decoding, and sparse attention. It also outlines deployment considerations including memory planning, interconnect bandwidth, expert load balancing, acceptance-rate measurement, and prefix caching.
Why MoE Models Can Be Larger
Mixture-of-Experts (MoE) models split the feed-forward layer into many expert networks. A router selects a small number of experts for each token, and only those selected experts participate in computation. As a result, the total parameter count can be very large, while the compute per inference pass is determined only by the activated parameters.
This design leads to two conclusions. First, model capacity and inference compute can scale separately. Second, all expert weights must fit in GPU memory, so MoE is not memory-friendly. During deployment, teams need to estimate both the memory occupied by total parameters and the compute latency determined by activated parameters.
The parameter scale, layer count, and expert count cited here come from the source material. The source reports 744B total parameters, 40B activated per pass, 80 layers, and 256 experts. These figures should be checked against the official technical report; this article does not independently verify them.
1. MLA: Shrinking the KV Cache with Low-Rank Compression
One major bottleneck in long-text generation is the KV cache. Standard multi-head attention caches full Key and Value tensors for every token in every layer. The number of cache bytes per token per layer can be written as:
2 × number of heads × head dimension × bytes per element
MLA (Multi-head Latent Attention) stores only a low-rank latent vector for each token. During attention computation, an up-projection matrix restores the Key and Value. The rotary position embedding (RoPE) portion cannot be applied directly to the compressed vector, so an additional smaller RoPE key must be stored. The number of cache bytes per token per layer is approximately:
(kv_lora_rank + RoPE dimension) × bytes per element
The simplified code below illustrates the structural difference between the two cache types:
import torch# Standard multi-head attention: cache full K and V per token per layerclass StandardKVCache:def __init__(self, batch_size, max_seq_len, num_heads, head_dim):self.k_cache = torch.zeros(batch_size, max_seq_len, num_heads, head_dim)self.v_cache = torch.zeros(batch_size, max_seq_len, num_heads, head_dim)# MLA: cache one low-rank latent vector and a separate RoPE key per tokenclass MLAKVCache:def __init__(self, batch_size, max_seq_len, kv_lora_rank, rope_dim):self.latent_cache = torch.zeros(batch_size, max_seq_len, kv_lora_rank)self.rope_k_cache = torch.zeros(batch_size, max_seq_len, rope_dim)
A set of example parameters makes the difference clear. Assume 128 heads, a head dimension of 128, and fp16 (2 bytes per element). The standard cache requires about 64 KB per token per layer. If MLA uses a kv_lora_rank of 512 and a RoPE dimension of 64, it requires about 1.1 KB per token per layer, a compression ratio of roughly 57×.
For a single 64K context across 80 layers, the standard cache is about 320 GiB, while MLA is about 5.6 GiB. This estimate includes only the KV cache, not weights or activations.
The tradeoff is extra up-projection compute during decoding: a small amount of compute is exchanged for GPU memory capacity. When GPU memory is the bottleneck, this trade is usually worthwhile.
2. Multi-Token Prediction: More Tokens per Forward Pass
A traditional autoregressive model generates one token per forward pass. During decoding, each step reads all weights and the historical cache. The compute is small, and speed is mainly limited by memory bandwidth.
Multi-Token Prediction (MTP) adds extra prediction heads so the model can predict multiple tokens after the current position at the same time. During training, these extra heads provide a denser learning signal.
At inference time, the extra prediction heads can act as a draft model for speculative decoding. They propose k candidate tokens at low cost, and then the main model verifies them in one forward pass in parallel. The main model compares the candidates from left to right, accepts the prefix consistent with its own judgment, and stops at the first mismatch.
If each draft token’s acceptance probability is independent and equal to α, the average number of tokens produced per step is:
(1 − α^(k+1)) / (1 − α)
With α=0.8 and k=2, each step produces about 2.44 tokens on average. The actual speedup depends on the real acceptance rate, which varies by task type and text content. Before launch, measure acceptance rates by request type rather than relying only on an overall average.
3. Sparse Attention: Reducing Long-Sequence Compute
Full attention compute scales quadratically with sequence length. Each Query computes relevance against all historical Keys. When context grows from 4K to 64K, attention compute grows by about 256×.
Sparse attention lets each Query focus only on a small set of the most relevant Keys. The sparse attention module in the source material uses a lightweight indexer to select Top-k Keys for each Query, then computes attention only over those Keys. Module naming and implementation details should follow the original technical report.
The cost has two parts. The attention computation itself depends on k and is largely independent of sequence length. However, the indexer still scans historical positions for each Query. This cost still grows with sequence length, though its constant factor is small.
Actual speedup also depends on kernel implementation. Selected Keys are usually non-contiguous in GPU memory and require gather operations. If memory access patterns are poorly designed, theoretical floating-point operation savings may not translate into speed gains. Evaluate end-to-end throughput and latency rather than theoretical compute alone.
4. Deployment: From Architecture to Production
Deploying very large MoE models places high demands on infrastructure. Several areas need advance planning.
First, GPU memory. Weights, KV cache, and activations must fit at the same time. KV cache size is directly related to maximum concurrency and maximum context length. Estimate it at peak load, not at average load.
Second, interconnect bandwidth. Expert parallelism requires frequent all-to-all communication, and bandwidth and latency directly affect throughput. In multi-node deployments, network quality between nodes can become a bottleneck more easily than per-GPU compute.
Third, load balancing. Monitor the proportion of tokens each expert receives. If some experts remain hot for long periods, overall speed slows and model quality can also suffer.
Fourth, speculative decoding acceptance rate. Measure it in buckets by request length and workload type, and adjust the draft length k accordingly.
Fifth, cache hits. For scenarios with fixed system prompts or multi-turn conversations, prefix caching can significantly reduce repeated computation.
For cloud services, GPU instances, container orchestration platforms, and object storage from mainstream cloud providers can handle weight distribution and training data reading. Logging and monitoring systems should cover the metrics above so batch size and caching strategy can be adjusted dynamically.
5. Conclusion
The core message of the technical report is that open-source MoE models continue to invest in parameter scale, data quality, and architecture details. MLA, multi-token prediction, and sparse attention target three bottlenecks: GPU memory, decoding throughput, and long-sequence compute. Their benefits vary by scenario.
For developers, the most valuable approach is to benchmark your own workload and measure GPU memory usage, time to first token, output tokens per second, and acceptance rate separately. With that data, you can decide whether to adopt a technique and how to configure it.
The deployment cost and operational complexity of very large MoE models are high. Validate with a small amount of traffic first, confirm the benefits and stability, and then ramp up gradually.
