Local Deployment of Trillion-Parameter MoE Models: Calculating VRAM and Costs
This article provides a comprehensive guide to calculating the hardware requirements and costs for locally deploying trillion-parameter Mixture-of-Experts (MoE) models. It covers how to calculate the minimum VRAM needed for model weights based on total parameters, details the complete VRAM budget including KV Cache and framework overhead, analyzes the bandwidth limitations that determine operational stability, and breaks down both hardware costs and alternative strategies like cloud leasing and expert pruning.
1. Calculating Weights: The VRAM Lower Bound
Let’s use a MoE model with 2.8 trillion total parameters as an example. The model contains 896 routing experts, with 16 activated per token, resulting in an activation ratio of roughly 1.79% (16 ÷ 896). While computation is determined by the activated parameters, VRAM must be able to hold the weights of all experts. Since routing results cannot be predicted in advance, missing any expert will interrupt inference. Therefore, VRAM must be calculated based on the total parameters, not the activated ones.
Weight size depends on the storage precision:
- FP32 (4 bytes per parameter): 2.8T × 4 bytes = 11.2TB.
- MXFP4 (4-bit elements, with an 8-bit scaling factor per 32 elements, averaging 4.25 bits per parameter): 2.8T × 4.25 ÷ 8 ≈ 1487.5GB.
The MXFP4 numbers rely on two prerequisites: the model must have undergone Quantization-Aware Training (QAT), and the inference engine must support this format. If only post-training quantization is applied to an FP32 model, the accuracy loss must be evaluated separately and the above figures cannot be directly applied.
2. The Complete VRAM Budget
Beyond the weights, there are three additional overheads.
- Non-quantized Tensors: Embedding layers, LayerNorm parameters, etc., usually retain high precision, taking about 200 to 300GB. The exact value depends on the model structure.
KV Cache: This grows with context length and concurrent requests and must reside in VRAM. The calculation formula for standard Multi-Head Attention is as follows:
KV Cache Bytes ≈ 2 × Number of Layers × Number of KV Heads × Dimension per Head × Context Length × Concurrent Requests × Bytes per Element
The “2” in the formula represents the two caches for K and V. If the model uses a compressed attention structure like MLA, the KV Cache will be much smaller, and you should substitute the actual parameters from the model configuration file.
Fragmentation and Framework Overhead: Typically accounts for 5% to 10%.
Adding the first two items: 1487.5GB of weights plus about 250GB for non-quantized parts totals roughly 1.7TB. Add fragmentation, and just fitting the model itself approaches 1.8 to 1.9TB. Therefore, 1.6TB is only the theoretical baseline for fitting the model, not for stable operation. For planning, it is recommended to have a total VRAM of no less than 2TB, with actual capacity adding a buffer for the context and concurrency requirements calculated using the KV Cache formula.
3. Bandwidth Determines Stable Operation
A MoE model requires an All-to-All communication at every layer. Tokens are sent to the GPUs hosting the selected experts, and after the experts complete their computation, the results are sent back to the original GPUs. Because experts are distributed across multiple cards, this communication overhead occurs at every layer.
To determine if the hardware is sufficient, compare two metrics: the communication time per layer and the computation time per layer. If communication time exceeds computation time, the GPUs will spend a significant amount of time waiting for data, causing the actual compute utilization to drop. The extent of this drop must be tested on the target hardware.
Common scenarios include:
- Standard 10GbE Ethernet: Both bandwidth and latency are far lower than NVLink or NVSwitch between GPUs, and All-to-All communication usually fails to meet latency requirements.
- PCIe Gen4 Interconnect: Inter-card bandwidth is also limited, and cross-card expert communication easily becomes a bottleneck.
- Consumer-grade GPUs (e.g., RTX 4090): Lacking NVLink, multi-card communication relies entirely on PCIe, making them generally unsuitable for this type of inference task.
An exception is offline tasks with extremely low concurrency and no strict speed requirements. Some solutions can run in such scenarios but cannot be directly used in production environments with latency requirements.
4. How to Calculate Costs
Hardware costs can be broken down as follows:
Total Hardware Cost = Number of Accelerator Cards × Unit Price (tax-inclusive) + Server & NVSwitch Base + High-Speed Network & Cables + Storage System
Data center modifications, electricity, and operations/maintenance personnel need to be accounted for separately. When calculating the three-year Total Cost of Ownership (TCO), hardware depreciation and electricity costs must also be included.
Taking 32 80GB cards as an example, the total VRAM is 2560GB, which covers the 2TB planning line with a buffer. 24 cards provide only 1920GB, falling below the 2TB line, and are not recommended. 64 cards offer more VRAM headroom and more flexible expert distribution, but procurement and data center investments will multiply.
Single card prices fluctuate significantly based on supply channels, purchase timing, and tax rates, so specific quotes are not provided here. Please refer to official current quotes, noting whether taxes are included, delivery cycles, and warranty terms. High-density racks typically require tens of kilowatts of power, so power supply and liquid cooling conditions should be confirmed with the data center before construction.
5. Cloud Leasing and Pruning Strategies
Dedicated Cloud Clusters typically support three billing models: on-demand, monthly subscription, and spot instances. Spot instances have lower unit prices but can be reclaimed at any time, making them unsuitable for long-term training or online services. Specific pricing is subject to the official announcements of various cloud providers. Before renting, compare the total costs of hourly and monthly billing, including storage and network fees.
Expert Pruning and Distillation is another route: extracting experts from a specific domain (such as code, math, or SQL) from the model and merging them into a much smaller model. This significantly reduces VRAM requirements and lowers the hardware barrier. However, this process requires training and evaluation, and the quality loss depends on the specific task. To determine feasibility, compare accuracy, latency, and unit cost on your own evaluation set. This article does not provide universal accuracy loss figures, as any data presented without specifying experimental conditions is meaningless.
