Local LLM VRAM Requirements: A 2026 Configuration Guide

    This article explains why vendor-published VRAM figures are only theoretical lower bounds and how to estimate real local LLM memory use. It provides a three-part formula and a Python script for calculating model weights, KV cache, and runtime overhead, then offers practical guidance for 2B, 4B, 26B MoE, and 31B dense models across common GPU VRAM classes and unified-memory devices. It also covers context length, quantization, tensor-parallel sharding, offloading, pre-deployment checks, and when to move from local hardware to cloud elasticity.

    1. Why vendor VRAM numbers should not be copied directly

    The VRAM figure reported by vendors is usually the raw BF16/FP16 weight size: parameter count × 2 bytes. That is a theoretical lower bound containing only weights. In real local inference, VRAM is consumed by four parts:

    1. Model weights: scale linearly with parameter count and quantization precision, and can be estimated fairly precisely.
    2. KV cache: grows linearly with number of layers × KV heads × head dimension × context length × concurrency. In long-context scenarios, it often exceeds the weights themselves.
    3. Runtime overhead: framework contexts, CUDA graph/compiled artifacts, communication buffers, intermediate activation tensors, and allocator fragmentation. This usually consumes another 10%–20%.
    4. Parallel replicas: tensor parallelism shards weights, but every layer still needs communication buffers. Adding GPUs does not reduce the total VRAM requirement proportionally.

    Therefore, all ranges in this article are practical starting points. Real numbers should be calculated from your model structure using the estimation script below.

    2. A calculable VRAM estimation model

    2.1 Three-part formula

    1. Total VRAM ≈ Weights + KV cache + runtime overhead
    2. Weights ≈ parameter count × bytes per parameter
    3. KV cache ≈ 2 × layers × KV heads × head dimension × sequence length × concurrency × KV precision bytes
    4. Runtime overhead ≈ (weights + KV cache) × 10%–20%

    Typical bytes per parameter:

    • FP16/BF16 = 2
    • INT8 = 1
    • INT4 group quantization ≈ 0.5–0.6, including scale/zero metadata

    2.2 Estimation script

    1. def estimate_vram(
    2. params_b: float, # total parameter count (in billions)
    3. bytes_per_param: float, # bytes per parameter
    4. layers: int,
    5. kv_heads: int, # KV heads after GQA/MQA
    6. head_dim: int,
    7. ctx_len: int,
    8. batch: int = 1,
    9. kv_bytes: int = 2, # KV cache precision: 2=FP16, 1=INT8
    10. overhead: float = 0.15,
    11. ) -> dict:
    12. GiB = 1024 ** 3
    13. weight = params_b * 1e9 * bytes_per_param
    14. kv = 2 * layers * kv_heads * head_dim * ctx_len * batch * kv_bytes
    15. runtime = (weight + kv) * overhead
    16. return {
    17. "weights_GiB": round(weight / GiB, 2),
    18. "kv_cache_GiB": round(kv / GiB, 2),
    19. "runtime_GiB": round(runtime / GiB, 2),
    20. "total_GiB": round((weight + kv + runtime) / GiB, 2),
    21. }
    22. # Example: 4B-class model, INT8 quantization, 32 layers, 8 KV heads, 8K context
    23. print(estimate_vram(params_b=4, bytes_per_param=1.0,
    24. layers=32, kv_heads=8, head_dim=128, ctx_len=8192))

    2.3 A comparison worth remembering

    At the same 8K context length, a 32-layer model with 8 KV heads (grouped-query attention) uses about 1 GiB of KV cache in FP16. If it instead uses traditional multi-head attention with 32 KV heads, the KV cache expands to about 4 GiB.

    Context length and attention structure often affect VRAM more than quantization precision.

    3. VRAM requirements by parameter size

    The table below gives practical ranges based on quantized weights, typical-context KV cache, and runtime overhead:

    Model size Estimated VRAM after quantization (including KV and runtime) Suggested hardware class Typical use case
    ~2B ~2–4 GB Lightweight devices with 4 GB or less, integrated-GPU platforms Validate a minimal end-to-end pipeline
    ~4B ~4–6 GB At least a 6 GB GPU or a 16 GB unified-memory device First local LLM experience for most users
    ~26B (MoE, ~4B active) ~12–16 GB 16 GB class is relatively comfortable Stronger inference without the heaviest models
    ~31B (dense) ~20–24 GB 24 GB or more Higher quality, coding, and long-context workloads

    MoE models need to be understood separately. VRAM is loaded according to total parameters, while speed is determined by active parameters. A model with ~26B total parameters and ~4B active parameters usually requires less than half the VRAM of a 26B dense model (depending on quantization), but its decoding speed is close to that of a 4B dense model. This is why it stands out in the 16 GB class: the memory fits, and the speed remains usable.

    4. How to choose by GPU VRAM class

    • Around 6 GB: Start with 4B-class models quantized to INT4–INT8. 26B/31B models are not impossible to try, but using them as the default starting point often causes OOM, especially with long context.
    • 8–12 GB: 4B-class models can run stably with some headroom. 26B MoE models can be tested in small steps, but context should be kept within 4K, and at least 1–2 GB should be reserved for allocator fragmentation.
    • 16 GB: 26B MoE models enter a range where serious evaluation makes sense. “It starts” is not the same as “it can serve stably.” Watch actual decoding speed and the VRAM curve under long context, rather than relying only on nominal specs.
    • 24 GB or more: 31B dense models are worth trying. 8K–16K context is usually still in a safe range. Beyond that, leave VRAM for longer context and higher concurrency.

    A counterintuitive rule: below the 24 GB class, a 26B MoE model is often more practical than a 31B dense model. The MoE model has more VRAM headroom and faster speed, while the dense model may offer more stable per-token quality but must read all weights from VRAM for every decoding step.

    5. Unified memory devices: all-in-one PCs, laptops, and integrated graphics

    These platforms do not have dedicated VRAM. Instead, look at two metrics: total unified memory and memory bandwidth.

    Unified memory class Recommended model scale Notes
    16 GB 4B runs smoothly; 26B is possible but slow Fine for everyday chat; large models are mainly limited by bandwidth
    18–24 GB Prioritize 4B; 26B depends on workload Noticeable improvement over 16 GB
    32 GB 4B runs smoothly; 26B can be used stably Sweet spot
    64 GB or more Both 26B and 31B can run Suitable for users who want quality without a discrete GPU

    There are two key constraints:

    1. The system does not expose all memory to the compute side. You must leave room for the operating system and swap space. Frequent swapping causes a sharp performance drop.
    2. Single-stream decoding speed is roughly determined by bandwidth:
    1. tokens/s ≈ memory bandwidth / weight bytes read per token
    2. # Example: 26B MoE with 4B active parameters, INT4
    3. # Reads about 2 GB per token
    4. # 200 GB/s bandwidth -> theoretical ceiling around 100 tokens/s
    5. # In practice, expect roughly 50–70% of that
    6. # Example: 31B dense model, INT4
    7. # Reads about 15.5 GB per token
    8. # 200 GB/s bandwidth -> theoretical ceiling around 13 tokens/s

    This explains why “fits in VRAM” does not mean “runs fast”: VRAM determines whether you can start, while bandwidth determines how fast you can run.

    6. Context length: the most overlooked VRAM sink

    • KV cache scales strictly linearly with context length. A 32K context uses 4× the KV cache of an 8K context.
    • RAG, long-document summarization, and code-repository-level tasks can fill VRAM before you notice.
    • Mitigation options, ordered by cost-effectiveness:
      1. Reduce context length and concurrency.
      2. Lower KV cache precision (INT8/FP8).
      3. Enable paged KV cache management to reduce fragmentation.
      4. Use structural methods such as sliding-window or sparse attention.
      5. Consider offloading only as a last resort.

    7. Quantization and sharding: a trade-off checklist

    1. Lower precision is not always better. INT4 has limited impact on general chat for dense models, but its effect is more noticeable for MoE routing, numerically sensitive layers, and long-chain reasoning. A practical approach is to keep higher precision for embeddings, the output layer, and attention scores.
    2. The quantization format must match the framework. Different inference frameworks support different quantization formats and hardware backends. Choosing the wrong format can disable acceleration and force a dequantization path.
    3. Offloading is a double-edged sword. Moving some layers to memory or disk can make a model “runnable,” but speed may drop to single-digit tokens/s. It is best suited for offline batch processing.
    4. Multi-GPU sharding includes communication costs. Sharding reduces per-GPU VRAM pressure but adds cross-GPU communication. For 4B–8B models, sharding is usually a net negative.

    8. Pre-deployment checklist

    • Use the script in Section 2 to calculate weights, KV cache, and runtime overhead for the actual model structure, then aim to keep total VRAM at no more than 80% of available VRAM.
    • Define target context length and concurrency instead of testing only a single request.
    • Record three curves: first-token latency, decoding tokens/s, and peak VRAM.
    • Observe for at least 30 minutes to confirm there is no fragmentation buildup or swapping jitter.
    • Integrate logs, metrics, and alerts into a unified observability setup. A common pattern is a logging service + monitoring/alerting + object-storage archive.

    9. What to do when it no longer fits locally

    When VRAM demand exceeds a single GPU’s capacity, or when stable multi-concurrency service is needed, there are usually three paths:

    1. Upgrade vertically to an accelerator card with more VRAM.
    2. Scale horizontally with tensor-parallel sharding.
    3. Move to on-demand cloud GPU instances or managed model inference services.

    On cloud platforms, you can typically combine GPU instances, container platforms, object storage, and monitoring/alerting to allocate resources elastically based on concurrency and context length, avoiding the need to hold hardware for peak demand.

    The decision rule is simple: if concurrency and context length fluctuate heavily, or if higher stability is required, cloud elasticity is often more cost-effective than buying a larger GPU. For single-user offline batch processing, local hardware is still usually more economical.

    10. Quick FAQ

    • It loads, but OOM happens as soon as I send a prompt: This is almost always caused by KV cache and activations. Reduce context length first.
    • VRAM is enough, but speed is very slow: The bottleneck is bandwidth or offloading. Check whether some layers have fallen back to memory/disk.
    • Quality drops noticeably: The benefit of lowering quantization precision diminishes. Prefer higher precision for sensitive layers or switch to a different quantization scheme.
    • It becomes slower after running for a while: VRAM fragmentation or swapping may be the cause. Restart the process, fix the context length, and test again.

    11. Decision flow summary

    1. Define task (chat / code / long documents) -> set context length and concurrency
    2. |
    3. Estimate weights + KV + runtime -> keep under ~80% of available VRAM
    4. |
    5. Not enough capacity -> reduce model size / lower quantization precision / use cloud elasticity
    6. Enough capacity but slow -> reduce active parameters (prefer MoE) / move to a higher-bandwidth class
    7. |
    8. Stress test for 30 minutes -> lock configuration and observability metrics

    In one sentence: VRAM determines whether you can run, bandwidth determines how fast you can run, and context length determines how long you can run. Put these three variables into a calculable formula rather than copying any existing lookup table, and you can match your local LLM setup to your hardware.