Very Large MoE Models: Calculating GPU Memory, Card Count, and Cost for Local Deployment

    This guide works through a worked example for sizing GPU memory, card count, and annual electricity cost for a very large mixture-of-experts (MoE) model deployed on local hardware. It covers the formulas for weights and KV cache, runtime and communication overhead, node-aligned card planning, parallelism options, and an electricity cost range. It also lists the checks to run in a proof of concept before buying hardware.

    1. Conclusions and Assumptions

    This article uses a hypothetical example to show the calculation. The example assumes about 2.8 × 10^12 total parameters, 896 experts, 16 experts activated per token, weights stored in a 4-bit microscaling format, a sequence length of 32,768 tokens, a batch size of 8, and a KV cache stored in BF16.

    Under the formulas in this article, the example needs about 1,723 GB of memory in total. A single 8-card node with 141 GB accelerators has a nominal total of 1,128 GB. Counting only usable memory, about 90% of that, leaves about 1,015 GB, which is not enough. The capacity lower bound is 14 cards. Aligning to 8-card nodes raises this to 16. The purchase plan uses 32 cards (four nodes) to leave headroom.

    These figures hold only for the assumptions above. If you change the model, the quantization scheme, or the workload, substitute your own values into the formulas below.

    Units: GB means 10^9 bytes, and GiB means 2^30 bytes. One GiB is about 1.074 GB. All memory figures in this article use GB, including the 141 GB nominal capacity that vendors quote.

    2. Step 1: Weight Memory Based on Total Parameters

    The formula for weight memory is:

    Weight memory = total parameters × bytes per parameter + scaling factor overhead

    A 4-bit format uses 0.5 bytes per parameter. Microscaling formats typically share one 8-bit scale value across every 32 parameters, which adds 1/32 byte per parameter. The example works out as follows:

    • Base weights: 2.8 × 10^12 × 0.5 bytes = 1,400 GB
    • Scaling factors: 2.8 × 10^12 × 1/32 bytes = 87.5 GB
    • Total: 1,487.5 GB, or about 1,385 GiB

    Block sizes and scale bit widths differ between quantization formats. For real calculations, use the documentation for the format you choose. Do not assume that “4-bit means 0.5 bytes” without checking.

    MoE memory planning requires special attention to expert layers. The router cannot know which experts each token will use before inference runs, so all expert weights must stay resident in memory. In the example, 16 ÷ 896 is about 1.79%. That is the activation ratio of the expert layers. The activation ratio of the whole model is higher, because attention and embedding layers take part in every inference step.

    Planning depends on three separate metrics, and each one determines a different resource:

    Metric Main determinants Use
    Memory capacity Total parameters, storage precision Lower bound on card count
    Compute per token Activated parameters Estimating compute demand
    Latency and throughput Expert scheduling, communication bandwidth, batch size Judging serving capacity

    Storage capacity is calculated from total parameters, and compute is calculated from activated parameters. The two cannot be interchanged.

    3. Step 2: KV Cache

    The formula for KV cache size is:

    KV cache bytes = 2 × layers × KV heads × head dimension × bytes per element × sequence length × batch size

    The factor of 2 accounts for the separate K and V caches. The example assumes 61 layers, 8 KV heads (using grouped-query attention), a head dimension of 128, 2 bytes per element (BF16), a sequence length of 32,768, and a batch size of 8.

    • KV cache per token: 2 × 61 × 8 × 128 × 2 = 249,856 bytes, about 244 KiB
    • Total cache: 249,856 × 32,768 × 8 = 65.5 GB, about 61.0 GiB

    The KV cache grows linearly with batch size and sequence length. Storing it in FP8 halves its footprint. If the model uses another attention structure, such as MLA, the formula above does not apply. Recalculate based on that structure’s cache layout.

    4. Step 3: Runtime and Communication Overhead

    Runtime overhead covers the inference framework, CUDA graphs, the activation workspace, and similar items. The example assumes 120 GB in total.

    Communication buffers hold the all-to-all dispatch and combine traffic in expert parallelism. The example assumes 50 GB in total.

    You can estimate an upper bound on communication volume first. In each layer, every token sends its activations once for dispatch and once for combine. The data volume per token per layer is:

    2 × activated experts × hidden dimension × bytes per element

    With 16 activated experts, a hidden dimension of 7,168, and BF16 (2 bytes per element), each token moves about 458,752 bytes per layer. For a decoding step with a batch size of 8 across all 61 layers, the upper bound per step is:

    8 × 458,752 × 61 ≈ 223.9 MB

    This is a data volume, not a latency. How much traffic crosses nodes depends on expert placement and routing results. Measure latency on your target hardware with a profiling tool.

    5. Step 4: Total Memory and Card Count

    The total requirement is the sum of four items:

    Total = weights + KV cache + runtime + communication buffers
    = 1,487.5 + 65.5 + 120 + 50 = 1,723 GB (about 1,605 GiB)

    Usable memory per card is the nominal capacity minus 10%. That reserve covers fragmentation and framework overhead:

    141 GB × 0.9 = 126.9 GB

    The minimum card count based on capacity is:

    1,723 ÷ 126.9 ≈ 13.6, rounded up to 14 cards

    Fourteen cards divide even