Heterogeneous Memory and Dual-GPU Inference: 41% Faster on a Trillion-Parameter Model

    This article examines a community hardware setup that runs a ~2.8 trillion-parameter sparse MoE model locally by combining persistent memory, a tmpfs RAM disk, and two 24GB GPUs. It explains why sparse expert routing makes "capacity from memory, compute from GPUs" viable, how hot shard placement trades capacity for latency, where dual-GPU scaling stops helping, and which metrics and optimizations matter for memory-constrained local inference.

    1. The Bottleneck: Running Trillion-Parameter Models Locally

    Once model size crosses into the trillions, the hard part of inference is no longer raw compute — it is where the parameters live. In one publicly documented community setup, a home server enthusiast ran a sparse Mixture-of-Experts (MoE) model of roughly 2.8 trillion parameters on a second-generation persistent memory host. Storing all parameters at 16-bit precision would take about 5.6TB, while the model files themselves total about 865GB.

    The core conflict is that no single machine has enough VRAM and RAM to hold the full parameter set, so the system must rely on tiered storage and on-demand data movement.

    The original persistent-memory-only configuration generated fewer than 3 tokens per second. After adding two high-performance 24GB GPUs (48GB of VRAM combined, covering only about 5.5% of the model files) and placing 45 of the 94 model shards (414GB in total) on a RAM disk while leaving the rest on persistent memory, generation rose to 3.11 tokens per second and prompt evaluation reached 16.8 tokens per second — roughly 41% and 26% improvements over the previous setup.

    2. Why Sparse Expert Architectures Fit VRAM-Starved Setups

    The model has 896 experts, and each token activates only 16 of them, 2 of which are shared experts, for about 104 billion activated parameters per pass. So although the full parameter set is enormous, the portion that actually participates in matrix operations for any given token is a small fraction.

    For an inference system, this is an opportunity: not all parameters need to sit in VRAM — only the experts that get routed to must be fetched quickly.

    That suggests a sensible division of labor: keep the routed expert tensors on the CPU side of the memory hierarchy (persistent memory plus RAM disk), with the CPU handling expert-related computation and data supply, while the GPU takes on attention computation and other parts that are more compute-sensitive and have better data locality. This split — compute from the cards, capacity from memory — is the central idea for raising throughput under VRAM constraints.

    3. Memory Tiering: Persistent Memory vs. RAM Disk

    Persistent memory offers large capacity and retains data across power loss, but has higher latency than RAM. A RAM disk (tmpfs) is essentially files mapped into memory: capacity is bounded by physical RAM, but access latency is low. Putting 414GB of hot shards on the RAM disk trades capacity for latency, pulling the most frequently accessed weights closer to the CPU.

    The placement strategy can be abstracted as the following pseudocode:

    1. shards = load_model_shards(total=94)
    2. hot_set = select_hot_shards(shards, budget_gb=414) # 45 shards
    3. for s in shards:
    4. if s in hot_set: place_on_tmpfs(s)
    5. else: place_on_persistent_memory(s)

    The key is hot shard identification: using expert activation frequency, layer position, and access patterns during the prompt and generation phases, the highest-traffic weights go to the low-latency tier first. The better the shard granularity, the smoother data retrieval on the CPU side and the less the GPU idles.

    4. Gains and Limits of Dual-GPU Parallelism

    At 48GB, VRAM is a tiny fraction of the 865GB model, yet it delivered more than 40% speedup, because the GPUs took over high-frequency operators such as attention and reduced the load on the CPU side. The gains are not linear, though: once VRAM cannot hold more hot data, adding cards mainly improves operator parallelism rather than the data supply bottleneck. At that point the real ceiling is memory bandwidth and the random-access cost of fetching experts.

    Evaluating a local inference setup therefore means looking at three metrics together: generation speed (tokens/s), prompt evaluation speed (tokens/s), and VRAM coverage. Together they determine the user experience, and judging by any one alone will mislead.

    5. Further Optimization Directions

    1. Custom quantization: choose different precision per tensor to shrink hot shards and cover more critical weights in VRAM, while keeping accuracy loss acceptable.
    2. Shard reordering: rearrange the layout based on expert activation statistics to improve memory access locality.
    3. Prefetching and caching: prefetch predictable expert routes to reduce random-access latency.
    4. Batching and concurrency: trade off throughput against time-to-first-token.

    6. Mapping to General Cloud Capabilities

    Reproducing a similar approach in the cloud can rely on general-purpose building blocks: object storage for model files, a container platform to orchestrate inference processes, logging and monitoring with alerting to track throughput and latency, and a message queue to smooth request spikes. Baidu AI Cloud can support the engineering delivery of large models with such general capabilities, but specific specifications and pricing should be confirmed in the official documentation.

    7. Conclusion

    The takeaway is that trillion-parameter local inference is not about piling on VRAM, but about systems engineering: tiered placement, compute-memory division of labor, and quantization-based compression. Understanding expert sparsity, the memory hierarchy, and the limits of parallelism is what lets you approach a usable experience on limited hardware.