Practical Guide to Deploying Large-Scale MoE Models Locally at Low Cost

    This guide explains how to run a 671B-parameter Mixture-of-Experts (MoE) model on local hardware at a lower cost. It covers how sparse expert activation makes a hybrid setup of GPU, system RAM, and CPU possible, how to choose hardware, how to offload experts and apply quantization, and how cloud deployment on Baidu AI Cloud fits in.

    As open-source large language models grow to several hundred billion parameters, the hardware cost of local deployment has become the main obstacle for enterprises and developers. Take the 671B-parameter MoE (Mixture of Experts) architecture, which is common in the industry today. With a traditional full-model loading approach, storing the model in FP16 still requires more than 1.3 TB of GPU memory. Even with INT4 quantization, memory needs remain at 300 to 400 GB. A single machine would then need several top-tier professional GPUs, and the hardware investment, ranging from hundreds of thousands to millions, puts this out of reach for many small and mid-sized companies. However, by understanding the characteristics of the MoE architecture and combining it with a heterogeneous computing approach, you can run the full-capability model locally at a much lower cost.

    1. Sparse Activation in MoE and Memory Optimization

    The core idea of MoE (Mixture of Experts) is to split a large neural network into multiple “expert” sub-networks. During inference, the router selects only the few experts that best match each input token for computation. In a 671B-parameter MoE model, the total parameter count is very large, but each inference step typically activates only a few tens to a hundred billion parameters.

    This sparse activation makes it possible to lower deployment costs. Not every expert is needed for every query, so there is no need to keep all parameters resident in expensive GPU memory. Based on this, you can use a heterogeneous inference setup that combines a GPU, a large-capacity system memory (RAM), and a CPU.

    In this approach, model parameters are divided into “hot experts” and “cold experts.” For general questions, some experts are called frequently. These hot experts stay in GPU memory to keep computation fast. Cold experts, which activate only in specific domains, are cached in system main memory, which costs less. When inference needs an expert stored in memory, the system loads it into GPU memory over the PCIe bus, or the CPU computes it directly.

    2. Hardware Selection for Low-Cost Local Inference

    If the main goal is local inference, without large-scale fine-tuning or full training, you do not need a large GPU cluster. The following hardware configuration offers good value for this purpose.

    1. CPU: Dual-socket enterprise processors
    Some computation and memory scheduling tasks run on the CPU. Choose a current-generation mainstream dual-socket enterprise CPU platform. A dual-socket setup provides many cores for parallel processing and more PCIe lanes, which maximizes the data transfer bandwidth between the GPU and system memory. High clock speeds and many cores also help speed up the computation of cold experts stored in memory.

    2. System memory (RAM): 1 TB or more of high-capacity, high-speed memory
    Memory is the core of this approach. Its capacity determines whether the full model weights fit. For a 671B-class model, plan for at least 1 TB of memory to cover the quantized model size and the base overhead of the operating system. Memory frequency and channel count also matter. DDR5 memory with eight or twelve channels can significantly increase data throughput and reduce latency from data movement.

    3. GPU: One professional GPU with large memory
    In this approach, the GPU no longer stores the full model. It focuses on computing hot experts and storing the KV cache. Choose a professional GPU with 80 GB or more of memory. This card acts as the inference accelerator and handles frequently used logic and complex tensor operations.

    3. Engineering Practice and Performance Tuning for Heterogeneous Inference

    Once the hardware is ready, the configuration and optimization of the inference framework are equally important. Traditional inference frameworks usually load the entire model into GPU memory by default. For this approach, use an inference engine that supports heterogeneous offloading.

    1. Hot and cold expert allocation
    Balancing latency and cost depends on how you allocate parameters. During initial deployment, run the model on a representative dataset and record how often each expert activates. Keep the top-K most frequently activated experts fixed in GPU memory, and offload the rest to system memory by layer or by block. Some advanced inference frameworks support dynamic monitoring, which adjusts the expert distribution in GPU memory based on the type of real-time query. However, this adds scheduling overhead, so you need to weigh stability against peak performance.

    2. Combining quantization techniques
    To further reduce memory usage and PCIe transfer volume, use quantization. For example, INT8 or INT4 quantization can compress the model to one-third of its original size or less. Quantization allows 1 TB of memory to hold the full model with more headroom, and it also reduces the time needed to move data from memory to GPU memory.

    3. Asynchronous prefetching to hide latency
    Moving data from memory to GPU memory always adds latency. To keep the GPU from sitting idle while it waits for data, enable asynchronous prefetching. While the GPU computes the hot experts for the current layer, the system loads the cold experts needed for the next layer into GPU memory in the background over PCIe. Overlapping computation with data transfer hides as much of the memory-to-GPU latency as possible.

    4. Cloud Elasticity and Enterprise Deployment Considerations

    The local setup described above greatly lowers the hardware barrier. However, buying a dual-socket server, 1 TB of memory, and professional GPUs still requires a significant upfront investment. Hardware maintenance, power consumption, and future upgrades also add ongoing costs. For companies in an exploration stage or with clear peaks and troughs in inference demand, cloud deployment may be a better option.

    Companies can use GPU compute instances combined with large-memory instances on Baidu AI Cloud to build a cloud-based heterogeneous inference environment. With Baidu AI Cloud’s container platform and elastic compute capabilities, developers can launch instances with large memory and a single GPU during peak demand for inference, then release those resources during quiet periods to control costs. Baidu AI Cloud’s monitoring, alerting, and log services can also track key metrics such as inference latency and memory bandwidth bottlenecks, which supports service availability. For details on specific instance types and availability, refer to the official documentation.

    Summary

    Running the full 671B-parameter MoE model locally is now practical. By using the sparse activation of the MoE architecture, you can keep frequently used experts in GPU memory and cache less frequently used experts in system memory. With one professional GPU, a dual-socket enterprise CPU, and 1 TB of memory, you can run inference at low cost with good availability. Whether you build a local server or deploy elastically on a public cloud platform such as Baidu AI Cloud, this heterogeneous computing approach gives companies a workable path to deploying large models within a limited budget.