Local Deployment of a 670B MoE LLM: Hardware Selection and Cost Estimation Guide
This article explains how to deploy a very large Mixture-of-Experts (MoE) language model locally, focusing on capacity limits, CPU/GPU memory offloading, quantization, performance expectations, and cost estimation. Using a roughly 670B-parameter model as an example, it shows how to estimate memory requirements, split layers between GPU and CPU, interpret prefill/decode behavior, and compare upfront hardware costs, operating expenses, and opportunity costs when deciding whether to self-host or rent cloud compute.
Local Deployment of a 670B MoE LLM: Hardware Selection and Cost Estimation Guide
1. Where the real cost comes from
Many developers assume that the biggest obstacle to running a very large model locally is compute power. In practice, the more common bottleneck is capacity.
Take a MoE model with roughly 670 billion parameters as an example. Even with relatively aggressive 4-bit quantization, such as a widely used quantization format like Q4_K_M, the model weights alone occupy about 377 GB of storage. This immediately rules out running the entire model from the memory of a single consumer-grade GPU. Instead, you need a heterogeneous setup combining CPU system memory and GPU memory.
This distinction is important. The cost of local deployment is not mainly about adding more compute. It is about assembling enough usable memory capacity and moving data through the system quickly enough.
2. Capacity estimation: find your lower bound
Before purchasing hardware, start with a simple capacity estimate:
# Estimate memory/VRAM needed for model weightstotal_params = 671e9 # Total number of parametersbits_per_weight = 4.5 # Average bits per weight for a 4-bit quantization schememodel_size_gb = total_params * bits_per_weight / 8 / 1e9print(f"The model weights need approximately {model_size_gb:.0f} GB")# Output: approximately 377 GB
This number is only the floor. Real deployments also need to account for:
- KV Cache: This grows with context length and can consume tens of GB in long-context scenarios.
- Runtime framework overhead: Inference frameworks require buffers, temporary tensors, and some memory headroom.
- Operating system and reserved memory: You should not expect to use 100% of available memory.
A practical rule of thumb is that total available memory should be at least 1.3 to 1.6 times the model weight size to support stable long-context inference.
3. Heterogeneous inference: how CPU and GPU share the workload
If the model cannot fit entirely into GPU memory, one common approach is to place only a portion of the layers in GPU memory and keep the rest in CPU system memory. The GPU handles the layers it can hold, while the CPU processes the remaining layers.
This kind of mixed offloading is now a common strategy for running very large models locally.
An illustrative layer allocation configuration might look like this:
model:quant: 4bittotal_layers: 61gpu_layers: 20 # Layers placed in GPU memory for speedcpu_layers: 41 # Layers placed in system memory for capacity
There is an obvious tradeoff here:
- More layers on the GPU means faster decoding, but also higher GPU memory requirements and higher cost.
- More layers on the CPU reduces hardware cost, but decoding becomes slower.
When selecting hardware, this ratio should be chosen based on the target workload. An interactive chat system needs lower latency, while an offline batch-processing system may tolerate slower speed.
4. Quantization: trading some precision for a large space reduction
Quantization compresses model weights from higher precision formats, such as 16-bit, down to 8-bit, 4-bit, or even lower. For local deployment of very large models, quantization is often a key prerequisite.
In general, lower precision means less memory consumption, but it can also introduce some quality loss.
When choosing a quantization level, consider the following principles:
- Protect the quality baseline: 4-bit is currently a common balance between size and quality. Going below this requires careful evaluation.
- Focus on activations, not just weights: In MoE models, only a small portion of parameters is activated during each inference. Quantization choices should align with the activation path.
- Run quality regression tests: After quantization, evaluate the model on representative business data to confirm that any accuracy loss is acceptable.
5. Performance expectations: why prefill is fast but decode is slow
Many people are surprised the first time they run a large model locally. Input processing can reach hundreds of tokens per second, while output generation may drop to only a dozen tokens per second. This is not necessarily a misconfiguration. The two phases have different characteristics:
- Prefill: Input tokens can be processed in parallel, making this phase compute-bound. The GPU can be used effectively, so speed is relatively high.
- Decode: Each generated token requires reading most of the activated parameters again, making this phase memory-bandwidth-bound.
A simplified estimate of the theoretical upper bound for decoding speed is:
# Theoretical upper bound for decode speed (memory-bandwidth bound)bandwidth = 2000e9 # Memory bandwidth, example value of 2 TB/sactive_params = 671e9 * 0.06 # Assume about 6% of parameters are activatedactive_bytes = active_params * 4.5 / 8decode_tps_upper = bandwidth / active_bytesprint(f"Theoretical decode upper bound: approximately {decode_tps_upper:.1f} tokens/s")
This illustrates an important point: decode speed is mainly determined by memory bandwidth, not just clock frequency. This is also why a high-end dual-socket server platform with high-bandwidth memory can often deliver better decode performance than a single-socket platform.
A commonly cited reference point from official tutorials, with prefill above 200 tokens/s and decode around 14 tokens/s, reflects this pattern. A large gap between prefill and decode is normal.
6. How expert selection affects inference
Large MoE models can balance a very large total parameter count with a manageable amount of computation per token. They achieve this through expert selection, also known as routing. During inference, each token activates only a small number of expert networks.
As a result:
- You pay storage and memory costs for the full 377 GB of total weights.
- You pay bandwidth and compute costs only for the small subset of parameters activated during each decode step.
Understanding this helps with deployment optimization. If the hardware can cache frequently used experts and reduce repeated swapping of cold experts, decode throughput may improve. If routing is too dispersed or experts are frequently moved in and out, the memory subsystem can become the main bottleneck.
7. Cost estimation: upfront investment versus ongoing operation
The practical question is simple: how much will this cost? It helps to break the cost into three parts.
1. Upfront hardware investment (Capex)
The main components are:
| Component | Role | Cost impact |
|---|---|---|
| Server platform with dual-socket CPUs | Provides large memory capacity and high memory bandwidth | High |
| Memory (hundreds of GB of DDR5) | Stores layers that cannot fit into GPU memory | High |
| High-end GPU | Accelerates prefill and part of decoding | High |
| Storage (fast SSD) | Stores model weights and KV cache paging | Medium |
A dual-socket server with a high-end GPU, capable of running a 377 GB model, is typically a high-performance workstation or server configuration. The upfront cost is usually on the order of tens of thousands, though it varies widely depending on memory capacity and GPU model.
2. Operating cost (Opex)
Such a platform can draw over 1 kW at full load. Key operating costs include:
Electricity:
Annual electricity cost ≈ power (kW) × usage hours × electricity priceCooling and facility costs: High-power systems require stronger cooling, which adds indirect cost.
Operations and depreciation: Usually amortized over 3 to 5 years.
A rough estimate of annual electricity cost:
# Rough estimate of annual operating costpower_kw = 1.2 # Total system powerhours = 6000 # Annual operating hoursprice = 0.8 # Electricity price per kWh (example value)annual_cost = power_kw * hours * priceprint(f"Approximate annual electricity cost: {annual_cost:.0f}")
3. Opportunity cost
This includes the human time spent on model selection, tuning, quantization, and performance optimization. This part is often more expensive than the hardware itself and is easy to underestimate.
8. Build or rent? Four decision factors
If building a local system is too expensive, or if the usage frequency is low, renting cloud compute may be more economical. The decision can be evaluated along four dimensions:
- Usage frequency: For sustained 24/7 workloads, self-hosting may lower costs over time. For intermittent use, renting is more flexible.
- Data compliance: If data cannot leave your environment, or if private deployment is required, local deployment may be almost mandatory.
- Elasticity requirements: If you frequently test different model sizes or need sudden capacity increases, cloud-based pay-as-you-go is simpler.
- Operational capability: Local deployment requires skills in system operation, cooling, and power management. Without these capabilities, cloud platforms are often more stable.
Conclusion
The main cost of deploying a very large MoE model locally is not simply compute power. It comes from capacity constraints and bandwidth bottlenecks.
A practical approach is to:
- Use quantization to reduce the model size to a manageable range.
- Use heterogeneous CPU/GPU inference to move data efficiently between system memory and GPU memory.
- Build a cost model that includes upfront hardware, ongoing operations, and opportunity cost.
If the long-term total cost of self-hosting exceeds the pay-as-you-go cost of cloud compute, or if the workload requires more elasticity and easier operations, moving to the cloud is often the more rational choice.
