Beyond MoE and MLA: What Actually Matters When Choosing a Large Language Model
Similar architectures don't mean similar inference costs or capabilities. Before choosing a model, ask three questions: Is your main bottleneck memory, throughput, or training cost? How long are your contexts, and how high is your concurrency? How many GPUs can you provision, and how much operational effort can you invest? This article breaks down the key design dimensions of modern LLMs—including Mixture of Experts (MoE) and Multi-head Latent Attention (MLA)—and shows how to evaluate them against your actual workload, with concrete formulas for memory and cost estimation.
1. Key Takeaways and Selection Criteria
| Design Dimension | Primary Impact | Effect on Inference Cost | Selection Guidance |
|---|---|---|---|
| Expert count and routing | Total parameters, knowledge capacity | Weight memory grows with total parameters; compute grows with activated parameters | More experts raise the memory bar; watch for balanced expert utilization |
| Attention head configuration (MHA, GQA, MLA) | KV Cache size | Under long contexts and high concurrency, KV Cache is often the memory bottleneck | Prioritize KV Cache size for long-text, high-concurrency scenarios |
| Optimizer and training recipe | Training stability, convergence speed | Essentially no effect on inference costs | Compare published training stability notes; don’t extrapolate to inference cost |
| Data efficiency | Capability density per parameter | Indirect: a smaller model may achieve equivalent results | Validate with your own business evaluation set, not a single leaderboard |
2. What MoE and MLA Actually Solve
MoE splits the feed-forward network into multiple experts, routing each token to only a few of them. Each forward pass activates only a subset of parameters, so compute is lower than a dense model of the same total parameter count. However, all expert weights must stay resident in GPU memory, because routing is decided at runtime. MoE therefore saves compute, not weight memory.
MLA addresses a different problem. Standard multi-head attention (MHA) stores Key and Value tensors for every layer and every attention head—the KV Cache. MLA first compresses Keys and Values into low-dimensional latent vectors and caches that compressed representation instead. Per-token cache usage drops, reducing memory pressure and memory bandwidth consumption. The trade-off is extra computation at inference time to reconstruct the latent vectors or absorb them into projection matrices.
Both techniques can coexist in one model, but they operate on different parts: MoE affects the parameters and compute of the feed-forward blocks, while MLA affects the caching and memory access of the attention blocks. Whether a design pays off depends on which of these dominates your workload.
3. Trade-offs: Experts, Attention Heads, Optimizers, and Data Efficiency
More experts generally mean more model capacity, but also a higher deployment bar. In multi-GPU deployments, expert parallelism requires cross-device communication, and communication latency drags down throughput. When routing is imbalanced, a few experts become hotspots while others sit idle, and real utilization falls below the theoretical value.
The attention head configuration determines KV Cache size. In MHA, the number of KV heads equals the number of query heads. GQA lets multiple query heads share a set of KV heads, shrinking the cache with a relatively simple implementation. MLA compresses the cache further, but its implementation and operator optimization are more complex. If your service handles mostly short texts at moderate concurrency, MHA or GQA may be cheaper to deploy, since operational tooling and inference framework support are more mature.
Optimizers and data efficiency mainly affect training. The optimizer determines whether training is stable and how fast it converges; data efficiency determines how much capability you get per unit of training. These choices shape the model’s capability ceiling and training cost, but inference-time memory and per-request cost are determined primarily by architecture. When evaluating a training recipe, look at the training setup and evaluation results in the published technical report, and note the report version and measurement conditions.
4. Memory and Cost Calculation Example
Inference memory breaks down into three parts: weights, KV Cache, and activations plus framework overhead.
Memory ≈ weight memory + KV Cache memory + activations and framework overhead
Weight memory is roughly total parameters multiplied by bytes per parameter—for FP16, 2 bytes per parameter. Estimate KV Cache as follows:
KV Cache bytes ≈ 2 × layers × KV heads × head dimension × sequence length × batch size × bytes per element
The factor of 2 accounts for the K and V caches. Bytes per element is 2 for FP16 and 1 for FP8. This formula applies to MHA and GQA, using the query head count and the grouped KV head count respectively. MLA’s cache structure differs: each layer caches latent vectors plus decoupled positional encodings per token, so use the latent dimension and positional encoding dimension given in the model’s report instead.
Here’s a worked example with hypothetical numbers—these represent no specific model and only illustrate the method. Assume 60 layers, 8 KV heads, head dimension 128, sequence length 32768, batch size 8, and 2 bytes per element:
KV Cache bytes ≈ 2 × 60 × 8 × 128 × 32768 × 8 × 2 ≈ 64.4 GB
Reducing the batch size to 4 brings the cache down to about 32.2 GB. Batch size and sequence length scale memory linearly, so pin down your maximum sequence length and target concurrency before tuning anything else.
For cost, amortize hardware spend over effective output:
Cost per million output tokens ≈ hourly hardware cost ÷ effective output tokens per hour × 1,000,000
Suppose you use 8 GPUs at 30 RMB per GPU-hour, and load testing yields a sustained throughput of 2,000,000 output tokens per hour. Hourly hardware cost is 240 RMB, so cost per million output tokens is roughly 120 RMB. Use sustained concurrency throughput, not short bursts. Multiply by a load-testing safety factor to cover traffic fluctuations, retries, and redundant instances.
Quantization affects both weights and cache. Switching weights from FP16 to FP8 roughly halves weight memory, but verify with your own evaluation set that the quality loss is acceptable. The KV Cache data type can be set independently, which may yield additional memory savings—also requiring validation.
5. Deployment Checklist
Before going live, check the following in order:
- Parallelism strategy: Confirm the combination of tensor parallelism, expert parallelism, and pipeline parallelism; ensure weights and cache fit on each GPU with room left for activations.
- Context and batch size: Define maximum sequence length and target batch size, and compute worst-case KV Cache using the formula above.
- Quantization: Record precision settings for weights and KV Cache separately, and compare pre- and post-quantization results on your business evaluation set.
- Scheduling: Enable mechanisms such as continuous batching, and record time-to-first-token and per-token latency.
- Load testing: Start from low concurrency and ramp up gradually, recording P50, P95, and P99 latency. Find the point where throughput stops growing and treat that as your capacity ceiling.
- Monitoring: Memory usage, KV Cache occupancy, expert load distribution, request error rate, and cost per token.
- Rollback plan: Keep the previous model version and configuration, and define explicit rollback triggers such as error rate or latency thresholds.
After a model version update, parameters and metrics may change. The numbers in this article only demonstrate the calculation method. Before making formal decisions, verify against the official technical reports and latest documentation, and run load tests with your own business data.
