How We Achieved 41% Faster Inference for a 2.8 Trillion-Parameter MoE Model

    This article breaks down a hands-on experiment that sped up local inference for a 2.8 trillion-parameter Mixture-of-Experts (MoE) model by about 41% in the token generation stage. It walks through the capacity math that makes "weights larger than memory" workable, the separation of responsibilities between GPU and CPU, the two-tier host cache backed by persistent memory and a tmpfs RAM disk, and why the decode stage benefits more than prefill. Readers will find a reusable tuning checklist covering shard heat profiling, VRAM usage, RAM disk sizing, precision tiers, and segmented metrics.

    1. Background: A “Small VRAM, Huge Parameters” Inference Experiment

    A home server enthusiast publicly shared the upgrade results of a second-generation persistent-memory inference host in a technical community. After adding two consumer-grade RTX 3090 cards (48GB of VRAM combined), the machine ran the full weights of a Mixture-of-Experts (MoE) large model with roughly 2.8 trillion total parameters at a generation speed of about 3.11 token/s, while the prompt evaluation (prefill) stage reached about 16.8 token/s. Compared with the pure persistent-memory setup from a month earlier, the generation stage improved by about 41% and the prefill stage by about 26%.

    These numbers are worth developers’ attention not because the absolute speed is high, but because they validate an engineering path: when the model’s parameter count far exceeds VRAM and memory capacity, the deciding factor for inference performance is not peak compute, but how the data movement path is organized. The rest of this article abstracts the experiment into a transferable methodology.

    2. Capacity Ledger: First, Do the Math on “It Won’t Fit”

    The first step in any ultra-large-parameter inference plan is not picking a GPU, but running the capacity numbers. Using the model’s public structure as a reference:

    • About 2.8 trillion total parameters, 896 experts, with 16 experts activated per token (2 of which are shared experts);
    • About 104 billion parameters activated per token, an activation ratio of roughly 3.7%;
    • Weights stored at 16-bit precision need about 5.6TB of storage in full; the actual deployed files are about 865GB (corresponding to a lower-bit packed format), with another ~414GB of shards placed on a RAM disk.

    This yields three hard constraints:

    1. VRAM can only be an accelerator, never a warehouse. 48GB of VRAM is only about 5.5% of the 865GB weight files.
    2. Memory and persistent memory are the main battleground; their bandwidth and random-read latency directly determine token generation speed.
    3. MoE’s sparse activation is the only “lever”: touching only about 1/56 of the experts per token is what makes “weights far larger than memory” work in practice.

    3. Architecture Breakdown: Who Computes, Who Stores

    The core design of this build is separation of responsibilities:

    • GPU side: handles attention computation and other parts that are sensitive to compute and bandwidth and have relatively regular computation graphs;
    • CPU side: keeps the routed expert tensors, carried by a two-tier system of persistent memory and a RAM disk;
    • Sharding strategy: of 94 model shards, 45 (about 414GB combined) reside on a tmpfs RAM disk, and the rest stay in persistent memory.

    The rationale is sound: attention computation is a “dense and repetitive” workload that is better placed in VRAM for high throughput; expert weights are a “sparse and random” workload with a very low hit rate in VRAM, so they are better left in a larger, cheaper memory tier and fetched on demand by the CPU side according to routing results.

    A schematic of the responsibility split (pseudocode, expressing only the scheduling idea):

    1. # Inference path per token (illustrative)
    2. hidden = gpu_attention(x) # dense compute stays in VRAM
    3. route = router(hidden) # routing scores, get Top-K experts
    4. for eid in route.topk(16): # includes 2 shared experts
    5. w = host_cache.fetch(eid) # check RAM disk first, fall back to persistent memory on miss
    6. hidden = moe_apply(hidden, w)

    The key is the two-tier hit order of host_cache: a RAM disk hit uses memory bandwidth, and only a miss pays the random-read cost of persistent memory.

    4. Why the 41% Speedup: Three Layers of Bottlenecks Released Together

    The speedup is not a single-point optimization, but three layers of bottlenecks relaxed at once:

    1. Capacity layer: moving 45 shards onto the RAM disk effectively promotes the hottest expert weights to a higher-bandwidth tier, lowering average fetch latency.
    2. Parallelism layer: the dual cards let attention computation overlap with expert fetching, so the GPU does not sit idle waiting for data from the CPU side.
    3. Scheduling layer: keeping routed experts on the CPU side and giving attention to the GPU avoids the jitter caused by low-frequency experts crowding VRAM.

    The smaller gain in the prefill stage (about 26%) versus the generation stage (about 41%) also fits the pattern: prefill is compute-intensive and batch-parallelizable, so its bottleneck leans toward compute; decode is memory-access-intensive and serial per token, so its bottleneck leans toward data supply. The benefit of memory tiering is therefore amplified in the decode stage.

    5. A Reusable Tuning Checklist

    • Profile shard heat first: measure how often each expert is hit by routing, put high-frequency shards on the RAM disk, and leave low-frequency ones in persistent memory.
    • Keep only the “must-compute” parts in VRAM: attention, normalization, and routing scores stay on the GPU; avoid using VRAM as a cold-data cache.
    • Control RAM disk size: the RAM disk consumes physical memory, so leave headroom for the page cache and runtime to prevent paging from backfiring.
    • Tier precision instead of a one-size-fits-all approach: applying different quantization precision to different tensors is the most certain source of future gains.
    • Look at metrics in segments: separately observe prefill and decode token throughput, VRAM usage, memory bandwidth, and hit rate, so a single average does not hide the bottleneck.
    • Reproducing on the cloud: if self-hosting is inconvenient, you can validate with a combination of general-purpose capabilities, for example a container platform to host the inference runtime, object storage for weights, and logging and monitoring services to track throughput and latency.

    6. Conclusion

    The real value of this experiment is pulling “local inference of ultra-large-parameter models” back from a compute narrative to a systems-engineering narrative: when VRAM is far smaller than the weights, the performance ceiling is set by memory tiering and the data supply path. The roughly 41% generation speedup comes from the combined effect of capacity tiering, parallel overlap, and separation of responsibilities, not from any single parameter. The takeaway for developers is clear—measure capacity and hit rate before talking about acceleration; locate bottlenecks by segment before talking about precision and quantization.