Exact Mathematical Formulas Behind LLMVRAMCalc.com

1. Model Weight Memory Formula

Weight_VRAM (GB) = Parameters (Billions) × (Bits_Per_Weight / 8) × 1.03 (Metadata & Embedding Overhead)

2. Standard GQA / MQA KV-Cache Formula

KV_Cache_Bytes_Per_Token = 2 (K and V) × num_hidden_layers × num_key_value_heads × head_dim × bytes_per_element
Total_KV_Cache (GiB) = (KV_Cache_Bytes_Per_Token × Context_Length × Batch_Size) / 1024³

3. DeepSeek-V3 / R1 Multi-head Latent Attention (MLA) Formula

Unlike standard GQA, DeepSeek-V3/R1 compresses KV representations into a low-rank latent vector (kv_lora_rank = 512, qk_rope_head_dim = 64) across 61 layers, requiring only ~70.27 KB per token in BF16.

4. Memory-Bandwidth Bound Decode Speed (Tokens/sec)

Decode_Speed (tok/s) ≈ (Memory_Bandwidth_GBps × Compute_Efficiency_Factor) / Active_Parameter_Weights_GB