Mathematical Reference

Memory And Inference Methodology

Public principles, assumptions and limitations. These are not certified measurements.

1. Weights And Runtime Overhead

Raw_Weight_Bytes = Parameter_Count * Bits_Per_Weight / 8

Raw tensor storage is only a starting point. Quantization metadata, unquantized tensors, drivers, runtime buffers and multi-GPU communication add memory. There is no universal overhead percentage.

2. Attention Cache

GQA_KV_Bytes = 2 * Layers * KV_Heads * Head_Dim * Bytes_Per_Element * Tokens * Batch

This is the basic standard-attention cache shape, before allocator overhead. MLA storage depends on the model and backend implementation; it does not provide a universal 82% reduction.

3. Decode And Prefill Peaks

Required_Memory = Weights + KV_Cache + Activations + Runtime_Overhead

A configuration can fit decoding while exceeding memory during prefill. Context, concurrency, attention kernels and chunked prefill affect peak usage. Safe context is an estimate under this model, not a deployment guarantee.

4. Throughput And Offloading

Bandwidth_Bound_Upper_Limit = Effective_Bandwidth / Bytes_Read_Per_Token

Bandwidth models describe limits and trends, not measured speed. Compute, kernels, batching, sparse activation, interconnects, host memory and scheduling also matter. Offloading does not necessarily transfer all weights every step or impose a fixed slowdown.

Not at ordinary 4-bit precision: raw weights alone are about 335.5GB in decimal units, before metadata, cache or runtime overhead. Lower precision, offloading and distributed execution require separate capacity analysis.

Attention Cache Memory Reference

One request, FP16 cache, decimal GB. Calculated from catalog layers, KV heads, head dimensions or MLA latent dimensions, before allocator and runtime overhead. These models are not equivalent-capability benchmarks.

Raw attention cache storage by context length
Context
Llama 3.1 8B Instruct
GQA · 8 KV heads · 32 layers
DeepSeek-R1-Distill-Qwen-14B
GQA · 8 KV heads · 48 layers
DeepSeek-R1 (671B Full MoE)
MLA · 576 latent · 61 layers
4k0.537 GB0.805 GB0.288 GB
8k1.074 GB1.611 GB0.576 GB
16k2.147 GB3.221 GB1.151 GB
32k4.295 GB6.442 GB2.303 GB
64k8.590 GB12.885 GB4.605 GB
128k17.180 GB25.770 GB9.211 GB

MHA uses the same 2 × layers × KV heads × head dimension × element bytes × tokens × concurrency shape, with KV heads equal to query heads. The MLA column reflects its catalog compressed-cache dimensions, not a universal compression ratio.

Memory Bandwidth And PCIe Link Reference

GPU values are catalog specifications. PCIe values are one-direction theoretical data rates after 128b/130b encoding, before protocol, device and software overhead. Neither is measured inference throughput.

Device / LinkGB/sBasis
NVIDIA GeForce RTX 3060 (12GB)360Catalog VRAM bandwidth
NVIDIA GeForce RTX 40901008Catalog VRAM bandwidth
NVIDIA GeForce RTX 50901792Catalog VRAM bandwidth
PCIe 3.0 x87.88Encoded one-direction ceiling
PCIe 3.0 x1615.75Encoded one-direction ceiling
PCIe 4.0 x815.75Encoded one-direction ceiling
PCIe 4.0 x1631.51Encoded one-direction ceiling
PCIe 5.0 x831.51Encoded one-direction ceiling
PCIe 5.0 x1663.02Encoded one-direction ceiling

VRAM Math And Architecture FAQ

Why can a model file fit while inference runs out of memory?

Weights are only part of the footprint. KV cache, activations, drivers, communication buffers and desktop applications consume memory. Long-prompt prefill can peak above decoding. Validate the actual backend and workload.

Can GQA, MHA and MLA cache sizes be compared directly?

Only with explicit layer counts, heads, head dimensions, precision and context. Cross-model examples illustrate storage shapes, not equivalent capability or speed. MLA values assume a backend that stores compressed latent states.

Are weight quantization and KV quantization the same?

No. Formats such as Q4_K_M describe weights. KV precision is independent and depends on the backend, device and attention kernels. Smaller weights do not automatically shrink all caches by the same factor.

Does PagedAttention guarantee a fixed memory saving?

No. Block allocation changes cache management and fragmentation. Utilization depends on block size, request lengths, concurrency and scheduling; a universal percentage is not a substitute for runtime measurement.

Can PCIe bandwidth be converted directly into real token throughput?

No. Encoded-link bandwidth is not effective transfer throughput. CPU execution, weight streaming, kernels and scheduling also matter. The link table is not an inference benchmark and does not imply a fixed offload slowdown.

Is all unified memory or aggregate multi-GPU VRAM available for weights?

No. Unified memory is shared with the OS and other applications. Multiple GPUs add sharding, duplicated tensors and communication costs. Verify model and backend support rather than just adding capacities.

Open VRAM Simulator