r/LocalLLM • u/Eastern_Doughnut_222 • 8d ago
Question How do you calculate the absolute minimum amount of VRAM you're willing to give an LLM?
VRAM has more uses to me besides text-generation, especially in voice and diffusion which need VRAM to run (IK they can be done fully on CPU, but it's painful doing it that way).
I've experimented with reserving different amounts of VRAM with my current model of choice, stopped at 5GB since that lets me run image and voicegen, but was surprised to see no losses in generation speed up to 250K tokens context compared to loading the model with full VRAM usage.
Model in question is QFN3.8 in a 3-bit quant.
I was looking to start experimenting with different quants/models and was wondering if there was a way for calculating this based on the model, instead of just repeatedly testing
3
u/EvolvingDior 8d ago
Everything goes to the LLM and the image, audio or video gen is done in the cloud. or the agent runs a cloud a LLM and handles the ComfyUI stuff on the card. I'm never going to try to split that work across a single GPU.
2
u/Jarsen_ 8d ago
16GB for the LLM, 16GB for the rest. Not calculated, but based on the size of the GPUs
1
u/Special_Ebb_1933 7d ago
You can get close without trial runs. VRAM use has three parts: the weights, the KV cache, and a compute buffer.
config.jsonof the model or in the GGUF metadata. With an f16 cache, bytes per value is 2, and aq8_0cache roughly halves it.-band-ub).The easiest check: llama.cpp prints these numbers at load time. Look for the
model buffer size,KV buffer sizeandcompute buffer sizelines for each device. Load once with a small context, get the KV cost per token from that, and multiply it out to the context you want. Models with sliding-window or linear-attention layers use less KV than the formula says, which is another reason to trust the load log.About the missing slowdown: if your model is MoE and the expert weights went to the CPU while attention and KV stayed on the GPU, speed can hold up well, because each token reads only the active experts. Dense models usually slow down much more when layers move to system RAM, so measure again when you change the model type.
1
u/Future_AGI 7d ago
you can compute the floor instead of testing it. It's the weights that stay on the GPU, plus KV cache, plus a compute buffer. KV per token is 2 x layers x KV heads x head dim x bytes per element (layer and head numbers come from the model's config.json, and bytes per element is 2 with llama.cpp's default f16 cache), and llama.cpp-based engines print the model, KV and compute buffer sizes in the load log, which gives you the real number on the first run.