Why Did a 14GB Model Crash a 24GB GPU?
You downloaded a 7B parameter model. The file is only 14GB on disk. Your GPU has 24GB of VRAM. You send your first prompt, and the terminal explodes with:
Model Weights: The Fixed Rent
Think of VRAM like a moving truck. The very first item loaded is the massive wardrobe: the model weights. You must pay this static rent before generating a single word.
VRAM (GB) = Parameters × Bytes per Parameter
• 7B Model = 14 GB (Fits 24GB GPU)
• 13B Model = 26 GB (Already overflows 24GB!)
• 70B Model = 140 GB (Needs 2x 80GB H100s!)
The KV Cache: The Expanding Monster
Every token the model reads or generates requires caching Key and Value attention vectors so it doesn't recalculate history. The longer the chat, the bigger the monster!
• 2,048 tokens = ~0.8 GB
• 16,384 tokens = ~6.4 GB
• 32,768 tokens (long document) = ~12.8 GB per user!
KV Size = 2 × Layers × Heads × HeadDim × SeqLen × Batch
Interactive VRAM Budget Simulator
Adjust model size, context tokens, and concurrency to watch VRAM fill in real-time. Test how close you get to the dreaded CUDA OOM threshold!
Quantization: The Vacuum-Sealing Trick
How compressing weight precision from 16-bit to 4-bit shrinks 70B models from 140GB down to 35GB.
Fluffy Winter Coat
16 bits = 2.0 Bytes / param
Folded Suit
8 bits = 1.0 Byte / param
Vacuum Sealed Box
4 bits = 0.5 Byte / param
Inference vs. Training: The 4x Trap
A model that easily fits on an RTX 4090 for inference will violently crash the same GPU during fine-tuning or training.
• Gradients: 4 bytes per parameter.
• Optimizer States (AdamW): 8 to 12 bytes per parameter!
• Backprop Activations: Saved for backward pass.
Three Golden VRAM Rules
Weights are Static Rent
Params × Bytes per weight. 70B in FP16 needs 140GB before anything runs.
KV Cache is the Dynamic Monster
Long context windows (32k) and multi-user concurrency cause memory to explode.
Quantization Saves Your Budget
INT4 & FP8 shrink memory 50–75%, letting massive models run on affordable GPUs.