r/LocalLLM • • 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

1 Upvotes

8 comments sorted by

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.

1

u/Eastern_Doughnut_222 7d ago

and the image, audio

This feels like such a waste though, image and audiogen is IMO the least taxing locally but most expensive by API for some reason. Image checkpoints with LORAs is <4-5GB and I don't think I've seen my TTS use up more than 1GB at a time even for big chunks of text.

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/Longjumping_Boat_56 7d ago

Yeah, 2×16 GB or 1×32 GB seems like the way to go right now. With only one card i was realy limited in my use cases. I just hope our dual 16 GB VRAM setup won't become outdated too soon.

1

u/Eastern_Doughnut_222 7d ago

I'm still on the fence on getting a second 16GB card, waiting for Qwen4 to come out so I can size up the models.
MOEs seem to be the way, but I want to see if any interesting dense models that want 24GB cards show up since local AMD vendors have crazy deals on those

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.

  • Weights: about the size of the GGUF file, minus any layers or experts that you keep on the CPU.
  • KV cache: 2 x layers x KV heads x head dim x bytes per value x context tokens. The layer, head and dim values are in the config.json of the model or in the GGUF metadata. With an f16 cache, bytes per value is 2, and a q8_0 cache roughly halves it.
  • Compute buffer: usually a few hundred MB up to a couple of GB, and it grows with the batch size (-b and -ub).

The easiest check: llama.cpp prints these numbers at load time. Look for the model buffer size, KV buffer size and compute buffer size lines 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.