Running Trillion-Parameter MoE Models with Limited VRAM: A Heterogeneous Inference Breakdown
As large language models scale toward trillions of parameters, GPU VRAM has become a critical bottleneck. This article breaks down a heterogeneous inference approach for running trillion-parameter Mixture of Experts (MoE) models when VRAM is insufficient. By leveraging a tiered storage hierarchy—combining GPU VRAM, system RAM (tmpfs), and Persistent Memory (PMem)—and dividing the computational labor between the GPU (attention) and CPU (sparse experts), developers can bypass hardware limits. We examine the storage architecture, benchmark results, practical takeaways, risk control, and potential optimization paths.
I. Why VRAM Becomes a Bottleneck
The Mixture of Experts (MoE) architecture has become a mainstream direction for large models, with parameter counts rapidly scaling from the hundreds of billions to the trillions. Taking a flagship MoE model as an example, it has a total of 2.8 trillion parameters. Storing the full weights in 16-bit precision requires about 5.6TB of space. A single consumer-grade GPU’s VRAM is far smaller than this number, and even a small cluster of GPUs struggles to hold all the weights.
A key characteristic of these models is that while the total parameter count is massive, the parameters actually activated per token represent only a small fraction. This model contains 896 experts, and each token activates 16 experts (2 of which are shared). The activated parameters are roughly 104 billion, accounting for about 3.7% of the total. In a single forward pass, most experts remain idle, making it unnecessary to load all of them into expensive VRAM.
This characteristic creates room for CPU participation in inference. The idea is to let the GPU only handle compute-intensive, highly reused parts—primarily attention calculations. Expert weights are stored in larger capacity storage media on the CPU side and read on demand. This article is based on a public community practice, outlining the engineering details and optimization paths.
II. Storage Hierarchy and Division of Labor
Where the weights are stored directly impacts generation speed. This practice utilizes three types of media:
- Memory disk (tmpfs): 45 shards are placed in tmpfs backed by system memory. Memory access latency is lower than persistent media, making it suitable for the most frequently read data. However, content in tmpfs resides in volatile memory and will be cleared upon power loss or reboot, requiring the model files to be reloaded.
- Persistent Memory (PMem): The remaining shards are placed on PMem. It offers large capacity and is byte-addressable, serving to hold weights that cannot fit into the memory disk.
- GPU VRAM: Two consumer-grade GPUs with a combined 48GB of VRAM store only routing-related resident data and the data required for attention calculations.
The model weights are split into 94 shards in total. The practitioner reported a resident footprint of about 414GB. This number shows a significant gap compared to the 5.6TB of full weights. The original material did not itemize the source of this gap, but it is likely related to quantization, caching, or unloaded portions. When replicating this setup, you should recalculate the resident size based on your chosen quantization format and residency strategy, rather than directly applying this figure.
In terms of computational division, the CPU is responsible for loading and computing the routed expert tensors. Since MoE only activates a few experts per step, the CPU can fetch data on demand from tmpfs or PMem, and then use multi-threading to complete the expert feedforward network (FFN) operations. The GPU is dedicated to attention calculations. The intermediate activations of attention have strong parallelism, and the weights are relatively concentrated, so delegating this to the GPU yields significant acceleration. Simultaneously, this division avoids frequently moving massive amounts of expert weights back and forth between VRAM and main memory.
The core logic of this division is resource allocation based on data “hotness.” Computations with the most frequent access and highest parallelism gains are placed in scarce, high-speed resources, while capacity-sensitive and sparsely accessed parts are placed in cheaper, high-capacity resources.
III. Test Results and Three Takeaways
The practitioner reported that by introducing tmpfs and dual GPUs on top of a previous PMem-only solution, the generation speed reached 3.11 tokens per second, an increase of about 41% over the older setup. Prompt evaluation speed reached 16.8 tokens per second, an increase of roughly 26%.
The original material did not specify hardware models, CPU core counts, memory and PMem capacities, GPU models, quantization bit-widths, batch sizes, or context lengths. It also did not clarify whether the measurement metric was output token speed or end-to-end latency. Therefore, these numbers should only be used as a reference and not treated as a performance guarantee.
Beyond the numbers, there are three takeaways from this practice worth noting:
- Placing hot data in tmpfs yields clear gains. After migrating nearly half of the shards from PMem to tmpfs, the read latency for expert weights dropped significantly, which was one of the main sources of the generation speed improvement. The key is whether the migrated content hits the hot path. As long as hot data resides on faster media, the overall gain may exceed what the capacity ratio of that medium would suggest.
- The GPU does not need to hold all the weights. Calculated against the full 5.6TB, 48GB represents only about 0.86%. Calculated against the 414GB resident footprint, it is about 11.6%. The GPU’s value lies in taking over the highly reused attention phase. When evaluating heterogeneous solutions, you should focus on how much computation the GPU offloads, not how many weights it holds.
- Prompt evaluation and generation require separate optimization. The evaluation phase is parallel batch computing, while the generation phase is autoregressive sequential decoding, which is more limited by memory bandwidth and weight loading latency. The different growth rates in the two metrics (26% vs. 41%) are a normal architectural result. Tuning should identify the bottlenecks for each phase separately.
IV. Optimization Directions and Risk Control
The practitioner estimated that the GPU-accelerated generation speed would fall between 2 and 4 tokens per second. The actual test result landed in this range and still has room for improvement. Future efforts can focus on three directions:
- Custom quantization strategies. Retain higher precision for routing gate weights, and experiment with lower bit-widths for the more fault-tolerant expert FFN layers. After each precision reduction, use a fixed evaluation dataset to check output quality and set a quality regression threshold. The speed gains from quantization cannot be evaluated independently of quality metrics.
- Expert prefetching and caching. Utilize the locality of routing history to proactively move expert weights with a high probability of activation into faster media, thereby masking loading latency.
- Pipeline scheduling. Overlap the CPU’s expert computation with the GPU’s attention computation in time, reducing idle periods where both ends wait for each other.
When deploying, three types of risks must be considered. First, tmpfs data is lost upon reboot; the original model files should be kept in persistent storage, and an automatic reload script should be prepared. Second, before using PMem, confirm its configuration mode, such as namespace settings in App Direct mode, and plan the capacity accordingly. Third, quantization may degrade output quality, so it must be tested with real tasks before going live.
V. Choosing a Solution When VRAM is Insufficient
How to run a trillion-parameter MoE model with insufficient VRAM? First, estimate the resident footprint. Align the total weights, quantization bit-width, activation ratio, and available memory, then decide which weights go into main memory and which go into VRAM. If the resident footprint exceeds available memory, you will need to lower the precision or reduce the resident data.
How to choose for CPU+GPU heterogeneous inference? Look at whether the computation has high reuse. Attention computation is highly parallel and has concentrated weights, making it suitable for the GPU. Sparsely activated experts are suitable for the CPU side, read on demand.
How to configure PMem and tmpfs? Put the most frequently accessed hot data into tmpfs, and the high-capacity cold data into PMem. Because tmpfs is cleared on reboot, the model files themselves must still be stored in persistent storage.
If deploying in the cloud, the logic is the same. Large memory instances can carry expert weights, general GPU instances can handle attention computations, and object storage can act as a cold data source and model distribution entry point. This allows for building an elastically scalable heterogeneous inference cluster, though network and storage latency in the cloud must be measured separately.
As model scales continue to expand while active parameters remain sparse, architectures that trade storage for compute and divide labor by layer will become increasingly common. Before using such solutions, calculate the resident footprint clearly, and then re-test performance on your own hardware and tasks to ensure reliable conclusions.
