Layered Storage and GPU Offloading: Accelerating Trillion-Scale MoE Inference on Limited VRAM

    How can a 2.8-trillion-parameter Mixture-of-Experts model run on a personal server with only 48GB of GPU memory? This article breaks down a real-world case study of tiered storage and CPU/GPU workload partitioning for ultra-large MoE inference. It covers the core mechanism of sparse activation, capacity budgeting and shard placement, where a 41% generation speedup came from, and practical tuning strategies from cache hit rates to selective quantization—showing that system-level data placement often matters more than simply adding more VRAM.

    1. Background: Why Limited VRAM Can Still Handle a Massive Model

    A publicly shared technical case describes deploying a Mixture-of-Experts (MoE) model with roughly 2.8 trillion parameters on a personal-server-class machine. The model has 896 experts, with 16 experts activated per token (2 of which are shared experts), meaning about 104 billion active parameters per token. If all parameters were stored at 16-bit precision, the theoretical footprint would be around 5.6TB, while the actual runtime model files total about 865GB. These two figures are not contradictory: the former is the uncompressed upper bound of the full parameter set, while the latter is the loadable set produced by sharding, loaders, and quantization strategies. In practice, you should always verify against the actual shard directory and runtime statistics.

    The most striking aspect of this case is the hardware ratio: the two GPUs combined provide only 48GB of VRAM—roughly 5.5% of the 865GB model files. Conventional wisdom says ultra-large model inference requires massive amounts of accelerator memory, but the sparse activation property of MoE models offers an alternative path: not all parameters need to reside on the GPU at once. Routed expert tensors can stay in the CPU-side high-capacity memory hierarchy, while the GPU handles attention computation and other parts better suited to parallel matrix operations.

    With the new configuration, generation speed reached 3.11 tokens/s and prompt evaluation speed reached 16.8 tokens/s. Compared to the previous setup that relied entirely on persistent memory, generation speed improved by about 41% and prompt evaluation by about 26%. These numbers show that in capacity-constrained scenarios, tiered storage and clear workload partitioning can deliver more direct gains than simply adding VRAM—but only if cache hit rates, data placement, and transfer paths are carefully engineered.

    2. Core Mechanism: MoE Sparse Activation and CPU/GPU Workload Splitting

    The defining characteristic of an ultra-large MoE model is “huge capacity, small activation.” Total parameters are enormous, but each token passes through only a handful of experts, so the inference system does not need to keep all experts resident on the GPU. In this case, routed expert tensors stay on the CPU side, carried by persistent memory and a RAM disk together, while the GPU handles attention computation. This split essentially trades capacity for bandwidth and caching for latency.

    Concretely, the system must satisfy three types of requirements simultaneously:

    1. Capacity: The full parameter set far exceeds single-machine VRAM, so persistent memory, a RAM disk, or local storage must form a tiered capacity pool.
    2. Bandwidth: Attention computation demands high parallel compute and belongs on the GPU. If expert-routed matrix operations require frequent cross-device transfers, that becomes the bottleneck.
    3. Latency: The generation phase is autoregressive, one token at a time, so per-token latency directly determines throughput. The prompt evaluation phase processes many tokens in parallel and is more sensitive to bandwidth and compute.

    In this case, the model was split into 94 shards, of which 45 shards—414GB in total—were placed in the RAM disk, with the rest kept in persistent memory. RAM disk access latency is significantly lower than persistent memory or local storage, so placing hot shards there reduces waiting time during generation. The two GPUs’ 48GB of VRAM cannot hold all experts, but it can hold attention-related tensors, some intermediate results, and caches—letting the GPU focus on the most compute-dense work.

    The key to this architecture is not “cramming the model into VRAM” but “getting the right data to the right tier at the right time.” If the expert routing distribution is stable, hot expert shards can be prioritized for the RAM disk. If routing fluctuates significantly, more sophisticated prefetching, cache replacement, and batching strategies are required.

    3. Performance Breakdown: Where Did the 41% Gain Come From?

    Generation speed improved by about 41% over the previous setup, while prompt evaluation improved by about 26%. The difference can be explained by workload characteristics.

    The generation phase produces one token at a time. Compute parallelism is low, but it is highly sensitive to expert weight reads, cache hits, and cross-tier data movement. After 45 shards were moved into the RAM disk, read latency for hot expert tensors dropped, and the CPU-side wait time for preparing expert weights shrank—so generation speed improved more noticeably. The prompt evaluation phase processes longer inputs at once, where GPU attention and matrix operations account for a larger share, so the marginal benefit of storage-tier improvements is relatively smaller, yielding about 26%.

    It is important to stress that 3.11 tokens/s and 16.8 tokens/s are observations from a specific implementation and should not be treated as general benchmarks. Inference throughput is jointly affected by model architecture, quantization precision, batch size, expert routing distribution, RAM disk capacity, interconnect bandwidth, CPU core count, and scheduling policy. The author had previously estimated that GPU acceleration would yield 2–4 tokens/s; the measured result fell within that range, indicating good predictability for the approach, though optimization headroom remains.

    4. Capacity Budgeting and Shard Placement: Measure First, Then Tune

    The first step of tiered inference is capacity budgeting. At minimum, an engineering plan must answer four questions: How large is the full parameter set? How large is the per-token activation? How much fits on the GPU? How much can the RAM disk and persistent memory each hold? The following pseudocode builds a budget model:

    1. total_params = 2.8e12
    2. bytes_per_param = 2 # 16-bit precision
    3. full_model_bytes = total_params * bytes_per_param
    4. active_params_per_token = 1.04e11
    5. active_bytes_per_token = active_params_per_token * bytes_per_param
    6. gpu_vram_total = 48GB
    7. gpu_usable_ratio = 0.75
    8. gpu_budget = gpu_vram_total * gpu_usable_ratio
    9. model_file_bytes = 865GB
    10. gpu_ratio = gpu_vram_total / model_file_bytes
    11. memory_disk_capacity = 512GB
    12. persistent_memory_capacity = 1024GB
    13. hot_shard_count = 45
    14. total_shard_count = 94
    15. hot_shard_bytes = 414GB

    After budgeting, follow the “hot/cold tiering” principle: expert shards with high access frequency and concentrated routing go to the RAM disk first; shards with low access frequency that must remain loadable go to persistent memory; extremely cold shards can go to local storage, but you must accept higher tail latency. In this case, 45 of 94 shards—about 47.9% of the shard count—went into the RAM disk and produced a significant generation speedup, showing that hotspot concentration is the key to the gains. If hotspots are scattered, insufficient RAM disk capacity causes frequent swapping, which increases jitter instead.

    Engineering practice should also set safety watermarks to avoid filling the RAM disk and triggering system-level reclamation. A RAM disk is volatile—data is lost on power failure or reboot—so a warmup process is needed: at startup, load hot shards based on routing statistics or historical access logs, then gradually open traffic. Shards in persistent memory require consistency checks to prevent loading corrupted data after an abnormal power loss.

    5. Tuning Roadmap: From Cache Hits to Custom Quantization

    Further optimization opportunities concentrate in four areas.

    First, improve the expert cache hit rate. Collect routing distribution statistics, rank experts by activation frequency, and pin high-frequency expert shards in the RAM disk while loading low-frequency experts on demand. A sliding-window statistic can be introduced to prevent stale static rankings.

    Second, optimize prefetching and batching. Although generation is serial token by token, the system can prefetch experts likely to be activated in the next layer between tokens. During prompt evaluation, requests can be merged to improve GPU utilization and memory bandwidth utilization. Bigger batches are not always better—watch tail latency and VRAM watermarks.

    Third, choose quantization precision per tensor. The public sharing mentions customizable quantization schemes, selecting precision by tensor sensitivity: attention- and normalization-related tensors keep higher precision, while insensitive parts of expert weights use lower precision to reduce capacity and bandwidth pressure. Quantization must be paired with accuracy regression testing to avoid degrading generation quality.

    Fourth, build out observability. At minimum, collect token throughput, time-to-first-token, expert cache hit rate, RAM disk read/write volume, persistent memory access latency, GPU utilization, CPU wait time, and OOM counts. Without these metrics, tuning devolves into blindly swapping configurations.

    6. Production Deployment and Boundaries

    In enterprise environments, this approach maps to a general tiered inference architecture: object storage holds cold model shards, a container platform orchestrates mixed CPU/GPU nodes, monitoring and alerting collect throughput and cache metrics, and a logging service records routing statistics and anomalies. General-purpose components such as object storage, container platforms, and monitoring/alerting services from Baidu AI Cloud can serve as infrastructure building blocks for this kind of architecture, but the actual gains still depend on model structure, data placement, and stress-test results.

    The boundaries must be understood clearly: a RAM disk improves latency, not capacity; persistent memory improves capacity and durability, but it is not infinite bandwidth; a low VRAM share does not mean the GPU is unimportant—attention computation remains on the critical path. If expert routing causes too much cross-device transfer, interconnect bandwidth becomes the new bottleneck. In addition, quantization precision, cache consistency, and power-loss recovery must all be covered by testing.

    Overall, this case proves a reusable principle: when facing an ultra-large MoE model, prioritize “capacity tiering, workload splitting, hotspot caching, and a metrics feedback loop” before discussing stacking more hardware. Achieving a ~41% generation speedup with dual GPUs holding only about 5.5% of the model files demonstrates that system-level data placement and CPU/GPU cooperation are usually worth doing before simply adding more VRAM.