Lately, more developers and tinkerers than ever are setting up their own local LLM environments on desktop rigs and home servers.
Poking around Hugging Face, Reddit’s r/LocalLLaMA, or open-source AI discords, the first weight class that usually catches your eye is around 8B — an 8-billion-parameter model. Models in this range deliver impressive coding capabilities and sharp English reasoning without requiring the small datacenter setup demanded by a 70B behemoth.
Naturally, anyone with a passing familiarity with computer architecture and quantization breaks out the napkin math:
“If an 8B model is quantized down to 4 bits, each parameter takes up exactly 0.5 bytes. 8 billion parameters times 0.5 bytes equals exactly 4GB. That means that dusty 4GB card in my closet or an entry-level budget GPU should handle it just fine, right?”
Pulling out your phone’s calculator and multiplying the two numbers yields a mathematically airtight result. It feels like an open-and-shut case. But the moment you spin up your terminal with high hopes and hit Enter on your run command, your screen delivers a cold, red splash of text instead of fluent prose:
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate ...
You put a 4GB model onto a 4GB card — why did the memory blow up? Where did all those missing gigabytes vanish to?
Let’s unpack the hidden overhead of real-world LLM inference runtimes. We will skip the dry academic formulas and take an under-the-hood look at what is actually happening across your GPU’s memory stages.
By the end of this breakdown, you will be able to calculate the VRAM footprint required to run any model you have your eye on.
1. The 4-Bit Illusion: Model Weights Are Heavier Than They Look
The first misconception to clear up is the actual size of the model weight file on disk. Many assume that a “4-bit model” means every single number inside the architecture is cleanly packed into a 4-bit (0.5-byte) integer, resulting in a neat 4.0GB file.
In practice, download a real quantized file — whether in .gguf, .safetensors, or an EXL2 format—and you will notice the file size sits somewhere between 4.6GB and 5.5GB. Two engineering realities explain this discrepancy.
Why It’s 4.2 to 4.5 bpw Instead of Flat 4.0
LLMs are natively trained using high-precision representations like FP16 (16-bit floating point, 2 bytes), BF16, or FP32 (4 bytes). Forcing those smooth, high-precision values into a rigid 4-bit integer grid — which offers only 16 possible values — inevitably triggers severe quantization noise and degrades output quality. Pushed too far, the model begins to hallucinate incoherently or loses track of basic sentence syntax.
Modern quantization frameworks like AWQ (Activation-aware Weight Quantization, Lin et al., 2023), GPTQ (Frantar et al., 2022), and llama.cpp’s custom GGUF quantization schemes bypass this problem using grouped (or block-level) quantization.
Rather than compressing billions of parameters into a single global scale, the engine slices weight matrices into smaller groups of 32, 64, or 128 elements. Each group receives its own reconstruction metadata: a floating-point scale value (capturing the group’s dynamic range) and a zero-point offset, typically stored in FP16.
Because this metadata accompanies every single group, it inflates the effective footprint per parameter beyond pure 4-bit storage. In practice, an average “4-bit” model consumes roughly 4.2 to 4.5 bpw (bits per weight). You are not just packing the raw numbers; you are packing the decoding key needed to restore them with minimal precision loss.
The Untouchable Layers That Guard Model Intelligence
An even bigger contributor is that real-world quantization pipelines deliberately leave certain sensitive layers alone. Certain modules inside a Transformer architecture degrade catastrophic amounts of reasoning capability if forced down to 4 bits.
Prime offenders include:
- The Token Embedding Layer, which converts token IDs into high-dimensional vectors.
- The final LM Head (Output Layer), which generates logits across the full vocabulary to predict the next token.
- Normalization layers (like LayerNorm or RMSNorm), which sit between attention blocks to keep activations bounded and stable.
To preserve the model’s actual IQ, modern quantization tools keep these sensitive layers intact at full 16-bit precision (FP16 or BF16, 2 bytes per value). With modern architectures expanding vocabulary sizes from 32,000 up to 128,000 tokens or more, the embedding table and LM head alone can consume several hundred megabytes up to roughly 1GB.
Add it all up, and an 8B 4-bit model file generally clocks in around 4.8GB to 5.2GB. Before you even run your first prompt, the model weights alone have already blown past a 4GB VRAM ceiling.
2. The Context Trap: The Growing Weight of the KV Cache
Suppose you discover your weights exceed 4GB and decide to upgrade to a 6GB card instead. The weights load onto the board without crashing. You fire off a prompt, ready to watch tokens generate on screen.
As soon as generation starts, a second major memory consumer kicks in: the KV Cache (Key-Value Cache).
The Model’s Working Memory for Ongoing Dialogue
Autoregressive models generate text token-by-token, predicting each subsequent word based on all preceding ones. If the engine had to recalculate attention from the initial prompt all the way through the newest token at every single step, generation times would scale quadratically. A long conversation would quickly slow down to minutes per token.
The KV Cache eliminates that bottleneck. The engine caches the intermediate Key and Value projection tensors computed during prior tokens directly inside VRAM. It functions like working memory: as long as prior tokens remain cached, the model only needs to compute attention for the newest arriving token against the historical keys and values.
The catch is that this short-term working memory grows linearly with the length of your conversation — your context window.
Even Modern Architectures Carry Real Weight
Recent architectures are far more memory-efficient than older Transformer models thanks to technologies like Grouped-Query Attention (GQA).
Under standard Multi-Head Attention (MHA), every attention query head gets its own dedicated Key and Value heads. GQA allows multiple query heads to share a single Key-Value head pair. This slashes KV cache memory consumption significantly compared to vanilla Transformers. Even with GQA in place, however, the raw physical memory requirement remains substantial.
For a typical 8B architecture with 32 layers, 8 KV heads, a head dimension of 128, running standard 16-bit precision (FP16/BF16 at 2 bytes per element):
- Memory per single token: roughly 131 KB
- 4,000 tokens (4K context, typical short exchange): approximately 0.52 GB
- 8,000 tokens (8K context, summarizing an article or code snippet): approximately 1.05 GB
- 32,000 tokens (32K context, long document analysis): approximately 4.2 GB
- 128,000 tokens (full native window for multi-document reasoning): roughly 16.8 GB
At 8,000 tokens — hardly an extreme prompt when pasting in documentation or multiple files — you have already dedicated over 1GB of VRAM strictly to tracking the conversation history.
If you are exploring Agentic workflows where models use browser tools, inspect system error logs, and manage persistent task loops, context lengths can easily swell into tens of thousands of tokens. Once context scales, the KV cache quickly overtakes the size of the model weights themselves.
3. The Worktable: Activation Tensors and Runtime Buffers
You have loaded the weights and budgeted memory for the conversation history. The GPU’s Tensor Cores are ready to churn through matrix multiplications. Yet there is still another transient category of memory consumption at work: Activation Memory and execution buffers.
Think of running an LLM like working in a carpenter’s workshop. Even if you have the finest tools and materials, if every square inch of your room is stacked to the ceiling with finished furniture and lumber, you cannot swing a hammer or guide a saw. You need open space on a workbench to manipulate materials.
In deep learning inference, that open workbench space is your activation buffer.
Stored in 4-Bit, Calculated in 16-Bit (W4A16)
Compressing weights to 4 bits is primarily a packing strategy to fit the model within VRAM storage constraints and maximize memory bandwidth. Most mainstream 4-bit quantization formats are W4A16 — weights are stored at 4 bits (Weight 4-bit), but computational activations are processed in 16-bit floating point (Activation 16-bit).
When the GPU executes a matrix-vector or matrix-matrix multiplication (GEMV/GEMM), it pulls those 4-bit weights out of memory and dequantizes them on the fly into 16-bit representations just prior to the math operation. As the signal propagates through tens of transformer blocks, the intermediate activations — layer normalization outputs, softmax distributions, and intermediate projection values — require temporary memory buffers.
- Intermediate Compute Buffers: Layer-by-layer forward passes, softmax evaluations, and attention computations generally require a dynamic workspace spanning a few hundred megabytes up to around 1GB of VRAM.
- Batch Size Scaling: If you run multiple concurrent user prompts on a self-hosted server, activation memory scales with batch size. Even in a single-user setup (batch size = 1), temporary allocation spikes occur during prompt ingestion (the prefill phase) when thousands of prompt tokens are evaluated in parallel.
4. Platform Taxes: The OS and Runtime Baseline
Finally, there are the non-negotiable overheads claimed by your operating system, display server, and machine learning framework.
The CUDA Context Baseline
Whether you run PyTorch, vLLM, TensorRT-LLM, or C++ backends like llama.cpp, targeting an NVIDIA GPU requires initializing the CUDA driver runtime.
Creating a CUDA context — mapping virtual GPU memory addresses, establishing driver communication channels, and spinning up framework memory pools — immediately claims roughly 300MB to 800MB of VRAM before a single parameter is touched. Running a blank Python script that does nothing more than call torch.cuda.init() will show an immediate drop in available memory.
Display Server and GUI Overhead
If your card is plugged into a monitor running a desktop operating system rather than sitting as a headless Linux server node, your everyday OS environment takes a cut.
On Windows, the Desktop Window Manager (DWM), GPU-accelerated web browsers, and background apps typically tie up anywhere from 500MB to 1.5GB of video memory. On macOS, unified memory pools dynamically split allocations, but desktop buffers still claim their share. As a result, the usable memory available for your LLM is almost always lower than the capacity stamped on your GPU’s box.
The Itemized Receipt: Real-World VRAM Requirements for 8B (4-Bit)
Let’s assemble these line items into a realistic VRAM bill for hosting a typical 8B 4-bit model with a standard 4K to 8K context window:
- Model Weights (Quantized 4-bit): ~4.8 GB — 5.2 GB
(Includes core 4-bit quantized weights, group-level scale/zero-point metadata, and unquantized FP16 embedding and output heads.) - KV Cache (4K to 8K Context): ~0.5 GB — 1.1 GB
(Assuming standard 16-bit precision under GQA architecture.) - Activation & Intermediate Runtime Buffers: ~0.3 GB — 0.8 GB
(Workspace for on-the-fly dequantization, attention buffers, and prompt prefill spikes.) - CUDA Driver Context & Framework Overhead: ~0.5 GB — 0.8 GB
(Baseline runtime allocations, communication pipelines, and driver context initialization.) - Total Usable VRAM Required: ~6.1 GB — 7.9 GB
(The realistic safe zone to prevent out-of-memory crashes on dedicated hardware.)
Reviewing these line items makes it obvious why running an 8B model on a 4GB graphics card triggers an immediate out-of-memory crash. You realistically need roughly 7GB to 8GB of headroom to give the model room to breathe.
Push that context window out to 16K or 32K tokens, and the KV cache expansion will quickly drive your memory footprint past 10GB.
Final Thoughts
Spec sheets and introductory tutorials often lean on simplified theoretical equations. Multiplying parameter counts by bit depths provides a useful back-of-the-envelope baseline, but real production inference depends on dynamic variables: quantization metadata, scratchpad buffers, evolving context states, and OS overhead.
The next time a colleague or forum user asks why their 4GB card cannot run an 8B 4-bit model, show them this memory breakdown. It serves as a handy guide to the unseen engineering layers that keep our local AI systems running smoothly.