Running a Trillion-Parameter MoE Model on Dual 24GB GPUs: A Practical Engineering Guide
This article explains how to run a 2.8-trillion-parameter Mixture-of-Experts (MoE) model on a consumer setup built around two 24GB GPUs. It covers capacity math (why 5.6TB, 865GB, and 414GB are different measures), MoE sparse activation, multi-tier memory layering with tmpfs and NVMe, the software stack and launch parameters, GPU/CPU division of labor, reproducible benchmarking conditions, result interpretation, quantization strategy, and a minimum pre-flight checklist. It is aimed at local experimentation, private validation, and low-concurrency single-user inference—not production serving.
TL;DR: The Takeaways Up Front
Applicable conditions: Local experiments, private validation, offline testing, and low-concurrency single-user inference.
Not suitable for: Online serving, multi-user concurrency, low-latency chat, or production SLAs.
Minimum hardware threshold: 2 consumer GPUs with 24GB each, 128GB+ of system RAM, a 1TB+ NVMe SSD, and a Linux environment with tmpfs support.
Core idea: Don’t try to fit all weights into VRAM. Let the GPU compute only the high-value parts, and stream expert weights from memory or NVMe on demand according to routing needs.
Biggest risks: A tmpfs partition that is too large and triggers system OOM; over-quantization that degrades quality; and insufficient random-read performance on the persistence tier causing jitter in generation speed.
1. Get the Capacity Numbers Straight: 5.6TB, 865GB, and 414GB Are Not the Same Thing
When discussing local deployment, the easiest mistake is misreading capacity figures. Seeing “2.8 trillion parameters,” many people assume the model weights must equal some fixed value, but in practice you need to distinguish at least three measures.
First, the full FP16/BF16 theoretical weight is about 5.6TB. The math is straightforward: 2.8 trillion parameters times 2 bytes per parameter, i.e., 2.8×10^12×2 ≈ 5.6×10^12 bytes, which is roughly 5.6TB. This is the theoretical upper bound, assuming every parameter is stored at 16-bit precision.
Second, 865GB should not be used directly as the current deployment capacity measure. In some scenarios you may see a file size like 865GB, which may correspond to a different export stage, a different precision configuration, a different sharding scheme, or an intermediate result that includes extra state files. Without a clear source, you can’t compare it directly to the current deployment package. This article consistently uses the “currently runnable shard package” measure.
Third, the deployment shard total used in this case is 414GB. It’s worth clarifying the composition: 414GB is not the result of FP16 full weights being magically compressed, but is closer to a “runnable loading package,” which may be a combination of the following:
- Quantization and mixed precision: Attention, shared experts, or sensitive modules are kept at higher precision, while routed experts are stored at low-bit or mixed precision.
- Sparse storage: Only the most frequently used routed-expert shards are packed; cold experts are read on demand, avoiding writing redundant snapshots to disk in full.
- Loader transformation: The shard format has been transformed to strip out some temporary tensors, duplicate metadata, and unnecessary state.
- Partial parameter snapshot: The deployment package may contain only the parameter mappings required for loading and inference, not the full training-state snapshot.
Working backward from the size, 414GB is about 0.414TB. If you simply average across 2.8 trillion parameters, each parameter occupies about 0.148 bytes, or roughly 1.2 bits. This means the measure must rely on low-bit quantization, sparse storage, or on-demand loading at the loader level—not on the traditional notion of “fully expanded weights.” So readers should not treat 414GB as a universal compression result that any trillion-parameter model can easily achieve, but rather as the runnable deployment package formed by this project under specific export, sharding, and loading strategies.
Under this measure, the combined 48GB of VRAM across two GPUs accounts for about 11.6% of the 414GB deployment package (48 ÷ 414 ≈ 0.116). In other words, even after the deployment package has been compressed or split from theoretical weights down to 414GB, 48GB of VRAM still comes nowhere close to holding all the weights. The truly viable approach isn’t “cram the whole model into VRAM,” but “let the compute units fetch the parameters they need, when they need them.”
2. MoE Sparse Activation: Why Trillion-Parameter Models Are Still Computable
The first reason this approach works is the sparse activation characteristic of the MoE architecture. A traditional dense model runs every token through all parameters, whereas an MoE model contains a large number of expert subnetworks, and each token only activates a subset of experts selected by the router.
In this case, the model has 896 experts, and each token actually activates 16 of them, including 2 shared experts. Shared experts are always active for every token, while routed experts are chosen dynamically based on the input. The activated parameter count per token is about 104 billion.
There’s an engineering implication here that’s easy to overlook: 104 billion activated parameters stored in FP16 is about 208GB—still beyond the dual-card 48GB of VRAM. So sparse activation doesn’t mean all activated weights fit in the GPU; it means that the expert weights actually read on each pass are only a small fraction of the full model. The question then shifts from “can VRAM hold 2.8 trillion parameters?” to “can the corresponding expert weights be delivered to the compute units quickly when needed?”
A simplified pseudocode of the single-layer routing process helps illustrate this:
hidden = layer_norm(input)router_scores = router(hidden)topk_experts = top_k(router_scores, k=16)expert_weights = load_expert_weights(topk_experts)output = combine_expert_outputs(hidden, expert_weights, router_scores)hidden = hidden + output
Here load_expert_weights is the most critical step in local deployment. If all expert weights sit in slow storage, generation speed will be dragged down by IO; if some hot experts are placed in a RAM disk or high-speed cache, throughput improves significantly.
When reproducing, it’s recommended to further record the real state of load_expert_weights:
- Cache hit rate: The proportion of expert reads served from the RAM disk within a recent window.
- Queue depth: The number of expert shards waiting to be read at the same time; an overly deep queue indicates rising IO pressure.
- Retry policy on failure: Whether the system falls back to a full load, skips the expert, or remounts the cache when an NVMe random read times out or a shard is missing.
If you have hit rate but not queue depth, you’ll easily misjudge performance; if you have speed but no retry policy, generation may also be interrupted.
3. Multi-Tier Memory Layering: Put Hot Data on Faster Storage
Since capacity can’t be fully satisfied, you have to layer storage. The basic principle: hotter data goes to faster storage tiers, colder data goes to large-capacity, low-cost, slightly slower tiers.
A reproducible example layering looks like this:
| Storage tier | Suggested type | Example capacity | Access characteristics | Contents |
|---|---|---|---|---|
| GPU VRAM | Dual 24GB consumer GPUs | 48GB | High bandwidth, low latency | Attention compute weights, current activations, necessary cache |
| RAM disk (tmpfs) | Carved from system memory | 32GB–48GB | High throughput, low latency, but consumes physical RAM | High-frequency routed-expert tensors, hot shards |
| Persistence tier | Large NVMe or fast persistent disk | 1TB–2TB | Large capacity, lower cost, but random reads may become a bottleneck | Most routed-expert tensors, cold shards |
Actual performance depends on the device. As an engineering reference, GPU VRAM typically has the highest bandwidth; a RAM disk can far exceed the random-read performance of ordinary hard drives; and a large NVMe may hit several GB/s on sequential reads but fluctuate noticeably when random reads and queue depth are insufficient. So when writing a reproduction report, don’t just record sequential reads—also record:
- 4K random read IOPS: Ideally observe the 4K random-read behavior while reading expert shards.
- Latency: Including average latency, P95, and P99; jitter affects the generation experience more than the average does.
- Filesystem type: Different mount options like tmpfs, ext4, and xfs affect mmap and caching behavior.
- Mount parameters: For example, tmpfs
sizeandmode, and whethernoatime/nodiratimeare set.
Shard selection shouldn’t be done by feel alone; base it on these criteria:
- Expert activation frequency: Count how often each expert is hit by the router over a recent window.
- Layer position and sharing relationships: Shared experts, early layers, or high-frequency layers can be prioritized for caching.
- Recency of access: Use LRU or LFU policies to evict cold shards.
- Shard granularity: A single shard of 1GB–5GB is recommended; too large hurts cache replacement, too small increases file-management overhead.
- RAM disk budget: tmpfs can’t be unlimited; keep it within a certain proportion of available system memory and reserve room for runtime.
In this case, the model was split into 94 shards totaling about 414GB, of which 45 shards were placed in the RAM disk. Compared to a baseline with all experts in the persistent tier, generation speed improved by about 41% and prompt evaluation speed by about 26%. Note the baseline definition here: the improvement comes from comparing “all cold experts on the NVMe persistence tier” against “45 hot shards moved onto the RAM disk.” The median difference across retests was about ±5%, so the conclusion should be read as “effective under this hot-spot distribution,” not “every workload will gain the same improvement.”
4. Software Stack and Key Parameters: Without These, Speed Isn’t Reproducible
Performance numbers without a software stack and parameters easily become non-reproducible marketing claims. So when deploying a trillion-parameter MoE model locally, record at least the following configuration. Below is a concrete reproduction skeleton with the project name, version, launch command, shard directory, and offload switches all fixed.
| Item | Example configuration | Notes |
|---|---|---|
| OS | Linux 5.15+ | RAM disk and mmap are better suited to Linux |
| GPU driver | NVIDIA Driver 535+ | Driver version affects P2P, CUDA, and memory management |
| CUDA | 12.1 or 12.2 | Must match the framework and PyTorch version |
| PyTorch | 2.1 or 2.2 | Needs support for the relevant MoE operators and CPU offload |
| Inference framework | KTransformers 0.2.0, MoE expert offload | Loads routed experts into CPU memory or VRAM on demand |
| Launch command | python -m ktransformers.server --model_path /data/moe-414g --cpu_infer true --batch 1 --ctx 2048 |
Fixed launch fields for easy reproduction |
| Shard directory | /data/moe-414g |
Contains 94 shards and the routing index |
| Offload switch | --cpu_infer true |
Enables CPU-side expert supply; hot shards can additionally point to tmpfs |
| Shard format | safetensors or GGUF | Different formats affect mmap and load speed |
| RAM disk mount | tmpfs | Check system memory first |
| Persistence tier | NVMe SSD | Record sequential reads, random reads, and latency |
| Batch size | 1 | Single-user local inference typically starts at batch=1 |
| Concurrent requests | 1 | Higher concurrency increases VRAM and memory pressure |
| Context length | 2048 or 4096 | Longer context means a larger KV Cache |
| Precision strategy | Attention FP16/BF16, experts at the project’s export precision | Record separately whether quantization is used |
| Warm-up | Run 64 or 128 tokens first | Avoid first-load and cache-miss effects skewing measurements |
For the RAM disk mount, don’t just copy and run a command. You must check system memory first, then create the mount directory, then mount the tmpfs. Example:
# Check memory first; confirm available memory can support tmpfs plus runtimefree -h# Then create the directorysudo mkdir -p /mnt/ramdisk# Only mount after confirming enough available memory, e.g., 48Gsudo mount -t tmpfs -o size=48G,mode=0755 tmpfs /mnt/ramdisk# Verify the mount resultdf -h /mnt/ramdisk
This must be clear: if system memory is insufficient, do not force-mount a large tmpfs. If free -h shows available memory less than 1.5× the recommended tmpfs size, or if the system is running other services simultaneously, reduce the tmpfs capacity or skip mounting entirely. Otherwise, the model may trigger OOM immediately at runtime.
5. Compute and Bandwidth Division of Labor: GPU Does Attention, CPU Side Supplies Experts
Multi-tier storage solves “where does the data come from”; next comes “who computes, and how.” In a Transformer layer, the attention portion has relatively small weights and is used by every token, so it’s well suited to staying resident in VRAM and being computed at high speed by the GPU. MoE expert weights are enormous but only sparsely hit according to routing results, so they’re better kept in large-capacity CPU-side memory or the persistence tier and streamed in per token as needed.
The core of this division: the GPU handles the high-compute-density, high-parallelism attention portion; CPU-side memory handles large-capacity storage and expert fetching. The CPU side doesn’t necessarily perform complex matrix operations, but it can handle data supply, cache management, and reading routed experts. This avoids forcing the huge expert weights into the GPU and lets large-capacity memory absorb cold and hot data.
Here you must distinguish two data paths and not simply blame the bottleneck on “slow storage”:
Path 1: Expert weights go from CPU memory or NVMe into the GPU via PCIe.
If the implementation moves expert weights into GPU VRAM for computation, the data passes through multiple levels: NVMe, CPU memory, PCIe, and GPU VRAM. Bottlenecks here may include:
- Insufficient NVMe random reads;
- Insufficient CPU memory bandwidth;
- Insufficient PCIe bandwidth;
- Low GPU VRAM copy efficiency;
- Frequent expert-shard switching causing queue buildup.
Path 2: The CPU computes the expert portion directly.
If the implementation keeps the expert matrices on the CPU side and lets the CPU perform expert computation while the GPU handles only attention or other highly parallel parts, the bottleneck shifts to:
- CPU core count and memory channel count;
- Memory bandwidth;
- Vector instruction support;
- Expert matrix size;
- Whether the scheduler can effectively hide latency.
So when generation speed is low, you can’t just say “NVMe is too slow.” A more accurate diagnosis is: first confirm the data path, then determine whether PCIe transfer, CPU compute, memory bandwidth, or persistence-tier random reads are causing the bottleneck.
This also explains why “moving hot shards to the RAM disk” helps the generation phase more noticeably. During generation, decoding happens token by token, and each step reads a large amount of expert weights but produces only one token, so the bottleneck is usually memory bandwidth and IO; whereas the prompt evaluation phase processes many input tokens in parallel with higher compute density and is more easily affected by GPU compute.
6. Performance Measurement Conditions: How to Read 16.8 and 3.11 tokens/s
The case reports a prompt evaluation speed of about 16.8 tokens/s and a token-by-token generation speed of about 3.11 tokens/s. To make these numbers meaningful, you must add the measurement conditions. Below is the measurement baseline table for this reproduction; if you change the hardware, you can’t directly reuse these speeds.
| Measurement item | Reproduction baseline |
|---|---|
| GPU | 2× 24GB consumer GPUs, e.g., RTX 4090 |
| CPU | Example: AMD Ryzen 9 7950X |
| System memory | 128GB DDR5-5600 |
| RAM disk | 48GB tmpfs |
| NVMe | 2TB PCIe 4.0 SSD |
| Context length | 2048 |
| Batch | 1 |
| Concurrency | 1 |
| Sampling parameters | temperature=0.6, top_p=0.9 |
| Warm-up rounds | 3 rounds, 128 tokens each |
| Official test | 5 runs, take the median |
| System state | swap off, desktop apps closed, no other heavy-IO processes |
Under these conditions, 16.8 tokens/s and 3.11 tokens/s serve as an example reference, but they can’t be directly extrapolated as fixed values for all devices, all context lengths, and all workloads. In general, the generation phase is more affected by memory bandwidth and expert-read speed, while the prompt evaluation phase is more affected by GPU compute and parallelism.
If you want to reproduce, record at least the following:
- Hardware models: The specific model of the two 24GB GPUs, or at least the VRAM capacity and architecture; system memory capacity; CPU model and memory channel count; NVMe model.
- Storage state: RAM disk capacity, warm-up state, whether the persistence tier has built a cache, and filesystem type.
- Input/output lengths: For example, input length 1024 tokens, max output 512 tokens.
- Number of runs: Warm up 3 rounds first, then run the official test 5 times and take the median.
- Concurrency and batch: Start from batch=1 and concurrency=1.
- Sampling parameters: temperature, top_p, and others affect the compute path and routing distribution.
- System state: Whether swap is off, whether desktop apps are closed, and whether other processes are consuming memory or IO.
7. Interpreting the Results: Not “Smooth,” but “Runnable Under a Specific Configuration”
Before deployment, the practitioner estimated that generation speed with GPU acceleration would land roughly in the range of 2 to 4 tokens per second. The measured ~3.11 tokens/s falls within this expected range. That number isn’t smooth for interactive chat, but it’s enough to demonstrate the runnability of a trillion-parameter MoE model on consumer hardware.
A more accurate statement: under a specific hardware configuration, a specific model shard set, a specific context length, and a single-request workload, this approach verifies that a trillion-parameter-class MoE model can run in a consumer dual-GPU environment. It proves the engineering feasibility of “sparse activation + multi-tier storage + compute/bandwidth division of labor,” but it doesn’t mean any consumer device can blindly copy it.
To strengthen the verifiability of the conclusion, here’s a comparison table:
| Configuration | VRAM usage | Expert source | Generation speed trend | Suitability |
|---|---|---|---|---|
| Single 24GB card | Tighter | Mostly NVMe | Slower | Unsuitable for long context |
| Dual 48GB, full persistence tier | Attention fits | All experts read from NVMe | Slow, noticeable jitter | Only validates runnability |
| Dual 48GB, hot shards on RAM disk | Attention fits | Hot experts on tmpfs, cold experts on NVMe | Faster | Currently recommended |
| Small or dense model | Easier to fit | No large-scale expert offload involved | Better interactivity | Unsuitable for validating trillion-scale MoE |
In actual deployment, the following risks may still arise:
- Insufficient memory: An oversized tmpfs or insufficient system memory leads to OOM.
- IO jitter: Insufficient random-read performance on the persistence tier causes drastic fluctuations in generation speed.
- VRAM overflow: An overly long context or a poor cache configuration triggers insufficient VRAM.
- Quantization precision loss: Low-bit quantization may harm code, math, reasoning, and Chinese-language understanding.
- Data backup risk: The original model is huge, so you must back it up and verify it before replacing or deleting.
- Hot-shard invalidation: If the routing distribution changes, formerly hot shards may no longer be hot, and the caching strategy needs to be reassessed.
8. Next Optimization Directions: Quantization and Mixed Precision Are the Biggest Lever
To go from “it runs” to “it runs better,” quantization is one of the most direct optimization directions. The full FP16 theoretical weight is about 5.6TB; with 8-bit, 4-bit, or mixed precision, the model size can drop by a multiple. As the size falls, more weights can move into faster storage tiers, and some may even reside in VRAM.
But quantization shouldn’t be a blunt one-size-fits-all. A safer approach is to choose precision by tensor, by layer, and by sensitivity. For example:
| Module | Suggested strategy |
|---|---|
| Attention weights | Can keep FP16/BF16, prioritizing computational stability |
| High-frequency routed experts | Can try 8-bit or mixed precision to reduce RAM disk pressure |
| Low-frequency cold experts | Can quantize more aggressively, but run quality regression |
| Shared experts | Usually recommended to be conservative, since every token passes through them |
| Embedding or output layer | Must be evaluated separately based on task quality |
Before and after quantization, don’t just look at model size—you must establish a quality-regression method:
- Perplexity comparison: Use a fixed text set and compare perplexity changes before and after quantization.
- Task-set pass rate: For example, pass rates on math problems, coding problems, Chinese summarization, and instruction following.
- Manual sampling evaluation: Use fixed samples and manually compare factuality, coherence, and instruction-following ability.
- Error-type statistics: Distinguish numeric errors, format errors, hallucination, truncation, and repeated output.
It’s recommended to build a quantization comparison table that records at least: precision format, model size, VRAM usage, RAM disk usage, generation speed, prompt evaluation speed, task-quality score, and error rate or manual evaluation results.
9. Minimum Executable Checklist: Check These Five Things Before You Start
- Calculate the theoretical weights: Multiply the parameter count by bytes per parameter to get the theoretical size at FP16, 8-bit, and 4-bit.
- Check GPU VRAM: Record per-card and total VRAM, and judge whether attention weights and KV Cache fit.
- Check system memory and persistence tier: System memory must be enough to support tmpfs and runtime, and the persistence tier must be able to hold the shard package.
- Sample expert hotness: Run a short representative input, count expert activation frequency, and decide which shards go on the RAM disk.
- Do a benchmark measurement: Measure single-token loading, short generation, and long-text generation first, then decide whether to expand the context.
Frequently asked questions (FAQ):
How large a model can consumer dual GPUs run?
Don’t look at VRAM alone. MoE models can reduce VRAM pressure through sparse activation, expert offload, and multi-tier storage, but whether it ultimately runs depends on VRAM, memory bandwidth, persistence-tier speed, shard strategy, and context length.
What if the RAM disk isn’t big enough?
Reduce the number of hot shards, switch to quantization, or improve shard-selection precision. Don’t exhaust system memory just to enlarge tmpfs.
How do I troubleshoot slow generation?
First determine whether it’s memory-bound. Check CPU memory usage, tmpfs hit rate, NVMe random-read latency, GPU utilization, and expert-read wait time. If GPU utilization is low while read-wait is high, it’s usually a bandwidth or IO bottleneck.
Is it normal for prompt evaluation to be fast but generation slow?
Yes. Prompt evaluation is parallel processing and compute-intensive; the generation phase is token-by-token and memory-bandwidth-intensive.
Which common mistakes are easiest to hit?
Wrong shard paths, insufficient tmpfs capacity, slow persistence-tier reads, insufficient system memory, low first measurements due to no warm-up, obvious precision degradation after quantization, and no backup of the original model.
10. Summary: The Point Isn’t Cramming, but Keeping Data Supply Up with Compute
Running a trillion-parameter MoE model on consumer dual GPUs is essentially about using sparse activation to reduce per-pass compute, using multi-tier storage to compensate for insufficient VRAM, and using compute/bandwidth division of labor so the GPU and CPU-side memory each do what they’re good at. It offers not a fixed speed promise but a transferable engineering framework: first identify the bottleneck, then design storage layering, then tune routed-expert caching, and finally use quantization to gain more space.
For developers who want to deploy large models locally or in low-cost environments, the value of this approach is breaking the “data far exceeds compute” dilemma into measurable, optimizable, and reproducible engineering problems. As long as you clarify the capacity measure, record environmental conditions, and control the risks, you can progressively approach a runnable local large-model solution on consumer hardware.
