VRAM Planning for Local LLM Deployment: From Parameter Count to Benchmarking

    A practical guide to estimating how much VRAM a large language model actually needs when run locally. It explains why vendor-published VRAM figures describe only static weights rather than the true peak, breaks total VRAM into three estimable parts (weights, KV cache, and runtime overhead), and provides a ready-to-use Python estimation script. It also covers VRAM-tier recommendations, how to judge unified-memory platforms, why sparse-activation (mixture-of-experts) models matter, quantization trade-offs, a reproducible step-by-step benchmarking process, and a checklist of common mistakes. The goal is to turn VRAM from a single static number into a dynamic budget you can reason about for your own hardware, weights, and workload.

    1. First, a correction: the published VRAM number is not a “minimum to run”

    For any open-source model release, the VRAM reference figure is almost always the theoretical footprint of the half-precision original weights — that is, “parameter count × 2 bytes.” This number describes only the static weights and includes none of the dynamic overhead produced during inference. What actually determines whether you can run the model is the peak VRAM:

    1. peak VRAM = weights + KV cache + transient activations + runtime overhead + fragmentation & reserve

    Of the five terms, only the first is a constant. This means the same model, the same weights, under different context lengths, different concurrency levels, and different inference engines can vary by 2–3x in peak VRAM. So when someone says “model X needs 24GB,” the precise meaning is “it needs 24GB under some specific configuration” — and that configuration is often left unstated.

    The second common misjudgment concerns post-quantization estimates. Many people compute a 4-bit model as “parameter count × 0.5 bytes,” but the actual footprint is usually 5–15% higher, for three reasons: group quantization itself requires storing a scale factor and zero point per group (metadata overhead); the embedding layers, output layers, and normalization layers usually retain higher precision and are not quantized; and the inference framework’s own memory pool, attention intermediate buffers, and communication buffers also take up space.

    2. Break VRAM into three parts to estimate

    2.1 Weights: controllable and predictable

    The only variable in weight footprint is “bytes per parameter.” Take a dense model of roughly 30B total parameters as an example:

    Precision tier Bytes per parameter (approx.) Weight VRAM (order of magnitude) Quality impact
    FP16 / BF16 2.0 ~60GB baseline
    8-bit (Q8-class) ~1.06 ~32GB essentially lossless
    4-bit group quantization ~0.55–0.60 ~17–18GB minor, imperceptible on most tasks
    3-bit ~0.45 ~13–14GB degradation starts to show on small models
    2-bit ~0.30–0.35 ~9–11GB obvious degradation, only for validating the pipeline

    Note that “bytes per parameter” is a global average, not a number that applies to every tensor. Finer grouping (one scale factor per 32 weights) gives better precision but more metadata; coarser grouping (64 or 128) gives a smaller footprint but larger error. This is the real source of differences between implementations under the same “4-bit” label.

    2.2 KV cache: the easiest thing to get wrong

    The KV cache stores the attention keys and values of historical tokens, and its footprint is:

    1. KV bytes = 2 × layers × KV heads × head_dim × sequence length × concurrency × bytes per element

    A concrete example: a 30B-class model with 60 layers, 8 KV heads, head_dim of 128, and an FP16 cache:

    • 8K context, single conversation: ~1.9GB
    • 32K context, single conversation: ~7.5GB
    • 32K context, 4-way concurrency: ~30GB

    The third case already exceeds the total VRAM of most consumer GPUs. This is why “it loads but crashes the moment I follow up” and “short contexts run blazingly fast, but pasting in one long document freezes it” are two symptoms of the same problem — the weights fit, but there is no budget for the KV cache.

    There are three mitigations, ranked by cost-effectiveness: quantize the KV cache to 8-bit (usually near-lossless and halves it directly), cap the maximum concurrency (a single card basically supports only 1–2 streams), and adopt a sparse strategy that keeps full cache only for the most recent N layers (saves more but requires engine support, and long-range coreference ability degrades).

    2.3 Runtime overhead: reserve, don’t max out

    The inference framework itself, the memory-pool cache, transient tensors during warm-up, and the workspaces of operator libraries together usually amount to 0.5–2GB. The peak often occurs in the prefill stage (processing a long prompt in one shot) rather than the decode stage — this is especially visible on long-document summarization tasks.

    The recommended safety waterline is to treat 80–85% of total VRAM as the ceiling. Configuring right up against 100% means that an occasional long input triggers out-of-memory, and fragmentation makes “500MB still free yet unallocatable” the norm.

    3. A ready-to-use estimation script

    Combine the three parts into one function; computing it before you configure is far faster than trial and error:

    1. def estimate_vram_gb(
    2. params_b, # total parameters (billions), e.g. 30 for 30B
    3. bits_per_weight, # average bit width, e.g. 0.55 (4-bit group)
    4. layers, # number of layers
    5. kv_heads, # number of KV heads
    6. head_dim,
    7. ctx_len, # target context length
    8. batch=1, # concurrency
    9. kv_bits=16, # KV cache precision, 8 for 8-bit
    10. overhead_gb=1.5, # runtime reserve
    11. quant_meta=1.08, # uplift for quant metadata and unquantized layers
    12. ):
    13. gib = 1024 ** 3
    14. weight = params_b * 1e9 * (bits_per_weight / 8) * quant_meta
    15. kv = 2 * layers * kv_heads * head_dim * ctx_len * batch * (kv_bits / 8)
    16. total = weight / gib + kv / gib + overhead_gb
    17. return round(weight / gib, 1), round(kv / gib, 2), round(total, 1)
    18. print(estimate_vram_gb(30, 0.55, 60, 8, 128, ctx_len=32768, batch=1))
    19. # -> (21.3, 7.5, 30.3) weights / KV / total

    You will usually reach two conclusions: first, the weights are larger than you imagined (because of the metadata uplift); second, in long-context scenarios the KV cache can account for a quarter or more of total demand.

    4. Choosing by VRAM tier

    Available VRAM Approx. capacity Recommended precision Typical scenario
    4GB class 2–3B, context 2K–4K 4-bit edge devices, pipeline validation
    6GB class 3–4B smoothly; 7–8B barely 4–5 bit entry-level experience on your first local machine
    8GB class 7–8B stable, context 4K–8K 4-bit main tier for interactive chat
    12GB class 8–14B, context 8K–16K 4-bit everyday use needing some reasoning quality
    16GB class 14B comfortably; 20–30B total-param sparse-activation models runnable 4-bit the sweet spot balancing quality and speed
    24GB and above 30B-class dense model at 4-bit to start, or larger context and concurrency 4–5 bit code generation, long-document processing
    48GB and above 32B–70B class at 4-bit, or multi-GPU parallel 4-bit locally replacing a small server

    The selection principle is simple: first compute the KV budget from your target context length, then work backward from the remaining headroom to the weight magnitude you can afford — not the other way around (pick a model first and then check whether it fits).

    5. Judging unified-memory platforms

    Integrated-graphics or unified-memory-architecture platforms don’t look at dedicated-card capacity; they look at two metrics: total available unified memory and memory bandwidth.

    • 16GB: 3–8B models stable at 4-bit; 20–30B total-param sparse-activation models can be attempted but are clearly bandwidth-limited in speed.
    • 32GB: 8–14B smooth; 20–30B sparse-activation models usable day to day; a 30B dense model at 4-bit is an extreme configuration.
    • 64GB and above: 30B dense model at 4-bit is usable, 70B class needs more memory, and the system and other programs must leave enough headroom.

    Three rules of thumb: first, weights + peak KV + system usage (reserve 25–30% of physical memory) must not exceed the limit; second, memory bandwidth directly determines tokens generated per second — a bandwidth-starved platform will be unusably slow even if it fits; third, once swapping kicks in, generation speed drops by an order of magnitude, which is the most common cause of “it runs but is absurdly slow” — not a problem with the model itself.

    6. A key insight about sparse-activation models

    Sparse-activation (mixture-of-experts) models with 20–30B total parameters that actually activate 3–4B per token are a very important class of choice for local deployment, because they decouple VRAM demand from compute speed:

    • VRAM demand scales with total parameters (all expert weights must be resident)
    • Inference speed approaches that of a dense model with the activated parameter count

    These models are especially valuable on the 16GB tier: you get the knowledge coverage and language quality of a larger parameter scale at close to the speed of a mid-size model. The trade-off is that you cannot load only some experts to save VRAM — 4-bit is the prerequisite for these models to fit on small-VRAM devices.

    7. Quantization trade-offs: more aggressive is not always better

    4-bit is the de facto standard for local deployment, but three details deserve attention:

    Quantization can actually be slower in high-VRAM scenarios. 4-bit weights must be dequantized back to the compute precision before computation. When bandwidth is not the bottleneck and compute is (small models, high concurrency, batched inference), the extra dequantization cost can exceed the benefit from VRAM-bandwidth savings, and 8-bit is actually faster in that case.

    Sensitive layers are worth bumping back up. Keeping the embedding and output layers at higher precision, and reducing quantization aggressiveness on the few layers where error is most amplified, buys a clear quality recovery for a very small footprint cost — the most cost-effective operation available.

    The calibration dataset should match the real use case. The sample distribution used during quantization calibration directly affects the result. If the model mainly does code completion but the calibration set is all general conversation corpus, then degradation on code tasks will be worse than the general benchmark suggests.

    8. A reproducible benchmarking process

    Don’t just check “does it start.” Run a complete calibration in the following order:

    1. Cold start: record weight-load time and VRAM usage after loading finishes, to get the true weight baseline.
    2. Short-context baseline: fix a single stream at 2K context, record first-token latency and tokens generated per second.
    3. Context ladder: step through 8K → 16K → 32K, recording the VRAM peak and speed-decay curve at each level. This step tells you where the real VRAM ceiling is.
    4. Concurrency stress: at long context, raise concurrency to 2, then 4, and find the inflection point where VRAM runs out or speed collapses.
    5. Soak test: run continuously for 30+ minutes, watching whether VRAM and memory grow monotonically (leaks or caches not released).
    6. Quality regression: compare output quality against a half-precision baseline using a fixed task set, confirming quantization loss is within an acceptable range.

    Only five metrics need to be recorded: first-token latency, output tokens per second, VRAM peak, memory peak, and whether unrecoverable out-of-memory occurs.

    9. A checklist of common mistakes

    • “The vendor said 8GB is enough”: ignores KV cache and runtime — that’s the weights number.
    • “Loads = usable”: stability on short chats doesn’t mean stability on a 32K long document; they are two different operating points.
    • “Multi-GPU gives linear speedup”: tensor parallelism is affected by interconnect bandwidth and topology, so real gains are usually sublinear; the sharding strategy also changes the feasibility boundary for long contexts.
    • “Lower quantization = more savings”: 2–3 bit is barely usable on large-param models and collapses in quality very quickly on small-param models, actually producing unusable output.
    • “Rated VRAM = available VRAM”: the desktop environment, display output, and other resident processes all consume it; the available value is often several hundred MB to over 1GB lower than the rated figure.
    • “Testing short text is enough”: real workloads vary enormously in input-length distribution; stress testing must cover your actual worst case.

    10. A supplementary note for cloud scenarios

    When doing the same thing on public-cloud GPU instances tiered by VRAM spec (for example, the GPU compute instances offered by Baidu AI Cloud), the judgment logic is unchanged; it just adds a cost dimension: first validate the functional pipeline with a small-spec instance plus aggressive quantization, then step up tiers to find the “smallest spec under the premise of acceptable quality.” Pairing this with object storage to distribute model weights, monitoring alerts to watch VRAM and memory waterlines, and piping request logs and latency metrics into a logging service lets you complete selection stress-testing without holding high-spec resources long-term — avoiding “renting a card for a month just to test VRAM once.”

    Conclusion

    The VRAM problem in local LLM deployment is essentially reducing a static-number problem back to a dynamic-budget problem. Compute the three parts — weights, KV cache, and runtime overhead — separately, treat context length and concurrency as explicit variables, and then calibrate with a step-wise stress test. After that you no longer need to rely on any sweeping conclusion like “model X needs Y VRAM” — because you already know exactly where the safe ceiling is for your machine, your weights, and your workload.