Running Large Models on Limited VRAM: A Practical Guide to Local Deployment of Sparse MoE Architectures
This article explains how to run a 35B-parameter sparse mixture-of-experts (MoE) model locally on a consumer PC with only 16GB of RAM and 8GB of VRAM, achieving usable generation speeds of around a dozen tokens per second. It covers the principles of sparse activation, quantization choices, CPU-MoE layer offloading, context window trade-offs, and memory bandwidth bottlenecks, offering practical tuning advice for developers interested in private, low-cost local LLM inference.
Introduction: Can Consumer Hardware Handle Large Models?
In many people’s minds, large language models with tens of billions of parameters are the exclusive domain of professional compute clusters, leaving ordinary developers dependent on cloud APIs. However, with the growing adoption of sparse activation architectures (Mixture of Experts, or MoE) and continuous improvements in inference frameworks, this situation is changing fundamentally. Based on a real local deployment experiment, this article shows how to run a sparse activation model with 35B total parameters on an ordinary computer with only 16GB of RAM and 8GB of VRAM, achieving a usable generation speed of more than a dozen tokens per second.
It’s worth emphasizing that this class of models can rival much larger dense models in capability, while their inference cost is far lower. This means local deployment is no longer a “toy demo” — it is a genuinely productive solution.
1. The Core Principle: Why Sparse Models Suit Low-End Hardware
Traditional dense models engage all of their parameters in every inference step. A 27B dense model means that generating a single token requires matrix computations across the full 27B parameter scale. Mixture-of-experts architectures change this logic: the model contains many internal “expert” subnetworks, and during each inference step, a routing mechanism selects only a few experts to participate.
Take the class of model discussed in this article as an example: it has 35B total parameters, but only around 3B parameters are activated per step. In other words, only a small fraction of the parameters actually participates in computation during any given interaction, while the remaining experts stay on standby. This property brings two key advantages:
- Drastically reduced computation. The floating-point operations required for inference scale with the number of activated parameters. A 3B activation footprint means the compute pressure is comparable to that of a small model.
- Flexible memory access patterns. Parameters of non-activated experts do not need to reside in fast memory; they can even be loaded from disk on demand.
It is this second property that forms the theoretical basis for low-VRAM deployment.
2. Setting Up the Deployment Environment
2.1 Building the Inference Framework
The first step of local inference is setting up an efficient inference runtime. The mainstream local inference frameworks generally support hybrid CPU-GPU computation and provide layer-offloading capabilities specifically designed for sparse models. The build and installation process itself is not complicated — just follow the project documentation. If you are not familiar with compilation workflows, you can also use AI-assisted coding tools: give them the project repository URL, describe your requirements, and let them handle dependency installation and compilation automatically.
It’s also worth noting that if your local compute is truly insufficient, you can deploy inference workloads to cloud container platforms. Mainstream cloud providers offering container and compute services can serve as an elastic complement to local deployment, which suits scenarios with higher concurrency and stability requirements.
2.2 Choosing a Quantization Format
Raw weights downloaded directly from a model repository are usually too large and must be quantized. For a 35B-class model, a medium-strength integer quantization format is recommended. The quantized weight file is roughly 18GB, substantially compressing storage and bandwidth requirements while keeping accuracy loss under control. You can download from public model-hosting communities — just make sure all sharded files are complete.
3. The Key Technique: Layer Offloading and CPU-MoE Scheduling
This is the heart of the entire setup. Running 18GB of weights plus a 64K context window on 8GB of VRAM relies on a layered strategy: keep hot data in VRAM and cold data in system memory.
The logic is as follows. The model’s parameters fall into two categories. The first includes components used in every inference step — the routing network, shared experts, embedding layers, and so on. The second is the sparsely activated expert parameters, of which only a few are called each time. The optimization strategy is to place the first category in GPU VRAM for accelerated computation, while handing the sparse expert portion to the CPU. Experts that aren’t activated don’t even need to be loaded into memory; they can wait on disk.
The practical tuning method:
- Set GPU-offloaded layers to the maximum, letting the framework prioritize VRAM.
- Starting from zero, gradually increase the number of layers offloaded to the CPU, restarting and testing each time while observing VRAM usage.
- Stop when VRAM usage stabilizes at around 80%, reserving roughly 20% for the context’s key-value cache.
In my testing, offloading 33 layers to the CPU was the optimal configuration: VRAM usage settled around 7.3GB, RAM usage was only about 3GB, and the system remained very stable.
4. Trading Off Context Length Against VRAM
Long contexts are another major consumer of VRAM. With a 64K context, for example, the key-value cache can easily eat several gigabytes of VRAM if left unprocessed. The solution is to enable cache quantization, storing the key-value cache in a low-precision format, which substantially reduces VRAM usage. It’s also advisable to enable an optimized attention implementation, which both lowers VRAM consumption and improves computational efficiency on long sequences.
Context length should match your actual use case: for document analysis or long conversations, 64K is a reasonable baseline; for short Q&A scenarios, you can reduce it to gain more VRAM headroom.
5. Bottleneck Analysis: Bandwidth Matters More Than Capacity
In real testing with a 23K-token conversation context, generation speed was around 16 tokens per second — subjectively not far off from some cloud services. Analyzing the bottleneck reveals that the primary speed limiter is memory bandwidth rather than memory capacity. Throughout inference, system memory essentially serves as a data channel between disk and VRAM. Ordinary dual-channel DDR4 memory becomes the weak link; upgrading to a high-frequency DDR5 platform would theoretically deliver a significant speedup.
This has clear implications for hardware purchasing decisions: on a limited budget, prioritizing memory bandwidth and channel count usually yields greater returns than adding VRAM capacity.
6. Practical Recommendations and Conclusion
Looking back at the whole approach, several points are worth remembering. First, sparse activation architectures are naturally suited to heterogeneous deployment — understanding the “few activated parameters, many total parameters” characteristic is a prerequisite for configuration. Second, quantization precision and offloading layer counts must be tuned through repeated experimentation on your own hardware; there is no one-size-fits-all parameter set. Third, always reserve VRAM headroom for the context cache to avoid out-of-memory crashes during long conversations.
Local deployment of large models is moving from a geek pastime toward everyday productivity. As long as you understand the underlying principles and tune patiently, an ordinary PC with a gaming GPU can run models that once required professional servers. For developers who care about both data privacy and cost, this path is well worth serious exploration.
