Back to the planner

How it works

VRAMwise adds up the GPU memory an LLM needs to serve your workload with vLLM, then checks it against each cloud GPU instance. These are estimates: test on the real instance before you rely on them.

The formulas

  1. 1. Weights

    W = parameters x bytes per weight

    Every parameter is stored once. Bytes per parameter: BF16 / FP16 2 bytes, FP8 1 byte, INT8 1 byte, INT4 (AWQ / GPTQ) 0.5 bytes. The worked example below shows the size for an 8B model.

  2. 2. KV cache

    KV per token = 2 x layers x KV heads x head dim x bytes; KV = KV per token x tokens x users

    For every token in a conversation the model keeps a Key and a Value per layer, so it does not compute them again. The cache grows with the context length and with the number of users served at the same time. When a model is split over more GPUs than KV heads, each KV head is copied to several GPUs, so the cache takes GPUs / KV heads times the memory.

  3. 3. Overhead

    O = 0.1 x W + 1.40 GiB per GPU

    Activations (temporary values while the model runs) plus the CUDA context and framework buffers on each GPU.

  4. 4. Required VRAM and headroom

    R = W + KV + O; with headroom: R x (1 + h)

    The total the workload needs. Headroom is a safety margin on top. If R fits but not with headroom, the instance is marked Tight.

  5. 5. Max users

    Room for the cache = usable VRAM - W - O; max tokens = room / KV per token; max users = max tokens / average tokens

    Usable VRAM is the GPU memory times the vLLM memory utilization (for example 0.9). What is left after the weights and overhead holds the KV cache, and that decides how many requests of the average length can run at once.

  6. 6. Full-context rule

    max tokens >= context length

    vLLM refuses to start when one request at the full context length does not fit in the KV cache. So an instance is only "Fits" when a single full-length request fits, even with one user.

  7. 7. Speed estimate

    upper = bandwidth per GPU x GPUs / (active parameters x bytes per weight); realistic = upper x 0.6

    Generating a token reads all active weights from GPU memory once, so memory bandwidth sets the upper bound. Real servers reach about 60% of it. This is a rough estimate; test on the real instance.

Worked example

Llama 3.1 8B, BF16 / FP16 weights and KV cache, on 1 x NVIDIA L40S (48 GiB spec memory). Context length 8,192 tokens, 8,192 tokens per request, 8 users, GPU memory utilization 0.9.

Worked example values
Weights (W)14.96 GiB
KV cache per token131,072 bytes
KV cache for one full request1 GiB
KV cache for 8 users8 GiB
Overhead (O)2.89 GiB
Required VRAM (R)25.85 GiB
With 20% headroom31.02 GiB
Usable VRAM (48 GiB x 0.9)43.20 GiB
Room for the KV cache25.35 GiB
Max tokens in the cache207,669
Max users (at 8,192 tokens each)25
Speed per user (estimate)32.3 tokens/sec
StatusFits

The planner uses the memory the cloud reports when it is smaller than the spec value, so it can show slightly fewer users for the same instance.