Running a 35B MoE Model Locally on a Budget
Learn how shared system memory, integrated GPU inference, and quantization can make local deployment of a 35B-class MoE model feasible on budget hardware. This guide covers memory planning, deployment steps, performance bottlenecks, benchmarking, and the practical limits of single-user inference and local agent workflows.
1. The Challenge: The GPU Memory Wall
When running language models with more than 30 billion parameters locally, the first constraint is often GPU memory capacity rather than compute performance. A discrete GPU has a fixed pool of dedicated memory that must accommodate model weights, activations, the KV cache, and inference runtime buffers.
For a 35B-parameter model, 4-bit weights alone theoretically occupy about 17.5 GB. Once activations, context caching, runtime overhead, and memory fragmentation are included, total requirements can easily exceed 20 GB. Loading the entire model directly into a GPU with 4 GB or 8 GB of memory is therefore generally impractical.
Integrated GPUs in mini PCs offer a different approach. Instead of relying on dedicated video memory, they share system RAM with the CPU. If the operating system, drivers, and inference runtime support this arrangement properly, the GPU can access a larger memory pool. This turns the GPU memory wall into a problem of system memory capacity and bandwidth planning—and makes it possible to explore running 30B-class sparsely activated models on budget hardware.
This is not a way to fit a large model onto low-end hardware without compromise. It involves trade-offs among memory capacity, bandwidth, quantization quality, context length, and response speed. The approach is suitable for personal research, offline experiments, privacy-sensitive applications, and agent prototypes, but not high-concurrency online services.
2. The Core Approach: Shared Memory, Low-Overhead Compute, and Quantization
The approach has four main components:
- Shared memory architecture: The integrated GPU and CPU use system RAM, so model weights are no longer constrained solely by dedicated GPU memory capacity.
- Low-overhead graphics and compute interfaces: The inference runtime submits tensor operations to the integrated GPU through a general-purpose compute interface, reducing intermediate copies and driver overhead.
- Quantization and sparse activation: Group-wise 4-bit or 5-bit quantization compresses weights, while the MoE architecture reduces the computation required for each forward pass.
- CPU/GPU coordination: Compute-intensive operations, such as matrix multiplication, run on the integrated GPU. Lightweight tasks, including sampling, scheduling, and tool invocation, remain on the CPU, forming an asynchronous pipeline.
MoE models have a large total parameter count but activate only a subset of parameters for each token. This reduces computation, but it does not by itself reduce the memory needed to keep all model weights resident.
MoE therefore does not solve the memory problem on its own. It must be combined with shared memory and quantization. In practice, memory capacity, bandwidth, quantization quality, and runtime scheduling efficiency determine the user experience.
3. Memory Planning: Estimate Requirements Before Loading
Estimate memory requirements before attempting to load the model. The following pseudocode provides a rough planning framework:
total_parameters = 35e9quantization_bits = 4weight_memory_GB ≈ total_parameters × quantization_bits / 8 / 1e9KV_cache_GB = layer_count × hidden_dimension × context_length× batch_size × precision_factorruntime_overhead_GB = activation_buffers + temporary_tensors+ driver_and_framework_overheadrequired_shared_memory_GB = weight_memory_GB + KV_cache_GB+ runtime_overhead_GBmemory_budget_with_headroom_GB = required_shared_memory_GB × (1.1 to 1.2)
These are planning estimates rather than exact allocation formulas; actual requirements depend on the model architecture and runtime.
At 4 bits per parameter, a 35B model requires approximately 17.5 GB for weights alone. Allowing more than 20 GB for the model, context cache, and runtime is a reasonable starting point.
A system with 32 GB of RAM may have limited headroom after accounting for the operating system, desktop environment, and file cache. A 64 GB configuration provides more breathing room. Increasing the context window to tens of thousands of tokens can substantially expand the KV cache, requiring a corresponding reduction in batch size or context length.
Practical guidelines include:
- Prioritize space for model weights while leaving sufficient room for runtime buffers.
- Start with a 2K or 4K context window and increase it only after confirming stability.
- Disable unnecessary desktop effects and background applications to reduce memory contention.
- Monitor shared memory usage and swap activity. Frequent paging can sharply reduce generation speed.
- Retain higher precision for quantization-sensitive layers and use more aggressive quantization for less sensitive layers.
4. Deployment Workflow: From Environment Checks to Benchmarks
A reproducible local deployment should follow a structured process.
Step 1: Check the Environment
Confirm that the integrated GPU is recognized by the compute interface and that the driver version is compatible with the inference runtime.
Also verify:
- Available system RAM and dual-channel memory configuration
- Cooling capacity and power stability
- Sufficient disk space for original weights, intermediate quantization files, and the final model
Step 2: Prepare the Inference Runtime
Choose a local inference runtime that supports shared memory allocation, quantized model loading, and a low-overhead compute interface.
Check whether it can:
- Map model weights into shared memory
- Select the integrated GPU as the primary compute device
- Configure context length, batch size, and CPU thread count
- Report memory usage, time to first token, and token generation rate
Step 3: Convert and Quantize the Model
Validate the conversion and quantization workflow on a smaller model before applying group-wise quantization to the target model.
After quantization, compare the original and quantized models on representative question answering, coding, and summarization tasks. If quality degrades noticeably, increase the quantization bit width or retain higher precision for critical layers.
Step 4: Tune Startup Settings
Iterate around three goals: staying within the memory budget, maintaining usable interactive speed, and preserving acceptable output quality.
The following is an illustrative configuration, not a runtime-specific configuration file:
device: integrated_gpushared_memory_budget_gb: 24context_length: 4096batch_size: 1threads: 8quantization: 4bit_groupwisekv_cache_type: fp16monitor:- shared_memory_usage- tokens_per_second- first_token_latency
Step 5: Run Benchmarks
Do not judge the setup by a single generation-speed measurement. Record:
- Time to first token
- Sustained token generation rate
- Peak memory usage
- Memory growth or leaks during extended operation
- Temperature and thermal behavior
The test set should include short questions, long-document summarization, code completion, and multi-turn conversations.
For agent workflows, also test tool invocation, state retention, and stability across repeated reasoning and execution cycles.
5. Performance Bottlenecks: Bandwidth, Quantization, and Scheduling
Shared system memory eases the capacity constraint, but memory bandwidth often becomes the main bottleneck.
Large-model decoding is typically memory-bandwidth intensive: the speed at which weights can be read directly affects generation throughput. Dual-channel memory, higher memory speeds, appropriate timings, and lower background memory usage all influence performance.
Quantization reduces bandwidth pressure, but lower precision is not always better. Four-bit quantization often offers a useful balance between capacity and quality. More aggressive quantization can cause substantial quality degradation.
Although MoE reduces active computation, expert routing and weight access can still introduce overhead. Poor CPU/GPU coordination can also cause synchronization stalls, particularly when intermediate results are repeatedly copied between devices.
Optimization priorities include:
- Improve memory bandwidth utilization and eliminate unnecessary copies.
- Use asynchronous submission and pipelining to hide scheduling overhead.
- Limit batch size and context length to prioritize single-user responsiveness.
- Use more compact KV cache precision or paged cache management where supported.
- Profile the workload to identify bottlenecks rather than adjusting thread counts blindly.
6. Extending Local Inference into Agent Workflows
Local inference is useful beyond one-off conversations. Combined with local tools, file retrieval, task orchestration, and state management, it can support a complete agent workflow.
The main benefits are avoiding cloud inference API calls and keeping inference data on the device. Ongoing costs are primarily electricity and hardware depreciation.
The trade-off is capability: local models may be less reliable than larger cloud-hosted models at complex planning, long-context tasks, and tool use.
A practical agent architecture can be divided into five layers:
- Inference layer: The local model interprets intent, plans steps, and generates results.
- Tool layer: File operations, command execution, and retrieval are exposed through controlled interfaces.
- State layer: Conversation history, task progress, and intermediate results are stored.
- Monitoring layer: Latency, memory usage, error rates, and tool-call success rates are tracked.
- Security layer: Tool permissions are restricted, sensitive directories are isolated, and high-risk operations are audited.
For team collaboration, model files, evaluation logs, and task records can be integrated with general-purpose cloud services such as object storage, logging, monitoring, and alerting while core inference remains local. Any data uploaded to those services should be considered separately from the privacy benefits of local inference.
7. Suitable Use Cases and Risk Controls
This approach is best suited to low-cost experimentation, offline inference, privacy-sensitive prototypes, and single-user agents. It is not a good fit for highly concurrent services with strict latency requirements.
The main risks and controls are:
- Memory exhaustion and paging: Generation speed can collapse when the system starts swapping. Set memory thresholds and define fallback settings.
- Driver and runtime compatibility: Pin a known-working combination before upgrading and retain a rollback path.
- Quantization-related quality loss: Maintain task-level evaluations rather than relying only on perplexity.
- Long-context instability: Limit context length and monitor KV cache growth.
- Thermal and power instability: Observe temperatures and clock behavior during sustained inference.
- Unsafe tool execution: Apply least-privilege permissions and audit local tool use.
8. Conclusion
Running a 35B-class MoE model on a budget mini PC is not magic. It depends on the combination of shared memory, low-overhead compute interfaces, quantized inference, and sparse activation.
The engineering value lies in shifting the constraint from dedicated GPU memory capacity to system memory capacity, bandwidth, and scheduling efficiency.
Start with memory planning, validate the workflow on a smaller model, and then tune context length, quantization, and thread settings incrementally. Use benchmarks to measure the actual experience rather than assuming that successful model loading guarantees usable performance.
For developers seeking to avoid cloud inference charges, keep inference data local, or prototype agents, this is a practical path worth evaluating. High-concurrency production services still require a layered design with more capable compute infrastructure and, where appropriate, cloud resources.
