Memory Before GPUs: Sizing Private Deployments for Trillion-Parameter MoE Models
This technical article presents a practical sizing sequence for private deployments of trillion-parameter MoE models: estimate GPU memory before selecting GPUs, choose precision before benchmarking, and calculate TCO before scaling out. It covers memory-budget formulas and worked examples for weights and KV cache, server and interconnect checks, FP8 versus INT4 applicability, accuracy regression and rollback, inference benchmarking metrics, TCO components, version-selection risk control, and a launch checklist.
Memory Before GPUs: Sizing Private Deployments for Trillion-Parameter MoE Models
Executive Summary
Hardware selection should proceed in three steps: estimate GPU memory before choosing GPUs; choose precision before benchmarking; calculate TCO before scaling out. Each step below includes formulas, worked examples, and check items. The figures in this article are examples only. Replace actual parameters with the configuration in the official model card for the selected model, and use your own benchmark results as the final basis.
1. Why GPU Memory Comes First in Private Deployment
Enterprises move to private deployment mainly for three reasons: data sovereignty, compliance requirements, and long-term inference cost. After call volume reaches a certain scale, token-based API fees continue to grow, while the fixed costs of a self-built cluster remain relatively stable.
For sparse mixture-of-experts (MoE) models, the bottleneck is not peak compute. Each token activates only a small number of experts, so per-token compute is close to that of a dense model with a few hundred billion parameters, while model capability comes from all parameters. The first hardware selection metric is therefore GPU memory capacity; the second is memory bandwidth; the third is inter-GPU and inter-node communication capability. Expert weights should remain resident in GPU memory. If they are swapped in and out between CPU and GPU, latency will fluctuate noticeably.
2. Memory Budget Formulas and Quantization Conversion
2.1 Total Memory Formula
Total memory requirement ≈ weight memory + KV cache memory + activation and communication buffers
Definitions:
- Weight memory: total parameter count × bytes per parameter. Both expert weights and non-expert weights must be counted.
- KV cache memory: number of concurrent sequences × context length × number of layers × bytes cached per token per layer.
- Activation and communication buffers: as a rule of thumb, reserve 10% to 20% of the sum of weight memory and KV cache memory. The final value should be based on framework measurements.
2.2 Weight Bit-Width Conversion
Using 1 trillion total parameters as an example:
| Precision | Bytes per parameter | Weight memory | Relative to BF16 |
|---|---|---|---|
| BF16 | 2 | 2 TB | 1× |
| FP8 | 1 | 1 TB | 0.5× |
| INT4 | 0.5 | 0.5 TB | 0.25× |
Actual INT4 models also store additional parameters such as group scaling factors, so memory will be slightly higher than the table values. Some layers—such as the router network, output layer, and some attention layers—are often kept at higher precision, depending on the framework’s quantization configuration.
2.3 KV Cache Example
Long-context models often use multi-head latent attention (MLA), which caches compressed low-dimensional latent variables. The number of cached elements per token per layer depends on the latent dimension and positional encoding dimension in the model configuration. Assume 576 BF16 elements per token per layer (1,152 bytes), 60 layers, 8 concurrent sequences, and a 128K context (131,072 tokens):
KV cache ≈ 8 × 131,072 × 60 × 1,152 bytes ≈ 72.5 GB
The compression effect depends on the model configuration; a generic compression ratio cannot be applied. The values 576 and 60 above are only for demonstrating the calculation method. For formal sizing, read the real values from the official configuration file.
2.4 Reverse Sizing Example
Assume a single GPU has 80 GB nominal memory and 85% is counted as usable, or about 68 GB per GPU.
- FP8 option: weights 1,000 GB + KV cache 72.5 GB = 1,072.5 GB. Adding a 15% buffer gives about 1,233 GB. Dividing by 68 GB gives 18.1, so at least 19 GPUs are required. The actual GPU count must also satisfy the partitioning requirements of expert parallelism and tensor parallelism; common values are 24 or 32.
- INT4 option (KV cache still counted as BF16): weights 500 GB + KV cache 72.5 GB = 572.5 GB. Adding a 15% buffer gives about 658 GB. Dividing by 68 GB gives 9.7, so at least 10 GPUs are required.
The difference in GPU count between the two options is significant. The quantization decision should therefore be made before GPU selection.
3. Server and Interconnect Selection
Check four categories of constraints one by one:
- Memory capacity: total memory of a single server or cluster must exceed the memory requirement and retain headroom.
- Memory bandwidth: MoE expert computation depends on weight read speed; insufficient bandwidth reduces output tokens per second.
- Interconnect communication: expert parallelism generates substantial all-to-all communication. Intra-node and inter-node network bandwidth must be sized against communication volume; do not look only at per-GPU specifications.
- Software stack: the inference framework version must support the target model architecture (MoE routing, MLA, etc.) and the selected quantization format. Validate in a test environment before launch.
Other items to confirm: model weights are on the order of terabytes, so plan for loading time and storage capacity; rack power and cooling must support full-load operation.
4. Applicability Boundaries of INT4 and FP8
4.1 Applicable Conditions
| Option | Suitable scenarios | Prerequisites |
|---|---|---|
| FP8 | Default starting point; services sensitive to accuracy | Hardware and framework support FP8; scaling factor configuration is usually required |
| INT4 | Tight GPU memory, or the business can accept some accuracy regression | Calibration dataset required; accuracy regression must be completed |
4.2 Accuracy Regression Steps
- Extract an evaluation set from real business traffic, covering typical tasks such as long text, multi-step reasoning, tool calls, and format following.
- Run the evaluation on the BF16 or FP8 baseline and record all metrics.
- Run the candidate quantized version on the same evaluation set and calculate metric deltas.
- Have the business owner set acceptable thresholds. For example, if accuracy on key tasks drops by more than 2 percentage points, do not launch. The threshold is a business decision and should not be set by the technical team alone.
4.3 Rollback Plan
Keep the image and configuration of the previous precision version. Rehearse the switch in a test environment to ensure rollback can be completed within the agreed time in the event of a failure.
5. Inference Tuning and Benchmarking
5.1 Core Metrics
- Time to first token (TTFT): time from request to the first output token.
- Time per output token (TPOT): average generation interval during the output phase.
- Throughput: output tokens per second, converted to effective throughput per GPU by dividing total throughput by the GPU count.
- P99 latency: tail latency, which determines whether the service meets its SLO.
- Peak memory and expert load balance: an overloaded GPU can become the overall bottleneck.
5.2 Benchmarking Steps
- Sample input and output length distributions from online logs; benchmark data must match the real distribution.
- Start from low concurrency and increase load step by step, recording changes in throughput and P99 latency.
- Find the knee of the throughput curve—the point where latency begins to rise noticeably.
- Under the SLO constraint, take the maximum concurrency as the capacity of a single cluster.
5.3 Parameter Check Items
- Expert parallelism (EP): determines how experts are distributed and affects communication volume.
- Tensor parallelism (TP): affects per-layer computation partitioning and communication.
- Pipeline parallelism (PP): affects layer partitioning and may increase latency.
- Maximum batch tokens and KV cache block size: directly affect memory usage and throughput.
- Expert load statistics: if some experts remain overloaded for long periods, adjust routing or the parallelism strategy.
6. TCO Calculation
6.1 Cost Components
| Item | Calculation method |
|---|---|
| Hardware depreciation | Total server purchase price ÷ depreciation period (commonly 3 to 5 years) |
| Electricity | Full-load power (kW) × 24 × 365 × electricity price × PUE |
| O&M labor | Converted from dedicated headcount and labor cost |
| Software and support | Counted according to contract or license fees |
| Redundant resources | Cost corresponding to GPUs reserved for failover and canary releases |
6.2 Unit Cost
Cost per million tokens = annual total cost ÷ annual processed million tokens
Example: assume an annual total cost of CNY 1,000,000 and annual processing of 1.5 billion tokens (1,500 million tokens). The cost per million tokens is approximately CNY 0.67. When comparing with API prices, ensure the billing basis is consistent, and use the supplier’s current public price or contract.
7. Version Selection and Risk Control
Newer model versions are not necessarily more suitable for production. Version selection should be based on the following materials: official model cards and change notes, publicly available community test records, and results on your own evaluation set. Version pricing should be based on the official pricing page or contract; cost cannot be inferred from the version number alone.
8. Launch Checklist
- Memory budget reviewed against official model card parameters
- Cluster GPU count meets parallel partitioning requirements and retains redundancy
- Quantization accuracy regression passed; thresholds confirmed by the business owner
- Rollback plan rehearsed in the test environment
- Benchmark reaches expected concurrency under the target SLO
- Monitoring covers memory, expert load, queue length, and error rate
- Model and framework versions locked
- Logs desensitized, and access permissions configured according to least privilege
- TCO model established and reviewed quarterly
Completing this checklist item by item can significantly reduce the probability of rework after launch.
