To run a model on your own machine, three things have to fit in memory: the weights, the KV cache and some room for the runtime.
Weights are the easy part. Every parameter is stored with some number of bits, so the weights take the parameter count times the bits per weight, divided by 8 to get bytes. Quantised formats use fewer bits per weight, which is why the same model can come in very different file sizes.
The KV cache is the part people forget. Attention reuses every earlier token’s keys and values, so the runtime keeps them, and the cache grows with every token in the context. The KV cache entry shows how to work out its size per token.
The runtime needs room too, for the graphics driver, scratch buffers and the logits it produces.
When the total is more than a graphics card holds, runtimes such as llama.cpp can put some layers on the card and the rest in system RAM, at a cost in speed, because every token then has to wait for the slower memory.
The explainer adds these up for real models and hardware, and shows which part fills the memory first.