Local Deployment of a Trillion-Parameter MoE Model: Calculating GPU Count and VRAM Requirements

    This article explains how to estimate the GPU and VRAM requirements for deploying a trillion-parameter Mixture of Experts model locally. Using an example 2.8T-parameter configuration with about 104B active parameters and 1.56TB of weights, it covers weight size calculations, GPU count planning, KV cache budgeting for long context and concurrency, parallel strategy selection, quantization trade-offs, and a vLLM launch example.

    Local Deployment of a Trillion-Parameter MoE Model: Calculating GPU Count and VRAM Requirements

    1. Key Takeaways

    Whether a trillion-parameter model can run locally depends mainly on three things: whether the weights fit fully into VRAM or memory, whether there is still room for KV cache under long context and high concurrency, and whether GPU-to-GPU interconnect can handle communication between experts.

    The numbers below come from an example configuration and have not been verified against official sources. Before purchasing, recalculate based on the official model page and config.json.

    2. Total Parameters Are Large, but Compute Is Not

    A Mixture of Experts (MoE) model splits the feed-forward network into many experts. Each token passes through only the few experts selected by the router. Therefore, the compute per inference is determined by the active parameters, not the total parameters.

    In the example configuration, the total parameter count is 2.8T, and the single-token active count is about 104B. The activation ratio is 104 ÷ 2800 ≈ 3.7%. 104B is 104 billion parameters, which is in the hundred-billion class. A single inference is roughly equivalent in compute to a 104B dense model, while the model can store knowledge at close to the trillion-parameter scale.

    The cost is in VRAM. All experts must reside in VRAM somewhere; otherwise, once a token is routed to an expert, there is no way to compute it. Inference saves compute but spends VRAM and inter-GPU communication.

    3. Parameter Composition of the Example Model

    The following configuration comes from the source material and should be treated as an assumed configuration:

    • Routed experts: 896 fine-grained experts.
    • Routing: the router selects the Top-16 routed experts for each token.
    • Shared experts: 2, always active for every token.
    • In each MoE layer, each token actually uses 18 experts: 16 routed plus 2 shared.

    Selecting 16 from 896 experts gives about 7×10^33 combinations. This large combinatorial space allows the model to dynamically assemble computation paths based on the input.

    Fine-grained experts let each expert be more focused, while shared experts carry general semantics and avoid storing the same knowledge repeatedly in every routed expert. Whether the 104B active parameters include the 2 shared experts must be checked against the official configuration.

    4. How to Calculate Weight Size

    This article uses decimal units: 1TB = 10^12 bytes, 1GB = 10^9 bytes.

    1. 1.56TB ÷ 2.8T parameters ≈ 0.557 Byte/parameter ≈ 4.46 bit/parameter

    For comparison, FP16 or BF16 uses 2 bytes per parameter, so 2.8T parameters require about 5.6TB. The 1.56TB figure indicates that the weights have already been stored at low bit precision.

    4.46 bit is the full-model average. Weights usually use mixed precision: most experts are low-bit, while attention layers, embedding layers, and the router may retain higher precision.

    Units must be consistent. If a tool reports file size in binary TiB, convert using 1TiB ≈ 1.0995TB. If 1.56 is TiB, it is about 1.715TB, and the average bit count rises to about 4.9 bit, which cannot be directly compared with the decimal 4.46 bit.

    5. How Many GPUs Are Needed

    Weights must fit fully into VRAM or memory. You cannot simply look at GPU count multiplied by per-GPU capacity. The table below uses vendor-stated decimal GB. After subtracting weights, the remaining space must be reserved for KV cache, activations, communication buffers, and framework overhead.

    Configuration Total VRAM Remaining after subtracting 1.56TB of weights Conclusion
    8 × 80GB 640GB Insufficient Not feasible
    8 × 140GB 1120GB Insufficient Not feasible
    8 × 192GB 1536GB Insufficient, short by about 24GB Not feasible
    8 × 256GB 2048GB About 488GB (about 24%) Feasible, suitable for short context
    16 × 141GB 2256GB About 696GB Feasible
    32 × 80GB 2560GB About 1000GB Feasible, but communication overhead is high

    Eight 140GB GPUs cannot hold all weights. 1.56TB ÷ 8 ≈ 195GB, which already exceeds 140GB per GPU on average. For an 8-GPU deployment, per-GPU VRAM should be close to 256GB, and reserving 15% to 20% headroom is recommended.

    6. KV Cache: Long Context and Concurrency Are the Main Variables

    KV cache grows with context length and the number of concurrent requests. The KV space occupied by a single token is:

    1. KV per token = 2 × layers × KV heads × head dimension × bytes per element

    The 2 in the formula represents the two caches for K and V. The number of KV heads comes from config.json. For models using grouped-query attention (GQA) or multi-query attention (MQA), the number of KV heads is smaller than the number of attention heads, and this formula can be used directly. For models using compressed attention such as MLA, KV usage is much lower, and this formula cannot be applied directly.

    Take the assumed model as an example: 60 layers, 8 KV heads, head dimension 128, and BF16 storage at 2 bytes per element:

    • Single token: 2 × 60 × 8 × 128 × 2 ≈ 245,760 bytes, about 0.25MB.
    • Single request with 128K (131072) context: about 32GB.
    • 8 concurrent 128K requests: about 258GB.

    This result leaves almost no headroom for an 8 × 256GB configuration. Storing KV cache in FP8 can usually halve it, but only if both the hardware and framework version support it.

    7. How to Choose a Parallel Strategy

    Trillion-parameter MoE models generally need multiple parallel strategies combined.

    Strategy What is split VRAM benefit Main communication Applicable conditions
    Tensor parallelism (TP) Attention and linear-layer matrices in each layer Reduces per-GPU weight and KV usage by GPU count All-Reduce-style communication per layer Best for single-node 8-GPU NVLink; cross-node latency is high
    Expert parallelism (EP) 896 experts distributed across GPUs Each GPU stores only part of the experts; largest weight benefit All-to-All dispatch and aggregation per MoE layer Requires high-bandwidth interconnect and expert load balancing
    Pipeline parallelism (PP) Layers split into multiple stages Each stage stores only part of the layers Point-to-point transfer between stages, with smaller data volume Suitable for cross-node scaling, but has pipeline bubbles and higher first-token latency

    For a single-node 8-GPU scenario, prioritize TP, or TP combined with EP. Across multiple nodes, layer splitting (PP) is usually more stable than cross-node EP unless interconnect bandwidth is high enough.

    8. How Much Can Quantization Save?

    First, clarify the baseline. The numbers above assume 1.56TB of weights, an average of 4.46 bit, and mixed precision. If everything is compressed uniformly to pure 4-bit, weight size only decreases by about 10% (4 ÷ 4.46 ≈ 0.90). To halve the size, you would need to go down to about 2.2 bit, which would cause noticeable accuracy loss and cannot be done by simply changing the format. If you apply these numbers to a BF16 model, the conclusions will not hold; recalculate from your own baseline.

    Before and after quantization, verify two things:

    1. Whether expert load is skewed. Compare the routing hit distribution of the BF16 and quantized versions on the same batch of inputs, and observe whether individual experts are over-selected or almost never selected.
    2. Whether output quality degrades. Use a fixed evaluation set, such as 200 to 500 business samples, to compare accuracy, output-format compliance, and tool-call success rate.

    Prefer officially released quantized versions. The precision of self-quantized models is not controllable.

    9. Example Launch with vLLM

    The following example is based on vLLM 0.8 and later. Parameter names vary by version; before running, verify with vllm serve --help.

    1. vllm serve /models/example-moe-2.8T \
    2. --tensor-parallel-size 8 \
    3. --enable-expert-parallel \
    4. --enable-prefix-caching \
    5. --max-model-len 131072 \
    6. --max-num-seqs 16 \
    7. --gpu-memory-utilization 0.90 \
    8. --kv-cache-dtype fp8

    What each parameter does:

    • --tensor-parallel-size 8: splits weights across 8 GPUs.
    • --enable-expert-parallel: enables expert parallelism, distributing experts across GPUs. This requires framework support and sufficient GPU-to-GPU bandwidth.
    • --enable-prefix-caching: reuses KV for identical prefixes. Agent system prompts and tool definitions are usually fixed prefixes, so the benefit can be significant.
    • --max-model-len: maximum context per request, which directly determines the KV budget.
    • --max-num-seqs: maximum number of concurrent sequences, used to cap KV usage.
    • --gpu-memory-utilization: VRAM utilization ratio. Leaving headroom helps prevent out-of-memory errors caused by fragmentation.
    • --kv-cache-dtype fp8: stores KV cache in FP8. This can roughly halve KV memory when the hardware and framework version support it.