Local LLM Deployment: A Practical Guide to VRAM Planning and Compression
This guide examines where VRAM is consumed during local LLM inference, provides practical guidance for 8 GB to 24 GB memory tiers, and reviews quantization, MoE sparsity, layer offloading, CPU/GPU hybrid inference, and KV cache optimization. It also explains why 100B-class models may technically start on 12 GB but are not production-ready, includes VRAM estimation pseudocode, and outlines engineering practices for moving from “can deploy” to “can serve reliably.”
Local LLM Deployment: A Practical Guide to VRAM Planning and Compression
When deploying large models locally, the most common question is whether there is enough VRAM. This is largely correct: VRAM determines whether weights can be loaded, whether context can be extended, and whether concurrency can be maintained. It is the core hardware constraint for local inference. But “you must pursue extremely large VRAM” is not the whole conclusion. As quantization, sparsity, layer-wise loading, CPU/GPU hybrid inference, and KV cache optimization mature, low-VRAM devices can indeed run models with larger parameter counts. The key is to distinguish “can deploy” from “can use stably,” and to evaluate latency, throughput, context length, and concurrency with engineering methods.
1. Where VRAM Actually Goes
VRAM usage is not just model weights. A local inference run usually involves four types of overhead:
- Model weights: Parameter count multiplied by bytes per parameter is a rough lower bound. Under FP16, each parameter is about 2 bytes; Q8 is about 1 byte; Q4 is usually around 0.5–0.6 bytes per parameter, depending on the quantization scheme, group scaling, and metadata.
- KV cache: Longer context and higher concurrency increase KV cache size. It depends on layer count, attention head configuration, sequence length, batch size, and cache precision. It is the main incremental cost in long-context scenarios.
- Runtime buffers: Activations, temporary tensors, operator workspaces, batch buffers, and VRAM fragmentation all consume space. Different inference frameworks use different reservation strategies, so peak usage must be measured.
- Framework and driver overhead: Runtime contexts, communication buffers, graph capture, and paging management create fixed or semi-fixed usage.
Therefore, capacity estimation cannot rely only on “how large the model file is.” A Q4 weight file may look like only a few GB, but after adding long-context KV cache, batching, and runtime overhead, an 8 GB device can quickly hit the limit. Conversely, by limiting context, reducing batch size, quantizing the KV cache, and offloading layers, peak VRAM can be reduced significantly—but at the cost of speed.
2. Quick VRAM Tier Reference: What 8 GB to 24 GB Can Run
The table below provides general selection guidance. “Can run” means the model can start and complete inference under reasonable quantization, short context, and low concurrency. “Comfortable” means there is sufficient headroom under common context lengths and single concurrency. Actual results depend on model architecture, quantization quality, inference framework, and driver version.
| VRAM / unified memory tier | Main model range (mostly Q4) | Experience boundary | Common hardware class |
|---|---|---|---|
| 8 GB | 4B, 9B with aggressive quantization, small-active-parameter MoE with offloading | 4B is fairly stable; 9B is tight, and long context is prone to OOM | Entry-level discrete GPU, unified-memory devices |
| 12 GB | 9B Q4 is fairly comfortable; some mid-size models with aggressive quantization/offloading; small-active MoE | Mid-size models require reduced context and low concurrency | Mainstream discrete GPU |
| 16 GB | 9B is comfortable; mid-size Q4 models are worth trying; MoE partial offloading | Long context and high concurrency are still tight | Mid-to-high-end discrete GPU, larger unified memory |
| 24 GB | Mid-size Q4 models are fairly comfortable; larger MoE or 10B+ quantized models | Larger models still need compression, offloading, or sparse activation | High-end discrete GPU, large unified memory |
A common rule of thumb: a 9B model in Q4 has about 5–6 GB of weights. An 8 GB GPU can start it, but KV cache and runtime overhead make long context very difficult. 16 GB is better for stable use. A 27B model in Q4 usually already exceeds 14 GB of weights; adding KV cache and runtime overhead makes 24 GB a more reasonable starting point. If a 16 GB device is forced to run it, more aggressive compression, layer-wise loading, or CPU/GPU hybrid inference is required, and both speed and stability will drop noticeably. For models with tens or hundreds of billions of total parameters, you cannot simply assume “all weights reside in VRAM.” Evaluation must account for MoE sparse activation, weight streaming, and memory offloading.
3. Key Techniques for Running Large Models on Low VRAM
3.1 Quantization: Reduce Weight Size First
Quantization is the most direct VRAM optimization method. It maps high-precision weights to lower-bit representations, with common tiers such as Q8 and Q4. Q4 can significantly compress weights, but it is not lossless: quantization error can affect complex reasoning, long-document understanding, and code generation quality. In engineering practice, use a fixed evaluation set to compare against the original-precision model, focusing on task accuracy, output stability, and long-context degradation rather than file size alone.
3.2 Sparse MoE: Large Total Parameters, Fewer Activated per Token
An MoE model may have a very large total parameter count, but each token activates only some experts, so compute does not necessarily grow linearly with total parameters. However, the full weights still need to be stored or loaded on demand. If VRAM cannot hold all experts, expert offloading, layer-wise caching, or dynamic loading based on routing is required. In this case, the bottleneck shifts from compute to weight-read bandwidth, and first-token latency and throughput may degrade noticeably. Low-VRAM devices can run MoE, but they are better suited to low-concurrency, offline, or experimental scenarios.
3.3 Layer-Wise Loading and CPU/GPU Hybrid Inference
Layer-wise loading places some layers or experts in system memory or even high-speed storage, moving them to VRAM on demand for computation. This can overcome VRAM capacity limits, but it is affected by memory bandwidth, bus bandwidth, and storage I/O. Common strategies include keeping hot layers resident in VRAM, loading cold layers on demand, limiting concurrency to reuse cache, and pipelining small batches. In engineering practice, focus on monitoring peak VRAM, memory usage, disk read bandwidth, and first-token latency.
3.4 KV Cache Optimization: The Key to Long Context
KV cache optimization includes paged management, on-demand allocation, cache quantization, context truncation, and prefix reuse. For long-context tasks such as document QA and code repository analysis, KV cache may approach or even exceed weight usage. Reducing cache precision, limiting maximum context, and using paged allocation to reduce fragmentation are often more effective than simply moving to a larger VRAM device. However, cache quantization may also affect long-document consistency and needs evaluation.
3.5 Limits of Aggressive Compression
There are indeed explorations in the industry that compress mid-size models to a few GB through lower-bit quantization, structured compression, distillation, or hybrid strategies, bringing their size close to smaller models. But such approaches must answer three questions at the same time: how much capability is retained, whether long context remains stable, and whether throughput is acceptable. Small size does not equal production readiness. Especially in high-concurrency and low-latency scenarios, decompression overhead and accuracy loss caused by compression may offset the benefits.
4. Running a 100B-Parameter Model on 12 GB: Possible, but Scenario-Dependent
“Running a 100B-parameter model on 12 GB of VRAM” is not completely impossible technically, but it is usually not the traditional approach of keeping all weights resident in VRAM. It relies on combinations such as extreme quantization, MoE sparse activation, CPU/memory offloading, weight streaming, small context, and low concurrency. The result is that the model can start and complete some inference, but first-token latency is high, throughput is low, and long-context capability is limited. It is suitable for offline experiments, low-frequency QA, and capability validation, not for production scenarios such as real-time customer service or high-concurrency code completion.
Therefore, when evaluating low-VRAM solutions, establish three levels of conclusions: can start, can complete a single inference, and can stably serve the target workload. Only the third level corresponds to production readiness.
5. Capacity Estimation and Selection Pseudocode
The following is a general estimation approach. Actual results need to be calibrated through measurement with the target model architecture and inference framework.
function estimate_vram_gb(params_b, weight_bits, ctx_len, batch, kv_bytes_per_token):weight_gb = params_b * 1e9 * (weight_bits / 8) / (1024^3)kv_gb = ctx_len * batch * kv_bytes_per_token / (1024^3)runtime_overhead_gb = 1.0 to 2.0 // depends on framework, activations, and fragmentationsafety_factor = 1.15return (weight_gb + kv_gb + runtime_overhead_gb) * safety_factorfunction choose_profile(vram_gb, target_model_class, max_ctx, concurrency):if vram_gb >= 24 and target_model_class in ["mid-size Q4", "larger MoE"]:return "Comfortable: can keep a larger context and low-to-medium concurrency"elif vram_gb >= 16 and target_model_class in ["comfortable 9B", "mid-size aggressive quantization"]:return "Usable: limit context and concurrency, monitor peak VRAM"elif vram_gb >= 12 and target_model_class in ["9B Q4", "small-active MoE"]:return "Usable but tight: prioritize short context, single concurrency, and KV cache optimization"else:return "Experimental: requires layer-wise loading, offloading, or a smaller model"
When selecting a configuration, do not input only “parameter count.” At minimum, specify: target context length, concurrency, acceptable first-token latency, output tokens per second, whether CPU/memory offloading is allowed, and whether lower quantization precision is allowed. Write these constraints into load-test cases to obtain reproducible conclusions.
6. Engineering Deployment Recommendations
- Define the scenario before choosing the model: Offline summarization, document QA, coding assistance, and batch extraction have different tolerances for latency and concurrency. Low-VRAM devices should prioritize short-context, low-concurrency, batchable scenarios.
- Build a capacity ledger: Record weights, KV cache, runtime peak usage, system memory, and disk I/O. Re-run load tests whenever the quantization format, context length, or batch size changes.
- Monitor key metrics: First-token latency, output throughput, peak VRAM, OOM rate, system memory usage, disk read bandwidth, and request queue time. Do not look only at averages; pay attention to P95/P99.
- Design degradation strategies: Truncate or summarize when context exceeds limits, reduce batch size when VRAM is insufficient, move long tasks to asynchronous queues, and apply rate limiting under high concurrency.
- Ensure operability: Model file validation, version management, log redaction, access control, and runtime environment isolation. For centralized management of model files, container images, logs, and monitoring metrics, teams can use general capabilities such as object storage, container platforms, logging services, and monitoring/alerting. If using a cloud provider’s general capabilities, check the official documentation for specific APIs and billing.
- Run regression evaluations: After quantization and compression, compare business samples for accuracy, format compliance rate, long-document consistency, and refusal behavior, avoiding “it runs but is unusable.”
7. Conclusion
VRAM remains the core constraint for local LLM deployment, but the technical path has moved from “the bigger the VRAM, the better” to coordination among capacity, compression, and scheduling. 8 GB can attempt small-parameter models with aggressive quantization; 12 GB is suitable for small-to-mid-size models under low concurrency; 16 GB is closer to a stable experience; and 24 GB can more comfortably cover mid-size Q4 models. Running large-parameter models on low VRAM essentially trades quantization, sparsity, offloading, and cache optimization for capacity, while paying the cost in latency, throughput, or capability retention. In engineering practice, maintain a closed loop of “scenario—capacity—load testing—degradation,” and move “can deploy” toward “can serve reliably.” That is the reliable path for local LLM deployment.
