Trillion-Parameter MoE Local Inference: Calculate VRAM Before Compute
For trillion-parameter MoE models, local inference feasibility is often limited by VRAM capacity and bandwidth rather than peak TFLOPS, because all expert weights must remain resident and token decoding is memory-bound. This article explains how to break down weight memory, KV cache, runtime overhead, and redundancy; how to match hardware to high-concurrency, low-latency, and long-context workloads; how to validate quantization; and how to estimate GPU count with a worked example. It also covers long-duration stress testing, cloud validation, and a final selection checklist.
Introduction: Start with VRAM, Then Discuss Compute
When planning local inference deployment for large Mixture-of-Experts (MoE) models, many teams first compare accelerator peak compute (TFLOPS). For trillion-parameter MoE models, however, VRAM capacity and VRAM bandwidth usually determine feasibility more than raw compute throughput.
There are two reasons. First, an MoE model activates only part of its experts during each forward pass, but all expert weights must remain resident in VRAM. VRAM usage is therefore calculated from the total parameter count, not the activated parameter count. Second, token-by-token decoding is a memory-bound workload. Each generated token requires reading activated weights and the growing KV cache. The performance ceiling often depends on whether the model fits and whether data can be read fast enough.
This article follows the order of VRAM composition, workload tiers, quantization tradeoffs, capacity sizing, and stability validation, and ends with a selection checklist.
1. What Consumes VRAM
1.1 Weight Memory: Total Parameters × Bytes per Parameter
Weight memory is straightforward to calculate: total parameters × bytes per parameter.
For 1 trillion (1T) parameters:
- With FP8 quantization, 1 byte per parameter, weights require about 1 TB.
- With BF16 or FP16, 2 bytes per parameter, weights require about 2 TB.
- With INT4 quantization, 0.5 bytes per parameter, weights require about 0.5 TB.
The unit conversion here uses decimal units: 1 TB = 1000 GB. FP8 weights require about 1000 GB of VRAM, not “hundreds of GB.” Estimating GPU count from hundreds of GB will significantly undersize the deployment.
1.2 KV Cache: Formula and Applicable Boundaries
KV cache grows linearly with concurrency and context length. Under standard multi-head attention (MHA), the estimation formula is:
KV cache bytes = 2 × layers × KV heads × head_dim × sequence length × concurrent sequences × bytes per element
The terms are:
- 2: stores Key and Value separately.
- KV heads: in standard MHA, this equals the number of attention heads. Models using grouped-query attention (GQA) or multi-query attention (MQA) have significantly fewer KV heads than attention heads. Use the actual KV head count; otherwise, VRAM usage will be overestimated.
- Concurrent sequences: the number of requests simultaneously in decoding state, i.e., the batch size in the framework.
- Bytes per element: determined by the KV cache data type. BF16 is 2 bytes, and FP8 is 1 byte. KV cache precision can differ from weight precision and must be confirmed separately.
Models using compressed cache structures such as Multi-head Latent Attention (MLA) cannot apply the formula above directly. Use the per-token cache dimension from the official model documentation, then multiply by layers, sequence length, concurrency, and bytes per element.
1.3 Runtime Overhead and Redundancy
In addition to weights and KV cache, the inference framework also uses memory for computation graphs, temporary buffers, and communication buffers. This overhead is typically several GB to tens of GB and should be based on measured values or framework documentation.
Production environments also need VRAM headroom. Multiply the calculated result by a factor of 1.15 to 1.25. Insufficient headroom can cause VRAM overflow under long contexts or burst concurrency, leading to request queuing, swapping, or service interruption.
2. What Bandwidth and Compute Each Control
During decoding, each generated token requires reading activated weights and KV cache from VRAM. Single-token generation latency is roughly proportional to “data read ÷ VRAM bandwidth.” Bandwidth therefore directly limits single-stream speed and the upper throughput limit at high batch sizes.
Prefill is a different workload. Long prompts must be processed in parallel at once, which involves significant computation; peak compute matters more here. Large-batch matrix operations also depend on compute.
For conversational applications dominated by token-by-token interaction, adequate compute is usually sufficient. If VRAM specifications are reduced in pursuit of peak compute, deployment often runs into fit problems or long-context instability.
3. Select by Workload Type
Different businesses have very different hardware requirements. Rather than looking for a universal GPU, make decisions by workload tier.
3.1 High-Concurrency Services
For multi-user online inference services, such as an API gateway backend, prioritize as follows:
- Single-GPU VRAM capacity: larger capacity allows more weight replicas and KV cache per node and reduces cross-GPU communication.
- VRAM bandwidth: determines the throughput ceiling at high batch sizes.
- Multi-GPU interconnect capability: tensor parallelism depends on efficient inter-GPU communication. Insufficient interconnect bandwidth significantly reduces scaling efficiency.
Benchmark candidate hardware under the target model, target batch size, target context length, and target framework version. Do not directly adopt third-party performance multipliers, because those numbers usually depend on specific batching strategies and serving configurations.
3.2 Single-User, Low-Latency Workloads
For low-concurrency scenarios such as personal coding assistants and desktop agents, the key metrics are time to first token (TTFT) and per-token generation speed.
If the quantized model fits completely on a single GPU, single-GPU deployment avoids cross-GPU communication and usually has lower latency. In this case, there is no need to pay a premium for extremely large VRAM. Once the model must be split across multiple GPUs, cross-GPU communication latency can offset the advantages of a single GPU.
3.3 Long-Context Workloads
Tasks such as long-document analysis and repository-level code understanding can require context lengths of 64K or even 128K. In these cases, KV cache is often the main VRAM consumer and grows linearly with concurrency.
The selection criterion is no longer only “how fast is it,” but “how stable is it under pressure.” When VRAM approaches exhaustion, the inference framework may trigger request queuing, swapping, or even crashes. Capacity sizing should therefore use peak context length, not average length. Set length limits and queuing mechanisms for very long requests to prevent a single request from overwhelming the overall service.
4. Quantization Options and Accuracy Validation
The table below counts weight memory only and excludes KV cache and runtime overhead:
| Quantization precision | Bytes per parameter | Weight VRAM for 1T parameters (estimate) | Use case |
|---|---|---|---|
| BF16/FP16 | 2 | About 2 TB | Most complete precision; local single-machine deployment is nearly impossible |
| FP8 | 1 | About 1 TB | Small accuracy loss; mainstream choice for most production environments |
| INT4 | 0.5 | About 0.5 TB | Lower VRAM pressure, but accuracy must be validated first |
After quantization, do not simply check whether VRAM has been halved. Complete the following validation:
- Calibration set: use data consistent with the business distribution for quantization calibration, and keep an independent evaluation set.
- Evaluation tasks: compare results before and after quantization on representative tasks for the target business, recording changes in accuracy or human ratings.
- Regression threshold: define an acceptable accuracy drop in advance; if exceeded, the configuration fails.
- Fallback plan: if INT4 does not meet the threshold, fall back to FP8 and recalculate GPU count and cost.
5. Standard Capacity Sizing Process and a Reproducible Example
5.1 Sizing Steps
- Determine total parameter count and quantization precision, then calculate weight memory.
- Determine target concurrency, peak context length, and KV cache precision, then calculate KV cache using the formula.
- Add framework runtime overhead.
- Multiply by a redundancy factor of 1.15 to 1.25.
- Divide total requirement by usable VRAM per GPU and round up to the minimum GPU count.
- Check whether the GPU count matches the parallel strategy (e.g., a power of two) and confirm that multi-GPU interconnect can meet communication requirements.
5.2 Example
Assume the following conditions (illustrative data; replace with target model parameters in practice):
- Total parameters: 1T, FP8 weights, 1 byte per parameter.
- Layers: 80, KV heads: 8, head_dim: 128, KV cache in FP8, 1 byte per element.
- Peak context: 128K, i.e., 131072 tokens.
- Concurrent sequences: 16.
- Framework runtime overhead: 60 GB total.
- Redundancy factor: 1.2.
- Usable VRAM per GPU: 120 GB (actual usable value after subtracting system and framework usage).
The calculation is as follows.
Weight memory: 1,000,000,000,000 × 1 byte ≈ 1000 GB.
Single-sequence KV cache: 2 × 80 × 8 × 128 × 131072 × 1 byte ≈ 21.47 GB.
KV cache for 16 concurrent sequences: 21.47 GB × 16 ≈ 343.6 GB.
Subtotal requirement: 1000 + 343.6 + 60 ≈ 1403.6 GB.
Add redundancy: 1403.6 × 1.2 ≈ 1684.3 GB.
Minimum GPU count: 1684.3 ÷ 120 ≈ 14.04, rounded up to 15 GPUs. Because parallel strategies often require a power-of-two GPU count, choose 16 GPUs in practice, i.e., two 8-GPU servers.
If network bandwidth between the two servers is low, cross-machine tensor parallelism may become a bottleneck. In that case, re-evaluate the parallel strategy or choose a configuration with more GPUs per node.
6. Long-Duration Stress Testing and Stability
The standard for production selection should be stability under sustained load, not peak benchmark numbers. Run long-duration stress tests on candidate configurations with requests close to the real distribution, for at least several hours.
Metrics to monitor include:
- Peak VRAM usage and fragmentation;
- Number of OOM (out-of-memory) events;
- Number of downclocks caused by GPU thermal throttling;
- P99 TTFT, throughput (tokens/s), and request error rate.
Thresholds should be set according to the team’s service-level objectives (SLOs). For example: no OOM during the stress test, peak VRAM not exceeding 90% of available VRAM, and P99 TTFT no more than 1.2× the target value. Only configurations that meet the thresholds should move to procurement or launch.
In addition, serving framework batching parameters such as maximum batch size, prefix caching, and chunked prefill can often improve usable throughput without changing hardware. Tune them during stress testing as well.
7. Validate on the Cloud Before Local Procurement
Teams with limited budgets or unstable workloads can start with elastic GPU resources on general cloud platforms. On the cloud, they can complete workload profiling, capacity validation, and canary testing, and calibrate the sizing model with real traffic data. After confirming specifications and count, they can then decide whether to make a local purchase.
This approach avoids the risk of making a large fixed asset investment and later discovering that the selection does not match the workload.
Conclusion: Selection Checklist
Local inference selection for trillion-parameter MoE models is essentially about balancing VRAM capacity, bandwidth, and workload shape. High-concurrency services prioritize large VRAM and high bandwidth; single-user interaction prioritizes response speed; long-context workloads prioritize VRAM headroom and stability.
Before procurement, use the following five checks:
- Parameter scale: Is weight memory calculated from total parameter count?
- Quantization precision: Are weight and KV cache precisions determined, and has accuracy validation been completed?
- Peak context: Is KV cache calculated from peak length rather than average length?
- Concurrency: Is sizing based on target peak concurrency, and does it match the framework batch size?
- Redundancy factor: Is a 1.15 to 1.25 VRAM redundancy reserve included, and has long-duration stress testing been completed?
Calculate the VRAM budget first, then discuss compute. Following this order helps achieve a reasonable balance among performance, cost, and stability.
