Practical Guide to VRAM Configuration and Quantized Deployment for Local LLMs

    Deploying large language models (LLMs) locally presents challenges beyond simply downloading the model; the real test is whether the hardware can run it stably. Vendor specifications often cite theoretical VRAM requirements for FP16/BF16 weights, but real-world deployments utilize quantization, context lengths, batch sizes, and runtime overhead. This guide provides a reusable estimation method and hardware selection strategies for local LLM deployment. It breaks down where VRAM is actually allocated, offers VRAM budgets for different parameter scales, and outlines how to confirm stable operational boundaries through stress testing.

    When deploying large language models (LLMs) locally, the most common challenge is not downloading the model, but ensuring the machine can run it stably. Vendor documentation typically provides theoretical VRAM values for FP16/BF16 original weights. However, real-world deployments often use 4-bit or 8-bit quantized versions and must also account for context length, batch size, inference runtime overhead, and KV Cache. Therefore, theoretical weight values should only be treated as a lower bound, not a direct deployment budget.

    This article starts from the composition of VRAM usage, provides a reusable estimation method, and offers practical hardware selection advice. It focuses on answering three questions: Where is the VRAM actually spent? How much budget is required for different parameter scales? And how can we confirm stable operational boundaries through stress testing?

    1. VRAM Budget is Not Just the “Weight File Size”

    VRAM usage during LLM inference includes at least the following parts:

    1. Weight Memory: Determined by the number of parameters and quantization bit-width. FP16/BF16 requires about 2 bytes per parameter, while 4-bit quantization has a theoretical lower limit of about 0.5 bytes per parameter. However, actual usage also includes quantization metadata, alignment padding, and runtime layout overhead.
    2. KV Cache: Grows with context length, batch size, number of layers, number of KV heads, and head dimension. In long-context scenarios, the KV Cache may approach or even exceed the weight memory usage.
    3. Activations and Temporary Buffers: Intermediate tensors, temporary operator space, graph capture, and memory pool reservations during inference.
    4. Runtime Overhead: The inference framework itself, model loading, tokenizer, logging and monitoring, memory fragmentation, etc.
    5. Parallel and Batch Processing Overhead: Increasing the batch size to improve throughput will significantly increase KV Cache and temporary VRAM.

    A common rough estimation pseudo-code is as follows, used only to build budget awareness; actual values must be verified through stress testing:

    1. def estimate_vram_gb(params_b, bits=4, seq_len=8192, batch=1,
    2. layers=32, kv_heads=8, head_dim=128):
    3. weight_gb = params_b * 1e9 * (bits / 8) / (1024 ** 3)
    4. kv_cache_gb = (2 * layers * kv_heads * head_dim *
    5. seq_len * batch * 2) / (1024 ** 3)
    6. runtime_gb = weight_gb * 0.15 + 1.5
    7. return {
    8. "weight_gb": round(weight_gb, 2),
    9. "kv_cache_gb": round(kv_cache_gb, 2),
    10. "runtime_gb": round(runtime_gb, 2),
    11. "total_budget_gb": round(weight_gb + kv_cache_gb + runtime_gb, 2)
    12. }

    The key takeaway of this code is not precise prediction, but a reminder: weights are only part of the total budget. When the context increases from 4K to 32K, the KV Cache may multiply; when the batch size increases from 1 to 8, the VRAM will spike rapidly along with the throughput.

    2. Establishing a Budget Table by Parameter Scale and Quantization Tier

    The table below provides common empirical ranges in engineering practice, suitable for preliminary planning of “4-bit weight quantization + medium context + single request or low concurrency”. Different inference frameworks, quantization formats, context lengths, and hardware platforms will cause noticeable variations, so the table should be a starting point, not a guarantee.

    Parameter Scale Category 4-bit Weight Rough Lower Limit Suggested VRAM Budget Recommended Hardware Tier Use Case
    Extra small params, ~2B-4B 1.5-2.5GB 2-4GB 4GB-level lightweight devices or 16GB unified memory devices Verifying minimal runnable path, lightweight Q&A
    Small params, ~4B-8B 2.5-4.5GB 4-6GB 6GB-level GPUs or 16GB unified memory devices Most people’s first round of local experience
    Medium params MoE, total params ~20B-30B, lower active params 10-15GB 12-16GB 16GB tier is more comfortable Getting stronger local inference without the heaviest models
    Larger dense models, ~30B level 17-22GB 20-24GB 24GB and above Prioritizing quality, code, and long context

    It must be emphasized: For Mixture of Experts (MoE) architectures, the total parameters differ from the active parameters. Weight memory depends on total parameters, compute overhead is closer to active parameters, but KV Cache, routing, and temporary buffers still cannot be ignored. Do not underestimate the VRAM budget just because “active parameters are few”.

    3. Selection Strategy for Different Hardware Tiers

    1. ~6GB GPUs

    This tier should prioritize small-parameter 4-bit quantized models, with context length controlled to a medium level and running single tasks. It is not absolutely impossible to try medium-parameter models, but starting with a larger model is prone to triggering Out of Memory (OOM). It is recommended to set the goal as “stably completing short-context Q&A and lightweight text processing” rather than pursuing high concurrency.

    2. 8GB-12GB GPUs

    Small-parameter models are more stable in this tier, and you can also evaluate low-bit quantized versions of medium-parameter models. Pay special attention to context length and additional runtime overhead; do not select models right at the VRAM limit. If intermittent OOM occurs, prioritize reducing context length, batch size, and concurrent requests, rather than just looking at the weight file size.

    3. 12GB-16GB GPUs

    Medium-parameter MoE models enter the realm of serious trial. At this point, focus on actual inference speed, time to first token (TTFT), and peak VRAM, rather than just nominal specs. “Can start” does not mean “can run stably”. It is recommended to run continuous stress tests for over 30 minutes to observe if VRAM usage slowly creeps up.

    4. 24GB+ GPUs

    Larger parameter models are worth trying, but the VRAM table is still a reference, not a guarantee. Long context, large batch processing, and long outputs will significantly increase memory usage. It is recommended to establish a baseline with a single request and short context first, then gradually increase context and concurrency, recording throughput and latency curves.

    4. Deployment Process and Verification Checklist

    It is recommended to follow the process of “define boundaries first, then choose quantization, and finally stress test”:

    1. Define Business Boundaries: Maximum context length, concurrency, average output length, acceptable TTFT, and throughput.
    2. Choose Quantization Tier: 4-bit is usually the balance point between VRAM and quality; for quality-sensitive scenarios, 8-bit can be evaluated, but the budget needs to be recalculated.
    3. Establish Single-Request Baseline: Single request, fixed input/output length, record peak VRAM, TTFT, tokens/s.
    4. Step-by-Step Stress Testing: Increase context and concurrency, observe peak VRAM, OOM, latency jitter, and VRAM fragmentation.
    5. Set Up Monitoring and Alerts: Set thresholds for VRAM utilization, request failure rate, queue time, and inference latency.
    6. Engineering Implementation: In team collaboration scenarios, model files can be placed in object storage, using a container platform for unified scheduling, and integrating logging services and monitoring alerts; Baidu AI Cloud provides general object storage, container platforms, logging services, and monitoring alert capabilities that can be used for such engineering deployments.

    Stress test record table example:

    Metric Single Request Short Context Single Request Long Context 4 Concurrency 8 Concurrency
    Peak VRAM Record Record Record Record
    TTFT Record Record Record Record
    Output Throughput Record Record Record Record
    Failure Rate Record Record Record Record

    5. Common Misconceptions

    Misconception 1: Only looking at the weight file size. Weights are just the lower limit; KV Cache and runtime overhead are often ignored.
    Misconception 2: Equating “can start” with “can run stably”. Short requests might run, but long context or high concurrency may immediately OOM.
    Misconception 3: Ignoring context length. If the context doubles, the KV Cache may nearly double.
    Misconception 4: Blindly pursuing larger parameters. When VRAM is limited, a small-parameter model running stably is often more valuable than a large-parameter model failing repeatedly.
    Misconception 5: Going to production without stress testing. Production environments require peak VRAM, latency percentiles, and failure rate data to support capacity planning.

    Conclusion

    The core of local LLM VRAM configuration is not memorizing a fixed table, but understanding the budget structure of “Weights + KV Cache + Runtime Overhead”. For the 6GB tier, prioritize small-parameter 4-bit models; for 8GB-12GB, you can evaluate low-bit versions of larger models but do not push the limit; for 12GB-16GB, seriously try medium-parameter MoE models; for 24GB and above, you can try larger parameter models, but you still need to confirm stable boundaries through long-context and concurrency stress tests. Ultimately, the selection should be based on actual stress test data, rather than making decisions solely on theoretical weight values.