Running 35B MoE LLMs on 8GB VRAM: VRAM and Memory Ratio Tuning in Practice

    Consumer GPUs are usually constrained by VRAM capacity, which makes it hard to load the full weights of dense models with tens of billions of parameters. Sparse Mixture-of-Experts (MoE) architectures offer a way around this limit. Using a 35B-total-parameter MoE model that activates only about 3B parameters per inference, this article documents a local deployment on a consumer device with 16GB of memory and 8GB of VRAM, validated through multi-turn dialogue. It generalizes the practice into a reusable method built on two-level offloading (by layer and by expert), VRAM budget allocation, quantization choices, and incremental parameter tuning, and reports real-world results such as roughly 16 tokens/s at a context of about 23,000 tokens. It also covers the practical limits of the approach and a device-cloud collaboration outlook.

    Running large models on consumer GPUs has long been constrained by VRAM capacity. A GPU with 8GB of VRAM can hardly hold the full weights of a dense model whose total parameter count reaches the tens of billions. The emergence of the sparse Mixture-of-Experts (MoE) architecture offers a new way out of this dilemma. A recent batch of open-source models all adopt the MoE architecture: take a model with 35 billion total parameters as an example, only about 3 billion parameters are activated per inference. I completed a local deployment of such a model on a consumer device with 16GB of memory and 8GB of VRAM, and validated its usability in multi-turn dialogue. This article abstracts that experience into a general method, breaking down how to run these “large but sparse” models stably on edge devices when VRAM is smaller than the total parameter footprint.

    1. Background: The VRAM Shortage and the MoE Opportunity

    1.1 The VRAM Dilemma of Dense Models

    When a traditional dense model runs inference, the weights of every layer must be read, and the computation per token is roughly proportional to the total parameter count. The performance ceiling of the model is directly tied to VRAM capacity. Take a model in the 35B class as an example: stored at half precision, the weights alone require at least about 70GB of VRAM, far beyond what mainstream consumer GPUs can carry. Even with 4-bit quantization compressing the weights to around 20GB, it still won’t fit into 8GB of VRAM, and it even exceeds the common 16GB system memory.

    1.2 The MoE Architecture: Decoupling “Storage Cost” from “Compute Cost”

    The core idea of the MoE architecture is to introduce multiple parallel feed-forward networks as “experts” in each Transformer layer, and then have a gating network dynamically select a few of these experts to participate in computation for each token. As a result:

    • Storage cost is determined by the total parameter count: all 35B parameters still need to be loaded into memory or storage;
    • Compute cost is determined by the activated parameter count: each token effectively passes through only about 3B parameters, with a compute volume close to that of a dense small model of the same size.

    This “large storage, small compute” characteristic is exactly what consumer hardware needs most. Take a single conversation as an example: the user input is batch pre-filled, each generated token passes through all layers in sequence, and among the MoE layers only a few experts are typically selected. If we can get these few “on-duty” experts into VRAM for computation as quickly as possible, while the remaining experts stand by in CPU memory or even on storage, we may achieve near-full-speed inference under limited VRAM. Based on this idea, we can design an “on-demand offloading” scheme:

    1. Prioritize keeping the structures that “participate in computation at every step” resident in VRAM;
    2. Place the experts that are “selected by only some tokens” in memory or even on disk;
    3. When an expert is selected by the router, have the engine move it into VRAM on demand to participate in computation.

    2. Preparation: Hardware, Inference Engine, and Quantized Weights

    2.1 Hardware Baseline

    This scheme does not have high hardware requirements; an ordinary gaming PC or developer workstation is enough:

    • GPU: A consumer GPU with 8GB of VRAM is the key threshold for the scheme to work;
    • Memory: 16GB of system memory, used to hold most of the expert weights;
    • Storage: An SSD is recommended, with ample space reserved for quantized weights and optional expert files.

    2.2 Building the Inference Engine Locally

    To achieve “expert-level offloading,” the inference engine itself must have the corresponding capability. Some engines only support layer-level offloading by default: the model is either fully loaded into VRAM, or some layers stay in memory, with no way to dynamically switch experts within VRAM. It is recommended to build a mainstream open-source inference engine that supports CPU/GPU hybrid offloading directly from source locally. The build process itself is not complicated—just follow the official instructions—and the main goal is to obtain the latest optimizations and features. If building manually feels tedious, you can also let an AI coding assistant with code-execution capability do it for you; usually you only need to provide the project URL and a clear deployment goal.

    2.3 Obtaining a Quantized Model

    When VRAM is limited, model quantization is an unavoidable step. Quantization means representing model weights with lower numerical precision, which can dramatically reduce size while barely affecting quality. The GGUF format, a common general-purpose quantized model file format in the community, offers several quantization options, including:

    • General 4-bit integer quantization (Q4_0): Small precision loss, but slightly larger in size;
    • 4-bit approximate non-linear quantization (IQ4_NL): Uses different quantization parameters for each weight block, usually preserving more precision at the same size.

    Take a model with 35B total parameters as an example: the 4-bit quantized weights are about 18GB, still exceeding physical memory capacity. A better approach is to choose a quantized version that splits some layers into separate expert files, so the engine can load the corresponding expert on demand rather than reading all layers into memory at once. It is recommended to download quantized weights from official channels such as model hosting platforms, and to verify file integrity to avoid the security risks of model files from unknown sources.

    3. Core Scheme: Two-Level Offloading and VRAM Budgeting

    3.1 Level One: Offloading by Layer

    The engine usually provides a GPU offload parameter to specify how many model layers to offload to the GPU. This parameter can be controlled directly by layer count or indirectly by “batch size.” In practice, the safest starting point is to max out GPU offloading, letting the engine put as many layers into VRAM as possible, then gradually roll back based on VRAM usage. For MoE models, the engine prioritizes placing non-MoE structures such as attention layers, normalization layers, and embedding layers into VRAM, while leaving the MoE layers to compute on the CPU side. This way, the attention computation and routing decisions for each token can be completed at high speed in VRAM.

    3.2 Level Two: Offloading by Expert

    While keeping GPU offloading maxed out, some inference engines provide a parameter specifically for the number of CPU experts in MoE models, letting you separately specify how many experts stay on the CPU for computation. The logic is:

    • The gating network decides which experts the current token selects and must always participate in computation;
    • Shared experts handle the general computation for all tokens and likewise cannot be omitted;
    • Routed experts that are selected are temporarily moved into VRAM for computation;
    • Unselected experts do not participate in computation and can safely stay in memory or storage.

    Parameter tuning starts from “CPU experts = 0.” At this point all experts go to the GPU side, and VRAM quickly overflows; then gradually increase this value until VRAM usage stabilizes around 80%. The remaining roughly 20% of VRAM is reserved for the KV Cache and runtime buffers—exactly how much to leave depends on context length and batch size.

    1. # Pseudocode: determine the two-level offloading parameters by probing from zero
    2. gpu_layers = MAX # Max out GPU offloading; let the engine auto-assign non-MoE layers like attention
    3. cpu_experts = 0 # Number of experts allowed to compute on CPU; start at 0 and increase gradually
    4. while gpu_memory_usage < 0.8 * gpu_total_memory:
    5. cpu_experts += 1 # With each step, observe VRAM and memory usage

    3.3 VRAM Allocation and Memory Usage

    With the above configuration, running a 35B-total-parameter MoE model on a device with 16GB of memory and 8GB of VRAM yields roughly 3GB of memory usage and about 7.3GB of VRAM usage, leaving overall resource consumption in a fairly healthy state:

    Resource Capacity Actual Usage Notes
    VRAM 8GB ~7.3GB Includes attention layer weights, KV Cache, and compute buffers
    Memory 16GB ~3GB Mainly holds some expert weights and runtime data structures

    One point needs clarification: in common sparse MoE architectures, the multiple routed experts within the same layer are usually selected together by the same gating network. If one expert in a layer is selected, all the selected experts in that layer must participate in computation simultaneously, so the experts of the same layer are laid out adjacently, making it difficult to “keep an entire expert file out of memory.” The roughly 3GB of memory usage observed in the experiment is precisely the combined result of the resident expert weights and other runtime overhead.

    4. Performance: Decoding Speed After Context Growth

    More noteworthy is the performance. In an actual conversation, after 4 rounds of interaction the context had accumulated to about 23,000 tokens, at which point the generation speed was about 16 tokens/s. Although slightly slower than the server-side inference speed of commercial cloud large models, this is already at a “barely usable” level in a local offline environment.

    4.1 KV Cache Pressure from Context Growth

    As the conversation progresses, historical information in the context is converted into KV Cache that continuously accumulates in VRAM. Each attention layer needs to cache the Key and Value vectors of historical tokens, and their size is proportional to the sequence length. In long-context scenarios, the KV Cache may even exceed some of the model weights and become one of the main sources of VRAM usage. Therefore, on an 8GB-VRAM device, you must reserve enough space for the KV Cache; otherwise you will run into the problem of “working fine at startup but overflowing after a few rounds of conversation.”

    4.2 The Actual Bottleneck of Generation Speed

    Decoding speed is determined mainly by two factors:

    • Expert scheduling efficiency: When a selected expert is already in VRAM, computation can run at full speed; when an expert is not in VRAM, it must be moved from memory, adding extra wait time;
    • KV Cache size: The longer the context, the more historical cache must be read at each step, and the speed drops accordingly.

    In the experiment, 16 tokens/s was already close to the ceiling for this configuration. Although the perceived speed is slightly slower than cloud large models, it is perfectly acceptable for latency-insensitive scenarios such as code completion and local Q&A.

    5. Practical Points: From Parameter Probing to Engineering Deployment

    5.1 Probe Step by Step, Not All at Once

    Many beginners like to directly set an “optimal value” when configuring, but the actual optimal parameters vary greatly across different models, quantization methods, and GPUs. The recommended approach is to start with the default configuration and observe VRAM usage; then gradually increase the number of CPU experts, recording the changes in VRAM, memory, and speed with each increase, until VRAM usage approaches the limit.

    5.2 Watch Runtime Resource Fluctuation

    VRAM usage at startup does not represent the full picture. As the conversation proceeds, the KV Cache keeps growing and VRAM usage keeps rising. It is recommended to continuously monitor VRAM and memory usage during long conversations or batch tasks to avoid process crashes caused by resource exhaustion.

    5.3 Balancing Quantization and Precision

    Quantization parameters are not better the higher (more aggressive) they are. More aggressive quantization can further reduce size but may also cause precision loss and degrade output quality. It is recommended to test the output quality of different quantization versions on a small evaluation set before local deployment, to find the best balance between size and quality.

    5.4 From Local Deployment to Service

    Local deployment solves the question of “whether it can run,” but for real business adoption you also need to consider service-oriented concerns such as deployment, monitoring, and operations. At this point you can turn to the general capabilities offered by cloud platforms such as Baidu AI Cloud, for example:

    • Using a container platform for standardized deployment and elastic scaling of model services;
    • Using object storage to manage model versions and quantized weights;
    • Using logging services and monitoring/alerting to continuously track key metrics such as inference latency and VRAM usage.

    This preserves the privacy and cost advantages of local deployment while allowing smooth scaling to cloud services when needed.

    6. Applicability and Outlook

    The advantage of this scheme is that it lets VRAM-limited consumer devices run MoE models with a large total parameter count while maintaining an acceptable speed. It is especially suited to the following scenarios:

    • Local offline inference, such as code completion and document Q&A;
    • Scenarios with high data-privacy requirements, where data does not need to leave the local device;
    • Developers validating model quality locally before deciding whether to migrate to the cloud.

    But it also has clear boundaries: as context length keeps growing, the KV Cache continuously devours VRAM; and when higher throughput or lower latency is needed, the performance of a single consumer-grade device is still limited. In these cases, a more reasonable approach is a “device-cloud collaboration” architecture, where the local model handles lightweight, privacy-sensitive tasks and the cloud model handles complex reasoning and high-concurrency requests.

    Overall, by decoupling “storage cost” from “compute cost” through the sparse activation mechanism, the MoE architecture opens up new possibilities for running large models on consumer hardware. As long as you master the two-level offloading strategy of “offloading by layer + offloading by expert” and properly configure the allocation ratio between VRAM and memory, developers can run an MoE model with 35B total parameters and 3B activated parameters on a device with just 8GB of VRAM. This “trading time for space” approach also provides a reference paradigm for model deployment in more resource-constrained scenarios.